/* ==========================================================================
   Design tokens: "Instrument"
   Dark is phosphor on a scope (default); light is ink on chart paper.
   Every colour used anywhere on the site, CSS or canvas, comes from here.
   Canvases read the --viz-* aliases through LT.colors().
   ========================================================================== */

/* ---- Metric-matched fallbacks: the web-font swap causes no layout shift ---- */
@font-face{font-family:"LT Serif Fallback";src:local("Times New Roman"),local("TimesNewRomanPSMT"),local("Liberation Serif"),local("Tinos");size-adjust:82.8%;ascent-override:119.6%;descent-override:37.4%;line-gap-override:0%}
@font-face{font-family:"LT Serif Fallback";font-style:italic;src:local("Times New Roman Italic"),local("TimesNewRomanPS-ItalicMT"),local("Liberation Serif Italic"),local("Tinos Italic");size-adjust:89.2%;ascent-override:111%;descent-override:34.8%;line-gap-override:0%}
/* Sans 400: 102.7% (at 105% Arial set 2.6% wider than Geist 400), overrides rescaled to keep Geist's vertical metrics.
   Sans 500 keeps 105%: it already matches Geist 500 (buttons, pills, role titles). */
@font-face{font-family:"LT Sans Fallback";src:local("Arial"),local("ArialMT"),local("Liberation Sans"),local("Arimo");size-adjust:102.7%;ascent-override:97.84%;descent-override:28.73%;line-gap-override:0%}
@font-face{font-family:"LT Sans Fallback";font-weight:500;src:local("Arial"),local("ArialMT"),local("Liberation Sans"),local("Arimo");size-adjust:105%;ascent-override:95.7%;descent-override:28.1%;line-gap-override:0%}
@font-face{font-family:"LT Sans Fallback";font-weight:600;src:local("Arial Bold"),local("Arial-BoldMT"),local("Liberation Sans Bold"),local("Arimo Bold");size-adjust:101.9%;ascent-override:98.6%;descent-override:28.9%;line-gap-override:0%}
@font-face{font-family:"LT Mono Fallback";src:local("Courier New"),local("CourierNewPSMT"),local("Liberation Mono"),local("Cousine");size-adjust:100%;ascent-override:102%;descent-override:30%;line-gap-override:0%}

