/* RFD site kit, tokens v1.0.4. One token set for the four doors.
   Theme: dark is the default when the OS has no preference. The OS preference
   (prefers-color-scheme) is followed, so visitors without JS follow the OS too.
   [data-theme="dark|light"] on <html>, or on any element, overrides it for that subtree.
   Door: data-door="consulting|blog|arcade|play" picks the accent.

   Cascade rule: a custom property that uses var() is resolved on the element that declares it,
   and descendants inherit the RESOLVED value. So the accent must not be resolved from a theme
   that the door element happens to sit in or under. Each data-door element therefore stores BOTH
   literal accents and declares --rfd-accent as light-dark(light, dark). light-dark() is evaluated
   where the colour is USED, from that element's color-scheme, which every theme scope sets. Result:
   door outside theme, door inside theme, same element, and OS-only all give the right accent, with
   no selector matrix. light-dark() is Baseline 2024 (Chrome 123, Safari 17.5, Firefox 120); older
   engines use the @supports-not fallback below, which covers the common nestings only.
   Every colour pair is checked for WCAG AA by tests/test_site_kit.py, which models this cascade
   for every nesting. */

:root {
  color-scheme: dark;

  /* colour roles, dark */
  --rfd-bg: #0b1220;
  --rfd-surface: #111a2e;
  --rfd-surface-2: #1a2540;
  --rfd-text: #e5e9f2;
  --rfd-text-dim: #a3aec6;
  --rfd-border: #2b3858;
  --rfd-border-strong: #6f7fa3;
  --rfd-danger: #fca5a5;
  --rfd-ok: #5eead4;
  --rfd-warn: #fbbf24;

  --rfd-accent-ink: #0b1220; /* text on an accent-filled button */

  /* elevations */
  --rfd-shadow-1: 0 1px 2px rgb(0 0 0 / 0.4), 0 1px 3px rgb(0 0 0 / 0.3);
  --rfd-shadow-2: 0 6px 20px rgb(0 0 0 / 0.5), 0 2px 6px rgb(0 0 0 / 0.4);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --rfd-bg: #ffffff;
    --rfd-surface: #f8fafc;
    --rfd-surface-2: #eef2f7;
    --rfd-text: #0f172a;
    --rfd-text-dim: #475569;
    --rfd-border: #e2e8f0;
    --rfd-border-strong: #64748b;
    --rfd-danger: #b91c1c;
    --rfd-ok: #0f766e;
    --rfd-warn: #92400e;
    --rfd-accent-ink: #ffffff;
    --rfd-shadow-1: 0 1px 2px rgb(15 23 42 / 0.08), 0 1px 3px rgb(15 23 42 / 0.06);
    --rfd-shadow-2: 0 8px 24px rgb(15 23 42 / 0.12), 0 2px 6px rgb(15 23 42 / 0.08);
  }
}

[data-theme="light"] {
  color-scheme: light;
  --rfd-bg: #ffffff;
  --rfd-surface: #f8fafc;
  --rfd-surface-2: #eef2f7;
  --rfd-text: #0f172a;
  --rfd-text-dim: #475569;
  --rfd-border: #e2e8f0;
  --rfd-border-strong: #64748b;
  --rfd-danger: #b91c1c;
  --rfd-ok: #0f766e;
  --rfd-warn: #92400e;
  --rfd-accent-ink: #ffffff;
  --rfd-shadow-1: 0 1px 2px rgb(15 23 42 / 0.08), 0 1px 3px rgb(15 23 42 / 0.06);
  --rfd-shadow-2: 0 8px 24px rgb(15 23 42 / 0.12), 0 2px 6px rgb(15 23 42 / 0.08);
}

[data-theme="dark"] {
  color-scheme: dark;
  --rfd-bg: #0b1220;
  --rfd-surface: #111a2e;
  --rfd-surface-2: #1a2540;
  --rfd-text: #e5e9f2;
  --rfd-text-dim: #a3aec6;
  --rfd-border: #2b3858;
  --rfd-border-strong: #6f7fa3;
  --rfd-danger: #fca5a5;
  --rfd-ok: #5eead4;
  --rfd-warn: #fbbf24;
  --rfd-accent-ink: #0b1220;
  --rfd-shadow-1: 0 1px 2px rgb(0 0 0 / 0.4), 0 1px 3px rgb(0 0 0 / 0.3);
  --rfd-shadow-2: 0 6px 20px rgb(0 0 0 / 0.5), 0 2px 6px rgb(0 0 0 / 0.4);
}

