/* Phrazo — «Прогулка» /walk/, S1 cards (doc/walk_mode_spec.md §2.8, §3.6).
   Standalone page stylesheet: /walk/ loads only fonts.css + this file, so the
   paper tokens from /style.css are mirrored here (same approach as decks.css).

   Layout contract, mobile-first and non-negotiable:
     * 100dvh column — head / card / thumb zone; the thumb zone is fixed at the
       bottom above safe-area-inset-bottom and does NOT move on reveal;
     * every interactive target ≥44px, grade + primary 52–56px, ≥12px between
       the two grade buttons;
     * content max-width 640px, no horizontal overflow at 280–430px;
     * native form controls ≥16px (iOS never zooms the picker);
     * prefers-reduced-motion removes movement, never a control. */

:root {
  --paper:   #f4efe4;
  --paper-2: #ebe4d3;
  --ink:     #1d1b16;
  --pencil:  #4a463c;
  --muted:   #8a8576;
  --accent:  #2f7a4f;
  --accent-soft: rgba(47,122,79,0.14);
  --warn:    #b04638;
  --warn-soft:   rgba(176,70,56,0.12);
  --hint:    #b08524;
  --shadow-card: 4px 4px 0 rgba(29,27,22,0.10);
  --font-sans: "IBM Plex Sans", system-ui, sans-serif;
  --font-hand: "Caveat", cursive;
  --thumb-gap: 12px;
  /* three-band stack: center / top / bottom heights + the gap between them */
  /* One height for all three bands: the thumb aims by row, not by size.
     56px is the height the grade buttons had before the stack landed. */
  --band-main: 56px;
  --band-top:  56px;
  --band-sub:  56px;
  --band-gap:  12px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: inherit; }

/* ---------------------------------------------------------------- shell -- */

.wk-app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 0 14px;
}

.wk-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--pencil);
}

.wk-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  border: 0;
  background: none;
  color: var(--ink);
  font-size: 20px;
  text-decoration: none;
  cursor: pointer;
}

