/* =============================================================================
   Kwizzo: Crossfade — client/a11y.css
   Preference and adaptation styles. Owner: author D.

   OWNERSHIP BOUNDARY (ARCHITECTURE_CONTRACT / module_map)
   app.css owns components, layout and the design tokens. This file owns
   *adaptation*: every `prefers-reduced-motion`, `prefers-contrast` and
   `forced-colors` query, the `:focus-visible` ring, the `.kz-sr-only` utility
   and the reflow rules that must survive 200% zoom and a 320px viewport.
   index.html loads app.css first and this file second, so everything here wins
   on source order at equal specificity. No new component class is introduced:
   every selector below names a class app.css or screens.mjs already emits.

   HOW ADAPTATION WORKS HERE
   app.css exposes the whole motion and colour system as tokens, so this file
   adapts the application by flipping tokens rather than by re-styling parts:

     --kz-motion-scale  1 -> 0        zeroes every duration and delay
     --kz-anim-beat     name -> none  removes the reveal's entrance stagger
     --kz-anim-ghost    name -> none  removes the Signal Ghost pressure pulse
     --kz-focus / --kz-focus-halo / --kz-focus-w / --kz-focus-offset
     --kz-line / --kz-line-strong / --kz-ink-2 / --kz-shadow
     --kz-font-scale    written on :root by a11y.mjs applyPreferences()

   THE HOOKS a11y.mjs WRITES ON <html> (applyPreferences, a11y.mjs:1062)
     data-kz-motion        = "reduced" | "full"
     data-kz-contrast      = "more"    | "normal"
     data-kz-forced-colors = "active"  | "none"
     data-kz-switch        = "on"      | "off"
     data-kz-ghost         = "text"    | "full"
     data-kz-confirm-lock  = "on"      | "off"
     data-kz-split-allowed = "yes"     | "no"
     style --kz-font-scale = 1 .. 2
   The manual toggle sits ON TOP of the system preference, never under it: a
   player who explicitly turns motion back on keeps it, so every preference
   media query below is guarded by :not([data-kz-motion="full"]) and friends.
   app.css also ships `.reduced-motion` / `[data-motion="reduced"]` /
   `.kz-app.is-reduced-motion`; those spellings are honoured here too, so the
   manual toggle works with no media query involved at all.

   NO TEXT LIVES HERE
   Nothing in this file renders a word a player reads. The non-colour carriers
   added under forced colours are language-neutral glyphs, and every one of them
   is authored with the CSS alt-text form `content: "…" / ""` so a screen reader
   is not made to speak decoration. Where a browser lacks alt-text support the
   plain declaration that precedes it still paints the glyph.

   FOCUS RING, MEASURED (sRGB, WCAG 2.x, computed not assumed)
     light  ring #141210 on bg #f4f1e9 16.6:1   on surface #ffffff 18.7:1
     dark   ring #ffc24a on bg #0d0f12 11.9:1   on surface #16191e 11.0:1
   The ring never has to contrast with the control's own face: `outline-offset`
   holds it 2px clear and the halo box-shadow fills that gap with
   --kz-focus-halo, so a ring around .kz-btn--primary is measured against the
   halo (18.7:1 light, 11.0:1 dark) and never against the signal blue.

   HIGH-CONTRAST TOKENS, MEASURED
     light  ink-2 #3d3831 on surface 11.6:1  on bg 10.3:1   line #57514a 7.8:1
     dark   ink-2 #ded9cd on surface 13.0:1                 line #9aa2b0 7.1:1
   ========================================================================== */

/* -----------------------------------------------------------------------------
   1. THE TWO UTILITIES a11y.mjs DEPENDS ON

   .kz-sr-only  index.html:48-49 puts it on #kz-status and #kz-announce, and
                a11y.mjs ensureRegion() writes it on any live region it has to
                recreate. Those regions hold the clock and the reveal/ceiling/
                lock log; they carry no focusable content, so this hides them
                unconditionally and there is no focus-reveal exception to make.
   .kz-reason   a11y.mjs softDisable() appends it inside a control that has gone
                unavailable. It is the reason as *visible text* rather than a
                tooltip, which is the whole point of soft-disabling: the control
                keeps its tab stop and says why it does nothing.
   -------------------------------------------------------------------------- */