/* Door to accents: both literals live on the door element. Default (no data-door) is consulting. */
:root,
[data-door="consulting"] { --rfd-accent-dark: #93b4ff; --rfd-accent-light: #1e3a8a; }
[data-door="blog"] { --rfd-accent-dark: #8ed5ff; --rfd-accent-light: #0369a1; }
[data-door="arcade"] { --rfd-accent-dark: #c4b5fd; --rfd-accent-light: #6d28d9; }
[data-door="play"] { --rfd-accent-dark: #fac775; --rfd-accent-light: #92400e; }

/* Derived on every door element (and the root) so they carry that door's literals. */
:root,
[data-door] {
  --rfd-accent: light-dark(var(--rfd-accent-light), var(--rfd-accent-dark));
  --rfd-link: var(--rfd-accent);
  --rfd-focus: var(--rfd-accent);
}

/* Fallback for engines without light-dark() (Chrome < 123, Safari < 17.5, Firefox < 120, old WebViews).
   There the light-dark() accent is invalid at computed-value time, which would drop the focus ring
   shorthand's colour and leave filled buttons transparent. Here the accent, link and focus roles are
   LITERAL hex per nearest theme scope: the old selector matrix, kept inside @supports-not only.
   Supported nestings: door and theme on one element, door outside theme, theme outside door, and
   OS-only (dark default, prefers-color-scheme: light). Deeper mixes (a theme under another theme with
   a door inside, or several nested doors) always get a VALID colour, but at equal specificity the
   LATER rule in source wins, and the light-theme rules come later, so the accent can be a light-theme
   one on a dark surface. Worst cases: light > dark > blog (no outer door) gives #0369a1 on #0b1220,
   3.16:1; a light consulting door > dark > door gives #1e3a8a on dark, 1.81:1, and the focus ring is
   nearly invisible. Documented degrade; do not nest like that for engines older than the Baseline.
   SOURCE ORDER: this block MUST stay after the light-dark() rule above (":root, [data-door]"), because
   its rules tie that rule's specificity and win only by coming later. tests/test_site_kit.py checks it. */
@supports not (color: light-dark(#000, #fff)) {
  :root,
  [data-theme="dark"] { --rfd-accent: #93b4ff; --rfd-link: #93b4ff; --rfd-focus: #93b4ff; }
  [data-door="consulting"] { --rfd-accent: #93b4ff; --rfd-link: #93b4ff; --rfd-focus: #93b4ff; }
  [data-door="blog"] { --rfd-accent: #8ed5ff; --rfd-link: #8ed5ff; --rfd-focus: #8ed5ff; }
  [data-door="arcade"] { --rfd-accent: #c4b5fd; --rfd-link: #c4b5fd; --rfd-focus: #c4b5fd; }
  [data-door="play"] { --rfd-accent: #fac775; --rfd-link: #fac775; --rfd-focus: #fac775; }
  [data-theme="light"] { --rfd-accent: #1e3a8a; --rfd-link: #1e3a8a; --rfd-focus: #1e3a8a; }
  [data-theme="dark"] [data-door="consulting"] { --rfd-accent: #93b4ff; --rfd-link: #93b4ff; --rfd-focus: #93b4ff; }
  [data-theme="light"] [data-door="consulting"] { --rfd-accent: #1e3a8a; --rfd-link: #1e3a8a; --rfd-focus: #1e3a8a; }
  [data-theme="dark"] [data-door="blog"] { --rfd-accent: #8ed5ff; --rfd-link: #8ed5ff; --rfd-focus: #8ed5ff; }
  [data-theme="light"] [data-door="blog"] { --rfd-accent: #0369a1; --rfd-link: #0369a1; --rfd-focus: #0369a1; }
  [data-theme="dark"] [data-door="arcade"] { --rfd-accent: #c4b5fd; --rfd-link: #c4b5fd; --rfd-focus: #c4b5fd; }
  [data-theme="light"] [data-door="arcade"] { --rfd-accent: #6d28d9; --rfd-link: #6d28d9; --rfd-focus: #6d28d9; }
  [data-theme="dark"] [data-door="play"] { --rfd-accent: #fac775; --rfd-link: #fac775; --rfd-focus: #fac775; }
  [data-theme="light"] [data-door="play"] { --rfd-accent: #92400e; --rfd-link: #92400e; --rfd-focus: #92400e; }
  [data-door="consulting"] [data-theme="dark"] { --rfd-accent: #93b4ff; --rfd-link: #93b4ff; --rfd-focus: #93b4ff; }
  [data-door="consulting"] [data-theme="light"] { --rfd-accent: #1e3a8a; --rfd-link: #1e3a8a; --rfd-focus: #1e3a8a; }
  [data-door="blog"] [data-theme="dark"] { --rfd-accent: #8ed5ff; --rfd-link: #8ed5ff; --rfd-focus: #8ed5ff; }
  [data-door="blog"] [data-theme="light"] { --rfd-accent: #0369a1; --rfd-link: #0369a1; --rfd-focus: #0369a1; }
  [data-door="arcade"] [data-theme="dark"] { --rfd-accent: #c4b5fd; --rfd-link: #c4b5fd; --rfd-focus: #c4b5fd; }
  [data-door="arcade"] [data-theme="light"] { --rfd-accent: #6d28d9; --rfd-link: #6d28d9; --rfd-focus: #6d28d9; }
  [data-door="play"] [data-theme="dark"] { --rfd-accent: #fac775; --rfd-link: #fac775; --rfd-focus: #fac775; }
  [data-door="play"] [data-theme="light"] { --rfd-accent: #92400e; --rfd-link: #92400e; --rfd-focus: #92400e; }
  @media (prefers-color-scheme: light) {
    :root:not([data-theme]) { --rfd-accent: #1e3a8a; --rfd-link: #1e3a8a; --rfd-focus: #1e3a8a; }
    :where(:root:not([data-theme])) [data-door="consulting"] { --rfd-accent: #1e3a8a; --rfd-link: #1e3a8a; --rfd-focus: #1e3a8a; }
    :where(:root:not([data-theme])) [data-door="blog"] { --rfd-accent: #0369a1; --rfd-link: #0369a1; --rfd-focus: #0369a1; }
    :where(:root:not([data-theme])) [data-door="arcade"] { --rfd-accent: #6d28d9; --rfd-link: #6d28d9; --rfd-focus: #6d28d9; }
    :where(:root:not([data-theme])) [data-door="play"] { --rfd-accent: #92400e; --rfd-link: #92400e; --rfd-focus: #92400e; }
    :root:not([data-theme])[data-door="consulting"] { --rfd-accent: #1e3a8a; --rfd-link: #1e3a8a; --rfd-focus: #1e3a8a; }
    :root:not([data-theme])[data-door="blog"] { --rfd-accent: #0369a1; --rfd-link: #0369a1; --rfd-focus: #0369a1; }
    :root:not([data-theme])[data-door="arcade"] { --rfd-accent: #6d28d9; --rfd-link: #6d28d9; --rfd-focus: #6d28d9; }
    :root:not([data-theme])[data-door="play"] { --rfd-accent: #92400e; --rfd-link: #92400e; --rfd-focus: #92400e; }
  }
  [data-door="consulting"][data-theme="dark"] { --rfd-accent: #93b4ff; --rfd-link: #93b4ff; --rfd-focus: #93b4ff; }
  [data-door="consulting"][data-theme="light"] { --rfd-accent: #1e3a8a; --rfd-link: #1e3a8a; --rfd-focus: #1e3a8a; }
  [data-door="blog"][data-theme="dark"] { --rfd-accent: #8ed5ff; --rfd-link: #8ed5ff; --rfd-focus: #8ed5ff; }
  [data-door="blog"][data-theme="light"] { --rfd-accent: #0369a1; --rfd-link: #0369a1; --rfd-focus: #0369a1; }
  [data-door="arcade"][data-theme="dark"] { --rfd-accent: #c4b5fd; --rfd-link: #c4b5fd; --rfd-focus: #c4b5fd; }
  [data-door="arcade"][data-theme="light"] { --rfd-accent: #6d28d9; --rfd-link: #6d28d9; --rfd-focus: #6d28d9; }
  [data-door="play"][data-theme="dark"] { --rfd-accent: #fac775; --rfd-link: #fac775; --rfd-focus: #fac775; }
  [data-door="play"][data-theme="light"] { --rfd-accent: #92400e; --rfd-link: #92400e; --rfd-focus: #92400e; }
}

/* Theme-independent scales. */
:root {
  /* spacing, 4px base */
  --rfd-space-1: 4px;
  --rfd-space-2: 8px;
  --rfd-space-3: 12px;
  --rfd-space-4: 16px;
  --rfd-space-5: 24px;
  --rfd-space-6: 32px;
  --rfd-space-7: 48px;
  --rfd-space-8: 64px;

  /* type, fluid between 320px and 1200px viewports */
  --rfd-text-xs: clamp(0.75rem, 0.73rem + 0.1vw, 0.8125rem);
  --rfd-text-sm: clamp(0.8125rem, 0.79rem + 0.12vw, 0.9rem);
  --rfd-text-base: clamp(1rem, 0.96rem + 0.2vw, 1.0625rem);
  --rfd-text-lg: clamp(1.125rem, 1.06rem + 0.33vw, 1.3125rem);
  --rfd-text-xl: clamp(1.3125rem, 1.18rem + 0.66vw, 1.6875rem);
  --rfd-text-2xl: clamp(1.625rem, 1.38rem + 1.22vw, 2.25rem);
  --rfd-text-3xl: clamp(2rem, 1.6rem + 2vw, 3.125rem);

  --rfd-leading-tight: 1.2;
  --rfd-leading-body: 1.6;

  /* radii */
  --rfd-radius-1: 4px;
  --rfd-radius-2: 8px;
  --rfd-radius-3: 12px;
  --rfd-radius-pill: 999px;

  /* motion */
  --rfd-motion-fast: 120ms;
  --rfd-motion-base: 200ms;
  --rfd-motion-slow: 360ms;
  --rfd-ease: cubic-bezier(0.2, 0, 0, 1);

  /* font stacks: system fallbacks first-class, so a door can skip fonts.css (play does) */
  --rfd-font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --rfd-font-display: "Sora", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --rfd-font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* layout */
  --rfd-container: 1080px;
  --rfd-container-narrow: 720px;
  --rfd-gutter: 16px;
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --rfd-motion-fast: 0ms;
    --rfd-motion-base: 0ms;
    --rfd-motion-slow: 0ms;
  }
}
