/* ==========================================================================
   TOKENS.CSS — Red Bull Racing palette (v3 — Navy / Racing Red / Podium
   Yellow), recolor of the "Ember & Trace" system built for this site.

   v3 revision note — what changed and why:
   Deliberate move away from the warm-paper / ember-orange identity to a
   Red Bull Racing–inspired palette: deep navy canvas, racing red as the
   one dominant accent, podium yellow as a rare secondary accent. Nothing
   about the STRUCTURE below changed — the discipline that made v2 work
   (one saturated color spent sparingly and dramatically, not a rainbow of
   equally-loud accents; an instrument-panel radius scale instead of
   soft-rounded-everything; the Fraunces/Plex Sans/Plex Mono pairing) is
   exactly as considered as before. Only the primitive hex values moved.

   Because navy is inherently a DARK color, this version flips which theme
   is the default: the bare :root below is the navy/red/yellow palette,
   and it's unconditional — every visitor sees it regardless of their OS
   appearance setting. This is a deliberate personal-brand choice, not an
   adaptive dark-mode fallback: an earlier version auto-switched to a
   light variant for OS-light users, which meant most visitors never saw
   the Red Bull identity at all. The light variant still exists as an
   explicit :root[data-theme="light"] override for a future toggle, it
   just no longer triggers itself. Podium yellow stays the same hue in
   both themes — it has exactly one live consumer (the small nav-brand
   pulse dot), so there's no body-text contrast case to protect against.

   Everything theme-independent (spacing, radius scale, typography,
   motion durations/easing, the trace-node SVG structural rationale) is
   untouched from v2 — only the color primitives and the block that decides
   which theme is the default moved.
   ========================================================================== */