.wk-head-title {
  font-size: 14px;
  color: var(--pencil);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wk-progress {
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  white-space: nowrap;
}

.wk-account {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 10px;
  font-size: 14px;
  color: var(--pencil);
  text-decoration: none;
  max-width: 40vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wk-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 0 24px;
  min-height: 0;
}

.wk-title {
  font-family: var(--font-hand);
  font-weight: 700;
  font-size: 34px;
  line-height: 1;
  margin: 0;
}

.wk-subtitle { font-size: 16px; margin: 4px 0 0; }
.wk-tagline  { color: var(--pencil); font-size: 15px; margin: 0; }
.wk-note     { color: var(--muted); font-size: 14px; margin: 4px 0 0; }
.wk-legend   { font-size: 15px; padding: 0; color: var(--ink); }

/* ---------------------------------------------------------------- buttons */

.wk-btn {
  appearance: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 18px;
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  background: var(--paper);
  border: 1.5px solid var(--ink);
  border-radius: 0;
  text-decoration: none;
  text-align: center;
}

.wk-btn:hover { background: var(--accent-soft); }
.wk-btn:disabled, .wk-btn[disabled] { opacity: .45; cursor: not-allowed; }
.wk-btn-primary { background: var(--accent); color: var(--paper); min-height: 56px; }
.wk-btn-primary:hover { background: var(--accent); filter: brightness(1.06); }
.wk-btn-wide { width: 100%; }

:focus-visible { outline: 3px solid var(--hint); outline-offset: 2px; }

/* ------------------------------------------------------- states / notices */

.wk-state {
  padding: 24px 0;
  color: var(--pencil);
  font-size: 16px;
}

.wk-notice { display: flex; flex-direction: column; gap: 12px; }
.wk-notice-body { margin: 0; color: var(--pencil); }
.wk-notice-actions { display: flex; flex-direction: column; gap: 10px; }

.wk-skeleton { display: grid; gap: 10px; }
.wk-skeleton span {
  display: block;
  height: 72px;
  background: var(--paper-2);
  border: 1.5px dashed var(--paper-2);
}

/* --------------------------------------------------------- source picker */

.wk-sources { display: grid; gap: 12px; }

.wk-source {
  appearance: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  width: 100%;
  min-height: 64px;
  padding: 14px 16px;
  text-align: left;
  background: var(--paper);
  border: 1.5px solid var(--ink);
  box-shadow: var(--shadow-card);
  font-family: var(--font-sans);
  color: var(--ink);
}

.wk-source[aria-pressed="true"] { background: var(--accent-soft); }
.wk-source-title { font-size: 17px; font-weight: 600; }
.wk-source-sub   { font-size: 14px; color: var(--pencil); }
.wk-source-badge {
  align-self: flex-start;
  font-size: 12px;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 2px 8px;
  border: 1px solid var(--accent);
  color: var(--accent);
}
.wk-source-locked {
  cursor: default;
  color: var(--muted);
  border-style: dashed;
  box-shadow: none;
  flex-direction: row;
  align-items: center;
  gap: 10px;
}
.wk-source-lock { font-size: 18px; }

.wk-expired {
  border: 1.5px dashed var(--warn);
  background: var(--warn-soft);
  padding: 12px 14px;
}
.wk-expired h2 { margin: 0 0 4px; font-size: 17px; }
.wk-expired p  { margin: 0 0 10px; font-size: 14px; }

.wk-sizes { border: 0; margin: 0; padding: 0; }
.wk-size-row { display: flex; gap: 10px; margin-top: 8px; }
.wk-size {
  appearance: none;
  cursor: pointer;
  flex: 1;
  min-height: 48px;
  font-size: 16px;
  font-weight: 600;
  background: var(--paper);
  border: 1.5px solid var(--ink);
  color: var(--ink);
}
.wk-size[aria-checked="true"] { background: var(--accent); color: var(--paper); }

.wk-decklist { display: grid; gap: 10px; margin-top: 8px; }
.wk-deck {
  appearance: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  min-height: 56px;
  padding: 10px 14px;
  text-align: left;
  background: var(--paper);
  border: 1.5px solid var(--ink);
  color: var(--ink);
  font-family: var(--font-sans);
}
.wk-deck[aria-pressed="true"] { background: var(--accent-soft); }
.wk-deck:disabled { opacity: .5; cursor: not-allowed; }
.wk-deck-title { font-size: 16px; font-weight: 600; }
.wk-deck-count, .wk-deck-note { font-size: 13px; color: var(--pencil); }

.wk-scope { display: grid; gap: 12px; margin-top: 8px; }
.wk-field { display: grid; gap: 4px; font-size: 14px; color: var(--pencil); }
/* 16px keeps iOS Safari from zooming the page when a select opens (§3.6). */
.wk-field select {
  min-height: 48px;
  font-size: 16px;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--paper);
  border: 1.5px solid var(--ink);
  padding: 0 10px;
  width: 100%;
}
.wk-chip-static { font-size: 14px; color: var(--pencil); margin: 0; }

.wk-picker-actions { display: grid; gap: 10px; margin-top: auto; padding-top: 12px; }

/* ------------------------------------------------------------- onboarding */

.wk-onboarding { display: flex; flex-direction: column; gap: 14px; }
.wk-steps { margin: 0; padding-left: 20px; display: grid; gap: 8px; font-size: 16px; }

/* ------------------------------------------------------------- card cycle */

.wk-bar {
  height: 4px;
  background: var(--paper-2);
  margin-top: 6px;
}
.wk-bar-fill { display: block; height: 100%; width: 0; background: var(--accent); }

.wk-meta { display: flex; flex-wrap: wrap; gap: 8px; min-height: 22px; padding-top: 8px; }
/* 14px is the floor for any required label (§3.6) — and these chips carry
   «Повтор» and «+K повторов», which the player leans on. */
.wk-chip {
  font-size: 14px;
  padding: 1px 8px;
  border: 1px solid var(--pencil);
  color: var(--pencil);
}
.wk-chip[hidden] { display: none; }
.wk-chip-repeat { border-color: var(--hint); color: var(--hint); }
.wk-chip-demo   { border-color: var(--accent); color: var(--accent); }
.wk-chip-audio  { border-color: var(--muted); color: var(--muted); }

