/* =====================================================================
   MathVisuals — global stylesheet  (site.css)
   ---------------------------------------------------------------------
   This file IS the style guide in code. Every page on the site loads it
   first; page and tool stylesheets only add layout and tool-specific
   pieces, and they take every color, font, size, radius, border and
   shadow from the tokens defined here.

   A visual version of this guide lives at /style-guide.html.

   CONTENTS
     1. Design tokens ........ color (light + dark), type, space, shape
     2. Base / reset ......... element defaults kept deliberately small so
                               the tools' own markup is not disturbed
     3. Utilities ............ .sr-only, .container, .skip-link
     4. Buttons .............. the one button system shared by every page
     5. Form controls ........ inputs, selects, textareas
     6. Site header .......... brand, navigation, dark-mode toggle
     7. Tool pages ........... the full-screen tool frame + info section
     8. Prose & content ...... long-form text below each tool
     9. Site footer
    10. Motion & contrast preferences

   DESIGN PRINCIPLES (why the values are what they are)
     • Built for projectors and smartboards. Projectors lift blacks to
       grey and wash out pale colors, so body text is at least 7:1
       against its background (WCAG AAA), UI boundaries at least 3:1,
       and no border used to separate things is thinner than 2px.
     • One typeface: Atkinson Hyperlegible, designed by the Braille
       Institute so similar letters (I l 1, 0 O) can't be confused from
       the back of a room.
     • Type grows with the screen. Tool pages use a fluid "projector"
       root size, so a 1080p projector gets ~23px text automatically.
     • Dark mode is a full second palette, not an inverted filter.
       The toggle in the header stores the choice; until a choice is
       made, the operating-system preference is followed.
   ===================================================================== */


/* =====================================================================
   1. DESIGN TOKENS
   ===================================================================== */