.kz-sr-only {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.kz-reason {
  display: block;
  margin-block-start: var(--kz-s1);
  font-size: var(--kz-fs-100);
  font-weight: 400;
  line-height: var(--kz-lh-snug);
  color: var(--kz-ink-2);
  overflow-wrap: break-word;
}
.kz-reason:empty { display: none; }

/* -----------------------------------------------------------------------------
   2. FOCUS

   app.css ships a baseline ring on :focus so a visible indicator exists even if
   this file never loads. Here it is narrowed to :focus-visible — and only where
   :focus-visible is actually supported, so an old engine keeps the baseline
   rather than losing the ring. Neither outline nor box-shadow participates in
   layout, so nothing moves when focus arrives: the focus order and the geometry
   are both stable while the clock runs.
   -------------------------------------------------------------------------- */

:where(a[href], button, input, select, textarea, summary, [tabindex], [role="radio"],
       [role="option"], [role="tab"], [role="button"]):focus-visible {
  outline: var(--kz-focus-w) solid var(--kz-focus);
  outline-offset: var(--kz-focus-offset);
  box-shadow: 0 0 0 var(--kz-focus-offset) var(--kz-focus-halo);
}

@supports selector(:focus-visible) {
  :where(a[href], button, input, select, textarea, summary, [tabindex], [role="radio"],
         [role="option"], [role="tab"], [role="button"]):focus:not(:focus-visible) {
    outline: none;
    box-shadow: none;
  }
}

/* A soft-disabled control (aria-disabled, tab stop intact) still takes focus and
   still shows the ring — losing the ring there would strand a keyboard player on
   an element they cannot see. */
[aria-disabled="true"]:focus-visible,
[data-kz-inert]:focus-visible,
.is-inert:focus-visible {
  outline: var(--kz-focus-w) solid var(--kz-focus);
  outline-offset: var(--kz-focus-offset);
}

/* The skip link reveals itself on any focus, keyboard or not: it is the first
   thing in the document and the only way past the banner. */
#kz-skip:focus,
#kz-skip:focus-visible {
  inset-block-start: var(--kz-s3);
  outline: var(--kz-focus-w) solid var(--kz-focus);
  outline-offset: var(--kz-focus-offset);
}

/* Programmatic focus lands on headings and on #kz-app (tabindex="-1"). They get
   the ring too — a11y.mjs moves focus there on every screen swap and the player
   has to be able to see where it went. */
:where(#kz-app, .kz-screen__title, .kz-shield__title, [tabindex="-1"]):focus-visible {
  outline: var(--kz-focus-w) solid var(--kz-focus);
  outline-offset: var(--kz-focus-offset);
}

/* -----------------------------------------------------------------------------
   3. REDUCED MOTION

   Two independent paths, deliberately: the system preference, and a class /
   attribute hook so the settings toggle works with no media query at all.
   Both do the same three things — zero the motion scale, drop both animation
   names, and hard-stop any transition or animation a component might add later.

   What is NEVER removed is timing *text*. The countdown, the timing-profile
   sentence, the ledger and the question counter are information, not motion,
   and they are re-asserted visible at the end of each path.
   -------------------------------------------------------------------------- */

/* -- 3a. the manual hook (no media query) ---------------------------------- */

:root.reduced-motion,
:root[data-motion="reduced"],
:root[data-kz-motion="reduced"],
.kz-app.is-reduced-motion {
  --kz-motion-scale: 0;
  --kz-anim-beat: none;
  --kz-anim-ghost: none;
  scroll-behavior: auto;
}

:root.reduced-motion *,
:root.reduced-motion *::before,
:root.reduced-motion *::after,
:root[data-motion="reduced"] *,
:root[data-motion="reduced"] *::before,
:root[data-motion="reduced"] *::after,
:root[data-kz-motion="reduced"] *,
:root[data-kz-motion="reduced"] *::before,
:root[data-kz-motion="reduced"] *::after,
.kz-app.is-reduced-motion *,
.kz-app.is-reduced-motion *::before,
.kz-app.is-reduced-motion *::after {
  animation: none !important;
  transition: none !important;
  scroll-behavior: auto !important;
}

