/*
  Central stylesheet for every page. Update colors, spacing, or typography here
  to change the whole site at once.

  Theme (2026-09-19): the gamified direction built for the landing page, now
  shared. Hard vertical drop shadows make cards and buttons read as pressable
  game tiles. Pages that want it must load fonts.css alongside this file.

  Type, one job per face (2026-09-25 UI refresh):
  - Pixel Operator HB: page titles (h1), pixel letters in upper and lower case
    (2026-10-25; it replaced the dot-matrix Array, which visitors found hard to read).
  - Upheaval: short, loud titles only, in heavy arcade capitals (the landing
    hero, the Busters games, the Challenge area). It has no lowercase.
  Both have one weight, so their rules ask for 400: a bold would be faked and smear.
  - Dela Gothic One: section and card headings (h2, h3) and the nav, in title
    or sentence case. It is blocky enough that capitals shout.
  - Khand: numbers and small labels.
  - Clash Display 500: body copy.
  - Bungee: the wordmark, tags, buttons and all manipulative titles.
  - Kalam: handwritten notes.

  landing.css still sits on top of this for index.html, but only for the parts
  that are genuinely landing-only — the hero carousel, the chalkboards and the
  marker annotations.
*/

:root {
  /* Self-hosted faces, declared in fonts.css. */
  --font-display: "Pixel Operator HB", "Dela Gothic One", sans-serif;
  /* Short, loud titles: capitals only. */
  --font-arcade: "Upheaval", "Dela Gothic One", sans-serif;
  --font-heading: "Dela Gothic One", "Arial Black", sans-serif;
  --font-label: "Khand", "Arial Narrow", sans-serif;
  --font-body: "Clash Display", "Segoe UI", sans-serif;
  --font-hand: "Kalam", "Comic Sans MS", cursive;

  --cream: #fff6da;
  --paper: #ffffff;
  --ink: #17140f;
  --ink-soft: #433c2c;
  --muted: #5b543f;
  --yellow: #f6d51b;
  --yellow-soft: #fff0a8;
  --amber: #ff8a1e;
  --sky: #bfe6f2;
  --success: #a7e8b1;
  --danger: #ffaaa3;
  /* Chalk on the dark boards (landing, login, warmup): the answer boxes' dashed edge. */
  --chalk: #f3eee1;
  /* Chalkboards and marker scribbles: illustration colours. */
  --board: #24211d;
  --marker: #3a352e;

  /* The highlighter swash (see Swash): a hand-drawn stroke stretched behind a
     line of text. Yellow, and white for text on a yellow panel. It began on
     the home page (2026-10-29) and is the site's mark for "this one". */
  --swash-yellow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 600 70' preserveAspectRatio='none'%3E%3Cpath fill='%23f6d51b' d='M6 14 C120 4 300 12 470 6 C560 3 596 8 594 18 L592 52 C590 63 470 60 330 63 C210 66 90 62 10 58 C2 57 3 40 6 14 Z'/%3E%3C/svg%3E");
  --swash-white: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 600 70' preserveAspectRatio='none'%3E%3Cpath fill='%23ffffff' d='M6 14 C120 4 300 12 470 6 C560 3 596 8 594 18 L592 52 C590 63 470 60 330 63 C210 66 90 62 10 58 C2 57 3 40 6 14 Z'/%3E%3C/svg%3E");
  --border: var(--ink);

  /* Straight-down shadows: a tile sitting on the page, not a sticker offset to
     one side. Every rule that reads these tokens picks the direction up. */
  --shadow: 0 8px 0 var(--ink);
  --shadow-sm: 0 5px 0 var(--ink);

  /* Kept as aliases so component files (fastmath.css, passages.css) that
     reference the old names still resolve to sensible retro-theme colors. */
  --bg: var(--cream);
  --surface: var(--paper);
  --surface-strong: var(--paper);
  --text: var(--ink);
  --primary: var(--ink);
  --primary-dark: var(--ink);
  --secondary: var(--amber);
  --accent: var(--yellow-soft);
}

* {
  box-sizing: border-box;
}

