/* tokens.css — the site's palette, type scale and spacing, and nothing else.
 *
 * Every page links this first, including the nineteen "paper, animated" pages,
 * which load no other shared sheet. Those pages each carried their own copy of
 * a palette, and the copies had drifted into three: #f7f7fb/#1e4d7b on seven
 * of them, #ffffff/#143a63 in paper-anim.css, and the site's own blue on
 * basketball.html. A reader clicking a paper from publications.html changed
 * sites. Now there is one source and the seam is gone.
 *
 * This file holds declarations only — no element or class rules — so a page
 * can take the palette without taking a layout with it.
 *
 * themes.css (warm, navy) is appended after this by the bootstrap in each
 * page's <head> and overrides what it needs; it was already doing so on the
 * scene pages, which is why only the default theme showed the seam.
 */

:root {
    color-scheme: light;
    --bg-primary: #ffffff;
    --bg-secondary: #f1f3f6;
    --bg-card: #f7f8fa;
    /* the inside of an expanded panel, a step lighter than the card */
    --bg-revealed: #fbfcfd;

    --text-primary: #0b0d10;
    --text-secondary: #3a414b;
    --text-muted: #59616b;

    --accent: #1a5fd0;
    --accent-hover: #1248a8;
    --accent-subtle: rgba(26, 95, 208, 0.08);
    /* What to write on an accent fill. Fourteen rules said `color: white`,
       which is right only while the accent is dark. In dark mode the accent
       becomes a pale blue and white-on-pale came to 2.33:1 — the active
       language button, the primary action, the toast and the skip link were
       all close to illegible. .nav-cta already used dark ink there; this makes
       that the rule rather than the exception. */
    --on-accent: #ffffff;

    /* The accent's own hue, as a bare number. The chart ramps are built from
       it with calc(), so they rotate when the theme does instead of staying
       blue on a terracotta page. Keep it in step with --accent above: it is
       that colour's oklch hue, not an independent choice. */
    --hue-accent: 260;
    /* A real green, and a rare one: awards, a figure that beats its
       comparison, and success. Nothing structural. */
    --green: #0f6f4b;
    --green-subtle: rgba(15, 111, 75, 0.10);
    --warning: #9a5600;
    --warning-light: #c47400;
    --warning-subtle: rgba(154, 86, 0, 0.12);

    --border: #e1e5ea;
    --shadow: rgba(11, 13, 16, 0.08);

    /* Chrome. The footer is a solid block with its own light-on-dark
       palette, and the nav is a translucent sheet over the page. Both
       were hard-coded, which is why a palette change left them behind.
       --footer-ink is the base; the dimmer footer text is mixed from it. */
    --footer-bg: #11161f;
    --footer-ink: #eef2f8;
    --nav-bg: rgba(255, 255, 255, 0.74);
    /* Three real shadows. These were all `none` while 37 rules referenced
       them, so .card:hover promised a lift the page never performed. They are
       deliberately shallow — the site is flat and papery, and on the white
       default a card needs only enough edge to separate from the page. The
       colour is --shadow, so they follow the palette into dark mode. */
    --shadow-sm: 0 1px 2px var(--shadow);
    --shadow-md: 0 2px 6px var(--shadow), 0 1px 2px var(--shadow);
    --shadow-lg: 0 6px 20px var(--shadow), 0 2px 6px var(--shadow);
    --callout-radius: 0;
    
    /* Type. The three faces, named for what they do rather than for what
       they are: --font-sans resolved to a serif and --font-serif to a sans,
       which is a trap for anyone reading a rule and expecting the obvious.
       The four old names are kept as aliases, pointing at exactly what they
       always did, so nothing moves. */
    --font-text: "adobe-garamond-pro", Garamond, Georgia, serif;
    --font-display: "futura-pt", Futura, "Century Gothic", sans-serif;
    --font-mono: "pt-mono", Consolas, "SF Mono", monospace;

    --font-sans: var(--font-text);     /* deprecated: a serif, despite the name */
    --font-body: var(--font-text);     /* deprecated */
    --font-serif: var(--font-display); /* deprecated: a sans, despite the name */
    --font-ui: var(--font-display);    /* deprecated */

    /* Size scale. The sheet had 24 distinct rem sizes including four pairs a
       couple of hundredths apart, which is noise rather than hierarchy. */
    --text-2xs: 0.625rem;    /* 10px */
    --text-xs: 0.6875rem;    /* 11px */
    --text-sm: 0.75rem;      /* 12px */
    --text-base: 0.8125rem;  /* 13px */
    --text-md: 0.875rem;     /* 14px */
    --text-lg: 0.9375rem;    /* 15px */
    --text-xl: 1rem;         /* 16px */
    --text-2xl: 1.125rem;    /* 18px */
    --text-3xl: 1.5rem;      /* 24px */

    /* Running prose, kept out of the ramp above because that ramp is for UI
       and its steps are a pixel apart. Adobe Garamond has a small x-height,
       so it sets smaller than its nominal size: at 16px it read thin against
       everything around it. */
    --text-body: 1.0625rem;  /* 17px */
    
    /* Spacing scale. This existed before with eight steps and not one call
       site anywhere in the repo, while the sheet used thirty-one distinct
       values by hand. The steps below are the values the sheet had actually
       settled on, so adopting them is mostly a renaming — the few strays that
       did not fit (0.35rem, 0.9rem) snap to the nearest step. */
    --space-1: 0.25rem;   /*  4px */
    --space-2: 0.5rem;    /*  8px */
    --space-3: 0.75rem;   /* 12px */
    --space-4: 1rem;      /* 16px */
    --space-5: 1.25rem;   /* 20px */
    --space-6: 1.5rem;    /* 24px */
    --space-7: 2rem;      /* 32px */
    --space-8: 2.5rem;    /* 40px */
    --space-9: 3rem;      /* 48px */
    --space-10: 3.5rem;   /* 56px */
    --space-11: 4rem;     /* 64px */
    --space-12: 5rem;     /* 80px */

    /* The tag idiom had five paddings and four sizes across nine families for
       what is one shape. Three sizes earn their place: a tag that sits on its
       own line, one that sits inline in running text and so must stay tight,
       and a micro badge. */
    --tag-pad:        0.25rem 0.75rem;
    --tag-pad-inline: 0.25rem 0.5rem;
    --tag-pad-micro:  0.15rem 0.45rem;

    /* Two button sizes, because a button does one of two jobs. Either it is
       an action the page is offering — the three ranks, primary, secondary and
       quiet — or it is interface furniture: a theme picker, a language
       switcher, a rotator control, the What's New toggle. The sheet had eleven
       sizes across four typefaces, which is one per place a button happened to
       appear rather than one per job, and four of those had asked for
       --font-sans and so were set in a serif. Buttons are UI: they take
       --font-ui, like the rest of the chrome. */
    --btn-font:    var(--text-lg);  /* 15px — the three action ranks */
    --btn-font-sm: var(--text-sm);  /* 12px — chrome controls */

    /* A faint neutral surface tint, for hovers and quiet fills. These used
       --shadow, which is a shadow *colour*: rgba(11,13,16,.08) on the light
       palette, where it passes for a grey wash, and rgba(0,0,0,.5) on the dark
       one, where it is a half-black slab. A tint has to go the other way in
       dark mode, so it is mixed from the text colour and inverts with it. */
    --tint: color-mix(in srgb, var(--text-primary) 6%, transparent);

    --nav-height: 56px;
    --max-width: 1200px;

    /* Measure. Prose was running 112 to 119 characters a line, where the
       eye starts losing its place on the return sweep; 45 to 75 is the
       comfortable band. This is a max-width, so it does nothing inside a
       column already narrower than it and only bites on full-width text.
       The container stays wide, so tables, grids and figures are untouched. */
    
    /* Motion -----------------------------------------------------------
       Durations and curves as tokens. Quint-out is the workhorse: it leaves
       immediately and settles slowly, which reads as responsive rather than
       floaty. Back-out overshoots a little and is reserved for things the
       visitor acted on, so the interface answers back. */
    --dur-instant: 90ms;
    --dur-fast: 150ms;
    --dur-base: 260ms;
    --dur-slow: 420ms;
    --dur-slower: 640ms;

    --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
    --ease-out-quint: cubic-bezier(0.22, 1, 0.36, 1);
    --ease-out-back: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-in-out-quart: cubic-bezier(0.76, 0, 0.24, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

    /* The two original aliases, kept so the 80-odd existing call sites keep
       working; only their curves changed. */
    --transition-fast: var(--dur-fast) var(--ease-out-quart);
    --transition-smooth: var(--dur-base) var(--ease-out-quint);
}

/* The dark palette sits on <html>, not on <body>.

   It used to be declared on body, which works for anything that inherits but
   breaks any token derived from another one: a custom property declared on
   :root computes its own value on :root, so a mix like --tint, which is built
   from --text-primary, was frozen against the light text colour no matter what
   mode the page was in. Declaring the palette on the same element as :root
   means derived tokens re-resolve in dark mode instead of needing a second
   hand-written copy.

   Every control that turns dark mode on sets the class on both <html> and
   <body>, and the pre-paint script in <head> sets it on <html> first, so
   nothing depends on body carrying the tokens. */
html.dark-mode {
    color-scheme: dark;
    --bg-primary: #0a0c0f;
    --bg-secondary: #12151a;
    --bg-card: #161a20;
    --bg-revealed: #0e1115;

    --text-primary: #f2f5f9;
    --text-secondary: #c2c9d3;
    --text-muted: #949dab;

    --accent: #74abff;
    --accent-hover: #9cc4ff;
    --accent-subtle: rgba(116, 171, 255, 0.13);
    --green: #5fd3a0;
    --green-subtle: rgba(95, 211, 160, 0.13);
    --warning: #e8a74e;
    --warning-light: #f5bd70;
    --warning-subtle: rgba(232, 167, 78, 0.14);

    --border: #262b33;
    --shadow: rgba(0, 0, 0, 0.5);
    --footer-bg: #0d1117;
    --footer-ink: #eef2f8;
    --nav-bg: rgba(10, 12, 15, 0.74);
    --on-accent: var(--bg-primary);
}

/* Names the scene pages use. They were declared page-locally and referenced
   from shared CSS, so on research-visualized.html --accent-light and --warm
   resolved to nothing. Defined here against the palette above, they follow the
   theme rather than pinning a second one. */
:root {
    --accent-light: color-mix(in srgb, var(--accent) 72%, var(--bg-primary));
    --warm: var(--warning-light);
    --warm-deep: var(--warning);
    --glow: var(--bg-revealed);
}
