@import url("/fonts/fonts.css");

/* Tokens — mirror of the Tıldesu design system (tokens.json) */
:root {
  --surface: #FFFFFF;
  --surface-sunk: #F6F3F0;
  --line: #E8E2DC;
  --ink: #1F1A16;
  --ink-muted: #6E645C;
  --primary: #C9441C;
  --on-primary: #FFFFFF;
  --primary-soft: #FFE7DC;
  --brand-night: #2E1660;
  --sun: #FFC23D;
  --on-sun: #1F1A16;
  --sage: #2B7656;
  --live: #13843F;      /* "someone is waiting" pill: white text 5:1 */
  --on-live: #FFFFFF;
  --danger: #B3261E;
  --on-danger: #FFFFFF;
  --focus-ring: var(--ink);
  --shadow-card: 0 1px 2px rgba(31,26,22,.06), 0 6px 20px rgba(31,26,22,.06);
  --shadow-dice: 0 5px 0 #C8901A;

  --font-display: "Geologica", system-ui, sans-serif;
  --font-text: "Onest", system-ui, -apple-system, "Segoe UI", sans-serif;

  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 24px; --space-6: 32px; --space-7: 48px;
  --radius-sm: 10px; --radius-md: 14px; --radius-lg: 20px; --radius-tail: 6px;
  --radius-xl: 28px; --radius-full: 999px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --surface: #141110;
    --surface-sunk: #1F1A17;
    --line: #332B26;
    --ink: #F5EFE9;
    --ink-muted: #A89C92;
    --primary: #FF7A4F;
    --on-primary: #2A0E04;
    --primary-soft: #3A2218;
    --brand-night: #4A2A8C;
    --sun: #FFC94F;
    --on-sun: #141110;
    --sage: #5CC795;
    --live: #3FD47F;
    --on-live: #06210F;
    --danger: #FF6B5E;
    --on-danger: #2A0705;
    --shadow-card: none;
    --shadow-dice: 0 5px 0 #9A6C12;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--surface);
  color: var(--ink);
  font: 400 16px/24px var(--font-text);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

.ico { width: 24px; height: 24px; flex: none; display: inline-block; vertical-align: middle;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ico-sm { width: 18px; height: 18px; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: max(12px, env(safe-area-inset-top)) var(--space-4) 12px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; height: 32px; }
.brand img { height: 32px; width: auto; display: block; }
.topbar-actions { display: flex; gap: var(--space-2); }
.chip {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: var(--radius-full); padding: 6px 12px; font: 600 13px/18px var(--font-text);
  text-decoration: none; cursor: pointer;
}

main { max-width: 480px; margin: 0 auto; padding: var(--space-2) var(--space-4) calc(var(--space-6) + env(safe-area-inset-bottom)); }
.screen { display: flex; flex-direction: column; gap: var(--space-4); animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

h1 { font: 800 40px/44px var(--font-display); letter-spacing: -.01em; margin: var(--space-5) 0 0; text-wrap: balance; }
h2 { font: 800 30px/34px var(--font-display); margin: var(--space-1) 0 0; text-wrap: balance; }
.lead { font-size: 17px; line-height: 25px; color: var(--ink-muted); margin: 0; }
.muted { color: var(--ink-muted); margin: 0; }
.small { font-size: 13px; line-height: 18px; }
.center { text-align: center; }
.step { margin: var(--space-2) 0 0; font: 700 12px/16px var(--font-text); color: var(--primary); text-transform: uppercase; letter-spacing: .06em; }
.label { margin: 0 0 var(--space-3); font: 600 14px/20px var(--font-text); }
.hero-mark { width: 72px; height: 72px; margin-top: var(--space-5); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--space-4); }
.stack { display: flex; flex-direction: column; gap: var(--space-3); }
.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 6px; font: 600 14px/20px var(--font-text); }
.form small { color: var(--ink-muted); font-weight: 400; }
input, textarea {
  font: 400 16px/24px var(--font-text); color: var(--ink); background: var(--surface-sunk);
  border: 1px solid var(--line); border-radius: var(--radius-md); padding: 12px 14px; width: 100%;
}
input:focus, textarea:focus { outline: 2px solid var(--focus-ring); outline-offset: 1px; }
.form label.check { flex-direction: row; align-items: center; gap: 10px; font-weight: 500; }
.check input { width: 22px; height: 22px; accent-color: var(--primary); }
.error { color: var(--danger); margin: 0; min-height: 1em; font-size: 14px; }
.ok { color: var(--sage); }

.tabs { display: flex; background: var(--surface-sunk); border-radius: var(--radius-md); padding: 4px; }
.tab { flex: 1; border: 0; background: transparent; padding: 10px; border-radius: var(--radius-sm); font: 700 15px/20px var(--font-text); color: var(--ink-muted); cursor: pointer; }
.tab.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 48px; border: 0; border-radius: var(--radius-md); padding: 0 var(--space-5);
  font: 600 16px/24px var(--font-text); cursor: pointer; transition: transform .08s ease, opacity .2s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--primary); color: var(--on-primary); }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.btn.danger { background: var(--danger); color: var(--on-danger); }