/* The card grows, the thumb zone below never moves. Long phrases scroll INSIDE
   the card body (§2.8), which is why the overflow lives on .wk-card-body. */
.wk-main-card {
  padding-bottom: 0;
  justify-content: flex-start;
}

.wk-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex: 1;
  min-height: 40dvh;
  padding: 20px 16px;
  background: var(--paper);
  border: 1.5px solid var(--ink);
  box-shadow: var(--shadow-card);
  /* vertical scroll stays the browser's; horizontal drag is ours (§2.8). */
  touch-action: pan-y;
  /* A drag across a swipe card must not paint a text selection — and, more
     importantly, a selection left on the card turns the NEXT press into the
     browser's native "drag the selected text" gesture, which cancels the
     pointer stream (pointercancel, no move/up) and silently kills swiping.
     Deterministic on Linux Chromium and on real phones. */
  -webkit-user-select: none;
  user-select: none;
  cursor: pointer;
  overflow: hidden;
}

.wk-card-body {
  max-height: 55dvh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wk-ru {
  margin: 0;
  font-size: clamp(22px, 6vw, 30px);
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.wk-say { margin: 0; font-size: 15px; color: var(--muted); }

.wk-card[data-state="revealed"] .wk-ru,
.wk-card[data-state="answered"] .wk-ru { font-size: clamp(17px, 4.4vw, 20px); color: var(--pencil); }
.wk-card[data-state="revealed"] .wk-say,
.wk-card[data-state="answered"] .wk-say { display: none; }

.wk-en {
  margin: 0;
  font-size: clamp(22px, 6vw, 30px);
  line-height: 1.3;
  color: var(--ink);
  overflow-wrap: anywhere;
}

/* Drag feedback: the direction label is text, never colour alone (§3.6). */
.wk-swipe-label {
  position: absolute;
  top: 10px;
  font-size: 14px;
  font-weight: 700;
  padding: 2px 8px;
  border: 1.5px solid currentColor;
  opacity: 0;
}
.wk-swipe-pass { right: 10px; color: var(--accent); }
.wk-swipe-fail { left: 10px;  color: var(--warn); }
.wk-card[data-drag="pass"] .wk-swipe-pass { opacity: 1; }
.wk-card[data-drag="fail"] .wk-swipe-fail { opacity: 1; }

.wk-status {
  font-size: 14px;
  color: var(--warn);
  padding: 6px 0;
}
.wk-status[hidden] { display: none; }

/* Thumb zone: sticky at the bottom of the flow, clear of the home indicator.
   Its height is CONSTANT across prompt/revealed (§2.8 «Thumb zone ... не прыгает
   при reveal»): the replay row always occupies its slot and the swipe hint is
   taken out of the flow, so the grade buttons never move under the finger. */
.wk-thumb {
  /* sticky is also a positioned box, so it is the containing block for the
     absolutely positioned hint below. */
  position: sticky;
  bottom: 0;
  display: grid;
  gap: 10px;
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--paper);
}

/* ---- the three bands (owner decision 2026-08-20) -------------------------
   Three full-width bands, always three, stacked. The MEANING of a position is
   the same on every screen, so the thumb learns one map and never re-reads it:
     top    — «трудно» (не знал / повторить / пропустить): reached on purpose;
     center — «вперёд»: the most likely action of this screen;
     bottom — auxiliary and NON-destructive (ещё раз / пауза / готово).
   The bottom edge is where stray touches and system gestures land, so neither
   «Знал» (a false pass poisons the scheduler — that was bug D1) nor «Завершить»
   is ever placed there. Colour is a second signal only: every band has a full
   text label (§3.6). DOM order == visual order, so keyboard and screen reader
   walk them top → center → bottom. */
.wk-stack { display: grid; gap: var(--band-gap); }

.wk-band {
  appearance: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 6px 12px;
  font-family: var(--font-sans);
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  border: 1.5px solid var(--ink);
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
}
.wk-band:disabled { opacity: .45; cursor: not-allowed; }

/* center: the likely action — filled, tallest, unmissable with one thumb */
.wk-band-main { min-height: var(--band-main); font-size: 16px;
                background: var(--accent); color: var(--paper); }
/* top: the deliberate one — outlined, in the warn ink */
.wk-band-top  { min-height: var(--band-top); font-size: 16px;
                color: var(--warn); border-color: var(--warn); }
/* bottom: quiet, safe, never destructive */
.wk-band-sub  { min-height: var(--band-sub); font-size: 16px;
                color: var(--pencil); border-color: var(--pencil); }
.wk-band-sub[aria-pressed="true"] { background: var(--accent-soft); color: var(--ink); }

/* Secondary acquisition after a completed session. It stays in normal summary
   flow below the three-band grid and never occupies the fixed thumb zone. */
.wk-android-offer {
  display: grid;
  gap: 4px;
  /* .wk-main's 14px flex gap is the external clearance from .wk-stack. */
  margin: 0;
  padding: 14px 0 calc(10px + env(safe-area-inset-bottom, 0px));
  border-top: 1px dashed var(--pencil);
  color: var(--pencil);
}
.wk-android-offer p { margin: 0; font-size: 14px; }
.wk-android-offer a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  width: fit-content;
  color: var(--accent);
  font-weight: 600;
  text-underline-offset: 3px;
}