:root {
  /* ---------- 1a. Typography ---------- */
  --font-sans: "Atkinson Hyperlegible", "Segoe UI", system-ui, -apple-system,
               Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas,
               "Liberation Mono", Menlo, monospace;

  /* Root size for reading pages (home, style guide). Tool pages
     override this with --root-size-projector — see html.is-tool. */
  --root-size: clamp(16px, 0.9rem + 0.25vw, 20px);
  /* ≈18px on a 1280px laptop, ≈23px on a 1080p projector, 28px max */
  --root-size-projector: clamp(16px, 0.55rem + 0.75vw, 28px);

  /* Type scale (rem, so it follows the root size above).
     Smallest step is 0.8rem: below that nothing reads on a projector. */
  --fs-xs:   0.8rem;    /* captions, overline labels               */
  --fs-sm:   0.9rem;    /* secondary text, hints                    */
  --fs-md:   1rem;      /* body text, inputs, buttons               */
  --fs-lg:   1.2rem;    /* lead paragraphs, card titles             */
  --fs-xl:   1.45rem;   /* section headings (h3)                    */
  --fs-2xl:  1.8rem;    /* page section headings (h2), tool titles  */
  --fs-3xl:  2.3rem;    /* hero heading on small screens            */
  --fs-4xl:  clamp(2.3rem, 1.6rem + 2.4vw, 3.6rem);   /* hero h1     */

  --fw-regular: 400;
  --fw-bold: 700;

  --lh-tight: 1.15;     /* headings, big numbers   */
  --lh-snug: 1.3;       /* UI text, tool panels    */
  --lh-base: 1.6;       /* paragraphs              */

  --tracking-label: 0.08em;   /* UPPERCASE overline labels only */

  /* ---------- 1b. Spacing (4px-based, in rem) ---------- */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4.5rem;
  --space-9: 6rem;

  /* ---------- 1c. Shape ---------- */
  --radius-sm: 8px;      /* inputs, chips, small buttons   */
  --radius-md: 12px;     /* buttons, cards inside panels   */
  --radius-lg: 18px;     /* panels, cards, modals          */
  --radius-pill: 999px;  /* badges, toggles                */

  --border-width: 2px;          /* every visible boundary          */
  --border-width-thick: 3px;    /* emphasis: active, selected      */
  --border-width-accent: 6px;   /* color bands on cards / callouts */

  --focus-width: 3px;
  --focus-offset: 2px;

  /* ---------- 1d. Layout ---------- */
  --container: 72rem;           /* max width of reading pages        */
  --container-narrow: 46rem;    /* max width of long paragraphs      */
  --site-bar-h: 3.5rem;         /* header height (tool pages shrink it) */
  --tap-target: 44px;           /* WCAG 2.5.5 minimum touch size     */

  /* ---------- 1e. Motion ---------- */
  --ease-out: cubic-bezier(.2, .8, .3, 1);
  --dur-fast: 120ms;
  --dur-base: 200ms;

  /* ---------- 1f. Color — LIGHT theme (default) ----------
     Contrast ratios are measured against --color-surface (#fff). */
  --color-bg:            #eef2f7;   /* page background                  */
  --color-surface:       #ffffff;   /* panels, cards                    */
  --color-surface-2:     #f1f5f9;   /* panel heads, zebra rows, wells   */
  --color-surface-3:     #e2e8f0;   /* pressed / selected wells         */
  --color-overlay:       rgba(11, 18, 32, .62);  /* modal backdrop      */

  --color-ink:           #0b1220;   /* 18.7:1  headings, body text      */
  --color-ink-soft:      #1e293b;   /* 14.6:1  secondary text           */
  --color-ink-muted:     #475569;   /*  7.6:1  hints, captions (AAA)    */
  --color-ink-inverse:   #ffffff;   /* text on dark/solid fills         */

  --color-border-soft:   #cbd5e1;   /* dividers inside a panel (decorative) */
  --color-border:        #7b8ba1;   /*  3.5:1  input + panel outlines   */
  --color-border-strong: #475569;   /*  7.6:1  emphasised outlines      */

  --color-accent:        #1d4ed8;   /*  6.7:1  primary actions, links   */
  --color-accent-strong: #1e3a8a;   /* 10.4:1  hover, accent text       */
  --color-accent-soft:   #dbeafe;   /*         selected backgrounds     */
  --color-on-accent:     #ffffff;   /* text on an accent fill           */

  --color-danger:        #b91c1c;   /*  6.5:1  destructive, errors      */
  --color-danger-strong: #7f1d1d;
  --color-danger-soft:   #fee2e2;
  --color-success:       #166534;   /*  7.1:1  confirmations            */
  --color-success-soft:  #dcfce7;
  --color-warning:       #b45309;   /*  5.0:1  attention, highlights    */
  --color-warning-soft:  #fef3c7;

  --color-focus:         #1d4ed8;   /* focus ring — solid, never pale   */

  /* Data palette: for lines, series and categories inside tools.
     Dark shades, each ≥ 4.5:1 on white so a projector can't bleach
     them, ordered so neighbours differ strongly in hue. */
  --data-1: #1d4ed8;   /* blue    */
  --data-2: #be123c;   /* rose    */
  --data-3: #c2410c;   /* orange  */
  --data-4: #0f766e;   /* teal    */
  --data-5: #6d28d9;   /* violet  */
  --data-6: #15803d;   /* green   */
  --data-7: #a21caf;   /* magenta */
  --data-8: #0e7490;   /* cyan    */

  /* Shadows: subtle — depth comes from borders, which survive projection */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .08), 0 1px 3px rgba(15, 23, 42, .06);
  --shadow-md: 0 4px 14px rgba(15, 23, 42, .12), 0 2px 4px rgba(15, 23, 42, .06);
  --shadow-lg: 0 18px 45px rgba(15, 23, 42, .28);

  color-scheme: light;
}

/* ---------- 1g. Color — DARK theme ----------
   Applied when <html data-theme="dark">. theme-init.js sets that
   attribute before the page paints, from the saved choice or the OS.
   Contrast ratios measured against --color-surface (#111a2e).        */