/* Component layout rules must never override the native hidden state. */
[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

/*
  Gentle snapping on the card pages (owner, 2026-10-27): the dashboard, the
  four area hubs, the teacher pages and privacy carry body.snap-cards. When a
  scroll comes to rest near a card, the card settles just under the sticky
  header. Proximity, not the landing's mandatory snapping, so a long scroll
  is never fought. The very top is a stop of its own (body), so a page never
  snaps past its title on load. Tools, games, the warmup and the passages
  are left out on purpose: their content grows and shrinks as the student
  works, and the browser re-snaps when it does, which would jump the page.
*/
html:has(> body.snap-cards) {
  scroll-snap-type: y proximity;
  scroll-padding-top: 96px;
}

.snap-cards,
.snap-cards :is(.content-block, .manipulative-tile) {
  scroll-snap-align: start;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

/* Titles balance their lines and paragraphs avoid a lone last word. Both only
   choose where lines break, never how wide anything is. */
h1,
h2,
h3 {
  text-wrap: balance;
}

p,
li {
  text-wrap: pretty;
}

::selection {
  background: var(--yellow);
  color: var(--ink);
}

/*
  Gated pages ship with class="auth-gated" on <html> and stay invisible until
  assets/js/gate.js confirms the session and removes the class. ES modules are
  deferred, so without this a logged-out visitor would see a frame of gated
  content before the redirect fired. Each gated page carries a <noscript>
  override so the content is still readable with scripting off.
*/
.auth-gated body {
  visibility: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-weight: 500;
  color: var(--ink);
  background-color: var(--cream);
  background-image:
    radial-gradient(circle at 10% 6%, rgba(246, 213, 27, 0.6), transparent 32%),
    radial-gradient(circle at 94% 40%, rgba(246, 213, 27, 0.35), transparent 30%),
    radial-gradient(var(--ink) 1px, transparent 1px);
  background-size: auto, auto, 24px 24px;
  background-position: 0 0, 0 0, 0 0;
  background-repeat: no-repeat, no-repeat, repeat;
}

a {
  color: inherit;
  text-decoration: none;
}

/*
  Base heading type: the display face for page titles, the blocky heading face
  for everything below them. Every component rule below is a class or id
  selector, so it still wins; this only catches the headings nothing else
  claims — the hero's slide titles among them.
*/
h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.08;
}

/*
  The pixel-font bold (owner wanted weight, 2026-10-25). Pixel Operator has one
  weight, so each title is drawn twice, exactly one font pixel apart (its grid
  is 16 to the em), and spaced by the same pixel so letters do not merge. Any
  other offset leaves seams inside letters such as W. Only for the display face:
  the Bungee and arcade titles below take it off.
*/
h1,
.hero-copy h1,
.page-intro h1 {
  letter-spacing: 0.0625em;
  text-shadow: 0.0625em 0 0 currentColor;
}

h2 {
  margin: 0;
  font-family: var(--font-heading);
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.15;
}

h3 {
  margin: 0 0 8px;
  font-family: var(--font-heading);
  font-weight: 400;
  font-size: 1.2rem;
  line-height: 1.2;
  letter-spacing: 0;
}

:where(a, button, input, select, textarea):focus-visible {
  outline: 4px solid rgba(255, 138, 30, 0.72);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 200;
  top: 10px;
  left: 16px;
  padding: 12px 16px;
  transform: translateY(-200%);
  background: var(--yellow);
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 10px;
  font-family: var(--font-body);
  font-weight: 600;
}

.skip-link:focus {
  transform: translateY(0);
}

#main-content {
  scroll-margin-top: 175px;
}

.page-intro h1.tool-title {
  font-family: "Bungee", var(--font-heading);
  font-weight: 400;
  font-size: clamp(1.65rem, 3.1vw, 2.6rem);
  line-height: 1.25;
}

.page-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 40px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: "Bungee", sans-serif;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}

.brand-mark {
  height: 38px;
  width: auto;
  flex: none;
}

/* Stacked lockup — logo above, wordmark below — used in the footer to echo
   the flyers' actual layout (circle mark on top, "YAASK LABS" underneath). */
