/* ===========================================================================
 * shared-chrome.css — the APP-WIDE rules the vocab sheet used to smuggle
 * ===========================================================================
 * Split out of subjects/vocab/styles.css (usability finding C6). Everything
 * here is selected by markup OUTSIDE the vocab app — the static shell in
 * index.html (`header.topbar`, the `.icon-btn` topbar buttons), the shared
 * <ModeHeader> in shared-app-shell.jsx (`.mode-header*`, `.home-link-*`,
 * `.progress-bar-*`, `.mode-progress-chip`), every `.mode-screen` sub-surface
 * (editing lab, guided math, practice home, admin queue, why-lessons, year
 * tests), and the document-level element rules. It used to load LAST (after
 * every component sheet) purely because it rode along with the vocab styles;
 * it now loads right after app-surface.css, BEFORE every subject/component
 * sheet.
 *
 * CASCADE NOTE — the move is order-preserving. These rules previously beat
 * index.html's inline <style> (`.icon-btn`, `header.topbar`'s padding/gap,
 * `:root` tokens) and they still do: the inline block is in <head> above the
 * app-surface.css link, so it is still earlier in document order. No selector
 * in this file collides at equal specificity with anything in the sheets that
 * load between here and the vocab sheet (reading, math, tool-btn, hint,
 * mc-grid, mc-item, analogy-item, passage-item, passage-edit-item,
 * anchor-paper, focus-rings, editing) — verified sheet by sheet.
 *
 * The :root block is the app's TOKEN source, not vocab decoration:
 * --radius / --radius-sm / --radius-lg / --shadow* / --font-mono have no
 * other definition anywhere, and mc-item.css, analogy-item.css,
 * passage-item.css, passage-edit-item.css, mc-grid.css, hint.css and
 * tool-btn.css all consume them. foundation.js's activateTheme() re-binds most
 * of the colour tokens as inline styles on <html> at runtime; these values are
 * the pre-paint fallback plus the sole source for the ones it doesn't set.
 *
 * Anything vocab-only lives on in subjects/vocab/styles.css, scoped under
 * :where(.vocab-app) (the class on VocabApp's root in subjects/vocab/app.jsx).
 * :where() is used deliberately: it adds ZERO specificity, so scoping changed
 * only what those rules MATCH, never which rule wins a tie.
 * ========================================================================= */
:root {
  /* Bookish — warm paper, deep ink, warm brown accent (from reference projects) */
  --cream: #F4EFE6;
  --cream-2: #EDE5D6;
  --cream-3: #E4D9C3;
  --surface: #FBF8F2;
  --surface-2: #EDE5D6;
  --ink: #2A2620;
  --ink-soft: #6B6355;
  --ink-faint: #A39A88;
  --ink-70: rgba(42, 38, 32, 0.72);
  --ink-50: rgba(42, 38, 32, 0.5);
  --ink-30: rgba(42, 38, 32, 0.3);
  --ink-10: rgba(42, 38, 32, 0.1);
  --ink-5: rgba(42, 38, 32, 0.05);

  --accent-coral: #C96F4A;
  --accent-coral-tint: #F1E0D3;
  --accent-coral-ink: #8A3F21;

  --accent-lavender: #7A5A3A;
  --accent-lavender-tint: #E9DEC9;
  --accent-lavender-ink: #5A3E1F;

  --accent-sage: #5B7A4A;
  --accent-sage-tint: #DDE6CF;
  --accent-sage-ink: #3D5630;

  --accent-marigold: #C89C4A;
  --accent-marigold-tint: #EFE1C1;
  --accent-marigold-ink: #7A5A26;

  --bg: var(--cream);

  --radius-inset: 4px;   /* read-only panes — near-square, see CLAUDE.md */
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(42,38,32,0.04), 0 2px 6px rgba(42,38,32,0.04);
  --shadow: 0 1px 2px rgba(42,38,32,0.03), 0 8px 24px rgba(42,38,32,0.05);
  --shadow-lg: 0 2px 4px rgba(42,38,32,0.04), 0 16px 40px rgba(42,38,32,0.08);

  --font-display: "Lexend", -apple-system, system-ui, sans-serif;
  --font-serif-body: "Iowan Old Style", "Charter", Georgia, serif;
  --font-ui: "Geist", -apple-system, system-ui, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* Keyboard focus ring — ONE definition for the whole app. The browser
     default is `1px auto rgb(0,95,204)`, a system blue that is the only
     unbranded pixel on a cream/warm palette (usability finding P2.8). 2px in
     the live theme accent, offset so the ring reads as a halo around the
     control rather than a border on it. components/items/focus-rings.css
     aliases its --item-focus-* onto these so the choice rows stay identical.
     Fallback hex matches that sheet's. */
  --focus-color: var(--accent, #B86E3E);
  --focus-width: 2px;
  --focus-offset: 2px;
}


* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; height: 100%; }