.btn.big { min-height: 64px; border-radius: var(--radius-xl); font: 800 20px/24px var(--font-display); }
.btn.big .ico { width: 26px; height: 26px; }
.btn.on { background: var(--ink); color: var(--surface); }
.link { background: none; border: 0; color: var(--primary); font: 600 15px/20px var(--font-text); cursor: pointer; padding: 4px; }
.center-block { display: block; margin: 0 auto; }
.danger-text { color: var(--danger); }

.seg { display: flex; gap: var(--space-2); }
.seg button, .seg label {
  position: relative; flex: 1; text-align: center; border: 1px solid var(--line); background: var(--surface-sunk);
  border-radius: var(--radius-sm); padding: 12px 6px; font: 700 15px/20px var(--font-text); cursor: pointer; color: var(--ink);
}
.seg button.on { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
#durationSeg button { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.seg-wait { display: inline-flex; align-items: center; gap: 5px; margin-top: 2px; padding: 2px 9px 2px 7px; border-radius: var(--radius-full);
  background: var(--live); color: var(--on-live); font: 700 12px/16px var(--font-text); }
.seg-wait::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: live-pulse 1.6s ease-in-out infinite; }
.seg button.on .seg-wait { box-shadow: 0 0 0 2px var(--on-primary); }
@keyframes live-pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .seg-wait::before { animation: none; } }
.presence { display: flex; align-items: center; gap: 8px; margin: 0; font: 500 14px/20px var(--font-text); color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.presence b { color: var(--ink); font-weight: 700; }
.presence .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--sage); flex: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--sage) 22%, transparent); }
.presence.invite .dot { background: var(--primary); box-shadow: none; }
.presence-invite { display: inline-flex; align-items: center; gap: 8px; padding: 0; border: 0; background: none; cursor: pointer;
  font: 600 14px/20px var(--font-text); color: var(--primary); text-decoration: underline; text-underline-offset: 3px; }
.presence-invite:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; border-radius: 4px; }
.share-sheet { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(20, 17, 16, .45); padding: 0 max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px)); }
.share-card { width: 100%; max-width: 460px; display: flex; flex-direction: column; gap: var(--space-2);
  background: var(--surface); border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: var(--space-5) var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom, 0px)); box-shadow: var(--shadow-card); }