:root {
  /* ---- Colour: dark (default) ---- */
  color-scheme: dark;
  --bg: #0B0C0E;
  --bg-raised: #14161A;      /* top bar, overlays */
  --bg-plate: #08090B;       /* figure plates */
  --ink: #ECEAE3;
  --ink-2: #B3B1A9;
  --ink-3: #8E8D86;          /* labels and dimming; never use opacity for this */
  --rule: #25282E;
  --rule-strong: #60646D;    /* control borders */
  --grid: #1A1D23;
  --signal: #FF5A36;
  --signal-ink: #FF5A36;     /* signal as text under 24px */
  --on-signal: #0B0C0E;
  --signal-hot: #FFB49F;
  --signal-wash: rgb(255 90 54 / .14);
  --trace-2: #B9A6F0;        /* second series: Lam's lavender */
  --paper: #F7F5EF;          /* mounts for real figures (matplotlib PNGs) */
  --scrim: rgb(5 6 8 / .72);
  --shadow-overlay: 0 0 0 1px var(--rule-strong), 0 24px 64px -16px rgb(0 0 0 / .6);
  --grain-opacity: .035;
  /* v2: raised surfaces. --edge is a floating surface's border (--rule is 1.2:1 on --bg-raised, so a panel's edge dissolved
     into the dark room); --highlight its 1px top sheen; the shadows are per theme (light ones are ink, not black). */
  --edge: color-mix(in srgb, var(--ink) 14%, transparent);
  --highlight: inset 0 1px 0 rgb(255 255 255 / .05);
  --shadow-card: 0 24px 64px -16px rgb(0 0 0 / .6);
  --shadow-up: 0 -16px 40px -24px rgb(0 0 0 / .45);
  --shadow-side: -16px 0 40px -16px rgb(0 0 0 / .35);
  /* a dark ground swallows a black drop under a light button: the lift is a halo (the button swells by 1px into a soft
     phosphor ring), the drop kept for depth */
  --shadow-lift: 0 0 0 1px var(--ink), 0 0 0 4px color-mix(in srgb, var(--ink) 14%, transparent), 0 10px 22px -12px rgb(0 0 0 / .9);
  --shadow-print: 0 22px 44px -18px rgb(0 0 0 / .55), 0 2px 6px rgb(0 0 0 / .18);
  --shadow-print-under: 0 12px 26px -16px rgb(0 0 0 / .55), 0 1px 3px rgb(0 0 0 / .14);
  --shadow-tv: 0 30px 60px -24px rgb(0 0 0 / .7);
  --scrim-case: rgb(5 6 8 / .62);  /* over a blurred room (case.css); .9 where backdrop-filter is missing */
  --chip-alpha: 94%;               /* labels and chips on the room: bg-raised at this opacity (ink-3 keeps 4.5:1 even over a lit lamp) */

  /* Sequential ramp (LineWatch wait bands), monotonic luminance */
  --seq-1: #636363;
  --seq-2: #A26557;
  --seq-3: #D66046;
  --seq-4: #FF5A36;
  --seq-5: #FFB49F;

  /* ---- Canvas aliases (LT.colors() keys: bg, ink, ink2, dim, rule, grid, signal, hot, trace2, wash, seq1..seq5) ---- */
  --viz-bg: var(--bg-plate);
  --viz-ink: var(--ink);
  --viz-ink-2: var(--ink-2);
  --viz-dim: var(--ink-3);
  --viz-rule: var(--rule-strong);
  --viz-grid: var(--grid);
  --viz-signal: var(--signal);
  --viz-hot: var(--signal-hot);
  --viz-trace-2: var(--trace-2);
  --viz-wash: var(--signal-wash);
  --viz-seq-1: var(--seq-1);
  --viz-seq-2: var(--seq-2);
  --viz-seq-3: var(--seq-3);
  --viz-seq-4: var(--seq-4);
  --viz-seq-5: var(--seq-5);

  /* ---- Type ---- */
  --font-serif: "Instrument Serif", "LT Serif Fallback", Georgia, serif;
  --font-sans: "Geist", "LT Sans Fallback", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "LT Mono Fallback", ui-monospace, Menlo, monospace;

  --t-display: clamp(4rem, 2.6667rem + 5.9259vw, 8rem);        /* 64 to 128, serif, lh .9, -.02em */
  --t-h2: clamp(2.5rem, 1.6667rem + 3.7037vw, 5rem);            /* 40 to 80, serif, lh .95 */
  --t-claim: clamp(1.875rem, 1.5rem + 1.6667vw, 3rem);          /* 30 to 48, serif italic, lh 1.12 */
  --t-email: clamp(1.625rem, 1.0833rem + 2.4074vw, 3.25rem);    /* 26 to 52, serif */
  --t-h3: clamp(1.5rem, 1.2917rem + .9259vw, 2.125rem);         /* 24 to 34, serif */
  --t-readout: clamp(1.375rem, 1.2083rem + .7407vw, 1.875rem);  /* 22 to 30, mono 500 */
  --t-lede: clamp(1.125rem, 1.0625rem + .2778vw, 1.3125rem);    /* 18 to 21, sans, lh 1.5 */
  --t-body: clamp(1rem, .9792rem + .0926vw, 1.0625rem);         /* 16 to 17, sans, lh 1.6, max 68ch */
  --t-small: clamp(.875rem, .8542rem + .0926vw, .9375rem);      /* 14 to 15, sans */
  --t-label: clamp(.75rem, .7292rem + .0926vw, .8125rem);       /* 12 to 13, mono 500, caps, +.08em */
  --unit-size: .62em;                                           /* units: thin space, then .62em in ink-2 */
  /* v2: the room's micro scale (fixed px: chrome laid over a canvas, never prose). Nothing in #room is set below 11px. */
  --t-micro: 11px;          /* mono caps: kickers, FIG tags, callout labels, group heads, nav kickers, key captions */
  --t-caption: 12px;        /* mono, sentence case: notes, captions, hints, the clock, scores */
  --t-meta: 13px;           /* sans: toolbar, switcher, tools, text links, readout descriptors, compact buttons */
  --t-row: 14px;            /* sans: list rows (the object list, a room's objects, previous / next) */
  --t-title-sm: 24px;       /* serif: small titles (game plates, the game bar) */
  --track-caps: .08em;      /* mono caps, 12px and up */
  --track-caps-sm: .1em;    /* mono caps at 11px: small caps need more air, not less */
  --track-mono: .02em;      /* mono, sentence case */
  --track-ui: -.005em;      /* sans controls */
  --track-title: -.01em;    /* serif titles */
  --track-display: -.025em; /* serif display */

  /* ---- Space (8px baseline) ---- */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px;
  --s6: 32px; --s7: 48px; --s8: 64px; --s9: 96px; --s10: 144px;
  --section-pad: clamp(4.5rem, 3rem + 6.6667vw, 9rem);
  --bar-h: 56px;
  --content-max: 1360px;

  /* Grid: 4 cols / 16 margin / 12 gutter at the base; see breakpoints below */
  --cols: 4;
  --margin: 16px;
  --gutter: 12px;

  /* ---- Shape ---- */
  --radius-control: 2px;
  --radius-pill: 999px;
  --radius-lamp: 1px;
  /* v2, one rule: a control is cut (2px: buttons, chips, tags, a toolbar); a surface that floats is a card (the panel,
     popovers, the palette, the shortcut sheet, toasts); a surface docked to the bottom edge on a phone is the same card
     with its two free corners at twice the radius. A pill is a live status or a label floating on the room (an object's
     callout, the marker's pill); a room's plate is cut, a place not a thing. */
  --radius-card: 6px;
  --radius-sheet: calc(var(--radius-card) * 2);
  --ctl-sm: 32px;           /* the toolbar, the room switcher, list rows */
  --ctl-md: 40px;           /* panel actions and the pinned foot */
  --ctl-lg: 44px;           /* calls to action, the viewfinder's bar */
  --ctl-touch: 44px;        /* the floor for every target under pointer:coarse */
  --lamp: 6px;           /* lamps are 6px squares */
  --ev-size: 8px;        /* evidence marks are 8px circles */
  --focus-ring: 2px solid var(--signal);
  --focus-offset: 3px;

  /* ---- Motion ---- */
  --ease-out: cubic-bezier(.16, 1, .3, 1);      /* entrances */
  --ease-in: cubic-bezier(.7, 0, .84, 0);       /* exits */
  --ease-in-out: cubic-bezier(.65, 0, .35, 1);  /* morphs, wipe, flights */
  --dur-press: 90ms;
  --dur-hover: 160ms;
  --dur-toast: 200ms;
  --dur-dialog-in: 280ms;
  --dur-dialog-out: 200ms;
  --dur-drawer: 280ms;
  --dur-reveal: 520ms;
  --dur-wipe: 520ms;
  --dur-tip: 120ms;         /* v2: tooltips, pins */
  --dur-out: 170ms;         /* v2: the panel leaving */
  --dur-swap: 220ms;        /* v2: content swapping, the switcher's current mark */
  --dur-flight: 320ms;      /* v2: the switcher sliding to the free area */

  /* ---- Layers ---- */
  --z-raised: 1;
  --z-card-link: 2;
  --z-topbar: 100;
  --z-drawer: 300;
  --z-popover: 350;
  --z-toast: 400;
  --z-wipe: 500;
  --z-grid: 600;
  --z-skip: 700;
}