.brand-seal {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.brand-seal-mark {
  height: 84px;
  width: auto;
}

.brand-seal span {
  font-family: "Bungee", sans-serif;
  font-size: 1.3rem;
  letter-spacing: 0.02em;
  color: var(--cream);
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 22px;
  color: var(--ink);
  font-family: var(--font-heading);
  font-weight: 400;
  font-size: 1rem;
  letter-spacing: 0;
}

.site-nav a:not(.button):hover {
  text-decoration: underline;
  text-decoration-thickness: 3px;
  text-underline-offset: 5px;
}

.hero {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 28px;
  align-items: stretch;
  margin-bottom: 56px;
}

.hero-copy,
.hero-card,
.content-block,
.passage-card,
.page-intro {
  border: 3px solid var(--border);
  border-radius: 18px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.hero-copy,
.page-intro,
.content-block {
  padding: 32px;
}

/* A title that should shout: the arcade face (the Challenge area). */
.page-intro h1.arcade-title {
  font-family: var(--font-arcade);
}

.page-intro h1.arcade-title,
.page-intro h1.tool-title {
  letter-spacing: 0;
  text-shadow: none;
}

.hero-copy h1,
.page-intro h1 {
  margin: 0 0 18px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.5rem, 3.6vw, 3.4rem);
  line-height: 1.08;
}

.hero-text,
.page-intro p:not(.eyebrow),
.feature-card p:not(.eyebrow),
.study-panel p:not(.eyebrow),
.passage-card p:not(.eyebrow) {
  color: var(--ink-soft);
  font-size: 1.06rem;
  font-weight: 500;
  line-height: 1.65;
}

/* A dark tag with yellow capitals, like a level label on a game screen.
   Bungee, the wordmark face, is kept for these small tags only. */
.eyebrow {
  display: inline-block;
  margin: 0 0 16px;
  padding: 6px 12px;
  background: var(--ink);
  color: var(--yellow);
  border-radius: 8px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: "Bungee", var(--font-label);
  font-weight: 400;
  font-size: 0.8rem;
  line-height: 1.4;
}

.hero-actions,
.study-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  margin-top: 24px;
}

/* Bungee sits high in its box, so the padding is uneven to centre the caps. */
.button,
.site-nav a.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 2px 20px 0;
  border: 3px solid var(--ink);
  border-radius: 12px;
  font-family: "Bungee", var(--font-label);
  font-weight: 400;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  box-shadow: var(--shadow-sm);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.button:hover {
  transform: translateY(2px);
  box-shadow: 0 3px 0 var(--ink);
}

.button:active {
  transform: translateY(5px);
  box-shadow: 0 0 0 var(--ink);
}

.button-primary {
  color: var(--ink);
  background: var(--yellow);
}

.button-secondary {
  color: var(--ink);
  background: var(--paper);
}

.hero-card {
  display: grid;
  gap: 16px;
  padding: 24px;
  background: var(--ink);
  color: var(--cream);
}

.stat-card {
  padding: 20px;
  border-radius: 14px;
  background: rgba(255, 246, 218, 0.06);
  border: 2px solid rgba(246, 213, 27, 0.5);
}

/* Numbers take the condensed label face, never the display face: a figure
   read at a glance needs plain strokes, not arcade pixels. */
.stat-value {
  display: block;
  margin-bottom: 8px;
  font-family: var(--font-label);
  font-weight: 700;
  font-size: 1.9rem;
  color: var(--yellow);
}

.stat-label {
  color: rgba(255, 246, 218, 0.82);
  line-height: 1.55;
}

.content-block {
  margin-bottom: 36px;
}

.section-heading {
  max-width: 760px;
  margin-bottom: 30px;
}

/* Section titles take the heading face; only the page title (h1) keeps the
   dot-matrix display face, so the two never compete. */
.section-heading h2,
.passage-card h2 {
  margin: 0;
  font-family: var(--font-heading);
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.15;
}

/* A section card's own title is the same size, with or without the heading
   wrapper (2026-10-30: bare ones fell back to the browser's 1.5em). */
.section-heading h2,
.content-block > h2,
.content-block > .admin-section-heading h2 {
  font-size: clamp(1.35rem, 2.4vw, 1.7rem);
}

.study-panel h3,
.feature-card h3 {
  margin: 0;
  font-family: var(--font-heading);
  font-weight: 400;
  font-size: 1.2rem;
  line-height: 1.2;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.feature-card,
.passage-card {
  padding: 24px;
  border: 3px solid var(--border);
  border-radius: 16px;
  background: var(--paper);
  box-shadow: var(--shadow-sm);
}

.feature-card h3 {
  margin-bottom: 8px;
}

/* A yellow lip along the bottom inside edge, so the tile reads as lit. */
.card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  margin-bottom: 14px;
  border-radius: 12px;
  background: var(--ink);
  font-size: 1.3rem;
  box-shadow: inset 0 -4px 0 rgba(246, 213, 27, 0.35);
}