/* -- 3b. the system preference -------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  /* :not([data-kz-motion="full"]) — a player who overrode the system setting in
     settings keeps their override. a11y.mjs writes "full" only on an explicit
     choice, so before boot the attribute is absent and the preference stands. */
  :root:not([data-kz-motion="full"]) {
    --kz-motion-scale: 0;
    --kz-anim-beat: none;
    --kz-anim-ghost: none;
    scroll-behavior: auto;
  }

  :root:not([data-kz-motion="full"]) *,
  :root:not([data-kz-motion="full"]) *::before,
  :root:not([data-kz-motion="full"]) *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* -- 3c. the ghost pulse, named by hand ------------------------------------ *
   ACCESSIBILITY_TEST_MATRIX names the Signal Ghost pressure pulse specifically.
   app.css animates .kz-ghost__seg.is-on; screens.mjs GhostPanel emits
   .kz-ghost__pulse. Both are killed, in both paths, and the ghost's words stay:
   the panel is words first and the graphic was always optional.
   ------------------------------------------------------------------------- */

:root.reduced-motion .kz-ghost__seg,
:root[data-motion="reduced"] .kz-ghost__seg,
:root[data-kz-motion="reduced"] .kz-ghost__seg,
:root.reduced-motion .kz-ghost__pulse,
:root[data-motion="reduced"] .kz-ghost__pulse,
:root[data-kz-motion="reduced"] .kz-ghost__pulse,
.kz-app.is-reduced-motion .kz-ghost__seg,
.kz-app.is-reduced-motion .kz-ghost__pulse {
  animation: none !important;
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  :root:not([data-kz-motion="full"]) .kz-ghost__seg,
  :root:not([data-kz-motion="full"]) .kz-ghost__pulse {
    animation: none !important;
    opacity: 1;
  }
}

/* -- 3d. timing text survives every motion profile ------------------------- */

.kz-clock,
.kz-clock__line,
.kz-clock__label,
.kz-clock__value,
.kz-clock__state,
.kz-clock__profile,
.kz-clock__text,
.kz-ledger,
.kz-ledger dt,
.kz-ledger dd,
.kz-reveal__advance-note,
.kz-reveal__meta,
.kz-results__timing,
.kz-question__counter {
  opacity: 1;
  visibility: visible;
}

/* The bar keeps shrinking because screens.mjs writes its width inline each tick;
   only the tween between ticks is removed. The readout above it is the real
   clock, and it is text. */
:root.reduced-motion .kz-clock__fill,
:root[data-motion="reduced"] .kz-clock__fill,
:root[data-kz-motion="reduced"] .kz-clock__fill {
  transition: none !important;
}
@media (prefers-reduced-motion: reduce) {
  :root:not([data-kz-motion="full"]) .kz-clock__fill { transition: none !important; }
}

/* -----------------------------------------------------------------------------
   4. MORE CONTRAST

   The high-contrast values are declared once per theme as --kz-hc-* and then
   assigned to the live tokens by both the preference query and the manual
   attribute. That keeps light and dark correct without four copies of the
   palette, and it changes colour only: no border grows, no padding moves, so a
   contrast change under the clock cannot shift a control a player is aiming at.
   -------------------------------------------------------------------------- */

:root {
  --kz-hc-ink-2: #3d3831;
  --kz-hc-line: #57514a;
  --kz-hc-line-strong: #141210;
  --kz-hc-signal: #10309a;
  --kz-hc-ok: #114426;
  --kz-hc-bad: #7d1712;
  --kz-hc-urgent: #7a2d00;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --kz-hc-ink-2: #ded9cd;
    --kz-hc-line: #9aa2b0;
    --kz-hc-line-strong: #f2efe8;
    --kz-hc-signal: #b9d2ff;
    --kz-hc-ok: #9ce7b1;
    --kz-hc-bad: #ffb5a8;
    --kz-hc-urgent: #ffcd8c;
  }
}

:root[data-theme="dark"] {
  --kz-hc-ink-2: #ded9cd;
  --kz-hc-line: #9aa2b0;
  --kz-hc-line-strong: #f2efe8;
  --kz-hc-signal: #b9d2ff;
  --kz-hc-ok: #9ce7b1;
  --kz-hc-bad: #ffb5a8;
  --kz-hc-urgent: #ffcd8c;
}

@media (prefers-contrast: more) {
  :root:not([data-kz-contrast="normal"]) {
    --kz-ink-2: var(--kz-hc-ink-2);
    --kz-line: var(--kz-hc-line);
    --kz-line-strong: var(--kz-hc-line-strong);
    --kz-signal: var(--kz-hc-signal);
    --kz-ok: var(--kz-hc-ok);
    --kz-bad: var(--kz-hc-bad);
    --kz-urgent: var(--kz-hc-urgent);
    --kz-shadow: none;
  }
}