html[data-theme="dark"] {
  --color-bg:            #070c18;
  --color-surface:       #111a2e;
  --color-surface-2:     #18233c;
  --color-surface-3:     #22304f;
  --color-overlay:       rgba(2, 5, 12, .78);

  --color-ink:           #f1f5f9;   /* 15.8:1 */
  --color-ink-soft:      #dbe3ee;   /* 13.4:1 */
  --color-ink-muted:     #a9b6c9;   /*  8.4:1 */
  --color-ink-inverse:   #0b1220;

  --color-border-soft:   #2b3a5a;
  --color-border:        #64748b;   /*  3.6:1 */
  --color-border-strong: #94a3b8;   /*  6.8:1 */

  --color-accent:        #60a5fa;   /*  6.8:1 */
  --color-accent-strong: #93c5fd;
  --color-accent-soft:   #1b2f55;
  --color-on-accent:     #0b1220;   /* dark text on the light-blue fill */

  --color-danger:        #f87171;
  --color-danger-strong: #fca5a5;
  --color-danger-soft:   #3b1520;
  --color-success:       #4ade80;
  --color-success-soft:  #12301f;
  --color-warning:       #fbbf24;
  --color-warning-soft:  #3a2a0a;

  --color-focus:         #fbbf24;   /* amber ring reads on every dark fill */

  --data-1: #60a5fa;
  --data-2: #fb7185;
  --data-3: #fb923c;
  --data-4: #2dd4bf;
  --data-5: #a78bfa;
  --data-6: #4ade80;
  --data-7: #e879f9;
  --data-8: #22d3ee;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, .45);
  --shadow-lg: 0 18px 45px rgba(0, 0, 0, .6);

  color-scheme: dark;
}


/* =====================================================================
   2. BASE / RESET
   Kept small on purpose: the tools carry their own markup, and broad
   element rules here would change their layout.
   ===================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: var(--root-size);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Tool pages: bigger, fluid type for projection */
html.is-tool {
  font-size: var(--root-size-projector);
  --site-bar-h: clamp(48px, 2.6rem, 60px);
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  line-height: var(--lh-snug);
  color: var(--color-ink);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--dur-base), color var(--dur-base);
}

img,
svg,
video {
  max-width: 100%;
}

img {
  height: auto;
}

/* Author display rules outrank the browser's own [hidden] rule, and
   every tool toggles elements with el.hidden — make it always win. */
[hidden] {
  display: none !important;
}

a {
  color: var(--color-accent);
  text-underline-offset: .18em;
  text-decoration-thickness: .08em;
}

a:hover {
  color: var(--color-accent-strong);
}

/* One focus ring for the whole site: solid, thick, offset. */
:focus-visible {
  outline: var(--focus-width) solid var(--color-focus);
  outline-offset: var(--focus-offset);
}

::selection {
  background: var(--color-accent);
  color: var(--color-on-accent);
}


/* =====================================================================
   3. UTILITIES
   ===================================================================== */

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* First focusable element on every page — jumps keyboard users past
   the header straight to the tool or main content. */
.skip-link {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  z-index: 1000;
  padding: var(--space-2) var(--space-4);
  font-weight: var(--fw-bold);
  color: var(--color-on-accent);
  background: var(--color-accent);
  border-radius: var(--radius-md);
  transform: translateY(-160%);
  transition: transform var(--dur-fast);
}

.skip-link:focus {
  transform: none;
  color: var(--color-on-accent);
}

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: clamp(1rem, 4vw, 2.5rem);
}

.overline {
  margin: 0 0 var(--space-2);
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--color-accent);
}


/* =====================================================================
   4. BUTTONS
   ---------------------------------------------------------------------
   Usage:  <button class="btn btn-primary">…</button>

   Variants (color)                Sizes
     .btn-primary   solid accent      .btn-sm  (alias .btn-small)
     .btn-ghost     outlined neutral  .btn-lg  (alias .btn-big)
     .btn-quiet     same as ghost
     .btn-danger    outlined red — starts a destructive action
     .btn-solid-danger  solid red — confirms a destructive action

   Custom colors: any variant reads --btn-bg / --btn-fg / --btn-border,
   so a tool makes a themed button with one line, e.g.
     .btn-plot { --btn-bg: var(--data-5); }
   ===================================================================== */