.card-icon svg {
  width: 24px;
  height: 24px;
  color: var(--yellow);
}

.accent-block {
  background: var(--yellow-soft);
}

/* ---------- Panels on the card pages (2026-11-15) ----------

  The home page's panels, on every page that is a set of cards (the ones that
  carry body.snap-cards: the dashboard, the four areas, the teacher hub,
  Accounts, Student Progress): pale yellow, with white cards inside and a dark
  tag (.eyebrow) over the title. Until now these were white panels holding
  cream cards. Tool workspaces, the warmup, passages and the report form are
  not card pages and stay white: their greens and reds carry meaning, and
  long text wants a white page (owner). */
.snap-cards :is(.page-intro, .content-block, .progress-card) {
  border-radius: 22px;
  background: var(--yellow-soft);
}

/* The tag is as wide as its words, also where the panel lays its children out
   in a column (the dashboard), and the panel ends at its last line. */
.snap-cards .page-intro .eyebrow {
  width: fit-content;
}

.snap-cards .page-intro > p:last-child {
  margin-bottom: 0;
}

/* A card's title takes the swash under the pointer or the keyboard: the
   site's mark for "this one". Drawn behind the words, so nothing moves. */
:is(.manipulative-tile, .practice-tile) h3 {
  position: relative;
  z-index: 0;
  width: fit-content;
}

:is(.manipulative-tile, .practice-tile) h3::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -0.22em -0.5em -0.3em;
  background: var(--swash-yellow) center / 100% 100% no-repeat;
  opacity: 0;
  transition: opacity 0.12s ease;
}

:is(.manipulative-tile, .practice-tile):is(:hover, :focus-visible) h3::before {
  opacity: 1;
}

/* ---------- The pixel world, where it has a job (2026-11-15) ----------

  The home page's student, flag, bricks and blocky arrows, on the inner pages
  only where they mean something (owner: accents with a job): the student
  stands at the next thing to do, cheers at the flag when a set is finished,
  and wonders at the login; progress is laid in bricks; an arrow is the blocky
  one. Never inside a tool's canvas or a game, and not on teacher or admin
  pages. The sprites are the hero's (assets/images/hero, drawn by
  scripts/build-hero-sprites.mjs), at half the hero's size: kid.svg is four
  frames of 32x50 (stand, blink, jump, cheer), emote.svg three of 22x26
  (?, !, a heart), flag.svg two of 30x24. */
.cast {
  position: absolute;
  z-index: 2;
  bottom: calc(100% - 3px);
  display: flex;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none;
}

.cast-kid {
  position: relative;
  width: 32px;
  height: 50px;
  background: url("/assets/images/hero/kid.svg") 0 0 / 128px 50px no-repeat;
  animation: cast-blink 4.2s steps(1) infinite;
}

@keyframes cast-blink {
  93% { background-position: -32px 0; }
  96% { background-position: 0 0; }
}

/* What the student thinks, over their head: "?" by default. */
.cast-emote {
  position: absolute;
  left: 8px;
  bottom: calc(100% + 2px);
  width: 22px;
  height: 26px;
  background: url("/assets/images/hero/emote.svg") 0 0 / 66px 26px no-repeat;
  animation: cast-bob 1.2s steps(1) infinite;
}

@keyframes cast-bob {
  50% { translate: 0 -2px; }
}

/* The finish (2026-11-16): the home page's flag, student and confetti, built
   by js/celebrate.js wherever something is finished. The cloth waits low on
   the pole, runs up when the success shows, and waves; the student hops in
   and cheers; confetti is thrown from the top of the pole. Half the home
   page's size, as on its consultation card. */