/* The explicit choice, from settings. a11y.mjs writes "more" for either source,
   so this selector also covers the preference once the client has booted. */
:root[data-kz-contrast="more"] {
  --kz-ink-2: var(--kz-hc-ink-2);
  --kz-line: var(--kz-hc-line);
  --kz-line-strong: var(--kz-hc-line-strong);
  --kz-signal: var(--kz-hc-signal);
  --kz-ok: var(--kz-hc-ok);
  --kz-bad: var(--kz-hc-bad);
  --kz-urgent: var(--kz-hc-urgent);
  --kz-shadow: none;
}

/* Decoration that dilutes an edge is dropped rather than darkened, and anything
   that was distinguished by a shade alone gains a second signal. */
@media (prefers-contrast: more) {
  :root:not([data-kz-contrast="normal"]) .kz-card,
  :root:not([data-kz-contrast="normal"]) .kz-btn,
  :root:not([data-kz-contrast="normal"]) .kz-seat { box-shadow: none; }

  :root:not([data-kz-contrast="normal"]) .kz-link,
  :root:not([data-kz-contrast="normal"]) .kz-reveal__source-link,
  :root:not([data-kz-contrast="normal"]) .kz-reveal__source a,
  :root:not([data-kz-contrast="normal"]) .kz-screen a[href] { text-decoration: underline; }

  /* Unavailable was a dashed border plus a dimmer ink; at more contrast the ink
     comes back up and the dash is what carries the state. */
  :root:not([data-kz-contrast="normal"]) [aria-disabled="true"],
  :root:not([data-kz-contrast="normal"]) [data-kz-inert],
  :root:not([data-kz-contrast="normal"]) .is-inert {
    border-style: dashed;
    color: var(--kz-ink-2);
  }
}

:root[data-kz-contrast="more"] .kz-card,
:root[data-kz-contrast="more"] .kz-btn,
:root[data-kz-contrast="more"] .kz-seat { box-shadow: none; }

:root[data-kz-contrast="more"] .kz-link,
:root[data-kz-contrast="more"] .kz-reveal__source-link,
:root[data-kz-contrast="more"] .kz-reveal__source a,
:root[data-kz-contrast="more"] .kz-screen a[href] { text-decoration: underline; }

:root[data-kz-contrast="more"] [aria-disabled="true"],
:root[data-kz-contrast="more"] [data-kz-inert],
:root[data-kz-contrast="more"] .is-inert {
  border-style: dashed;
  color: var(--kz-ink-2);
}

/* -----------------------------------------------------------------------------
   5. FORCED COLOURS

   The player's palette wins, completely. Every token is mapped to a system
   colour so the parts of the design the UA does NOT override — gradients,
   shadows, currentColor chains — collapse to the same palette as everything
   else, and the three things that must never be carried by colour alone get a
   carrier that survives: a border *pattern* (border-style is not overridden) or
   a glyph (a glyph is text).

     correctness  ✓ / ✕ glyph + solid vs dashed border
     urgency      ▸ ▸▸ ▸▸▸ ■ glyph + solid / dashed / double track
     identity     the seat glyph screens.mjs already renders, the "(you)" and
                  "(simulated)" words already in the row, plus a Highlight
                  outline on the local seat and a dotted rule on a simulated one

   Selector lists name both vocabularies on purpose: app.css's markup contract
   (.kz-answer[data-verdict], .kz-clock__text, .kz-seat) and the classes
   screens.mjs actually emits (.kz-reveal[data-outcome], .kz-clock__value,
   .kz-scoreboard__row). Whichever renders, the carrier is there.
   -------------------------------------------------------------------------- */