.share-card a.btn { text-decoration: none; justify-content: center; }
.share-wa { background: #1F8F4E; color: #FFFFFF; border-color: #1F8F4E; }
.share-tg { background: #1E88D3; color: #FFFFFF; border-color: #1E88D3; }
.seg.four label { padding: 10px 4px; font-size: 14px; }
.seg label input { position: absolute; inset: 0; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
fieldset.q { margin: 0; }
fieldset.q legend { font: 700 16px/22px var(--font-text); padding: 0; margin-bottom: var(--space-3); float: left; width: 100%; }
fieldset.q legend small { display: block; font-weight: 400; color: var(--ink-muted); font-size: 13px; }
fieldset.q .seg { clear: both; }

.topic-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.topic {
  display: flex; align-items: center; gap: var(--space-3); text-align: left;
  background: var(--surface-sunk); border: 2px solid transparent; border-radius: var(--radius-lg);
  padding: 14px 12px; font: 600 15px/20px var(--font-text); color: var(--ink); cursor: pointer;
}
.topic.on { border-color: var(--primary); background: var(--primary-soft); }

.hello { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-top: var(--space-2); }
.hello h2 { font-size: 24px; line-height: 30px; }
.level { display: inline-flex; align-items: center; gap: var(--space-2); padding: 4px 12px 4px 4px; border-radius: var(--radius-full); background: var(--surface-sunk); font: 700 13px/18px var(--font-text); white-space: nowrap; }
.level img { width: 28px; height: 28px; display: block; }
.tags { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.tag { display: inline-flex; align-items: center; gap: 6px; background: var(--primary-soft); border-radius: var(--radius-full); padding: 6px 12px; font: 600 14px/20px var(--font-text); }
.row-between { display: flex; align-items: baseline; justify-content: space-between; }
.row-between .label { margin: 0 0 var(--space-3); }

/* Searching */
.pulse { position: relative; width: 140px; height: 140px; margin: var(--space-7) auto var(--space-2); }
.pulse span { position: absolute; inset: 0; border-radius: 50%; background: var(--primary); opacity: .22; animation: ripple 2.4s infinite ease-out; }
.pulse span:nth-child(2) { animation-delay: .8s; }
.pulse span:nth-child(3) { animation-delay: 1.6s; }
.pulse img { position: absolute; inset: 38px; width: 64px; height: 64px; border-radius: 16px; }
@keyframes ripple { from { transform: scale(.45); opacity: .5; } to { transform: scale(1.2); opacity: 0; } }

/* Call */
.call-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-top: var(--space-2); }
.partner { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.avatar { width: 52px; height: 52px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font: 800 22px/1 var(--font-display); flex: none; }
.partner-name { font: 800 20px/26px var(--font-display); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.partner-meta { display: flex; align-items: center; gap: 6px; }
.partner-meta img { width: 18px; height: 18px; }
.timer { font: 800 28px/32px var(--font-display); font-variant-numeric: tabular-nums; }
.timer.ending { color: var(--danger); }
.status { margin: 0; color: var(--ink-muted); font-size: 14px; }

.voices { display: flex; gap: 10px; }
.voice { flex: 1; display: flex; align-items: center; gap: var(--space-2); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); border-radius: var(--radius-md); padding: 10px 12px; font: 600 14px/20px var(--font-text); }
.voice .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line); transition: background .1s, box-shadow .1s; }
.voice.talking .dot { background: var(--sage); box-shadow: 0 0 0 5px color-mix(in srgb, var(--sage) 25%, transparent); }

.prompt { border: 2px solid var(--sun); border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) var(--radius-tail); box-shadow: var(--shadow-card); }
.prompt.pop { animation: pop .3s ease; }
@keyframes pop { 0% { transform: scale(.94); opacity: 0; } 100% { transform: none; opacity: 1; } }
.prompt-topic { display: flex; align-items: center; gap: 6px; font: 700 12px/16px var(--font-text); color: var(--ink-muted); text-transform: uppercase; letter-spacing: .06em; }
.prompt-topic .ico { width: 16px; height: 16px; }
.prompt-kz { font: 700 22px/28px var(--font-display); margin: var(--space-2) 0 var(--space-1); }
.prompt-ru { margin: var(--space-1) 0 0; color: var(--ink-muted); font-size: 13px; line-height: 18px; }

.dice-wrap { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); margin-top: var(--space-1); }
.dice { width: 88px; height: 88px; border-radius: var(--radius-xl); border: 0; cursor: pointer; background: var(--sun); color: var(--on-sun); box-shadow: var(--shadow-dice); display: grid; place-items: center; transition: transform .1s; }
.dice .ico { width: 40px; height: 40px; }
.dice:active { transform: translateY(3px); box-shadow: 0 2px 0 #C8901A; }
.dice:disabled { opacity: .7; cursor: default; }
.dice.rolling { animation: roll .5s infinite linear; opacity: 1; }
@keyframes roll { 0% { transform: rotate(0) scale(1); } 25% { transform: rotate(90deg) scale(.92); } 50% { transform: rotate(180deg) scale(1.05); } 75% { transform: rotate(270deg) scale(.95); } 100% { transform: rotate(360deg) scale(1); } }

.call-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: var(--space-2); }

/* After call */
.vote { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); }
.vote-btn { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 16px 8px; border-radius: 16px;
  border: 2px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; }
.vote-btn .ico { width: 32px; height: 32px; }
.vote-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
#likeBtn[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
#dislikeBtn[aria-pressed="true"] { border-color: var(--ink-muted); background: var(--surface-sunk); }
#screen-after h2 { margin-top: var(--space-6); }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--surface); padding: 12px 16px; border-radius: var(--radius-md); font-weight: 600;
  max-width: calc(100% - 32px); z-index: 10; text-align: center;
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.call-actions .btn { padding: 0 var(--space-3); white-space: nowrap; font-size: 15px; }
.tg-card { display: flex; flex-direction: column; gap: var(--space-3); align-items: flex-start; }
.tg-widget { min-height: 48px; }