.pixel-flag { position: relative; display: inline-block; flex: none; width: 76px; height: 56px; vertical-align: bottom; pointer-events: none; }
.pixel-flag-pole { position: absolute; left: 40px; bottom: 0; width: 4px; height: 56px; background: var(--ink); }
.pixel-flag-pole::before { content: ""; position: absolute; left: -3px; top: -5px; width: 10px; height: 7px; border: 2px solid var(--ink); background: var(--yellow); }
.pixel-flag-cloth { position: absolute; left: 44px; top: 30px; width: 30px; height: 24px; background: url("/assets/images/hero/flag.svg") 0 0 / 60px 24px no-repeat; transition: transform .6s cubic-bezier(.3, 1.4, .5, 1); }
.pixel-flag-kid { position: absolute; left: 0; bottom: 0; width: 32px; height: 50px; background: url("/assets/images/hero/kid.svg") 0 0 / 128px 50px no-repeat; opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .3s; }
.pixel-flag.is-raised .pixel-flag-cloth { transform: translateY(-26px); animation: flag-wave .9s steps(1) .6s infinite; }
.pixel-flag.is-raised .pixel-flag-kid { opacity: 1; transform: none; background-position: -96px 0; animation: kid-hop .5s steps(1) .3s 1, kid-cheer .5s steps(1) .8s infinite; }
@keyframes flag-wave { 50% { background-position: -30px 0; } }
@keyframes kid-hop { 0% { background-position: -64px 0; translate: 0 -14px; } 50% { translate: 0 -6px; } 100% { translate: 0 0; } }
@keyframes kid-cheer { 50% { translate: 0 -2px; } }
.pixel-fx { position: absolute; inset: 0; overflow: visible; }
.pixel-fx i { position: absolute; left: var(--x); top: var(--y); width: var(--s); height: var(--s); margin: calc(var(--s) / -2) 0 0 calc(var(--s) / -2); background: var(--c); animation: bit-arc var(--life) linear forwards; }
@keyframes bit-arc {
  0% { animation-timing-function: cubic-bezier(.2, .7, .5, 1); }
  35% { transform: translate(calc(var(--dx) * .5), var(--up)); animation-timing-function: cubic-bezier(.5, 0, .9, .5); }
  80% { opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)); opacity: 0; }
}

/* Where it stands: after the words of a finished heading, and at the start
   of a success strip. */
:is(.is-finished-heading, .complete-screen h2) { display: flex; align-items: flex-end; gap: 12px; }
:is(.level-success, #success-message) .pixel-flag { margin: 0 2px -4px -2px; }

@media (prefers-reduced-motion: reduce) {
  .pixel-flag-cloth, .pixel-flag-kid { transition: none; }
  .pixel-flag.is-raised .pixel-flag-cloth, .pixel-flag.is-raised .pixel-flag-kid { animation: none; }
}

@media (prefers-reduced-motion: reduce) {
  .cast-kid,
  .cast-emote {
    animation: none;
  }
}

/* ---------- A tool's opening (2026-11-16) ----------

  Every tool opens the same way (owner): the way-back tag, the title on the
  page with its description beside it (or under it, when it is a sentence or
  two), then the workspace at the tools' common width. The 24 tools built on
  explore.css always did; Distance Speed and Time, Number Chase, Linear
  Equations and Assumed Mean had the title in a card of its own and the
  narrower page, and take this through body.tool-page. Diagram Lab is left as
  it is (owner: its own animal). */
.tool-page .tool-intro {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 18px;
  margin-bottom: 18px;
  padding: 4px 0 0;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
}

.tool-page .tool-intro h1 {
  margin: 0;
}

.tool-page .tool-intro p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 1.05rem;
}

/* Once work starts the old title card shrank and took a shadow; the title on
   the page stays as it is (its description still steps aside). */
.tool-page.workspace-active .tool-intro {
  padding: 4px 0 0;
  border-radius: 0;
  box-shadow: none;
}

.tool-page.workspace-active .tool-intro h1 {
  font-size: clamp(1.65rem, 3.1vw, 2.6rem);
}

@media (min-width: 1001px) {
  .tool-page .page-shell {
    width: min(1360px, calc(100% - 32px));
  }
}

/* ---------- Swash ----------

  The highlighter swash as a motif (owner, 2026-10-29, on the home page; the
  whole site since 2026-11-15): one padded box with the stroke stretched
  behind it, so a title that wraps sits on one swash, standing 0.55em over
  the text and 0.64em under it. */
.swash {
  display: inline-block;
  padding: 0.55em 0.7em 0.64em;
  background: var(--swash-image, var(--swash-yellow)) center / 100% 100% no-repeat;
}

.tool-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 26px;
  border: 3px solid var(--border);
  border-radius: 16px;
  background: var(--paper);
  box-shadow: var(--shadow-sm);
}

.tool-card .eyebrow {
  align-self: flex-start;
}

/*
  The grid makes the cards in a row equal height, but their copy is not equal:
  one heading wraps to two lines, one description runs a line longer. Left
  alone each button comes to rest wherever the text above it happens to end,
  at visibly different heights. The card is a flex column, so an auto top
  margin on the last child sends every spare pixel above the button and pins
  it to the foot of the card.
*/
.tool-card > :last-child {
  margin-top: auto;
}