/* Narrow phones shrink the bands proportionally, never below 52/48/44 (§3.6
   target floor). 390/430 keep the full 72/60/56. */
@media (max-width: 360px) {
  :root { --band-main: 52px; --band-top: 52px; --band-sub: 52px; --band-gap: 10px; }
  .wk-band-main, .wk-band-top, .wk-band-sub { font-size: 15px; }
}
@media (max-width: 300px) {
  :root { --band-main: 48px; --band-top: 48px; --band-sub: 48px; --band-gap: 8px; }
}

/* One-time swipe hint floats ABOVE the thumb zone — it must never change the
   height of the zone it explains. */
.wk-swipe-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  margin: 0;
  padding: 2px 0 6px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  background: var(--paper);
}
.wk-swipe-hint[hidden] { display: none; }

/* Undo snackbar — 5s, above the thumb zone, never covering the grade buttons. */
.wk-snackbar {
  /* Anchored to the thumb zone, NOT to a hard-coded pixel offset: the stack is
     ~212px tall now and the old `bottom: 140px` put the snackbar straight on
     top of the «Не знаю» band for the whole 5s it lives. `bottom: 100%` of the
     sticky zone floats it above whatever ladder this viewport renders. */
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--ink);
  color: var(--paper);
  font-size: 15px;
  z-index: 20;
}
.wk-snackbar[hidden] { display: none; }
.wk-snack-text { flex: 1; min-width: 0; }
.wk-snack-action {
  min-height: 44px;
  padding: 6px 12px;
  background: transparent;
  color: var(--paper);
  border-color: var(--paper);
  font-size: 15px;
}
.wk-snack-action:hover { background: rgba(255,255,255,0.12); }

/* Bottom sheet: exit confirmation and the queue-full stop. */
.wk-sheet {
  position: fixed;
  inset: 0;
  background: rgba(29,27,22,0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 30;
}
.wk-sheet[hidden] { display: none; }
.wk-sheet-inner {
  width: min(640px, 100vw);
  display: grid;
  gap: 10px;
  padding: 16px 14px calc(16px + env(safe-area-inset-bottom, 0px));
  background: var(--paper);
  border-top: 1.5px solid var(--ink);
}
.wk-sheet-inner p { margin: 0 0 4px; font-size: 16px; }

/* ------------------------------------------------ format switch (§1.1) --- */
/* `Карточки | В наушниках`. Only rendered when the audio format really exists,
   so there is never a disabled tab promising something the build cannot do. */

.wk-modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border: 1.5px solid var(--ink);
}
.wk-mode {
  appearance: none;
  cursor: pointer;
  min-height: 48px;
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  background: var(--paper);
  border: 0;
}
.wk-mode + .wk-mode { border-left: 1.5px solid var(--ink); }
.wk-mode[aria-checked="true"] { background: var(--accent); color: var(--paper); }

/* ------------------------------------------------- preflight «В наушниках» */
/* Everything the walk promises is stated BEFORE the first play(): what will
   happen, how to control it with the headset, and that the phone can go away
   (§2.9). The primary button is the gesture that unlocks the audio element. */