@media (forced-colors: active) {

  /* Equal specificity to app.css's theme blocks, later in source order. */
  :root,
  :root:not([data-theme="light"]),
  :root[data-theme="light"],
  :root[data-theme="dark"] {
    --kz-bg: Canvas;
    --kz-surface: Canvas;
    --kz-surface-2: Canvas;
    --kz-surface-inset: Canvas;
    --kz-ink: CanvasText;
    --kz-ink-2: CanvasText;
    --kz-line: CanvasText;
    --kz-line-strong: CanvasText;
    --kz-signal: LinkText;
    --kz-signal-ink: Canvas;
    --kz-ok: CanvasText;
    --kz-ok-ink: Canvas;
    --kz-bad: CanvasText;
    --kz-bad-ink: Canvas;
    --kz-urgent: CanvasText;
    --kz-urgent-ink: Canvas;
    --kz-lane-a: CanvasText;
    --kz-lane-b: CanvasText;
    --kz-focus: Highlight;
    --kz-focus-halo: Canvas;
    --kz-shadow: none;
  }

  /* Shadows are dropped by the UA; anything that used one as a state needs a
     replacement, and an outline is the one that survives. */
  .kz-card,
  .kz-btn,
  .kz-seat,
  .kz-split__half { box-shadow: none; }

  .kz-seat[aria-current="true"] {
    outline: 2px solid Highlight;
    outline-offset: -2px;
  }

  /* -- focus stays visible, in the system's own emphasis colour ------------ */
  :where(a[href], button, input, select, textarea, summary, [tabindex], [role="radio"],
         [role="option"], [role="tab"], [role="button"]):focus-visible,
  #kz-skip:focus,
  [aria-disabled="true"]:focus-visible,
  [data-kz-inert]:focus-visible {
    outline: var(--kz-focus-w) solid Highlight;
    outline-offset: var(--kz-focus-offset);
    box-shadow: none;
  }

  /* -- urgency ------------------------------------------------------------ *
     The clock is the only part of the app whose meaning is time-critical, so it
     is also the only one given forced-color-adjust: none — a progress bar with
     a UA-forced Canvas fill on a Canvas track is not a progress bar at all.
     The glyph is the carrier that works with no bar and no colour at all.
     ---------------------------------------------------------------------- */
  .kz-clock__track {
    forced-color-adjust: none;
    background: Canvas;
    border-color: CanvasText;
  }
  .kz-clock__fill {
    forced-color-adjust: none;
    background-image: none;
    background-color: Highlight;
  }
  /* border-STYLE only: the track keeps its 14px box, so nothing under a
     player's thumb moves as the seconds run out. */
  .kz-clock[data-urgency="mid"] .kz-clock__track { border-style: dashed; }
  .kz-clock[data-urgency="high"] .kz-clock__track { border-style: double; }
  .kz-clock[data-urgency="over"] .kz-clock__track,
  .kz-clock[data-urgency="expired"] .kz-clock__track { border-style: dotted; }

  .kz-clock[data-urgency="mid"] .kz-clock__value::after,
  .kz-clock[data-urgency="mid"] .kz-clock__text::after {
    content: " \25B8";
    content: " \25B8" / "";
  }
  .kz-clock[data-urgency="high"] .kz-clock__value::after,
  .kz-clock[data-urgency="high"] .kz-clock__text::after {
    content: " \25B8\25B8\25B8";
    content: " \25B8\25B8\25B8" / "";
    font-weight: 700;
  }
  .kz-clock[data-urgency="over"] .kz-clock__value::after,
  .kz-clock[data-urgency="expired"] .kz-clock__text::after {
    content: " \25A0";
    content: " \25A0" / "";
  }

  /* -- correctness -------------------------------------------------------- *
     screens.mjs already writes ✓ / ✕ / — into .kz-reveal__mark and a word into
     .kz-answer__state, so both are kept legible and a border pattern is added
     underneath them. .kz-answer[data-verdict] is app.css's contract spelling
     and only exists from the reveal phase; nothing here can leak an answer
     earlier, because the attribute is not in the document earlier.
     ---------------------------------------------------------------------- */
  .kz-answer[data-verdict="correct"],
  .kz-reveal[data-outcome="correct"] { border-style: solid; }
  .kz-answer[data-verdict="wrong"],
  .kz-reveal[data-outcome="wrong"] { border-style: dashed; }
  .kz-reveal[data-outcome="none"] { border-style: dotted; }

  .kz-answer[data-verdict="correct"] .kz-answer__state::after {
    content: " \2713";
    content: " \2713" / "";
  }
  .kz-answer[data-verdict="wrong"] .kz-answer__state::after {
    content: " \2715";
    content: " \2715" / "";
  }

  .kz-answer__mark,
  .kz-verdict__mark,
  .kz-reveal__mark,
  .kz-lane__mark,
  .kz-crossfade__glyph,
  .kz-banner__mark,
  .kz-seat__glyph,
  .kz-glyph {
    border-color: CanvasText;
    color: CanvasText;
    background: Canvas;
  }

  /* -- player identity ---------------------------------------------------- *
     app.css already distinguishes the six seats by border-STYLE, which forced
     colours leaves alone — that is the carrier and it needs no help. What does
     need help is screens.mjs's table, where "you" and "simulated" were tags in
     the text and a colour on the row.
     ---------------------------------------------------------------------- */
  .kz-scoreboard__row[data-you] {
    outline: 2px solid Highlight;
    outline-offset: -2px;
  }
  .kz-scoreboard__row[data-simulated] { font-style: italic; }
  .kz-scoreboard__row[data-simulated] td:first-child::before {
    content: "\25CC\00A0";
    content: "\25CC\00A0" / "";
  }

  /* The lane a player committed to. Lane identity is the ◐ / ◑ glyph plus the
     lane's own label; the border pattern is the third signal. */
  .kz-lane[data-lane="b"],
  .kz-crossfade__band[data-lane="b"],
  .kz-clue[data-lane="b"] { border-inline-start-style: dashed; }
  .kz-lane__btn[data-lane-state="yours"] { border-style: double; }
  .kz-lane__btn[data-lane-state="closed"],
  .kz-lane__btn[data-lane-state="spent"],
  .kz-crossfade__band[data-state="closed"] { border-style: dotted; }

  /* -- unavailable, and the simulation notice ----------------------------- */
  [aria-disabled="true"],
  [data-kz-inert],
  .is-inert,
  .kz-btn[disabled],
  .kz-lane[disabled] {
    color: GrayText;
    border-color: GrayText;
    border-style: dashed;
  }
  [aria-disabled="true"] .kz-reason,
  [data-kz-inert] .kz-reason { color: GrayText; }

  .kz-banner,
  .kz-banner--sim,
  .kz-banner--degraded,
  .kz-banner[data-kind="sim"] {
    border-color: CanvasText;
    background: Canvas;
    color: CanvasText;
  }
  .kz-banner--degraded,
  .kz-banner[data-kind="degraded"] { border-style: dashed; }

  /* Decorative marks made of borders survive; the two made of a fill do not. */
  .kz-ghost__seg.is-on,
  .kz-ghost__pulse {
    forced-color-adjust: none;
    background: CanvasText;
    border-color: CanvasText;
  }
  .kz-bands > i { border-color: CanvasText; }

  /* Gradients are never overridden by the UA, so any that is left would paint
     an invented palette over a chosen one. */
  .kz-clock[data-urgency="high"] .kz-clock__fill,
  .kz-screen,
  .kz-card,
  .kz-shield { background-image: none; }

  #kz-skip {
    background: Canvas;
    color: CanvasText;
    border-color: CanvasText;
  }
}