.tool-card h3 {
  margin: 0;
  font-family: var(--font-heading);
  font-weight: 400;
  font-size: 1.25rem;
  line-height: 1.2;
}

.tool-card p:not(.eyebrow) {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.65;
}

.tool-list {
  margin: 0;
  padding-left: 20px;
  color: var(--ink-soft);
  line-height: 1.8;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.steps-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  counter-reset: step;
}

.step-card {
  position: relative;
  padding: 24px 24px 24px 60px;
  border: 3px solid var(--border);
  border-radius: 16px;
  background: var(--paper);
  box-shadow: var(--shadow-sm);
}

.step-card::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  top: 18px;
  left: 18px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--amber);
  color: var(--ink);
  font-family: "Bungee", var(--font-label);
  font-weight: 400;
  font-size: 0.85rem;
}

.step-card h3 {
  margin: 0 0 8px;
  font-family: var(--font-heading);
  font-weight: 400;
  font-size: 1.1rem;
  line-height: 1.2;
}

.step-card p:not(.eyebrow) {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.65;
}

.study-panel {
  justify-content: space-between;
  padding: 24px;
  border-radius: 16px;
  background: var(--paper);
  border: 3px solid var(--border);
}

.inner-page-shell {
  padding-top: 24px;
}

.page-intro {
  margin-bottom: 24px;
}

/* Once work starts, retain the tool's identity without repeatedly placing
   the full introductory treatment above the active workspace. */
.workspace-active .page-intro {
  padding: 18px 24px;
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
}

.workspace-active .page-intro .eyebrow {
  margin-bottom: 8px;
}

.workspace-active .page-intro h1 {
  margin: 0;
  font-size: clamp(1.25rem, 2.4vw, 1.8rem);
}

.workspace-active .page-intro p:not(.eyebrow) {
  display: none;
}

/* Flat and dashed: nothing to press. Kept distinct from the white secondary
   button, which the old grey fill made look switched off. */
.button:disabled {
  background: var(--cream);
  color: var(--muted);
  border-style: dashed;
  border-color: #8a8069;
  box-shadow: none;
  transform: none;
  cursor: not-allowed;
}

.passage-list {
  display: grid;
  gap: 18px;
}

.site-footer {
  margin-top: 12px;
  padding: 26px 32px;
  border: 3px solid var(--border);
  border-radius: 18px;
  background: var(--ink);
  color: var(--cream);
  box-shadow: var(--shadow);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.site-footer .brand {
  color: var(--cream);
}

/* On the dark footer, a black shadow disappears — swap it for yellow. */
.site-footer .button {
  box-shadow: 0 5px 0 var(--yellow);
}

.site-footer .button:hover {
  box-shadow: 0 3px 0 var(--yellow);
}

.site-footer .button:active {
  box-shadow: 0 0 0 var(--yellow);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: center;
  font-family: var(--font-heading);
  font-weight: 400;
  font-size: 1rem;
}

.footer-note {
  width: 100%;
  color: rgba(255, 246, 218, 0.65);
  font-size: 0.82rem;
}

@media (max-width: 860px) {
  .hero,
  .feature-grid,
  .tool-grid,
  .steps-grid {
    grid-template-columns: 1fr;
  }

  .site-header,
  .study-panel {
    align-items: flex-start;
    flex-direction: column;
  }
}

/* ---------- App header: the masthead (2026-11-15) ----------

  Every page behind a login shares this header, drawn by site-header.js, and
  the login and privacy pages write the same markup out. It is the home
  page's bar in its opening state (owner, 2026-11-15: the full-width
  masthead, not the floating island): a white bar across the window with the
  cards' border and shadow, the logo on its black tile as the left cap, Log
  out as the right cap, and the destinations spread between them. The current
  one sits on the highlighter swash. Unlike the home page's it never
  compacts, so nothing here needs a script.

  The bar is drawn by ::before, so the caps can sit flush with its ends, over
  its border. The exact page is named by the .breadcrumb above the main card,
  so the header never changes shape from page to page. It sits outside
  .page-shell so the bar can run edge to edge. */
.app-header {
  --bar-height: 64px;
  --bar-radius: 18px;
  position: sticky;
  top: 0;
  z-index: 50;
  /* The shadow's depth and a little air, so the page starts clear of the bar. */
  margin-bottom: 10px;
}

.app-header::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  border: 3px solid var(--ink);
  border-radius: var(--bar-radius);
  background: var(--paper);
  box-shadow: var(--shadow-sm);
}