.btn {
  --btn-bg: var(--color-surface);
  --btn-fg: var(--color-ink);
  --btn-border: var(--color-border-strong);
  --btn-bg-hover: var(--color-surface-2);

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45em;
  min-height: var(--tap-target);
  padding: .5em 1.1em;
  font: inherit;
  font-size: var(--fs-md);
  font-weight: var(--fw-bold);
  line-height: 1.1;
  white-space: nowrap;
  text-decoration: none;
  color: var(--btn-fg);
  background: var(--btn-bg);
  border: var(--border-width) solid var(--btn-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color var(--dur-fast), border-color var(--dur-fast),
              color var(--dur-fast), transform 80ms, filter var(--dur-fast);
}

.btn:hover {
  background: var(--btn-bg-hover);
  color: var(--btn-fg);
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: .5;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  --btn-bg: var(--color-accent);
  --btn-fg: var(--color-on-accent);
  --btn-border: var(--btn-bg);
  --btn-bg-hover: var(--btn-bg);
}

/* Solid buttons darken (light theme) or lighten (dark theme) on hover,
   whatever --btn-bg a tool gives them. */
.btn-primary:hover:not(:disabled),
.btn-solid-danger:hover:not(:disabled) {
  filter: brightness(.88);
}

html[data-theme="dark"] .btn-primary:hover:not(:disabled),
html[data-theme="dark"] .btn-solid-danger:hover:not(:disabled) {
  filter: brightness(1.12);
}

/* .btn-ghost and .btn-quiet need no rule: the .btn defaults ARE the
   outlined ghost button. The class names exist for readability. */

.btn-danger {
  --btn-fg: var(--color-danger);
  --btn-border: var(--color-danger);
  --btn-bg-hover: var(--color-danger-soft);
}

.btn-solid-danger {
  --btn-bg: var(--color-danger);
  --btn-fg: var(--color-ink-inverse);
  --btn-border: var(--color-danger);
  --btn-bg-hover: var(--color-danger);
}

html:not([data-theme="dark"]) .btn-solid-danger {
  --btn-fg: #ffffff;
}

.btn-sm,
.btn-small {
  min-height: 36px;
  padding: .35em .8em;
  font-size: var(--fs-sm);
  border-radius: var(--radius-sm);
}

.btn-lg,
.btn-big {
  padding: .6em 1.4em;
  font-size: var(--fs-lg);
}

/* Square icon-only button (close ×, magnify, etc.) */
.btn-icon {
  min-width: var(--tap-target);
  padding: 0;
}


/* =====================================================================
   5. FORM CONTROLS
   Applied through .form-control so the tools' own inputs keep their
   bespoke shapes (fraction boxes, coordinate fields) — those borrow
   the same tokens in their own stylesheets.
   ===================================================================== */

.form-control {
  display: block;
  width: 100%;
  min-height: var(--tap-target);
  padding: .55em .8em;
  font: inherit;
  font-size: var(--fs-md);
  color: var(--color-ink);
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-sm);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}

.form-control::placeholder {
  color: var(--color-ink-muted);
  opacity: 1;
}

.form-control:hover {
  border-color: var(--color-border-strong);
}

.form-control:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 var(--focus-width) var(--color-focus);
}

.form-control[aria-invalid="true"] {
  border-color: var(--color-danger);
}

textarea.form-control {
  min-height: 9rem;
  line-height: var(--lh-base);
  resize: vertical;
}

select.form-control {
  appearance: none;
  padding-right: 2.4em;
  background-image:
    linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 1.15em) 55%, calc(100% - .8em) 55%;
  background-size: .35em .35em;
  background-repeat: no-repeat;
}