body {
  font-family: var(--font-ui); color: var(--ink);
  background: var(--cream-2); /* page frame color behind the mobile shell */
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  transition: background var(--dur-settle) var(--ease-settle), color var(--dur-settle) var(--ease-settle);
}


::-webkit-scrollbar { width: 0; height: 0; }


/* ---------- SHARED: TOPBAR + CARDS ---------- */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px 12px;
}


.icon-btn {
  background: var(--surface); border: 1px solid var(--ink-10); border-radius: 999px;
  width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--ink);
  transition: background var(--dur-quick) var(--ease-settle);
  /* A button does not inherit the page font: the "Aa" glyph rendered in the
     UA default (Arial) — the only non-Lexend UI string in the shell (D20). */
  font-family: var(--font-ui); font-size: inherit;
}

.icon-btn:hover { background: var(--cream-2); }

.icon-btn.small { width: 28px; height: 28px; }
/* The 36px base reaches the 44px floor through `.icon-btn::after { inset: -4px }`
   in app-surface.css; the 28px `.small` variant only reached 36. Widen the
   overlay for it alone — the glyph box is untouched, the hit area is 44. */
.icon-btn.small { position: relative; }
.icon-btn.small::after { content: ''; position: absolute; inset: -8px; }


/* ================= MODE SCREENS (shared) ================= */
/* No `min-height: 100vh` here: .mode-screen lives inside main.stage, which
   carries the text-size `zoom`, so a vh resolved in layout px and was THEN
   painted ×1.1 — every mode screen in the app grew a phantom tenth of a page.
   It painted nothing either way; the cream fill is `.shell`'s (and
   `.shell-body`'s at desktop), both outside the zoom. */
.mode-screen { padding: 0 0 40px; }


.mode-header {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px 10px;
}

.home-link-btn {
  display: inline-flex; align-items: center; gap: 4px;
  background: transparent; border: none; padding: 0; cursor: pointer;
  color: var(--accent-coral); font-size: 15px; font-weight: 600;
  font-family: var(--font-ui, inherit);
  flex-shrink: 0;
}

.home-link-btn:hover { opacity: 0.8; }

/* Destination label next to the ‹ chevron (e.g. "Home", "Rules"). */
.home-link-label { font-size: 15px; font-weight: 600; line-height: 1; }

/* Legacy inline title — kept for any un-migrated caller, but the canonical
   placement is now the below-bar eyebrow (.mode-header-eyebrow). */
.mode-header-title {
  flex: 1; font-family: var(--font-display);
  font-size: 18px; font-weight: 600; line-height: 1.1;
  text-align: left; padding-left: 4px;
}

/* Activity title — below-bar eyebrow (small-caps), generalized from the
   exam screen's .exam-qtype so every surface labels its activity the same
   way without crowding the top bar. */
.mode-header-eyebrow {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--ink-soft); font-weight: 700;
  font-family: var(--font-ui, inherit);
  padding: 0 20px; margin-bottom: 14px;
}

/* In-bar variant (PracticeHeader inlineTitle): occupies the bar's flex space
   instead of its own row below. */