:root {
  color-scheme: dark;

  /* ---- Primitive · Canvas / fog neutrals (navy dark canvas, default) -- */
  --color-canvas-0: #0a0e21;   /* page canvas — Red Bull navy, deep and cool */
  --color-canvas-50: #10152c; /* raised surface (cards) */
  --color-canvas-100: #171d3a; /* hover / secondary surface */
  --color-canvas-150: #212849; /* overlay / popover */
  --color-fog-900: #f5f6fa;   /* primary text — cool white */
  --color-fog-700: #b8bcd4;   /* secondary text */
  --color-fog-500: #7d81a0;   /* tertiary text / placeholders */
  --color-fog-300: #454a68;   /* disabled / faint */
  /* alias so the one direct primitive reference in index.html (a muted
     readout-glyph dot) still resolves sensibly now that dark is default */
  --color-ink-500: var(--color-fog-500);

  /* ---- Primitive · Signal (Red Bull racing red — THE bold accent) ---- */
  --color-signal-soft: rgba(225, 6, 32, 0.18);
  --color-signal-base: #e10620;    /* solid — buttons, hub nodes, primary accent */
  --color-signal-strong: #ff2d47;  /* hover / pressed — brightens, not darkens */
  --color-signal-text: #ff5468;    /* accent text/icons/links on navy */
  --color-signal-glow: rgba(225, 6, 32, 0.5);

  /* ---- Primitive · Trace (podium yellow — rare secondary accent) ----- */
  --color-trace-soft: rgba(255, 196, 0, 0.16);
  --color-trace-base: #ffc400;
  --color-trace-strong: #ffd84d;
  --color-trace-text: #ffcf33;
  --color-trace-glow: rgba(255, 196, 0, 0.4);

  /* ---- Primitive · Functional ---------------------------------------- */
  --color-danger-500: #ff6b4a;   /* distinct from signal-red so real errors don't blend into the brand accent */
  --color-warning-500: #f2b705;
  --color-success-500: var(--color-trace-base);

  /* ---- Semantic · Surface --------------------------------------------- */
  --bg-canvas: var(--color-canvas-0);
  --bg-surface: var(--color-canvas-50);
  --bg-surface-raised: var(--color-canvas-100);
  --bg-overlay: rgba(4, 5, 12, 0.65);
  --bg-accent-soft-signal: var(--color-signal-soft);
  --bg-accent-soft-trace: var(--color-trace-soft);
  /* Single directional red ribbon (not a dual ambient blob) — quiet on
     navy; the motif graphic (see --motif-*) carries the hero moment. */
  --bg-hero: linear-gradient(
      118deg,
      transparent 0%,
      transparent 40%,
      rgba(225, 6, 32, 0.24) 50%,
      rgba(225, 6, 32, 0.06) 66%,
      transparent 78%
    ),
    var(--bg-canvas);

  /* ---- Semantic · Text -------------------------------------------------- */
  --text-primary: var(--color-fog-900);
  --text-secondary: var(--color-fog-700);
  --text-tertiary: var(--color-fog-500);
  --text-disabled: var(--color-fog-300);
  --text-link: var(--color-trace-text);
  --text-on-accent-signal: #1a0207; /* near-black warm ink on vivid red */
  --text-on-accent-trace: #241b00;  /* near-black on vivid yellow */

  /* ---- Semantic · Border -------------------------------------------------- */
  --border-hairline: rgba(245, 246, 250, 0.08);
  --border-default: rgba(245, 246, 250, 0.14);
  --border-strong: rgba(245, 246, 250, 0.24);
  --border-accent-signal: var(--color-signal-base);
  --border-accent-trace: var(--color-trace-base);
  --border-width-hairline: 1px;
  --border-width-default: 1px;
  --border-width-strong: 1.5px;

  /* ---- Semantic · Accent -------------------------------------------------- */
  --accent-primary: var(--color-signal-base);
  --accent-primary-hover: var(--color-signal-strong);
  --accent-secondary: var(--color-trace-base);
  --accent-secondary-hover: var(--color-trace-strong);
  --focus-ring: 0 0 0 3px rgba(225, 6, 32, 0.4);
  --danger: var(--color-danger-500);
  --warning: var(--color-warning-500);
  --success: var(--color-success-500);

  /* ---- Semantic · Shadow & Glow ------------------------------------------ */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 28px 64px rgba(0, 0, 0, 0.55);
  --glow-signal-sm: 0 0 0 1px var(--color-signal-base), 0 6px 20px var(--color-signal-glow);
  --glow-signal-md: 0 0 0 1px var(--color-signal-base), 0 12px 36px var(--color-signal-glow),
    0 0 64px var(--color-signal-glow);
  --glow-trace-sm: 0 0 0 1px var(--color-trace-base), 0 6px 20px var(--color-trace-glow);
  --glow-trace-md: 0 0 0 1px var(--color-trace-base), 0 12px 36px var(--color-trace-glow);

  /* ---- Motif · ring / trace graphic (navy dark canvas, default) ----------
     Energized reading: live traces glow racing-red (current flowing),
     pruned branches fade to dim neutral fog (unpowered), hub nodes are
     solid glowing red discs. Podium yellow stays off this graphic entirely
     — it's reserved for the rare secondary highlight elsewhere, per the
     restraint principle. ---------------------------------------------- */
  --motif-trace-stroke: rgba(225, 6, 32, 0.55);
  --motif-trace-stroke-dim: rgba(245, 246, 250, 0.12);
  --motif-node-fill: var(--color-signal-base);
  --motif-node-ring: rgba(245, 246, 250, 0.25);
  --motif-node-glow: drop-shadow(0 0 22px rgba(225, 6, 32, 0.65));
  --motif-grain-opacity: 0.18;
  --motif-grain-blend: overlay;

  /* ---- Typography · families (theme-independent) ------------------------ */
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI",
    Helvetica, Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas,
    monospace;

  /* ---- Typography · scale (1.25-ish modular, theme-independent) --------- */
  --text-xs: 0.75rem;    /* 12px — eyebrow labels, captions */
  --text-sm: 0.875rem;   /* 14px — meta, small UI */
  --text-base: 1rem;     /* 16px — body copy */
  --text-md: 1.125rem;   /* 18px — lead paragraph */
  --text-lg: 1.375rem;   /* 22px — card title / H4 */
  --text-xl: 1.75rem;    /* 28px — H3 */
  --text-2xl: 2.25rem;   /* 36px — H2 */
  --text-3xl: 3rem;      /* 48px — H1 (section) */
  --text-4xl: 4.5rem;    /* 72px — hero display */
  --text-5xl: 5.75rem;   /* 92px — max-contrast hero, use sparingly */

  --leading-tight: 1.04;
  --leading-snug: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.7;

  --tracking-tighter: -0.035em; /* hero display */
  --tracking-tight: -0.01em;    /* headings */
  --tracking-normal: 0em;
  --tracking-wide: 0.04em;      /* nav labels, eyebrows */
  --tracking-wider: 0.08em;     /* small-caps badges */

  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;
  --weight-black: 900; /* hero display only — the "extreme weight" end of the pair */

  /* ---- Spacing (4px base, theme-independent) ---------------------------- */
  --space-0: 0px;
  --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: 4rem;    /* 64px */
  --space-11: 5rem;    /* 80px */
  --space-12: 6rem;    /* 96px */
  --space-13: 8rem;    /* 128px */

  /* ---- Radius — instrument-panel scale, not soft-SaaS rounded-everything
     (theme-independent) ------------------------------------------------- */
  --radius-xs: 0.125rem; /* 2px  — stat tiles, hairline chips */
  --radius-sm: 0.25rem;  /* 4px  — buttons, inputs */
  --radius-md: 0.375rem; /* 6px  — cards */
  --radius-lg: 0.625rem; /* 10px — large surfaces, modals */
  --radius-xl: 1rem;     /* 16px — hero-scale containers only */
  --radius-full: 999px;  /* status dots, pill badges — semantic chips only */

  /* ---- Motion primitives (theme-independent) ------------------------------ */
  --duration-instant: 80ms;
  --duration-fast: 140ms;
  --duration-base: 220ms;
  --duration-slow: 380ms;
  --duration-glow-pulse: 2400ms;
  --duration-trace-flow: 3200ms; /* one signal traveling the output trace */
  --duration-ring-rotate: 90000ms; /* slow ambient ring-track rotation, hero graphic only */
  --duration-halo-breathe: 3600ms;

  --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1); /* slight overshoot */

  --transition-color: color var(--duration-fast) var(--ease-standard),
    background-color var(--duration-fast) var(--ease-standard),
    border-color var(--duration-fast) var(--ease-standard);
  --transition-transform: transform var(--duration-base) var(--ease-spring);
  --transition-shadow: box-shadow var(--duration-base) var(--ease-out);
  --transition-all-base: color var(--duration-base) var(--ease-standard),
    background-color var(--duration-base) var(--ease-standard),
    border-color var(--duration-base) var(--ease-standard),
    box-shadow var(--duration-base) var(--ease-out),
    transform var(--duration-base) var(--ease-spring);

  /* ---- Component tokens · Nav -------------------------------------------- */
  --nav-bg: rgba(10, 14, 33, 0.72);
  --nav-border: var(--border-hairline);
  --nav-blur: 16px;
  --nav-height: 4rem;

  /* ---- Component tokens · Button ------------------------------------------
     The primary CTA carries the one bespoke shape risk: a single chamfered
     top-right corner (a control-panel toggle, not a rounded pill) instead
     of the default radius. Secondary stays a plain rectangle for contrast. */
  --button-radius: var(--radius-sm);
  --button-notch: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 0 100%);
  --button-padding-y: var(--space-3);
  --button-padding-x: var(--space-6);
  --button-shadow-rest: var(--shadow-sm);
  --button-shadow-hover: var(--glow-signal-md);

  /* ---- Component tokens · Card -------------------------------------------- */
  --card-bg: var(--bg-surface-raised);
  --card-border: var(--border-default);
  --card-radius: var(--radius-md);
  --card-padding: var(--space-6);
  --card-shadow-rest: var(--shadow-sm);
  --card-shadow-hover: var(--shadow-lg), var(--glow-trace-sm);

  /* ---- Component tokens · Stat tile (dense readouts) ---------------------
     Default value color is neutral fog, not uniform yellow — yellow is
     spent on exactly one "promoted" tile + the live badge, per the
     restraint principle. --------------------------------------------- */
  --stat-tile-bg: var(--color-canvas-50);
  --stat-tile-border: var(--border-hairline);
  --stat-tile-radius: var(--radius-xs);
  --stat-tile-value-font: var(--font-mono);
  --stat-tile-value-color: var(--text-primary);
  --stat-tile-value-color-live: var(--color-trace-strong);
  --stat-tile-label-color: var(--text-tertiary);
}