/* =====================================================================
   6. SITE HEADER
   Same header on every page. On tool pages it is slimmer, and its
   height (--site-bar-h) is subtracted from the tool frame so the tool
   still fills exactly one screen.
   ===================================================================== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--color-surface);
  border-bottom: var(--border-width) solid var(--color-border-soft);
}

.site-header__inner {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-height: var(--site-bar-h);
}

/* Tool pages: full-width bar, not a centred container */
.is-tool .site-header__inner {
  max-width: none;
  padding-inline: clamp(.75rem, 1.5vw, 1.25rem);
  height: var(--site-bar-h);
}

.is-tool .site-header {
  position: relative;      /* tool frame does its own scrolling */
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  flex: none;
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
  letter-spacing: -.01em;
  color: var(--color-ink);
  text-decoration: none;
}

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

.brand__mark {
  width: 1.9em;
  height: 1.9em;
  flex: none;
}

.brand__name span {
  color: var(--color-accent);
}

.is-tool .brand {
  font-size: var(--fs-md);
}

/* Breadcrumb trail on tool pages: Home › Category › Tool */
.breadcrumb {
  min-width: 0;
  font-size: var(--fs-sm);
  color: var(--color-ink-muted);
}

.breadcrumb ol {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
  white-space: nowrap;
  overflow: hidden;
}

.breadcrumb li {
  overflow: hidden;
  text-overflow: ellipsis;
}

.breadcrumb li + li::before {
  content: "›";
  margin-right: var(--space-2);
  color: var(--color-border);
}

.breadcrumb a {
  color: var(--color-ink-muted);
  text-decoration: none;
}

.breadcrumb a:hover {
  color: var(--color-accent);
  text-decoration: underline;
}

.breadcrumb [aria-current="page"] {
  color: var(--color-ink);
  font-weight: var(--fw-bold);
}

.site-nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.site-nav__list {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav__link {
  display: inline-flex;
  white-space: nowrap;
  align-items: center;
  min-height: var(--tap-target);
  padding: 0 var(--space-3);
  font-weight: var(--fw-bold);
  color: var(--color-ink-soft);
  text-decoration: none;
  border-radius: var(--radius-sm);
}

.site-nav__link:hover {
  color: var(--color-accent);
  background: var(--color-surface-2);
}

.is-tool .site-nav__link {
  font-size: var(--fs-sm);
}

/* Mobile menu button — only shown at narrow widths */
.nav-toggle {
  display: none;
}

/* ---------- Dark-mode toggle ----------
   A switch-style button. aria-pressed="true" means dark mode is on.
   Icons swap with the theme; the label is for screen readers.        */
.theme-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: none;
  width: 4.1rem;
  height: 2.2rem;
  padding: 0;
  font: inherit;
  color: var(--color-ink);
  background: var(--color-surface-2);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background-color var(--dur-base), border-color var(--dur-base);
}

.theme-toggle:hover {
  border-color: var(--color-border-strong);
}

.theme-toggle__thumb {
  position: absolute;
  top: 50%;
  left: .2rem;
  display: grid;
  place-items: center;
  width: 1.65rem;
  height: 1.65rem;
  color: var(--color-on-accent);
  background: var(--color-accent);
  border-radius: 50%;
  transform: translate(0, -50%);
  transition: transform var(--dur-base) var(--ease-out), background-color var(--dur-base);
}

.theme-toggle[aria-pressed="true"] .theme-toggle__thumb {
  transform: translate(1.85rem, -50%);
}

.theme-toggle svg {
  width: 1.05rem;
  height: 1.05rem;
}

.theme-toggle .icon-moon,
.theme-toggle[aria-pressed="true"] .icon-sun {
  display: none;
}

.theme-toggle[aria-pressed="true"] .icon-moon {
  display: block;
}

.is-tool .theme-toggle {
  font-size: clamp(14px, .85rem, 18px);
}

/* ---------- Header on tablets and phones ---------- */
@media (max-width: 960px) {
  .nav-toggle {
    display: inline-flex;
    order: 3;
  }

  .site-nav {
    gap: var(--space-2);
  }

  /* the link list drops down below the bar */
  .site-nav__list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: var(--space-2) var(--space-4) var(--space-4);
    background: var(--color-surface);
    border-bottom: var(--border-width) solid var(--color-border-soft);
    box-shadow: var(--shadow-md);
  }

  .site-nav__list:not(.is-open) {
    display: none;
  }

  .site-nav__link {
    width: 100%;
    font-size: var(--fs-md);
  }

  .breadcrumb li:not(:last-child) {
    display: none;
  }

  .breadcrumb li + li::before {
    content: none;
  }

  .is-tool .brand__name {
    display: none;
  }
}


