/* ============================================================================
   16.100 Interactive Aerodynamics Tools — design tokens
   ----------------------------------------------------------------------------
   Single source of truth for color, type, spacing, radii, and timing.
   Rules live in docs/design-language.md; this file only states values.

   Themes:
   - `data-theme="light"` / `data-theme="dark"` on <html> select a theme.
   - With no attribute set, the OS preference applies via the
     @media (prefers-color-scheme: dark) block at the bottom.
   - KEEP IN SYNC: the dark palette appears twice (attribute selector and
     media fallback). Any edit to one dark block must be copied to the other.

   Canvas bridge:
   - JS drawing code reads colors with
       getComputedStyle(document.documentElement).getPropertyValue('--canvas-…')
     and must read ONLY `--canvas-*` tokens — never `--c-*` or neutrals.
   - In the light theme the canvas accents are slightly more chromatic than
     the text accents (line work needs less darkness than prose text);
     in the dark theme they alias the text accents exactly.
   ========================================================================== */

/* ---- Theme-independent tokens ------------------------------------------- */

:root {
  /* Typography — system stack, zero network requests.
     (Self-hosted Inter is a possible future upgrade; see design-language.md) */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono",
    monospace;
  /* Display serif for landing titles (Instrument). System faces only until a
     fonts decision says otherwise. */
  --font-display: Georgia, "Times New Roman", serif;

  /* Type scale (rem; root = 16px) */
  --fs-xs: 0.75rem;      /* 12px — scene counter, chrome labels   */
  --fs-sm: 0.875rem;     /* 14px — captions, control labels       */
  --fs-base: 1rem;       /* 16px — UI text, buttons               */
  --fs-body: 1.1875rem;  /* 19px — prose paragraphs               */
  --fs-h3: 1.3125rem;    /* 21px                                  */
  --fs-h2: 1.5rem;       /* 24px                                  */
  --fs-h1: 1.875rem;     /* 30px                                  */
  --fs-display: 2.25rem; /* 36px — tool title only                */

  --lh-prose: 1.6;
  --lh-ui: 1.4;
  --lh-tight: 1.25;

  --fw-normal: 400;
  --fw-medium: 500;   /* bold prose words, control values */
  --fw-semibold: 600; /* headings */

  /* Measure: prose column outer width incl. side padding.
     42rem − 2 × 1.5rem padding = 39rem ≈ 62ch at 19px. */
  --measure: 42rem;
  --measure-wide: 56rem; /* widest allowed figure */

  /* Spacing scale (4px base) */
  --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: 4rem;

  /* Radii */
  --radius-sm: 6px;   /* buttons, chips        */
  --radius-md: 10px;  /* figure band, panels   */
  --radius-full: 999px;

  /* Timing — UI transitions only. Simulation time lives in JS. */
  --t-fast: 150ms;
  --t-base: 250ms;
  --t-slow: 450ms;
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);

  /* Control geometry */
  --hit-target: 44px;    /* minimum touch target, everywhere        */
  --slider-track-h: 4px;
  --slider-knob: 32px;   /* visual knob; hit area padded to 44px    */

  /* Simulation bridge (JS-readable): max physics timestep, seconds. */
  --sim-dt-max: 0.05;
}

/* ---- Light theme (default when no data-theme attribute) ------------------ */

:root,
:root[data-theme="light"] {
  color-scheme: light;

  /* Neutrals */
  --bg: #f7f7f5;        /* page                                    */
  --surface: #ffffff;   /* raised chrome: buttons, segmented pills */
  --band: #f0f0ec;      /* soft tinted band behind figures         */
  --ink: #3e3e3b;       /* primary text          (10.0:1 on --bg)  */
  --ink-muted: #6b6b65; /* captions, labels      ( 5.0:1 on --bg)  */
  --line: #dededa;      /* hairlines, borders                      */
  --grid: #e3e3de;      /* DOM/SVG-side grid lines                 */

  /* Semantic physics accents — one concept, one hue, everywhere.
     All pass ≥ 4.5:1 on --bg and --band (verified). */
  --c-parcel: #1a7a4b;    /* Lagrangian parcel / material system (green: dyed fluid)  */
  --c-probe: #6847c6;     /* Eulerian probe / fixed control volume (violet)           */
  --c-local: #8d640a;     /* local term ∂/∂t (amber)                                  */
  --c-advective: #b81e80; /* advective term u·∇ (rose-magenta; decision-13)         */
  --c-influx: #2c6eb5;    /* inward boundary flux (blue)                              */
  --c-efflux: #c23a2b;    /* outward boundary flux (red)                              */
  --c-vortex: #b02a37;    /* vortex filament / vortex line (crimson)                  */
  --c-circulation: #bc4150; /* circulation measured along a loop (light crimson)     */

  /* Diverging scalar colormap (pressure-like); canvas area fills.
     Same families as influx/efflux, softer chroma for large areas. */
  --c-scalar-lo: #4e8fcb;
  --c-scalar-mid: #e9e8e4;
  --c-scalar-hi: #d8573f;

  /* Canvas bridge — the ONLY tokens JS may read */
  --canvas-bg: #f0f0ec;        /* equals --band: figures sit on the band  */
  --canvas-ink: #3e3e3b;
  --canvas-ink-muted: #82827b; /* annotation lines, ≥3:1 on --canvas-bg   */
  --canvas-grid: #ddddd6;

  --canvas-parcel: #1e9a5c;    /* line-work accents, ≥3:1 on --canvas-bg  */
  --canvas-probe: #7a5ae0;
  --canvas-local: #ad7c09;
  --canvas-advective: #d62a95;
  --canvas-influx: #3b82cf;
  --canvas-efflux: #de4530;
  --canvas-vortex: #c4303d;
  --canvas-circulation: #d65a68;

  --canvas-scalar-lo: var(--c-scalar-lo);
  --canvas-scalar-mid: var(--c-scalar-mid);
  --canvas-scalar-hi: var(--c-scalar-hi);

  /* Lecturer's ink (design-language C8, decision-14): the presenter's
     pens, never a figure's. The ink pen is --canvas-ink. */
  --canvas-pen-red: #d0271d;
  --canvas-pen-blue: #1d5fd3;
  --canvas-pen-highlight: #f5c400;
}