/* ==========================================================================
   Navy is the theme for every visitor, not just a dark-preference
   fallback — there is deliberately no @media (prefers-color-scheme:
   light) switch here. The light variant still exists below as an
   explicit :root[data-theme="light"] override, ready to wire up to a
   toggle if one gets added later, but nothing switches to it on its own.
   ========================================================================== */

/* ==========================================================================
   Light theme — explicit choice (wins over system preference in both
   directions; a user who picks light gets it even on a dark-preferring OS).
   Mirrors the media query above so a future theme toggle has somewhere to
   attach without retouching the token values.
   ========================================================================== */
:root[data-theme="light"] {
  color-scheme: light;

  --color-paper-0: #f7f8fb;
  --color-paper-50: #eceefa;
  --color-paper-100: #dde1f0;
  --color-ink-900: #0a0e21;
  --color-ink-700: #2c3252;
  --color-ink-500: #5b6084;
  --color-ink-300: #a7abc4;

  --color-signal-soft: #ffd9de;
  --color-signal-base: #d1041c;
  --color-signal-strong: #9e0315;
  --color-signal-text: #b8031a;
  --color-signal-glow: rgba(209, 4, 28, 0.28);

  --color-trace-soft: rgba(255, 196, 0, 0.16);
  --color-trace-base: #ffc400;
  --color-trace-strong: #e6b000;
  --color-trace-text: #a67d00;
  --color-trace-glow: rgba(255, 196, 0, 0.35);

  --color-danger-500: #b3271c;
  --color-warning-500: #a6660a;
  --color-success-500: var(--color-trace-base);

  --bg-canvas: var(--color-paper-0);
  --bg-surface: var(--color-paper-50);
  --bg-surface-raised: #ffffff;
  --bg-overlay: rgba(10, 14, 33, 0.5);
  --bg-accent-soft-signal: var(--color-signal-soft);
  --bg-accent-soft-trace: var(--color-trace-soft);
  --bg-hero: linear-gradient(
      118deg,
      transparent 0%,
      transparent 42%,
      rgba(209, 4, 28, 0.1) 50%,
      rgba(209, 4, 28, 0.03) 64%,
      transparent 76%
    ),
    var(--bg-canvas);

  --text-primary: var(--color-ink-900);
  --text-secondary: var(--color-ink-700);
  --text-tertiary: var(--color-ink-500);
  --text-disabled: var(--color-ink-300);
  --text-link: var(--color-trace-text);
  --text-on-accent-signal: #fff5f5;
  --text-on-accent-trace: #ffffff;

  --border-hairline: rgba(10, 14, 33, 0.08);
  --border-default: rgba(10, 14, 33, 0.14);
  --border-strong: rgba(10, 14, 33, 0.24);
  --border-accent-signal: var(--color-signal-base);
  --border-accent-trace: var(--color-trace-base);

  --accent-primary: var(--color-signal-base);
  --accent-primary-hover: var(--color-signal-strong);
  --accent-secondary: var(--color-trace-base);
  --accent-secondary-hover: var(--color-trace-strong);
  --focus-ring: 0 0 0 3px rgba(209, 4, 28, 0.3);
  --danger: var(--color-danger-500);
  --warning: var(--color-warning-500);
  --success: var(--color-success-500);

  --shadow-sm: 0 1px 2px rgba(10, 14, 33, 0.06), 0 1px 1px rgba(10, 14, 33, 0.04);
  --shadow-md: 0 4px 12px rgba(10, 14, 33, 0.08), 0 2px 4px rgba(10, 14, 33, 0.06);
  --shadow-lg: 0 16px 40px rgba(10, 14, 33, 0.14), 0 4px 10px rgba(10, 14, 33, 0.08);
  --glow-signal-sm: 0 0 0 1px var(--color-signal-base), 0 6px 18px var(--color-signal-glow);
  --glow-signal-md: 0 0 0 1px var(--color-signal-base), 0 10px 32px var(--color-signal-glow),
    0 0 48px var(--color-signal-glow);
  --glow-trace-sm: 0 0 0 1px var(--color-trace-base), 0 6px 18px var(--color-trace-glow);
  --glow-trace-md: 0 0 0 1px var(--color-trace-base), 0 10px 32px var(--color-trace-glow);

  --motif-trace-stroke: rgba(10, 14, 33, 0.22);
  --motif-trace-stroke-dim: rgba(10, 14, 33, 0.09);
  --motif-node-fill: var(--color-signal-base);
  --motif-node-ring: rgba(10, 14, 33, 0.22);
  --motif-node-glow: drop-shadow(0 0 14px rgba(209, 4, 28, 0.35));
  --motif-grain-opacity: 0.05;
  --motif-grain-blend: multiply;

  --nav-bg: rgba(247, 248, 251, 0.82);
  --nav-border: var(--border-hairline);

  --button-shadow-rest: var(--shadow-sm);
  --button-shadow-hover: var(--glow-signal-md);

  --card-bg: var(--bg-surface-raised);
  --card-border: var(--border-default);
  --card-shadow-rest: var(--shadow-sm);
  --card-shadow-hover: var(--shadow-lg), var(--glow-trace-sm);

  --stat-tile-bg: var(--color-paper-100);
  --stat-tile-border: var(--border-hairline);
  --stat-tile-value-color: var(--text-primary);
  --stat-tile-value-color-live: var(--color-trace-text);
  --stat-tile-label-color: var(--text-tertiary);
}