/* ---- Colour: light (explicit choice) ---- */
[data-theme="light"] {
  color-scheme: light;
  --bg: #F2F0EA;
  --bg-raised: #FAF9F5;
  --bg-plate: #E9E6DD;
  --ink: #141518;
  --ink-2: #3D3F45;
  --ink-3: #5C5D63;
  --rule: #D8D4C9;
  --rule-strong: #857F73;
  --grid: #C5D3D9;
  --signal: #C83912;         /* graphics, focus, borders, and text of 24px or more */
  --signal-ink: #B23210;     /* text under 24px */
  --on-signal: #FFFFFF;
  --signal-hot: #7A1E06;
  --signal-wash: rgb(200 57 18 / .12);
  --trace-2: #5A43C6;
  --paper: #FFFFFF;
  --scrim: rgb(20 21 24 / .32);
  --shadow-overlay: 0 0 0 1px var(--rule-strong), 0 16px 40px -12px rgb(20 21 24 / .18);
  --grain-opacity: .05;
  --edge: color-mix(in srgb, var(--rule-strong) 45%, transparent);
  --highlight: inset 0 1px 0 rgb(255 255 255 / .7);
  --shadow-card: 0 16px 40px -12px rgb(20 21 24 / .18);
  --shadow-up: 0 -12px 32px -20px rgb(20 21 24 / .16);
  --shadow-side: -12px 0 32px -16px rgb(20 21 24 / .14);
  --shadow-lift: 0 8px 18px -10px rgb(20 21 24 / .5);
  --shadow-print: 0 18px 36px -18px rgb(20 21 24 / .34), 0 1px 4px rgb(20 21 24 / .12);
  --shadow-print-under: 0 10px 22px -14px rgb(20 21 24 / .3), 0 1px 3px rgb(20 21 24 / .1);
  --shadow-tv: 0 26px 52px -24px rgb(20 21 24 / .34);
  --scrim-case: rgb(20 21 24 / .36);
  --chip-alpha: 92%;
  --seq-1: #828282;
  --seq-2: #A36C5E;
  --seq-3: #BB533B;
  --seq-4: #C83912;
  --seq-5: #7A1E06;
}