/* -----------------------------------------------------------------------------
   6. THE REMAINING a11y.mjs PREFERENCE HOOKS
   -------------------------------------------------------------------------- */

/* Text-only Signal Ghost. screens.mjs already hides the graphic when the pref is
   set; this is the same guarantee expressed in CSS, so a repaint that has not
   run yet cannot flash a graphic the player asked not to see. The ghost's words
   are never touched. */
:root[data-kz-ghost="text"] .kz-ghost__pulse,
:root[data-kz-ghost="text"] .kz-ghost__graphic,
.kz-ghost[data-text-only="true"] .kz-ghost__pulse,
.kz-ghost[data-text-only="true"] .kz-ghost__graphic { display: none; }

/* Split view is withheld, never squeezed: a11y.mjs measures the viewport with
   (min-width: 760px) and (min-height: 420px) and says no by attribute. */
:root[data-kz-split-allowed="no"] .kz-split,
:root[data-kz-split-allowed="no"] [data-split="on"] .kz-split { grid-template-columns: 1fr; }

/* Switch mode parks a fixed two-button pad at the bottom of the viewport
   (a11y.mjs PAD_STYLE). The pad reserves its own body padding; this makes sure
   the last control on a screen is not the thing sitting under it. */
:root[data-kz-switch="on"] .kz-screen { padding-block-end: calc(var(--kz-s8) + 56px); }