/* ---- Dark theme (attribute) ---------------------------------------------- */
/* Lecture Mode defaults to dark for projection: high-luminance accents on
   near-black. KEEP IN SYNC with the media-fallback block below.             */

:root[data-theme="dark"] {
  color-scheme: dark;

  /* Neutrals */
  --bg: #0f1115;
  --surface: #191c22;
  --band: #15181d;
  --ink: #e7e5e1;       /* 15.0:1 on --bg */
  --ink-muted: #9c9a93; /*  6.7:1 on --bg */
  --line: #2b2e34;
  --grid: #22252b;

  /* Semantic physics accents — all ≥ 5.8:1 on --bg and --band */
  --c-parcel: #52c787;
  --c-probe: #ae97f6;
  --c-local: #e0ad45;
  --c-advective: #ef82b2;
  --c-influx: #64a9e4;
  --c-efflux: #ef6b55;
  --c-vortex: #f0646e;
  --c-circulation: #f58c95;

  /* Diverging scalar colormap — muted extremes, near-bg midpoint */
  --c-scalar-lo: #5b8fc4;
  --c-scalar-mid: #23262c;
  --c-scalar-hi: #c9614c;

  /* Canvas bridge — dark canvas accents alias the text accents */
  --canvas-bg: #15181d;
  --canvas-ink: #e7e5e1;
  --canvas-ink-muted: #8e8c86;
  --canvas-grid: #262a32;

  --canvas-parcel: var(--c-parcel);
  --canvas-probe: var(--c-probe);
  --canvas-local: var(--c-local);
  --canvas-advective: var(--c-advective);
  --canvas-influx: var(--c-influx);
  --canvas-efflux: var(--c-efflux);
  --canvas-vortex: var(--c-vortex);
  --canvas-circulation: var(--c-circulation);

  --canvas-scalar-lo: var(--c-scalar-lo);
  --canvas-scalar-mid: var(--c-scalar-mid);
  --canvas-scalar-hi: var(--c-scalar-hi);

  /* Lecturer's ink (design-language C8, decision-14): the presenter's
     pens, never a figure's. The ink pen is --canvas-ink. */
  --canvas-pen-red: #ff6655;
  --canvas-pen-blue: #5fa4ff;
  --canvas-pen-highlight: #ffd84a;
}

/* ---- Dark theme (OS preference fallback, no attribute set) ---------------- */
/* Identical to the block above. KEEP IN SYNC.                                */

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;

    --bg: #0f1115;
    --surface: #191c22;
    --band: #15181d;
    --ink: #e7e5e1;
    --ink-muted: #9c9a93;
    --line: #2b2e34;
    --grid: #22252b;

    --c-parcel: #52c787;
    --c-probe: #ae97f6;
    --c-local: #e0ad45;
    --c-advective: #ef82b2;
    --c-influx: #64a9e4;
    --c-efflux: #ef6b55;
    --c-vortex: #f0646e;
    --c-circulation: #f58c95;
  --c-circulation: #f58c95;

    --c-scalar-lo: #5b8fc4;
    --c-scalar-mid: #23262c;
    --c-scalar-hi: #c9614c;

    --canvas-bg: #15181d;
    --canvas-ink: #e7e5e1;
    --canvas-ink-muted: #8e8c86;
    --canvas-grid: #262a32;

    --canvas-parcel: var(--c-parcel);
    --canvas-probe: var(--c-probe);
    --canvas-local: var(--c-local);
    --canvas-advective: var(--c-advective);
    --canvas-influx: var(--c-influx);
    --canvas-efflux: var(--c-efflux);
    --canvas-vortex: var(--c-vortex);
    --canvas-circulation: var(--c-circulation);
  --canvas-circulation: var(--c-circulation);

    --canvas-scalar-lo: var(--c-scalar-lo);
    --canvas-scalar-mid: var(--c-scalar-mid);
    --canvas-scalar-hi: var(--c-scalar-hi);

    /* Lecturer's ink (design-language C8, decision-14): the presenter's
       pens, never a figure's. The ink pen is --canvas-ink. */
    --canvas-pen-red: #ff6655;
    --canvas-pen-blue: #5fa4ff;
    --canvas-pen-highlight: #ffd84a;
  }
}
