/* tokens.css — the ONE design-token sheet for the nipmip family (2026-07-30).
 *
 * Loaded by every family page (dashboard, /sites, claude/usage, id/*) via
 * <link rel="stylesheet" href=".../shared/tokens.css">. Pages must NOT carry
 * their own :root token blocks — that per-page drift is exactly what this file
 * exists to end. Component styles stay per-page; colors come from here.
 *
 * Modes (data-theme attribute, set pre-paint by each page's boot snippet and
 * owned at runtime by shared/chrome.js):
 *   light — Light
 *   dark  — the dark. `System` resolves to it at night and the explicit `Dark`
 *           choice IS it; the two are the same by design.
 * The `theme` cookie is system|light|dark and `light`/`dark` are used as
 * data-theme VERBATIM — only `system` consults prefers-color-scheme.
 * (2026-07-30 `dark` briefly meant a third straight-black mode; Walter
 * reverted that 2026-07-31 — "dark should be basically the same as system".
 * The black look survives as the Blackout theme below, which is where he
 * wanted it. Do not turn it back into a mode.)
 *
 * Themes (data-palette attribute; `palette` cookie on .nipmip.net; absent =
 * Nipmip blue): each palette is just --accent + --accent2. Everything else —
 * background wash, surface tint, borders, logo — is DERIVED from those two
 * via color-mix, so a theme re-tints the whole estate, not just buttons.
 * `blackout` is the one exception: it re-tints the NEUTRALS instead of the
 * accents, which is why it composes with either mode rather than replacing it
 * — pure black under Dark, pure white under Light, accents untouched by both.
 */

/* Scrollbars are part of the shared chrome, not per-page decoration.
   Three things this fixes, all reported by Walter on 2026-07-30:
   1. They didn't match — only the dashboard styled its thumb (var(--border),
      accent-tinted → blue) while every other page used the OS default gray.
   2. `scrollbar-gutter: stable` reserves the track's width on EVERY page,
      scrolling or not. Without it a page that scrolls is ~15px narrower than
      one that doesn't (on classic scrollbars — macOS/headless overlay
      scrollbars hide this), so the right-hand end of the topbar — the avatar —
      lands in a different place per site.
   3. "always have that sleek small blue scrollbar in place even if the site
      doesn't need it." A reserved gutter is EMPTY, so a short page showed
      nothing. `overflow-y: scroll` makes the bar always present — but note
      what Chrome actually draws then: measured with real Chrome (--headless=new
      + OverlayScrollbar disabled, since old headless doesn't raster scrollbars
      at all), a non-overflowing page gets the TRACK and NO THUMB. So the line
      Walter wants always visible has to be the TRACK, not the thumb.
      Hence: track = var(--border), i.e. exactly the color the thumb used to
      be, and the thumb is lifted 35% toward --accent so it still reads as the
      position indicator on a page that does scroll. Short page = one continuous
      blue line; long page = that line plus a brighter thumb.
   Do not put `scrollbar-color`'s track back to `transparent` — Chrome ignores
   ::-webkit-scrollbar-track entirely once scrollbar-color is set, so that
   property is where the always-visible line actually comes from. */
html{
  overflow-y: scroll;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--accent) 35%, var(--border)) var(--border);
}
::-webkit-scrollbar{ width:10px; height:10px }
::-webkit-scrollbar-track{ background:var(--border); border-radius:6px }
::-webkit-scrollbar-thumb{ background:color-mix(in srgb, var(--accent) 35%, var(--border)); border-radius:6px }
::-webkit-scrollbar-thumb:hover{ background:var(--text3) }
::-webkit-scrollbar-corner{ background:transparent }