/* -----------------------------------------------------------------------------
   7. REFLOW — 320 CSS px equivalent, and 200% (to 400%) zoom.

   The contract is one axis of scrolling on the controller surface. Three
   mechanisms carry it, in this order:

   a. Nothing establishes a minimum width. Every flex and grid child that could
      refuse to shrink is pinned to min-inline-size: 0, and every string that
      could be one long token is allowed to break.
   b. Every multi-column container is auto-fit with a `min(100%, …)` track, so it
      collapses to one column by measurement rather than by breakpoint. This is
      what makes 200% zoom and --kz-font-scale: 2 behave, because neither is
      visible to a media query.
   c. Genuinely two-dimensional content — the results table — scrolls inside
      itself, which WCAG 1.4.10 allows and the page never does.

   Media queries are authored in em so that a browser text-size increase moves
   them exactly as a page zoom does.
   -------------------------------------------------------------------------- */

/* -- a. nothing refuses to shrink ----------------------------------------- */

.kz-app,
.kz-screen,
.kz-screen__body,
.kz-card,
.kz-question,
.kz-answers,
.kz-answers__grid,
.kz-lanes,
.kz-lane,
.kz-lane__row,
.kz-clue,
.kz-clue-list,
.kz-reveal,
.kz-reveal__lanes,
.kz-reveal__lane,
.kz-reveal__row,
.kz-ghost,
.kz-scoreboard,
.kz-split,
.kz-split__half,
.kz-row,
.kz-actions,
.kz-banner,
.kz-picker__row,
.kz-report,
.kz-fieldset { min-inline-size: 0; }

.kz-prompt,
.kz-question__prompt,
.kz-clue__text,
.kz-answer__label,
.kz-lane__name,
.kz-lane__state,
.kz-lane__hint,
.kz-host__text,
.kz-host__line,
.kz-reveal__explanation,
.kz-reveal__source-link,
.kz-banner__body,
.kz-banner__text,
.kz-screen__detail,
.kz-picker__name,
.kz-picker__reason,
.kz-alias,
.kz-ghost__line { overflow-wrap: anywhere; }

/* An href printed as its own label is the one string that is reliably longer
   than a 320px controller. */
.kz-reveal__source-link,
.kz-link { word-break: break-word; }

/* -- b. containers collapse by measurement, not by breakpoint -------------- *
   app.css already does this for the containers it knows about. These are the
   ones screens.mjs emits that app.css has no rule for, so without this they
   lay out as raw inline-block runs: no gap between adjacent 44px targets, and
   nothing to make them wrap. The gap token is app.css's 12px, which clears the
   8px separation a11y.mjs auditTargets() measures.
   ------------------------------------------------------------------------- */

.kz-actions,
.kz-lane__row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--kz-gap-target);
  align-items: stretch;
}
.kz-actions > *,
.kz-lane__row > * { min-inline-size: 0; }
.kz-lane__row > .kz-lane__btn { flex: 1 1 14rem; }

.kz-answers__grid,
.kz-reveal__lanes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  gap: var(--kz-gap-target);
}

.kz-report__reasons {
  display: grid;
  gap: var(--kz-gap-target);
  min-inline-size: 0;
}
.kz-report__option {
  display: flex;
  align-items: center;
  gap: var(--kz-s3);
  min-block-size: var(--kz-target);
  min-inline-size: 0;
}

/* -- c. the one place a second axis is allowed ----------------------------- *
   A results table is two-dimensional by meaning. It scrolls inside its own
   section; the document does not. app.css sanctions exactly this escape hatch
   as .kz-scroll-x, and these are its properties applied where the table is.
   ------------------------------------------------------------------------- */

.kz-scoreboard {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-gutter: stable;
}
.kz-scoreboard__table { inline-size: 100%; }

/* -- 480px and below: one column everywhere -------------------------------- */

@media (max-width: 30em) {
  .kz-answers,
  .kz-answers__grid,
  .kz-lanes,
  .kz-crossfade,
  .kz-reveal__lanes,
  .kz-ledger { grid-template-columns: 1fr; }

  .kz-lane__row { display: grid; grid-template-columns: 1fr; }
  .kz-lane__row > .kz-lane__btn { flex: none; }

  .kz-actions { display: grid; grid-template-columns: 1fr; }
  .kz-actions > .kz-target { inline-size: 100%; }

  .kz-split,
  [data-split="on"] .kz-split { grid-template-columns: 1fr; }

  /* The shield reserved 70dvh for a headline; at this width that is a screen of
     empty space above the one button the player has to reach. */
  .kz-shield { min-block-size: auto; padding: var(--kz-s5) var(--kz-s3); }
}

