/* ---------------------------------------------------------------------------
   base.css
   The picture book shell: palette, type, cards, controls. Shared by every scene
   so the colour language stays identical wherever a role appears.

   Colour roles. These mean the same thing in every scene, and the reader is
   meant to learn them by repetition:
     locked    violet   claims that have accrued but are not counted in supply
     circ      coral    supply that is actually in circulation
     expand    green    expansion, issuance rising, reserves accumulating
     contract  red      contraction, buybacks, burning
     reserve   teal     hard reserves held by the protocol

   Two typefaces only: the system sans stack, and the system mono stack for
   numbers and technical vocabulary. Zero downloaded fonts.
   --------------------------------------------------------------------------- */

:root{
  --paper:#FBF2E2;
  --paper-2:#F3E4CA;
  --card:#FFFCF5;
  --card-2:#FFF8E9;
  --ink:#241E18;
  --ink-soft:#6E6053;
  --hair:#C9B79A;

  --locked:#5B3E9B;
  --locked-soft:#EFE9FA;
  --circ:#E0552F;
  --circ-soft:#FCEAE1;
  --expand:#2E9E67;
  --contract:#CB3220;
  --reserve:#157A6E;

  --shadow:5px 5px 0 var(--ink);
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "Cascadia Mono", "Segoe UI Mono", Consolas, monospace;
}

*{box-sizing:border-box}
html,body{margin:0;padding:0;overflow-x:hidden;max-width:100%}
body{
  background:var(--paper);
  color:var(--ink);
  font-family:var(--sans);
  font-size:16px;
  line-height:1.5;
  -webkit-text-size-adjust:100%;
  padding:0 14px calc(28px + env(safe-area-inset-bottom));
}
.wrap{max-width:430px;margin:0 auto}

/* ---------- header ---------- */
header{padding:26px 2px 6px}
.kicker{
  font-family:var(--mono);font-size:11px;letter-spacing:.16em;
  text-transform:uppercase;color:var(--ink-soft);margin:0 0 10px;
}
h1,.scene-title{
  font-size:clamp(28px,8.6vw,38px);line-height:1.03;
  letter-spacing:-.025em;font-weight:850;margin:0 0 12px;
}
.page-title{font-size:clamp(34px,10.5vw,46px)}
.masthead{padding-top:34px}
.progress{
  font-size:12.5px;line-height:1.5;color:var(--ink-soft);margin:0 0 6px;
}

/* ---------- the presentation layer ----------
   Scenes arrive one at a time and settle. Full viewport sections, a lateral
   entrance, progress marks and keyboard advance. dvh, so the Android URL bar
   collapsing does not resize a scene mid scroll.

   THERE IS NO SCROLL SNAPPING, AND IT SHOULD NOT BE PUT BACK.

   It was here, as `scroll-snap-type: y proximity` with `scroll-snap-align: start`
   on every section, and it was removed after it was reported yanking mid read on
   a real phone. The reason is structural rather than a matter of tuning. Nine of
   the fourteen sections are taller than the viewport, and a section taller than
   the screen has no correct resting position, so the only snap point it can
   offer is its own top. What then pulls a reader out of a paragraph is the
   snap point of the section they are approaching, which no amount of weakening
   the current section's alignment can prevent.

   Snapping only the sections that fit does not fix it either. That leaves the
   short ones still pulling a reader off the bottom of the tall one before them.

   Everything snapping was added for survives without it: the sections are still
   a viewport tall, content still arrives laterally, the marks still say where
   you are, and the arrow and page keys still move scene to scene. The one thing
   lost is the settle at the end of a flick on the five sections that fit, which
   is a small price for never fighting a thumb. */
@media (prefers-reduced-motion: no-preference){ html{scroll-behavior:smooth} }

.masthead,.scene{
  min-height:100vh;
  min-height:100dvh;
  display:grid;
  /* safe centring: a scene taller than the screen falls back to top aligned
     rather than overflowing off both ends where the top becomes unreachable */
  align-content:safe center;
  /* No block padding, deliberately. min-height is border box, so every pixel of
     padding here comes straight out of the content box, and scenes 2 and 6 carry
     about 740px against a 780px screen. A 34px gutter was enough to push both of
     them over. The breathing room they need already exists: every scene opens
     with a header carrying 26px of its own top padding, and closes on a card
     with 18px beneath it. Clearance from the progress marks is not this rule's
     job either, since those are position:fixed and float over whatever is at the
     bottom of the screen regardless. */
  padding-block:0;
}
.scene{position:relative}