.mode-header-eyebrow--inline {
  flex: 1; min-width: 0; padding: 0; margin: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* min-width: 0 is load-bearing, not tidiness (study P0.1): the runner's rail
   rides in here, and its counter carries text-overflow: ellipsis as the row's
   declared safety valve. A flex item defaults to min-width: auto, so without
   this the block refuses to shrink below its content and grows past the
   header instead — which pushed the karalama button off the right edge of a
   402pt screen during a deneme. The buttons themselves keep flex-shrink: 0
   (.icon-btn), so the counter is the one thing that gives. */
.mode-header-right { display: flex; align-items: center; gap: 8px; min-width: 0; }

.mode-header-meta { display: flex; gap: 6px; }

/* Runner rail overrides (study P0.4). Scoped to `.runner-rail` because they
   change shared chrome (.mode-header, .home-link-btn) for THAT bar only — the
   runner is the one surface where the row is genuinely full:
     · the back button may shrink and its label truncate. Shared chrome pins
       it at flex-shrink 0, which is what made the icons lose;
     · the tools never shrink and never wrap — they are the reason the bar
       exists;
     · the ‹ chevron keeps a 44pt hit box even with the label gone (study
       P1.15: it measured 22×22 in a deneme, and it is the only way out).
       The pad is on ::after, so nothing about the bar's layout changes. */
.runner-rail .mode-header { min-width: 0; }
.runner-rail .home-link-btn { flex-shrink: 1; min-width: 18px; overflow: hidden; }
.runner-rail .home-link-btn > svg { flex: 0 0 auto; }
.runner-rail .home-link-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.runner-rail .home-link-btn::after { left: -13px; right: -13px; top: -13px; bottom: -13px; }
/* The tools, the clock and the score never give ground; the counter is the
   rail's designated safety valve and carries flex: 0 1 auto inline. */
.runner-rail .mode-header-right > span > * { flex: 0 0 auto; }

.mode-progress-chip {
  background: var(--ink); color: var(--cream); font-variant-numeric: tabular-nums;
  padding: 5px 11px; border-radius: 999px; font-size: 12px; font-weight: 600;
}


/* When an eyebrow follows the bar, keep them tight (10px); the eyebrow adds
   its own 14px below. When the bar is the last header child (no eyebrow),
   restore the original 18px breathing room. */
.progress-bar-track {
  height: 5px; background: var(--ink-5); border-radius: 99px; overflow: hidden;
  margin: 0 20px 10px;
}

.progress-bar-track:last-child { margin-bottom: 18px; }

.progress-bar-fill {
  /* Flat, not a gradient: both stops resolve to theme.accent, so the gradient
     was a no-op between one colour and itself (usability D21). */
  height: 100%; background: var(--accent-coral);
  transition: width var(--dur-settle) var(--ease-settle);
}


.mode-body { padding: 0 20px; }

/* 16px is the floor, not a preference: iOS Safari zooms the whole page when a
   focused field is under 16px, and nothing zooms it back (usability A11/B13). */
input, select, textarea {
  font-family: inherit; font-size: 16px; padding: 8px 12px; border: 1px solid var(--ink-10);
  border-radius: 10px; background: var(--bg); color: var(--ink); width: 100%;
}

textarea { font-family: var(--font-mono); font-size: 16px; resize: vertical; }

input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-coral); outline-offset: -1px; border-color: transparent; }

/* Placeholders: a project token, not Chrome's grey. The UA default resolves to
   rgb(117,117,117) = 4.35:1 on the input's cream fill — just under AA (P2.11).
   --ink-soft is 5.6:1 on --surface and still 4.7:1 on the deepest cream the
   app paints an input on. `opacity: 1` because Firefox dims placeholders on
   top of the colour, which would undo the ratio. */
input::placeholder,
textarea::placeholder { color: var(--ink-soft); opacity: 1; }

/* ---------- Keyboard focus ring (app-wide) ----------
 * Everything focusable that does not paint its own ring gets the branded one.
 * :focus-visible only, so a mouse click never draws it; inputs keep their own
 * inset rule above (an input's ring belongs on its border, not around it).
 * Low specificity by design — a component that needs a different shape sets
 * its own outline (see components/items/focus-rings.css for the choice rows). */
:focus-visible {
  outline: var(--focus-width) solid var(--focus-color);
  outline-offset: var(--focus-offset);
}

/* High-contrast: the system colours must win, same as focus-rings.css. */
@media (forced-colors: active) {
  :focus-visible { outline: 2px solid CanvasText; outline-offset: 2px; }
}

/* An animation name is global and cannot be scoped, so any name the shell
   animates with has to live here. index.html's mobile bottom sheet
   (`animation: fadeIn 0.3s`) and `.confirm-scrim.open` both reference this and
   nothing else defines it — the vocab sheet was their only source. The
   vocab-only names (slideUp / pop) stayed behind: mc-item.css and
   analogy-item.css have their own `mc-shake`/`an-shake` and index.html its
   own `focus-ask-pop`, so none of them collide. */
@keyframes fadeIn { from { opacity: 0; } }