/* =====================================================================
   7. TOOL PAGES
   ---------------------------------------------------------------------
   <div class="tool-frame">  holds the original tool. It is exactly one
   screen tall minus the header, which reproduces the tools' original
   "100vh" layouts. The SEO / teacher-notes section sits below it, so
   the projected view is unchanged and the page simply scrolls on.
   ===================================================================== */

.tool-frame {
  position: relative;
  height: calc(100vh - var(--site-bar-h));
  height: calc(100dvh - var(--site-bar-h));
  overflow: hidden;
  background: var(--color-bg);
  font-size: var(--fs-md);
  line-height: var(--lh-snug);
}

/* Stacked tools on tablets/phones grow to fit their content
   (each tool stylesheet switches to .tool-frame--flow at its own
   breakpoint by setting height:auto). */

/* "Scroll for teacher notes" cue at the bottom of the bar */
.tool-info-link {
  font-size: var(--fs-sm);
}


/* =====================================================================
   8. PROSE & CONTENT  (teacher notes under each tool, home sections)
   ===================================================================== */

.tool-info {
  /* reading-page sizes even though the html root is projector-sized */
  font-size: clamp(16px, 0.9rem + 0.25vw, 20px);
  padding-block: var(--space-8);
  background: var(--color-surface);
  border-top: var(--border-width) solid var(--color-border-soft);
}

.tool-info__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 20em;
  gap: var(--space-7);
  align-items: start;
}

@media (max-width: 900px) {
  .tool-info__grid {
    grid-template-columns: 1fr;
    gap: var(--space-6);
  }
}

.prose {
  max-width: var(--container-narrow);
  font-size: 1em;
  line-height: var(--lh-base);
  color: var(--color-ink-soft);
}

.prose h2 {
  margin: var(--space-7) 0 var(--space-3);
  font-size: 1.8em;
  line-height: var(--lh-tight);
  color: var(--color-ink);
}

.prose h2:first-child,
.prose .overline + h2 {
  margin-top: 0;
}

.prose h3 {
  margin: var(--space-5) 0 var(--space-2);
  font-size: 1.25em;
  line-height: var(--lh-tight);
  color: var(--color-ink);
}

.prose p,
.prose ul,
.prose ol {
  margin: 0 0 var(--space-4);
}

.prose li {
  margin-bottom: var(--space-2);
}

.prose li::marker {
  color: var(--color-accent);
  font-weight: var(--fw-bold);
}

.prose strong {
  color: var(--color-ink);
}

.prose .lead {
  font-size: 1.2em;
  color: var(--color-ink);
}

/* Teacher callout box */
.callout {
  margin: var(--space-5) 0;
  padding: var(--space-4) var(--space-5);
  background: var(--color-accent-soft);
  border-left: var(--border-width-accent) solid var(--color-accent);
  border-radius: var(--radius-md);
  color: var(--color-ink);
}

.callout p:last-child {
  margin-bottom: 0;
}

/* FAQ — native <details>, no script needed */
.faq {
  margin: 0 0 var(--space-4);
}

.faq details {
  border: var(--border-width) solid var(--color-border-soft);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}

.faq details + details {
  margin-top: var(--space-3);
}

.faq summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--tap-target);
  padding: var(--space-3) var(--space-4);
  font-weight: var(--fw-bold);
  color: var(--color-ink);
  cursor: pointer;
  list-style: none;
}

.faq summary::-webkit-details-marker {
  display: none;
}

.faq summary::after {
  content: "+";
  flex: none;
  font-size: 1.4em;
  line-height: 1;
  color: var(--color-accent);
}

.faq details[open] summary::after {
  content: "−";
}