/* ---- Colour: light (no stored choice, OS prefers light; also covers visitors without JS) ---- */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
    --bg: #F2F0EA;
    --bg-raised: #FAF9F5;
    --bg-plate: #E9E6DD;
    --ink: #141518;
    --ink-2: #3D3F45;
    --ink-3: #5C5D63;
    --rule: #D8D4C9;
    --rule-strong: #857F73;
    --grid: #C5D3D9;
    --signal: #C83912;
    --signal-ink: #B23210;
    --on-signal: #FFFFFF;
    --signal-hot: #7A1E06;
    --signal-wash: rgb(200 57 18 / .12);
    --trace-2: #5A43C6;
    --paper: #FFFFFF;
    --scrim: rgb(20 21 24 / .32);
    --shadow-overlay: 0 0 0 1px var(--rule-strong), 0 16px 40px -12px rgb(20 21 24 / .18);
    --grain-opacity: .05;
    --edge: color-mix(in srgb, var(--rule-strong) 45%, transparent);
    --highlight: inset 0 1px 0 rgb(255 255 255 / .7);
    --shadow-card: 0 16px 40px -12px rgb(20 21 24 / .18);
    --shadow-up: 0 -12px 32px -20px rgb(20 21 24 / .16);
    --shadow-side: -12px 0 32px -16px rgb(20 21 24 / .14);
    --shadow-lift: 0 8px 18px -10px rgb(20 21 24 / .5);
    --shadow-print: 0 18px 36px -18px rgb(20 21 24 / .34), 0 1px 4px rgb(20 21 24 / .12);
    --shadow-print-under: 0 10px 22px -14px rgb(20 21 24 / .3), 0 1px 3px rgb(20 21 24 / .1);
    --shadow-tv: 0 26px 52px -24px rgb(20 21 24 / .34);
    --scrim-case: rgb(20 21 24 / .36);
    --chip-alpha: 92%;
    --seq-1: #828282;
    --seq-2: #A36C5E;
    --seq-3: #BB533B;
    --seq-4: #C83912;
    --seq-5: #7A1E06;
  }
}

/* ---- Grid breakpoints ---- */
@media (min-width: 600px)  { :root { --cols: 8;  --margin: 24px; --gutter: 16px; } }
@media (min-width: 900px)  { :root { --cols: 12; --margin: 32px; --gutter: 20px; } }
@media (min-width: 1200px) { :root { --cols: 12; --margin: 40px; --gutter: 24px; } }

/* ---- Reduced motion, or motion paused by the visitor (WCAG 2.2.2) ---- */
@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-press: .01ms; --dur-hover: .01ms; --dur-toast: .01ms; --dur-dialog-in: .01ms;
    --dur-dialog-out: .01ms; --dur-drawer: .01ms; --dur-reveal: .01ms; --dur-wipe: .01ms;
    --dur-tip: .01ms; --dur-out: .01ms; --dur-swap: .01ms; --dur-flight: .01ms;
  }
}
html[data-motion="paused"] {
  --dur-press: .01ms; --dur-hover: .01ms; --dur-toast: .01ms; --dur-dialog-in: .01ms;
  --dur-dialog-out: .01ms; --dur-drawer: .01ms; --dur-reveal: .01ms; --dur-wipe: .01ms;
  --dur-tip: .01ms; --dur-out: .01ms; --dur-swap: .01ms; --dur-flight: .01ms;
}