/* ==========================================================================
   Motif · grain texture (theme-independent noise image; the
   opacity/blend tokens above do the theme adaptation) — a compact SVG
   feTurbulence data URI, no external asset, no build step.
   ========================================================================== */
:root {
  --motif-trace-width: 1.75px;
  --motif-node-radius: 7px;
  --motif-node-radius-sm: 4px;
  --motif-grain-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.9 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --motif-grain-size: 240px 240px;
}

/* ==========================================================================
   Motion primitives — keyframes
   ========================================================================== */
@keyframes pulse-glow {
  0%,
  100% {
    box-shadow: 0 0 0 0 var(--color-trace-glow);
  }
  50% {
    box-shadow: 0 0 0 6px transparent;
  }
}

@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* A single signal traveling the "promoted" output trace out of the gate
   node — the one orchestrated motion moment tied to the motif, not a
   scattering of ambient effects. Animates stroke-dashoffset on a dashed
   overlay path; see .hero-trace__pulse in preview.html. */
@keyframes trace-flow {
  0% {
    stroke-dashoffset: 240;
    opacity: 0;
  }
  8% {
    opacity: 1;
  }
  85% {
    opacity: 1;
  }
  100% {
    stroke-dashoffset: 0;
    opacity: 0;
  }
}

/* Slow ambient rotation of the hero graphic's ring-guide tracks only —
   never the labeled nodes/text riding on them, so nothing becomes
   unreadable mid-spin. Purely atmospheric: the graph's real state (which
   dots glow, which lines exist) never depends on rotation. */
@keyframes ring-rotate {
  to {
    transform: rotate(360deg);
  }
}

@keyframes ring-rotate-reverse {
  to {
    transform: rotate(-360deg);
  }
}

/* Hub nodes breathing — the two load-bearing skills read as "alive," a
   gentle scale+opacity pulse on the halo only, not the node itself. */
@keyframes halo-breathe {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.3;
  }
  50% {
    transform: scale(1.18);
    opacity: 0.5;
  }
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --duration-instant: 0ms;
    --duration-fast: 0ms;
    --duration-base: 0ms;
    --duration-slow: 0ms;
    --duration-glow-pulse: 0ms;
    --duration-trace-flow: 0ms;
    --duration-ring-rotate: 0ms;
    --duration-halo-breathe: 0ms;
  }
}
