/* Flashcard trainer on top of tokens.css + components.css. Tokens only. */

[hidden] { display: none !important; }

.site-header { background: color-mix(in srgb, var(--bg) 84%, transparent); backdrop-filter: blur(20px) saturate(130%); -webkit-backdrop-filter: blur(20px) saturate(130%); }
.name-mark::before { display: none; }
.nav-link-plain { font-size: 15px; font-weight: 700; padding: 12px 4px; }
.nav-link-plain:hover { color: var(--accent-deep); }

/* Trainer: edge-to-edge field, the app sits in it. */
.trainer { padding-top: calc(var(--header-height) + clamp(24px, 3.4vw, 48px)); padding-bottom: clamp(48px, 6vw, 88px); }
.trainer-grid { display: grid; grid-template-columns: minmax(280px, 0.8fr) minmax(0, 1.2fr); gap: clamp(32px, 6vw, 96px); align-items: start; }
.trainer-title { font-size: var(--fs-h2); font-weight: 600; line-height: 0.98; letter-spacing: var(--tr-h2); text-wrap: balance; }
.trainer-side .lead { margin-top: 22px; max-width: 460px; }

.progress { margin-top: 36px; }
.progress-nums { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 24px; }
.progress-nums > div { display: grid; gap: 6px; padding-top: 14px; border-top: 1px solid var(--line-strong); }
.progress-nums strong { font-size: clamp(34px, 3.6vw, 52px); font-weight: 600; line-height: 1; letter-spacing: -0.06em; font-variant-numeric: tabular-nums; }
.progress-nums span { color: var(--muted); font-size: var(--fs-small); font-weight: 600; }
.bar { height: 10px; margin-top: 22px; overflow: hidden; border-radius: 999px; background: var(--line-strong); }
.bar i { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--accent-bright); transition: width 420ms var(--ease-out); }

.controls { display: grid; gap: 12px; margin-top: 36px; }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg button, .toggle { display: inline-flex; min-height: 44px; align-items: center; gap: 8px; padding: 0 16px; border: 1px solid var(--line-strong); border-radius: 999px; background: color-mix(in srgb, var(--bg) 60%, transparent); cursor: pointer; font-size: 15px; font-weight: 700; transition: background-color 180ms ease, color 180ms ease, border-color 180ms ease; }
.seg button:hover, .toggle:hover { border-color: var(--ink); }
.seg button[aria-pressed="true"], .toggle[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: var(--bg); }
.seg button:disabled { opacity: 0.45; cursor: default; }
.label-gap { margin-top: 12px; }
#dirs button { text-align: left; white-space: normal; line-height: 1.25; padding-block: 8px; }
.control-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.toggle svg, .button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Card */
.stage { display: grid; gap: 20px; }
.card-wrap { perspective: 1600px; }
.card { position: relative; display: grid; min-height: clamp(340px, min(40vw, 100svh - 330px), 500px); cursor: pointer; transform-style: preserve-3d; transition: transform 620ms var(--ease-out); border-radius: var(--radius-lg); outline-offset: 6px; }
.card.flipped { transform: rotateY(180deg); }
.card.enter { animation: card-in 380ms var(--ease-out); }
@keyframes card-in { from { opacity: 0; translate: 0 18px; } to { opacity: 1; translate: 0 0; } }
.face { grid-area: 1 / 1; display: flex; flex-direction: column; gap: 18px; padding: clamp(24px, 3.6vw, 44px); border-radius: var(--radius-lg); color: var(--on-field); box-shadow: var(--shadow); backface-visibility: hidden; -webkit-backface-visibility: hidden; overflow: hidden; }
.back { transform: rotateY(180deg); }
.face .label { color: color-mix(in srgb, var(--on-field) 70%, transparent); }
.face-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.speak { display: grid; flex: none; width: 64px; height: 64px; place-items: center; border: 0; border-radius: 999px; background: var(--on-field); color: var(--field-sand); cursor: pointer; transition: transform 180ms var(--ease-out); }
.speak:hover { transform: scale(1.06); }
.speak:active { transform: scale(0.94); }
.speak.speaking { background: var(--accent-bright); color: var(--accent-ink); }
.speak svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.word { display: grid; flex: 1; place-items: center; font-size: clamp(64px, 10vw, 136px); font-weight: 700; line-height: 1; letter-spacing: -0.055em; text-align: center; overflow-wrap: anywhere; }
.word.long { font-size: clamp(48px, 7vw, 100px); }
.word[lang="ru"] { font-size: clamp(40px, 5.6vw, 80px); letter-spacing: -0.05em; overflow-wrap: normal; text-wrap: balance; }
.hint { color: color-mix(in srgb, var(--on-field) 66%, transparent); font-size: 15px; font-weight: 600; text-align: center; }
.translation { display: grid; flex: 1; place-items: center; font-size: clamp(40px, 5.6vw, 76px); font-weight: 700; line-height: 1.02; letter-spacing: -0.05em; text-align: center; text-wrap: balance; }
.forms { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 18px; }
.forms li { display: grid; gap: 6px; padding-top: 12px; border-top: 1px solid color-mix(in srgb, var(--on-field) 22%, transparent); }
.forms b { font-size: clamp(20px, 2.2vw, 30px); font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; overflow-wrap: anywhere; }
.note { font-size: 15px; line-height: 1.4; }
.added { display: inline-block; margin-right: 6px; padding: 3px 9px; border-radius: 999px; background: var(--on-field); color: var(--field-sand); font-size: var(--fs-micro); font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; vertical-align: 2px; }