.app-header-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: var(--bar-height);
}

/* The left cap: the logo on a black tile, flush with the bar's end. Pure
   black, to match the logo's own disc; the logo covers the tile (Logo.png is
   421x376 with its disc 357px across, so only its empty sides are cropped). */
.app-header .brand {
  flex: none;
  gap: 14px;
  white-space: nowrap;
}

.app-header .brand-mark {
  box-sizing: border-box;
  width: var(--bar-height);
  height: var(--bar-height);
  border-radius: var(--bar-radius);
  background: #000;
  object-fit: cover;
}

/* The destinations, spread across the bar between the caps. */
.app-nav {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-evenly;
  gap: 4px;
  font-family: var(--font-heading);
  font-size: 1rem;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 14px;
  border: 2px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  white-space: nowrap;
  cursor: pointer;
}

/* The link to the other site is hidden where it is not offered (site-switch.js). */
.nav-link[hidden] {
  display: none;
}

/* It leaves this site, so it is dashed like the admin's switch, not a destination. */
.app-header .app-nav .nav-link.nav-site-switch {
  border-style: dashed;
  border-color: var(--ink);
}

.app-nav .nav-link:hover {
  text-decoration: underline;
  text-decoration-thickness: 3px;
  text-underline-offset: 5px;
}

/* Where you are: on the swash, as every link of the home page's bar is. */
.app-nav .nav-link.is-current {
  min-height: 0;
  padding: 0.55em 0.7em 0.64em;
  border: 0;
  border-radius: 0;
  background: var(--swash-yellow) center / 100% 100% no-repeat;
  text-decoration: none;
}

.nav-link svg {
  width: 12px;
  height: 12px;
  transition: transform 0.15s ease;
}

.app-header-actions {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-heading);
  font-size: 1rem;
}

/* The right cap: Log out (or Log in, or the way home, on the public pages).
   The bar's full height with its corners, in the buttons' face. Ink, like the
   logo's tile at the other end: yellow is kept for the page's own action and
   for where you are. .nav-cap-primary is the home page's yellow Log in. */
.nav-logout,
.nav-cap {
  justify-content: center;
  height: var(--bar-height);
  min-height: var(--bar-height);
  padding: 2px 26px 0;
  border: 0;
  border-radius: var(--bar-radius);
  background: var(--ink);
  color: var(--cream);
  font-family: "Bungee", var(--font-label);
  font-weight: 400;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.nav-logout:hover,
.nav-cap:hover {
  color: var(--yellow);
}

.nav-cap.nav-cap-primary {
  border: 3px solid var(--ink);
  background: var(--yellow);
  color: var(--ink);
}

.nav-cap.nav-cap-primary:hover {
  color: var(--ink);
  box-shadow: inset 0 -4px 0 rgba(23, 20, 15, 0.22);
}

/* An admin's way across to the other area (2026-10-22): a round icon beside
   Log out, dashed because it leaves this area rather than moving within it.
   Its label is for screen readers (and the title for a pointer) on a desktop,
   and shows in the tablet menu. The copy inside the nav is the menu's. */
.nav-switch {
  justify-content: center;
  width: 44px;
  padding: 0;
  border: 2px dashed var(--ink);
}

.nav-switch svg {
  flex: none;
  width: 18px;
  height: 18px;
}

.nav-switch-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.app-nav .nav-switch {
  display: none;
}

/* Small desktops: the same bar, a little tighter, so it stays one row. */
@media (min-width: 1001px) and (max-width: 1200px) {
  .app-nav .nav-link {
    padding: 0 8px;
    font-size: 0.92rem;
  }

  .app-nav .nav-link.is-current {
    padding: 0.55em 0.6em 0.64em;
  }
}

/* The Menu button exists only on narrow screens. */
.nav-toggle {
  display: none;
}

/* Yellow line icon on an ink square: the one icon treatment on every page. */
.icon-box {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--ink);
  color: var(--yellow);
}

.icon-box svg {
  width: 20px;
  height: 20px;
}

.icon-box-lg {
  width: 48px;
  height: 48px;
  border-radius: 12px;
}

.icon-box-lg svg {
  width: 24px;
  height: 24px;
}