/* -- 320px equivalent: the case the audit fails first ---------------------- */

@media (max-width: 20em) {
  .kz-screen { padding-inline: var(--kz-s2); }
  .kz-card { padding-inline: var(--kz-s3); }
  .kz-clue { padding-inline-start: var(--kz-s3); }
  .kz-host { padding-inline-start: var(--kz-s3); }

  /* Tracking is what pushes a mono kicker past the viewport once the type ramp
     has been scaled; the words themselves fit. */
  .kz-kicker,
  .kz-answer__state,
  .kz-clock__label,
  .kz-ledger dt,
  .kz-host__intent,
  .kz-reveal__cue { letter-spacing: 0.04em; }

  .kz-final-score,
  .kz-ledger dd { letter-spacing: 0; }

  /* Two full-width tap targets stacked, still 44px apart-clear. */
  .kz-answers__grid,
  .kz-lane__row,
  .kz-actions { gap: var(--kz-gap-target); }
}

/* -- short and wide: a zoomed landscape phone ------------------------------ *
   Vertical scrolling is allowed and expected; what is not allowed is the
   vertical rhythm of the reveal pushing the advance control so far down that a
   player starts scrolling sideways looking for it.
   ------------------------------------------------------------------------- */

@media (max-height: 30em) and (orientation: landscape) {
  .kz-shield { min-block-size: auto; }
  .kz-reveal__pause { margin-block: var(--kz-s4); }
  .kz-reveal__explain { margin-block-start: var(--kz-s5); }
  .kz-screen { padding-block: var(--kz-s4) var(--kz-s6); }
}

/* -- the print / high-zoom floor ------------------------------------------- *
   At the largest text scale the host surface's 1.35x ramp stacks on top of the
   player's own scale and stops fitting. The host surface is a shared screen and
   is never the controller, so it gives up its extra ramp rather than the room
   giving up reading it.
   ------------------------------------------------------------------------- */

@media (max-width: 40em) {
  [data-surface="host"],
  [data-kz-surface="host"] { --kz-surface-scale: 1; }
  [data-surface="host"] .kz-screen,
  [data-kz-surface="host"] .kz-screen { max-inline-size: 100%; }
}

/* -----------------------------------------------------------------------------
   8. PRINT
   -------------------------------------------------------------------------- */

@media print {
  :root,
  :root:not([data-theme="light"]),
  :root[data-theme="light"],
  :root[data-theme="dark"] {
    color-scheme: light;
    --kz-bg: #fff;
    --kz-surface: #fff;
    --kz-surface-2: #fff;
    --kz-surface-inset: #fff;
    --kz-ink: #000;
    --kz-ink-2: #000;
    --kz-line: #000;
    --kz-line-strong: #000;
    --kz-signal: #000;
    --kz-signal-ink: #fff;
    --kz-ok: #000;
    --kz-ok-ink: #fff;
    --kz-bad: #000;
    --kz-bad-ink: #fff;
    --kz-urgent: #000;
    --kz-urgent-ink: #fff;
    --kz-lane-a: #000;
    --kz-lane-b: #000;
    --kz-shadow: none;
  }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  #kz-switch-pad,
  #kz-chrome,
  #kz-skip { display: none !important; }

  html,
  body,
  #kz-app,
  .kz-app,
  .kz-screen,
  .kz-card,
  .kz-scoreboard {
    background: #fff !important;
    color: #000 !important;
    box-shadow: none !important;
  }

  .kz-scoreboard {
    overflow: visible;
    overflow-x: visible;
  }

  .kz-card,
  .kz-reveal__row,
  .kz-scoreboard__row {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .kz-banner--sim,
  .kz-results__timing {
    visibility: visible;
    opacity: 1;
    background: #fff !important;
    color: #000 !important;
    border-color: #000 !important;
  }

  .kz-banner--sim { display: flex; }
  .kz-banner--sim > .kz-glyph {
    background: #fff !important;
    color: #000 !important;
    border-color: #000 !important;
  }
  .kz-results__timing { display: block; }
}