:root{
  color-scheme: dark;
  --accent:#3b82f6; --accent2:#8b5cf6;
  --accent-soft:color-mix(in srgb, var(--accent) 13%, transparent);
  --bg:#0a0e16;
  --bg-grad:radial-gradient(1300px 760px at 88% -12%, color-mix(in srgb, var(--accent) 20%, transparent), transparent 60%),
            radial-gradient(1100px 680px at -10% 6%, color-mix(in srgb, var(--accent2) 22%, transparent), transparent 58%),
            radial-gradient(900px 900px at 50% 118%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 55%),
            linear-gradient(158deg, #0d1119 0%, #0a0d13 50%, #0b0e14 100%);
  --surface:color-mix(in srgb, var(--accent) 5%, #0f151e);
  --surface2:color-mix(in srgb, var(--accent) 6%, #141b26);
  --surface3:color-mix(in srgb, var(--accent) 8%, #1a2231);
  --border:color-mix(in srgb, var(--accent) 14%, #242e3c);
  --border2:#33405400;
  --text:#e8eef6; --text2:#9aa7b8; --text3:#647084;
  --blue:#5ea1ff; --green:#43c463; --red:#ff5d5d; --yellow:#e3b341;
  --purple:#c08bff; --orange:#ff9f52; --cyan:#38d3c8; --pink:#f778ba;
  --danger:#ff6b6b;
  --track:color-mix(in srgb, var(--accent) 8%, #1a2231);
  --shadow:0 1px 2px #0006, 0 8px 24px -12px #0009;
  --radius:14px; --radius-sm:9px;
  --dur-fast:.12s; --dur:.15s; --dur-slow:.3s; --dur-slower:.5s;
  --ease:cubic-bezier(.2,.7,.2,1); --ease-spring:cubic-bezier(.34,1.56,.64,1);
}

:root[data-theme="light"]{
  color-scheme: light;
  --accent:#2563eb; --accent2:#7c3aed;
  --bg:#eef1f6;
  --bg-grad:radial-gradient(1300px 760px at 88% -12%, color-mix(in srgb, var(--accent) 15%, transparent), transparent 62%),
            radial-gradient(1100px 680px at -10% 6%, color-mix(in srgb, var(--accent2) 14%, transparent), transparent 60%),
            radial-gradient(900px 900px at 50% 118%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 58%),
            linear-gradient(158deg, #f4f7fc 0%, #eef1f6 52%, #ebeef5 100%);
  --surface:#ffffff;
  --surface2:color-mix(in srgb, var(--accent) 3%, #f7f9fc);
  --surface3:color-mix(in srgb, var(--accent) 4%, #eef1f7);
  --border:color-mix(in srgb, var(--accent) 10%, #dde3ec);
  --border2:#00000000;
  --text:#131a24; --text2:#4c586a; --text3:#8893a4;
  --blue:#1f6feb; --green:#1a7f37; --red:#cf222e; --yellow:#9a6700;
  --purple:#8250df; --orange:#bc4c00; --cyan:#0a7c74; --pink:#bf3989;
  --danger:#cf222e;
  --track:#e7ecf3;
  --shadow:0 1px 2px #0000000d, 0 10px 30px -18px #0f172a40;
}

/* ── Themes — two accent colors each; light mode gets deeper variants for
      contrast on white. ─────────────────────────────────────────────────── */
:root[data-palette="ocean"]{--accent:#06b6d4;--accent2:#3b82f6}
:root[data-theme="light"][data-palette="ocean"]{--accent:#0891b2;--accent2:#2563eb}
:root[data-palette="forest"]{--accent:#22c55e;--accent2:#14b8a6}
:root[data-theme="light"][data-palette="forest"]{--accent:#16a34a;--accent2:#0d9488}
:root[data-palette="sunset"]{--accent:#f97316;--accent2:#ec4899}
:root[data-theme="light"][data-palette="sunset"]{--accent:#ea580c;--accent2:#db2777}
:root[data-palette="grape"]{--accent:#a78bfa;--accent2:#e879f9}
:root[data-theme="light"][data-palette="grape"]{--accent:#7c3aed;--accent2:#c026d3}
:root[data-palette="graphite"]{--accent:#94a3b8;--accent2:#64748b}
:root[data-theme="light"][data-palette="graphite"]{--accent:#475569;--accent2:#334155}

/* Blackout — the odd one out, and deliberately so. Every other theme re-tints
   the ACCENTS and lets the neutrals derive; this one re-tints the NEUTRALS and
   leaves --accent/--accent2 at whatever the mode gives (Nipmip blue by
   default). It was `data-theme="black"` — the explicit Dark mode — for one day
   (2026-07-30 → 2026-07-31); Walter reverted Dark to plain dark and asked for
   this look to live "under themes" instead.

   It FOLLOWS the mode rather than pinning dark (Walter, 2026-07-31: "light mode
   blackout should be different. should be lighter blackout?"). Same idea run in
   both directions: drive the base to the extreme — pure #000 / pure #fff — and
   step the surfaces AWAY from that extreme toward mid-gray, so the elevation
   ladder still reads without any color doing the work. Only a whisper of
   accent in the surfaces and the faintest top glow, so it's a theme and not a
   void. The two blocks are explicit and symmetric on purpose: both are
   (0,3,0), so neither depends on source order, and every variable one sets the
   other sets too — a var present in only one would leak the wrong mode's
   neutral across. Keep them in lockstep when editing. */
:root[data-theme="dark"][data-palette="blackout"]{
  --bg:#000000;
  --bg-grad:radial-gradient(1200px 640px at 50% -18%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 60%);
  --surface:color-mix(in srgb, var(--accent) 4%, #0a0a0d);
  --surface2:color-mix(in srgb, var(--accent) 5%, #0e0e12);
  --surface3:color-mix(in srgb, var(--accent) 7%, #131318);
  --border:color-mix(in srgb, var(--accent) 12%, #1d1d24);
  --border2:#00000000;
  --text:#e8eef6; --text2:#9aa7b8; --text3:#647084;
  --track:color-mix(in srgb, var(--accent) 7%, #131318);
  --shadow:0 1px 2px #000a, 0 8px 24px -12px #000;
}
/* Whiteout, in all but name. Note the surfaces go DOWN from the #fff base
   while the dark form's go UP from #000 — in both cases away from the extreme,
   which is what keeps cards visible against the page. */
:root[data-theme="light"][data-palette="blackout"]{
  --bg:#ffffff;
  --bg-grad:radial-gradient(1200px 640px at 50% -18%, color-mix(in srgb, var(--accent) 6%, transparent), transparent 60%);
  --surface:color-mix(in srgb, var(--accent) 2%, #fbfbfc);
  --surface2:color-mix(in srgb, var(--accent) 3%, #f5f5f7);
  --surface3:color-mix(in srgb, var(--accent) 4%, #ededf0);
  --border:color-mix(in srgb, var(--accent) 10%, #e0e0e6);
  --border2:#00000000;
  --text:#14171c; --text2:#565b64; --text3:#8b9099;
  --track:color-mix(in srgb, var(--accent) 4%, #ededf0);
  --shadow:0 1px 2px #0000000d, 0 10px 30px -18px #00000047;
}

/* ── Motion (2026-08-10) ──────────────────────────────────────────────────
   Same charter as the colors above: pages must NOT invent their own timing.
   Unlike --shadow these are NOT re-declared per mode or per theme — motion is
   physics, not brand, so they live once in the base :root beside --radius.

   The values are MEASURED, not chosen. Across infrastructure/site the timings
   in use were .15s (12 uses) and .12s (10) with a long tail of .3/.4/.5/.6/.7,
   and the only real easing curve was cubic-bezier(.2,.7,.2,1) (3 uses). So the
   house style already existed — it was just written down nowhere, which is how
   twelve distinct durations accumulated. --dur is the default; reach for
   --dur-fast on hover/focus tints and --dur-slow(er) only for things that
   travel (sheets, drawers, page transitions).

   --ease-spring is the estate-wide overshoot (cubic-bezier(.34,1.56,.64,1),
   11 uses across fishmas/paint/toyota). It is deliberately NOT the default —
   an overshoot on a hover tint reads as a wobble. Use it when something
   arrives (a card popping in), never when something merely changes color.

   Adding a duration or a curve here is a design decision; picking a raw number
   in a page stylesheet is how the drift started. Prefer var(--dur) over .15s
   even when they're identical today. */
@media (prefers-reduced-motion: reduce){
  :root{ --dur-fast:0s; --dur:0s; --dur-slow:0s; --dur-slower:0s }
}