/* The way back (owner, 2026-11-15): on a page inside an area (a tool, a game,
   a passage, the warmup, a teacher's page), the area's name is a dark tag over
   the title, and the tag is the link back to it, with the blocky arrow
   pointing back. It is the card pages' .eyebrow with a job. Until now this
   was a line of text, "Tinker › Fountain"; the page's own name is still in
   the markup for screen readers, and the title under the tag shows it. */
.breadcrumb {
  display: flex;
  margin: 0 0 12px;
}

.breadcrumb a {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 6px 12px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--yellow);
  font-family: "Bungee", var(--font-label);
  font-weight: 400;
  font-size: 0.8rem;
  line-height: 1.4;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.breadcrumb a::before {
  content: "";
  flex: none;
  width: 13px;
  height: 11px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 13 11' shape-rendering='crispEdges'%3E%3Cpath fill='%23f6d51b' d='M5 4h8v3H5zM4 1h1v9H4zM3 2h1v7H3zM2 3h1v5H2zM1 4h1v3H1zM0 5h1v1H0z'/%3E%3C/svg%3E") center / contain no-repeat;
  transition: translate 0.12s ease;
}

.breadcrumb a:hover::before {
  translate: -3px 0;
}

/* The separator and the page's own name: read out, not shown. */
.breadcrumb > span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .breadcrumb a::before {
    transition: none;
  }
}

/* ---------- The header on narrow screens (2026-10-22) ----------

  Desktop first: everything above leaves the desktop bar exactly as it is,
  and this is a separate layout for tablets and narrow windows (phones have
  their own site). Seven destinations no longer fit one row, so they fold into
  a Menu panel inside the bar, under its row. The Menu button becomes the
  right cap, as on the home page, and Log out stays in the bar beside it, one
  tap away on a shared classroom device. site-header.js only toggles
  .is-open; the breakpoint lives here alone. */
@media (max-width: 1000px) {
  html:has(> body.snap-cards) {
    scroll-padding-top: 84px;
  }

  .app-header-inner {
    flex-wrap: wrap;
    gap: 0 10px;
  }

  .app-header .brand {
    margin-right: auto;
  }

  .nav-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: var(--bar-height);
    padding: 0 22px;
    border: 0;
    border-radius: var(--bar-radius);
    background: var(--ink);
    color: var(--yellow);
    font-family: var(--font-heading);
    font-size: 0.95rem;
    cursor: pointer;
  }

  .nav-toggle::after {
    content: "";
    width: 8px;
    height: 8px;
    border-right: 2.5px solid currentColor;
    border-bottom: 2.5px solid currentColor;
    transform: translateY(-2px) rotate(45deg);
    transition: transform 0.15s ease;
  }

  .app-header.is-open .nav-toggle::after {
    transform: translateY(2px) rotate(-135deg);
  }

  /* With the Menu button as the cap, Log out is a plain pill beside it. */
  .nav-logout {
    height: auto;
    min-height: 44px;
    padding: 0 16px;
    border: 2px solid var(--ink);
    border-radius: 999px;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-heading);
    font-size: 1rem;
    letter-spacing: 0;
    text-transform: none;
  }

  .nav-logout:hover {
    color: var(--ink);
  }

  .app-nav {
    display: none;
    order: 3;
    flex: 0 0 100%;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 8px;
    padding: 6px 14px 16px;
  }

  .app-header.is-open .app-nav {
    display: grid;
  }

  .app-nav .nav-link,
  .app-nav .nav-link.is-current {
    justify-content: flex-start;
    min-height: 52px;
    padding: 0 16px;
    border: 2px solid var(--ink);
    border-radius: 14px;
    background: var(--paper);
  }

  .app-nav .nav-link.is-current {
    background: var(--yellow);
  }

  .app-header-actions .nav-switch {
    display: none;
  }

  .app-nav .nav-switch {
    display: flex;
    justify-content: flex-start;
    gap: 10px;
    width: auto;
    padding: 0 16px;
    border-style: dashed;
    background: transparent;
  }

  .app-nav .nav-switch-label {
    position: static;
    width: auto;
    height: auto;
    clip: auto;
  }

  /* A 44px tap area for the way-back tag. */
  .breadcrumb a {
    min-height: 44px;
  }
}

/* Last, so it outranks the transitions above. */
@media (prefers-reduced-motion: reduce) {
  .button,
  .nav-link svg,
  .nav-toggle::after {
    transition: none;
  }
}