.wk-preflight { gap: 10px; }
.wk-pre-line { margin: 0; font-size: 17px; }
.wk-pre-ready { color: var(--pencil); font-size: 15px; }
.wk-pre-note { margin: 0; font-size: 15px; color: var(--pencil); }
.wk-pre-warn { margin: 0; font-size: 15px; color: var(--warn); }
/* The 1×/2×/3× memo is the whole hands-free contract — it gets card weight. */
.wk-pre-hint {
  margin: 6px 0;
  padding: 12px 14px;
  font-size: 17px;
  line-height: 1.4;
  border: 1.5px dashed var(--accent);
  background: var(--accent-soft);
}

/* ------------------------------------------------------------ player §2.9 */

.wk-main-player { justify-content: center; gap: 12px; }
.wk-play-body { display: flex; flex-direction: column; gap: 12px; }
.wk-main-player .wk-ru { font-size: clamp(22px, 6vw, 30px); }
.wk-main-player .wk-en { font-size: clamp(20px, 5.2vw, 26px); color: var(--pencil); }
.wk-lock-note { margin: 0; font-size: 14px; color: var(--muted); }

/* «Отменить последнюю оценку» floats above the stack for its 5 seconds, so the
   three bands never move while it comes and goes. */
.wk-float-undo {
  position: absolute;
  right: 0;
  bottom: 100%;
  margin-bottom: 6px;
  min-height: 44px;
  padding: 6px 12px;
  font-family: var(--font-sans);
  font-size: 15px;
  cursor: pointer;
  color: var(--ink);
  background: var(--paper);
  border: 1.5px solid var(--ink);
}
.wk-float-undo[hidden] { display: none; }

/* «Завершить» in the header: destructive, so it is deliberately far from the
   thumb zone. Still a 44px target. */
.wk-head-finish {
  appearance: none;
  cursor: pointer;
  min-height: 44px;
  padding: 0 10px;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--pencil);
  background: none;
  border: 0;
  border-bottom: 1px dashed var(--pencil);
}
.wk-head-finish:hover { color: var(--ink); border-color: var(--ink); }

/* Player-side status line (interruption / stall / unit error). Distinct from
   the queue line above it, which keeps talking about the network. */
.wk-status-player { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; color: var(--pencil); }
.wk-status-player[hidden] { display: none; }
.wk-status-player[data-kind="warn"] { color: var(--warn); }
.wk-note-action { min-height: 44px; font-size: 15px; padding: 6px 12px; }

/* ----------------------------------------------------------------- summary */

.wk-summary-totals  { margin: 0; font-size: 18px; }
.wk-summary-counts  { margin: 0; font-size: 16px; }
.wk-summary-repeats,
.wk-summary-hard    { margin: 0; font-size: 15px; color: var(--pencil); }
/* Live save state: colour is a SECOND signal only — the wording already says
   whether the progress is saved, still flying or lost (§3.6). */
.wk-save-state      { margin: 8px 0 0; font-size: 15px; color: var(--accent); }
.wk-save-state[data-state="pending"] { color: var(--pencil); }
.wk-save-state[data-state="dropped"] { color: var(--warn); }
.wk-save-retry      { margin-top: 8px; }
.wk-save-retry[hidden] { display: none; }
.wk-guest-cta       { margin: 8px 0 0; font-size: 15px; color: var(--pencil); }

/* --------------------------------------------------------------- responsive */

/* 280px-wide phones: the bands are full width anyway, so only the page padding
   and the title give ground (band heights are handled by their own queries). */
@media (max-width: 330px) {
  .wk-app { padding: 0 10px; }
  .wk-title { font-size: 30px; }
  .wk-android-offer a { overflow-wrap: anywhere; }
}

/* Landscape: the card gives up height so the three bands stay reachable
   (§3.6) — they keep their own floor of 52/48/44. */
@media (orientation: landscape) and (max-height: 520px) {
  :root { --band-main: 48px; --band-top: 48px; --band-sub: 48px; --band-gap: 8px; }
  .wk-card { min-height: 22dvh; }
  .wk-card-body { max-height: 28dvh; }
  .wk-btn-primary { min-height: 48px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