.faq details > div {
  padding: 0 var(--space-4) var(--space-4);
}

.faq details p:last-child {
  margin-bottom: 0;
}

/* Side panel: quick facts + related tools */
.aside-card {
  padding: var(--space-5);
  background: var(--color-surface-2);
  border: var(--border-width) solid var(--color-border-soft);
  border-radius: var(--radius-lg);
}

.aside-card + .aside-card {
  margin-top: var(--space-5);
}

.aside-card h2 {
  margin: 0 0 var(--space-3);
  font-size: var(--fs-xs);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--color-ink-muted);
}

.facts {
  display: grid;
  gap: var(--space-3);
  margin: 0;
}

.facts div {
  display: grid;
  gap: 2px;
}

.facts dt {
  font-size: .85em;
  font-weight: var(--fw-bold);
  color: var(--color-ink-muted);
}

.facts dd {
  margin: 0;
  color: var(--color-ink);
}

.link-list {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.link-list a {
  display: block;
  padding: var(--space-2) var(--space-3);
  font-weight: var(--fw-bold);
  text-decoration: none;
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border-soft);
  border-radius: var(--radius-sm);
}

.link-list a:hover {
  border-color: var(--color-accent);
}

.link-list small {
  display: block;
  font-weight: var(--fw-regular);
  color: var(--color-ink-muted);
}

.tag {
  display: inline-block;
  padding: .15em .65em;
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  color: var(--color-accent-strong);
  background: var(--color-accent-soft);
  border-radius: var(--radius-pill);
}

html[data-theme="dark"] .tag {
  color: var(--color-accent-strong);
}

.tag--free {
  color: var(--color-success);
  background: var(--color-success-soft);
}


/* =====================================================================
   9. SITE FOOTER
   ===================================================================== */

.site-footer {
  font-size: clamp(16px, 0.9rem + 0.25vw, 20px);
  padding-block: var(--space-7) var(--space-6);
  color: var(--color-ink-muted);
  background: var(--color-surface-2);
  border-top: var(--border-width) solid var(--color-border-soft);
}

.site-footer__grid {
  display: grid;
  grid-template-columns: 2fr repeat(4, 1fr);
  gap: var(--space-6);
}

.site-footer h2 {
  margin: 0 0 var(--space-3);
  font-size: var(--fs-xs);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--color-ink);
}

.site-footer ul {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-footer a {
  color: var(--color-ink-soft);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--color-accent);
  text-decoration: underline;
}

.site-footer p {
  margin: var(--space-3) 0 0;
  line-height: var(--lh-base);
  max-width: 30em;
}

.site-footer__bottom {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-6);
  padding-top: var(--space-5);
  font-size: var(--fs-sm);
  border-top: var(--border-width) solid var(--color-border-soft);
}

@media (max-width: 860px) {
  .site-footer__grid {
    grid-template-columns: 1fr 1fr;
  }

  .site-footer__about {
    grid-column: 1 / -1;
  }
}

@media (max-width: 480px) {
  .site-footer__grid {
    grid-template-columns: 1fr;
  }
}


/* =====================================================================
   10. MOTION & CONTRAST PREFERENCES
   ===================================================================== */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

@media (prefers-reduced-motion: no-preference) {
  html:not(.is-tool) {
    scroll-behavior: smooth;
  }
}

/* Windows / macOS "increase contrast": go to pure black / white ink
   and full-strength borders. */
@media (prefers-contrast: more) {
  :root {
    --color-ink: #000000;
    --color-ink-soft: #000000;
    --color-ink-muted: #1f2937;
    --color-border: #000000;
    --color-border-soft: #475569;
    --color-border-strong: #000000;
  }

  html[data-theme="dark"] {
    --color-ink: #ffffff;
    --color-ink-soft: #ffffff;
    --color-ink-muted: #e2e8f0;
    --color-border: #e2e8f0;
    --color-border-strong: #ffffff;
  }
}

@media print {
  .site-header,
  .site-footer,
  .skip-link {
    display: none;
  }
}