.answer { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.button.big { min-height: 64px; font-size: 19px; border-radius: 999px; padding-inline: 24px; }
.keys { max-width: 560px; }
@media (hover: none) { .keys { display: none; } }

.done { display: grid; align-content: center; min-height: clamp(340px, min(40vw, 100svh - 330px), 500px); padding: clamp(28px, 4vw, 52px); border-radius: var(--radius-lg); background: var(--field-mint); color: var(--on-field); }
.done .eyebrow { color: color-mix(in srgb, var(--on-field) 80%, transparent); }
.done .lead { margin-top: 16px; color: color-mix(in srgb, var(--on-field) 72%, transparent); }
.done-title { font-size: var(--fs-h2); font-weight: 600; line-height: 0.98; letter-spacing: var(--tr-h2); }
.done .button-glass { border-color: color-mix(in srgb, var(--on-field) 30%, transparent); background: transparent; color: var(--on-field); }

/* Sync band */
.sync-title { font-size: var(--fs-h3); font-weight: 600; line-height: 1.1; letter-spacing: var(--tr-h3); }
#sync .split > :first-child .lead { margin-top: 16px; }
.sync-body { display: grid; gap: 14px; }
.sync-code { display: grid; gap: 8px; padding-top: 14px; border-top: 1px solid var(--line-strong); }
.sync-code strong { font-size: clamp(40px, 4.6vw, 64px); font-weight: 600; line-height: 1; letter-spacing: -0.04em; }
.sync-row { display: flex; gap: 10px; }
.field-input { flex: 1; min-width: 0; min-height: 48px; padding: 0 18px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--bg); font-size: 16px; }
.field-input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
#codeInput { text-transform: uppercase; letter-spacing: 0.06em; }
#codeInput::placeholder { text-transform: none; letter-spacing: 0; color: var(--muted); }
.sync-state { color: var(--muted); }
.sync-state[data-state="ok"]::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: var(--accent); vertical-align: 1px; }

/* List */
.board tbody tr { cursor: pointer; }
.board tbody tr:hover td { background: var(--accent-faint); }
.board td, .board th { padding: 14px 20px; }
.board td:first-child, .board th:first-child { width: 64px; color: var(--muted); font-variant-numeric: tabular-nums; }
.board .part-row td { padding: 12px 20px; background: var(--surface-2); color: var(--muted); font-size: var(--fs-micro); font-weight: 800; letter-spacing: var(--tr-eyebrow); text-transform: uppercase; cursor: default; }
.board .part-row:hover td { background: var(--surface-2); }
.v { font-weight: 700; }
.known-mark { display: inline-block; width: 18px; height: 18px; margin-left: 8px; vertical-align: -3px; stroke: var(--accent); fill: none; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.list-added { margin-left: 8px; color: var(--muted); font-size: var(--fs-micro); font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }

.foot { padding: 32px 0 calc(32px + env(safe-area-inset-bottom)); background: var(--surface-2); }

@media (max-width: 900px) {
  .trainer-grid { grid-template-columns: 1fr; }
  .stage { order: -1; }
  .trainer-side .lead { display: none; }
  .trainer-title { font-size: clamp(34px, 9vw, 52px); }
  .progress { margin-top: 22px; }
}
@media (max-width: 760px) {
  .trainer { padding-top: calc(var(--header-height) + 14px); }
  .card, .done { min-height: min(440px, 62svh); }
  .speak { width: 56px; height: 56px; }
  .word { font-size: clamp(54px, 17vw, 84px); }
  .word.long { font-size: clamp(40px, 12vw, 64px); }
  .translation { font-size: clamp(36px, 10vw, 54px); }
  .word[lang="ru"] { font-size: clamp(32px, 9vw, 48px); }
  .forms b { font-size: 19px; }
  .button.big { min-height: 60px; font-size: 18px; padding-inline: 12px; }
  .col-forms { display: none; }
  .keys { display: none; }
  .sync-row { flex-direction: column; }
  #sync .split { grid-template-columns: 1fr; gap: 24px; }
  .board td, .board th { padding: 12px 14px; }
  .board td:first-child, .board th:first-child { width: 44px; }
  .intro-row { grid-template-columns: 1fr; gap: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .card { transition: none; }
  .card.enter { animation: none; }
}