/* Lateral entrance. Hidden only while scripting is on and the section has not
   arrived yet, so a scripting failure leaves everything visible. One way: coming
   back to a scene does not replay it. */
[data-entrances="on"] .masthead:not([data-entered="true"]) > *,
[data-entrances="on"] .scene:not([data-entered="true"]) > *{
  opacity:0;transform:translateX(26px);
}
[data-entrances="on"] .masthead > *,
[data-entrances="on"] .scene > *{
  transition:opacity .42s ease-out, transform .52s cubic-bezier(.22,.61,.36,1);
}
[data-entrances="on"] .scene > :nth-child(2){transition-delay:.06s}
[data-entrances="on"] .scene > :nth-child(3){transition-delay:.12s}
[data-entrances="on"] .scene > :nth-child(4){transition-delay:.17s}
[data-entrances="on"] .scene > :nth-child(5){transition-delay:.21s}
[data-entrances="on"] .scene > :nth-child(n+6){transition-delay:.25s}

/* ---------- progress ----------
   One mark per .scene, so the reader knows how much is left. Fourteen of them
   since the end check was added, which is correct: there really is one more
   thing after scene 13. An indicator, not a control: no tap targets this
   small. */
.progress-marks{
  position:fixed;left:0;right:0;z-index:12;
  bottom:calc(7px + env(safe-area-inset-bottom));
  display:flex;justify-content:center;gap:4px;
  pointer-events:none;
}
.progress-marks span{
  width:10px;height:3px;border-radius:2px;background:var(--hair);
  transition:background .25s ease-out, height .25s ease-out;
}
.progress-marks span[data-past="true"]{background:var(--ink-soft)}
.progress-marks span[data-on="true"]{background:var(--ink);height:6px}

@media (prefers-reduced-motion: reduce){
  html{scroll-behavior:auto}
  [data-entrances="on"] .masthead:not([data-entered="true"]) > *,
  [data-entrances="on"] .scene:not([data-entered="true"]) > *{opacity:1;transform:none}
  [data-entrances="on"] .masthead > *,
  [data-entrances="on"] .scene > *{transition:none}
  .progress-marks span{transition:none}
}
.standfirst{margin:0 0 14px;font-size:16.5px;color:#4A4038}
.disclaimer{
  font-size:12px;line-height:1.45;color:var(--ink-soft);
  border:2px dashed var(--hair);border-radius:14px;padding:9px 11px;margin:0 0 20px;
}
.disclaimer a{color:var(--ink)}

/* ---------- ambient touch ----------
   One quiet line saying a stage answers a finger. It goes the first time that
   stage is touched and keeps its space, so nothing reflows under the reader.
   Kept small on purpose: scenes 2 and 6 have under 40px of headroom against a
   780px screen and this line has to fit inside it.

   The cursors live here rather than in a per-scene file because they belong to
   the shared poke system, not to any one scene. */
.poke-hint{
  font-family:var(--mono);font-size:10.5px;letter-spacing:.1em;text-transform:uppercase;
  color:var(--ink-soft);text-align:center;
  margin:-10px 0 12px;
  transition:opacity .35s ease-out;
}
.poke-hint[data-done="true"]{opacity:0}
#s1-grab,#s2-grab{cursor:ew-resize}
#s2-lidHit{cursor:pointer}
#s6-grab{cursor:grab}
#s6-grab:active{cursor:grabbing}
@media (prefers-reduced-motion: reduce){ .poke-hint{transition:none} }

/* ---------- cards ---------- */
.card{
  background:var(--card);border:3px solid var(--ink);border-radius:22px;
  box-shadow:var(--shadow);padding:14px;margin:0 0 18px;
}
.card > h3{
  font-size:12px;font-family:var(--mono);letter-spacing:.13em;text-transform:uppercase;
  color:var(--ink-soft);margin:0 0 10px;font-weight:600;
}
.stage-card{padding:10px 10px 6px;background:var(--card-2)}
svg{display:block;width:100%;height:auto}

/* ---------- readout chips ---------- */
.readouts{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin:0 0 14px}
.chip{
  border:3px solid var(--ink);border-radius:16px;background:var(--card);
  box-shadow:3px 3px 0 var(--ink);padding:9px 10px;
}
.chip .lab{
  display:block;font-family:var(--mono);font-size:10px;letter-spacing:.1em;
  text-transform:uppercase;color:var(--ink-soft);margin-bottom:2px;
}
.chip .val{display:block;font-family:var(--mono);font-size:22px;font-weight:700;line-height:1.15}
.chip .sub{display:block;font-size:10.5px;line-height:1.3;color:var(--ink-soft);margin-top:3px}
.chip.locked{background:var(--locked-soft)}
.chip.locked .val{color:var(--locked)}
.chip.circ{background:var(--circ-soft)}
.chip.circ .val{color:var(--circ)}

/* ---------- hint line ---------- */
.hint{text-align:center;font-size:13.5px;color:var(--ink-soft);margin:2px 0 0;min-height:2.8em}
.hint b{color:var(--ink);font-weight:700}
.hint.tight{min-height:0;margin-top:8px}

/* ---------- range control ---------- */
.rowlab{display:flex;justify-content:space-between;align-items:baseline;gap:10px;margin:0 0 8px}
.rowlab .big{font-size:17px;font-weight:800}
.rowlab .num{font-family:var(--mono);font-size:17px;font-weight:700}
input[type=range]{-webkit-appearance:none;appearance:none;width:100%;height:34px;background:transparent;margin:0}
input[type=range]::-webkit-slider-runnable-track{
  height:16px;border-radius:10px;background:var(--paper-2);border:3px solid var(--ink);
}
input[type=range]::-webkit-slider-thumb{
  -webkit-appearance:none;appearance:none;width:34px;height:34px;border-radius:50%;
  background:var(--locked);border:3px solid var(--ink);box-shadow:2px 2px 0 var(--ink);margin-top:-12px;
}
input[type=range]::-moz-range-track{
  height:16px;border-radius:10px;background:var(--paper-2);border:3px solid var(--ink);
}
input[type=range]::-moz-range-thumb{
  width:30px;height:30px;border-radius:50%;background:var(--locked);border:3px solid var(--ink);
}
input[type=range]:focus-visible{outline:3px solid var(--locked);outline-offset:4px;border-radius:12px}
.scale{
  display:flex;justify-content:space-between;font-family:var(--mono);
  font-size:10.5px;color:var(--ink-soft);letter-spacing:.06em;text-transform:uppercase;
}

/* ---------- segmented control ---------- */
.seg{display:grid;grid-auto-flow:column;grid-auto-columns:1fr;gap:8px;margin:0}
.seg button{
  font:inherit;font-size:13.5px;font-weight:700;cursor:pointer;
  padding:10px 4px;border:3px solid var(--ink);border-radius:14px;
  background:var(--card);color:var(--ink);
}
.seg button[aria-checked="true"]{background:var(--ink);color:var(--paper)}
.seg button:focus-visible{outline:3px solid var(--locked);outline-offset:3px}

/* ---------- stats row ---------- */
.stats{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin:12px 0 0}
.stat{text-align:center;border:2.5px solid var(--ink);border-radius:14px;padding:7px 4px;background:var(--paper)}
.stat .v{display:block;font-family:var(--mono);font-size:18px;font-weight:700;line-height:1.2}
.stat .k{display:block;font-size:10.5px;color:var(--ink-soft);line-height:1.25;margin-top:1px}

/* ---------- lesson ---------- */
.lesson{background:var(--locked-soft)}
.lesson p{margin:0 0 10px;font-size:16px}
.lesson p:last-child{margin-bottom:0}
.lesson .plain{font-size:18.5px;font-weight:800;line-height:1.28;letter-spacing:-.01em}
.lesson .term{
  font-family:var(--mono);font-size:12.5px;color:#4B3E63;
  border-left:4px solid var(--locked);padding-left:10px;line-height:1.5;
}

/* ---------- the light scenes ----------
   Connective tissue between the tentpoles. One stage, one line of vocabulary,
   no lesson card. The animation is meant to carry it. */
.term-line{
  font-family:var(--mono);font-size:12.5px;line-height:1.55;color:var(--ink-soft);
  border-left:4px solid var(--hair);padding-left:10px;margin:14px 2px 4px;
}
.term-line b{color:var(--ink);font-weight:700}

/* ---------- footer ---------- */
footer{padding:4px 2px 10px;font-size:12px;color:var(--ink-soft);line-height:1.5}
footer a{color:var(--ink)}

.quiet{
  display:inline-block;font:inherit;font-size:12px;color:var(--ink-soft);
  background:none;border:0;border-bottom:1.5px dotted var(--hair);
  padding:2px 0;cursor:pointer;
}
.quiet:focus-visible{outline:3px solid var(--locked);outline-offset:3px}

.rm-note{display:none}
@media (prefers-reduced-motion: reduce){
  .rm-note{display:block;font-size:13px;color:var(--ink-soft);margin:8px 0 0}
}
