/* ==========================================================================
   Bedrock: the semantic token layer (plan 53, from Design/AdminRedesign/assets/tokens.css)
   --------------------------------------------------------------------------
   Three tiers, and admin components may only read the last one.

   1. PRESET INPUTS (--color-*): emitted inline on :root by ThemeResolution.CssVariables(),
      and by sidebar.js applyThemeToPage() during a live preview. Not declared here.
      --color-primary-fill is the contrast-guarded primary (ThemeResolution.PrimaryFill):
      the primary darkened (or lightened) until --color-primary-text reaches 4.5:1 on it.
   2. MODE (data-mode="light" | "dark" on <html>): emitted from ResolvedTheme.DataMode.
      Picks the status palette and the direction of every derived mix.
   3. SEMANTIC TOKENS (--surface, --text, --accent, --on-accent ...): derived from 1 and 2 with
      color-mix(), on :root AND every [data-theme] element, so a nested theme (the gallery's
      preview frames) recomputes them instead of inheriting stale values.

   Loaded after bedrock.css and rsx-theme.css and BEFORE retrosix-theme.css, so the r6 preset's
   own --surface / --accent / --text still win on [data-theme="r6"].
   This is the ONLY stylesheet allowed to hold a colour literal, on the admin surface
   (AdminUiStandardTests) and the public site alike (ThemeColourLiteralTests refuses one in
   bedrock.css and rsx-theme.css). --font-* and --radius-sm / --radius-lg belong to the
   existing shells and are deliberately not redeclared here.
   ========================================================================== */

/* ---------- Mode: the status palette and the mix direction ---------- */

:root,
[data-mode="light"] {
  color-scheme: light;
  --mix-ink: #000;          /* what "stronger" mixes towards */
  --mix-lift: #fff;         /* what "raised" mixes towards */
  --danger-base: #d92d20;
  --danger-ink: #b42318;
  --warning-base: #f79009;
  --warning-ink: #93370d;
  --success-base: #12b76a;
  --success-ink: #05603a;
  --info-base: #2e90fa;
  --info-ink: #175cd3;
  --shadow-rgb: 15, 23, 42;
  --shadow-strength: 0.08;
  /* Light presets carry mid-tone primaries (#6366f1 and #d97706 sit at 4.5:1 and 3.2:1
     against white), so the fill is taken a step darker to keep button text at AA. */
  --accent-fill-mix: 86%;
  /* Light: a soft grey page with white cards on it */
  --_page: color-mix(in oklab, var(--color-surface) 55%, var(--color-sidebar));
  --_card: var(--color-bg);
  --_input: var(--color-bg);
  --_lift: 0%;
}

[data-mode="dark"] {
  color-scheme: dark;
  --mix-ink: #fff;
  --mix-lift: #fff;
  --danger-base: #e5484d;
  --danger-ink: #ff9592;
  --warning-base: #f5a524;
  --warning-ink: #ffca6b;
  --success-base: #30a46c;
  --success-ink: #6fe0a6;
  --info-base: #3e8bff;
  --info-ink: #8ec0ff;
  --shadow-rgb: 0, 0, 0;
  --shadow-strength: 0.45;
  --accent-fill-mix: 100%;
  /* Dark: the deep background is the page, the preset surface is the card */
  --_page: var(--color-bg);
  --_card: var(--color-surface);
  --_input: color-mix(in oklab, var(--color-bg) 60%, var(--color-surface));
  --_lift: 6%;
}

/* ---------- Semantic tokens: the only names components read ---------- */

:root,
[data-theme] {
  /* Surfaces */
  --surface-page: var(--_page);
  --surface-sidebar: var(--color-sidebar);
  --surface: var(--_card);
  --surface-raised: color-mix(in oklab, var(--_card), #fff var(--_lift));
  --surface-muted: color-mix(in oklab, var(--_card) 94%, var(--color-text) 6%);
  --surface-input: var(--_input);
  --surface-hover: color-mix(in oklab, var(--color-text) 6%, transparent);
  --surface-active: color-mix(in oklab, var(--color-primary) 13%, transparent);
  --surface-overlay: rgba(var(--shadow-rgb), 0.5);

  /* Text */
  --text: var(--color-text);
  --text-muted: color-mix(in oklab, var(--color-text-muted) 85%, var(--color-text));
  --text-subtle: color-mix(in oklab, var(--color-text-muted) 75%, var(--color-bg));
  --text-heading: var(--color-text);

  /* Lines */
  --border: var(--color-border);
  --border-strong: color-mix(in oklab, var(--color-border) 60%, var(--color-text) 40%);
  --border-input: color-mix(in oklab, var(--color-border) 75%, var(--color-text) 25%);

  /* Accent: fill for the one primary button, text for links and active tabs */
  --accent: color-mix(in oklab, var(--color-primary-fill, var(--color-primary)) var(--accent-fill-mix), var(--mix-ink));
  --accent-hover: color-mix(in oklab, var(--accent) 88%, var(--mix-ink));
  --on-accent: var(--color-primary-text);
  --accent-text: color-mix(in oklab, var(--color-primary) 72%, var(--color-text));
  --accent-soft: color-mix(in oklab, var(--color-primary) 13%, var(--surface));
  --accent-border: color-mix(in oklab, var(--color-primary) 45%, var(--border));
  --brand-2: var(--color-accent);

  /* Status: base fills, readable ink, soft washes, borders */
  --danger: var(--danger-base);
  --on-danger: #fff;
  --danger-text: var(--danger-ink);
  --danger-soft: color-mix(in oklab, var(--danger-base) 12%, var(--surface));
  --danger-border: color-mix(in oklab, var(--danger-base) 45%, var(--border));
  --warning: var(--warning-base);
  --on-warning: #1f1300;
  --warning-text: var(--warning-ink);
  --warning-soft: color-mix(in oklab, var(--warning-base) 13%, var(--surface));
  --warning-border: color-mix(in oklab, var(--warning-base) 50%, var(--border));
  --success: var(--success-base);
  --on-success: #fff;
  --success-text: var(--success-ink);
  --success-soft: color-mix(in oklab, var(--success-base) 12%, var(--surface));
  --success-border: color-mix(in oklab, var(--success-base) 45%, var(--border));
  --info: var(--info-base);
  --info-text: var(--info-ink);
  --info-soft: color-mix(in oklab, var(--info-base) 12%, var(--surface));
  --info-border: color-mix(in oklab, var(--info-base) 45%, var(--border));
  --neutral-soft: color-mix(in oklab, var(--color-text) 8%, var(--surface));

  /* Brand platforms: fixed colours with fixed ink, never inherited */
  --youtube: #d4001a;
  --on-youtube: #fff;
  --twitch: #7c3aed;
  --on-twitch: #fff;

  /* Focus */
  --focus: color-mix(in oklab, var(--color-primary) 80%, var(--color-text));
  --focus-ring: 0 0 0 2px var(--surface-page), 0 0 0 4px var(--focus);

  /* Fixed inks for the few things that sit on a photo or a coloured track, whatever the theme */
  --knob: #fff;
  --on-media: #fff;
  --media-scrim: rgba(0, 0, 0, 0.78);
  --knob-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);

  /* Elevation */
  --shadow-1: 0 1px 2px rgba(var(--shadow-rgb), var(--shadow-strength));
  --shadow-2: 0 4px 14px rgba(var(--shadow-rgb), calc(var(--shadow-strength) * 1.4));
  --shadow-3: 0 18px 48px rgba(var(--shadow-rgb), calc(var(--shadow-strength) * 2.2));

}

/* ==========================================================================
   The public site's colours (plan 53 stage 2). Every colour bedrock.css and rsx-theme.css used
   to hold as a literal now comes from here, by the same value, so the site looks exactly as it
   did and ThemeColourLiteralTests can refuse a new literal in either file.
   ========================================================================== */

/* ---------- Defaults under the preset inputs ----------
   :where() keeps these at zero specificity: ThemeResolution's inline :root block, sidebar.js's
   live preview and every [data-theme] override below still win, exactly as they did when these
   sat at the top of bedrock.css. */
:where(:root) {
  --color-primary: #6366f1;
  --color-accent: #8b5cf6;
  --color-bg: #0f0f23;
  --color-surface: #1a1a2e;
  --color-text: #e2e8f0;
  --color-text-muted: #94a3b8;
  --color-border: #2d2d44;
  --color-sidebar: #16162a;
  /* Never set by bedrock.css before; its two readers fell back to this same white. */
  --color-primary-text: #ffffff;

  /* The status set the public pages read (the admin reads --danger and friends above) */
  --color-info: #3b82f6;
  --color-success: #22c55e;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;
  --color-danger-rgb: 239, 68, 68;
  --color-info-bg: rgba(59, 130, 246, 0.12);
  --color-success-bg: rgba(34, 197, 94, 0.12);
  --color-warning-bg: rgba(245, 158, 11, 0.12);
  /* The subtle hover wash. Same value as ever, deliberately: it is barely visible on a light
     theme, and quietly "fixing" that would change how four surfaces look. */
  --color-hover-wash: rgba(255, 255, 255, 0.05);

  /* Fixed swatches: categories, statuses and one-off tints that must NOT follow the theme */
  --color-white: #ffffff;
  --color-violet: #8b5cf6;
  --color-emerald: #10b981;
  --color-emerald-strong: #059669;
  --color-sky: #0ea5e9;
  --color-blue: #3b82f6;
  --color-grey: #6b7280;
  --color-red: #ef4444;
  --color-danger-strong: #dc2626;
  --color-danger-deep: #7f1d1d;
  --color-danger-edge: #b91c1c;
  --color-danger-wash: #fee2e2;
  --alert-success-text: #15803d;
  --alert-success-text-dark: #4ade80;
  --alert-warning-text: #b45309;
  --alert-warning-text-dark: #fbbf24;
  --hot-start: #ff6b35;
  --hot-mid: #ff4500;
  --hot-end: #e03e00;
  --usage-ok: #a8d5b5;
  --usage-low: #e6c68a;
  --usage-empty: #d99a94;
  /* The theme picker's two sample swatches: they show midnight and clean-light, whatever is on */
  --preview-dark-bg: #0f0f23;
  --preview-dark-text: #e2e8f0;
  --preview-light-bg: #ffffff;
  --preview-light-text: #1e293b;
  /* A mask's opaque stop: only its alpha is read, never shown as a colour */
  --mask-solid: #000000;

  /* Channel triples, for the rgba(var(--x-rgb), a) washes of a fixed colour */
  --white-rgb: 255, 255, 255;
  --black-rgb: 0, 0, 0;
  --amber-rgb: 245, 158, 11;
  --green-rgb: 34, 197, 94;
  --emerald-rgb: 16, 185, 129;
  --red-rgb: 239, 68, 68;
  --sky-rgb: 14, 165, 233;
  --hot-glow-rgb: 255, 69, 0;

  /* Brand colours: the platform's own, never the theme's */
  --brand-youtube: #ff0033;
  --brand-youtube-fill: #e0162b;
  --brand-youtube-fill-hover: #ff1f3c;
  --brand-youtube-edge: #ff3d55;
  --brand-youtube-rgb: 224, 22, 43;
  --brand-twitch: #9146ff;
  --brand-twitch-hover: #a66bff;
  --brand-discord: #5865f2;
  --brand-gold: #f5c542;
  /* RetroSix's own logo colours, for the home hero's glow on every theme */
  --brand-magenta-rgb: 255, 46, 196;
  --brand-cyan-rgb: 34, 200, 255;

  /* Subscription tiers: the badge fills, the promo card edges and the support ring */
  --tier-core: #b87333;
  --tier-core-rgb: 184, 115, 51;
  --tier-core-ring: #cd7f32;
  --tier-pro: #6b7fd7;
  --tier-pro-rgb: 107, 127, 215;
  --tier-pro-ring: #9fbbe6;
  --tier-ultra-from: #f59e0b;
  --tier-ultra-to: #a855f7;
  --tier-ultra-rgb: 168, 85, 247;
  --tier-ultra-ring: #f5a142;
  --ring-shimmer: #fff6d6;

  /* Code blocks: One Dark (dark themes) and One Light ([data-theme="light"]) */
  --syntax-red: #e06c75;
  --syntax-blue: #61afef;
  --syntax-orange: #d19a66;
  --syntax-cyan: #56b6c2;
  --syntax-gold: #e6c07b;
  --syntax-crimson: #e45649;
  --syntax-purple: #c678dd;
  --syntax-green: #98c379;
  --syntax-grey: #5c6370;
  --syntax-plain: #abb2bf;
  --syntax-light-purple: #a626a4;
  --syntax-light-green: #50a14f;
  --syntax-light-orange: #986801;
  --syntax-light-grey: #a0a1a7;
  --syntax-light-blue: #4078f2;
  --syntax-light-gold: #c18401;
  --syntax-light-cyan: #0184bc;
}

/* The light preset type's defaults, after the :root ones so they win on a light page. */
:where([data-theme="light"]) {
  --color-bg: #ffffff;
  --color-surface: #f8fafc;
  --color-text: #1e293b;
  --color-text-muted: #64748b;
  --color-border: #e2e8f0;
  --color-sidebar: #f1f5f9;
}

/* ---------- RetroSix (data-theme="rsx"), the site default ----------
   The auth design system's palette, moved from rsx-theme.css. The values the retrosix preset
   already carries are read from the preset inputs, so they cannot drift from ThemePresets; the
   rest are the design system's own shades of them, fixed. The --color-* lines map the status set
   the wiki reads onto the RetroSix one. (The nine preset inputs are not mapped here: the inline
   :root block always outranked that mapping, so it never applied.) */
[data-theme="rsx"] {
  /* Surfaces */
  --rs-bg: var(--color-bg);
  --rs-bg-grad-a: #0a0f14;
  --rs-bg-grad-b: var(--color-bg);
  --rs-bg-darker: #070b12;
  --rs-surface: var(--color-surface);
  --rs-surface-2: #111c2e;
  --rs-surface-3: #17253b;
  --rs-border: var(--color-border);
  --rs-border-strong: #2c4468;
  --rs-border-hover: #3a5a8c;
  --rs-input-bg: #08111f;
  --rs-tooltip: #16233a;
  --rs-table-head-end: #121c2e;
  --rs-modal-top: #142033;
  --rs-modal-bottom: #0c1320;
  --rs-scrim: #04070b;
  --rs-glass: #101720;
  --rs-well: #040810;
  --rs-overlay-dark: rgba(var(--black-rgb), 0.9);
  /* Channel triples for gradient stops, which must stay legacy rgba() to draw as they always have */
  --rs-surface-rgb: 13, 20, 32;
  --rs-surface-2-rgb: 17, 28, 46;
  --rs-surface-3-rgb: 23, 37, 59;
  --rs-input-bg-rgb: 8, 17, 31;
  --rs-accent-blue-rgb: 43, 92, 255;
  --rs-overlay-medium: rgba(var(--rs-surface-rgb), 0.85);

  /* Text */
  --rs-text: var(--color-text);
  --rs-text-muted: var(--color-text-muted);
  --rs-text-dim: #7889a6;
  --rs-placeholder: #647a99;

  /* Accent: RetroSix blue, cyan and magenta */
  --rs-accent: var(--color-primary);
  --rs-accent-strong: #0aa5ff;
  --rs-accent-dim: #1749d8;
  --rs-accent-ink: var(--color-primary-text);
  --rs-accent-glow: color-mix(in srgb, var(--rs-accent) 28%, transparent);
  --rs-accent-blue: #2b5cff;
  --rs-magenta: var(--color-accent);
  --rs-magenta-strong: #e5159f;
  --rs-magenta-glow: color-mix(in srgb, var(--rs-magenta) 28%, transparent);
  --rs-shadow-accent: 0 0 0 1px color-mix(in srgb, var(--rs-accent) 18%, transparent), 0 20px 60px -30px var(--rs-accent-glow);

  /* Status, and the pale inks that sit on their washes */
  --rs-success: #21e3c6;
  --rs-success-ink: #03211e;
  --rs-danger: #ff4d8f;
  --rs-danger-ink: #2a0518;
  --rs-info: #5f8cff;
  --rs-info-ink: #05192b;
  --rs-warning: #ff7ad4;
  --rs-amber: #ffb347;
  --rs-violet: #8b6bff;
  --rs-ink-on-magenta: #fff5fb;
  --rs-ink-success: #a8f5e8;
  --rs-ink-danger: #ffc0da;
  --rs-ink-warning: #ffd1ef;
  --rs-ink-info: #c9d6ff;
  --rs-ink-blocked: #ffb6d3;
  --rs-ink-accent: #a7ecff;
  --rs-ink-subscriber: #ffb9ea;
  --rs-ink-hot: #ffb0e6;
  --rs-ink-bright: #f4f8ff;
  --rs-ink-user: #eaf7ff;
  --rs-ink-avatar: #eafffb;

  /* Brands and tiers */
  --rs-youtube: var(--rs-magenta);
  --rs-twitch: var(--rs-accent-blue);
  --rs-bronze: #5f8cff;
  --rs-silver: var(--rs-accent);
  --rs-gold: var(--rs-magenta);

  /* The wiki's status set, mapped onto RetroSix's */
  --color-success: var(--rs-success);
  --color-warning: var(--rs-warning);
  --color-danger: var(--rs-danger);
  --color-danger-rgb: 255, 77, 143;
  --color-info: var(--rs-info);
  --color-info-bg: color-mix(in srgb, var(--rs-accent) 10%, transparent);
  --color-success-bg: color-mix(in srgb, var(--rs-success) 12%, transparent);
  --color-warning-bg: color-mix(in srgb, var(--rs-warning) 12%, transparent);
  --color-hover-wash: color-mix(in srgb, var(--rs-accent) 6%, transparent);
  --color-surface-hover: color-mix(in srgb, var(--rs-accent) 6%, transparent);
}

/* ---------- Urizel (data-theme="r6"): the CRT palette retrosix-theme.css reads ----------
   Moved from retrosix-theme.css by the same values, so the theme looks exactly as it did and
   ThemeColourLiteralTests can refuse a literal there. Fixed constants under their own names:
   retrosix-theme.css still maps them onto --bg, --text, --r6-gold and the rest on [data-theme="r6"],
   so nothing here changes which theme they apply to. On :root because the theme's @keyframes read
   the channel triples too. */
:root {
  --r6-palette-bg: #0a1018;
  --r6-palette-surface: #0f1822;
  --r6-palette-text: #e8e0d4;
  --r6-palette-text-muted: #9a8e80;
  --r6-palette-text-dim: #6a5e52;
  --r6-palette-teal: #2ab5b0;
  --r6-palette-teal-glow: #48d4cf;
  --r6-palette-gold: #d4a030;
  --r6-palette-gold-glow: #e8b84a;
  --r6-palette-pink: #d64a78;
  --r6-palette-pink-glow: #e86a98;
  --r6-palette-link-hover: #6eeae5;
  --r6-palette-code-bg: #080e14;
  --r6-palette-border: #1a2a38;
  --r6-palette-success: #3aad5c;
  /* The hero title's neon tube and the first heading's cool white */
  --r6-palette-neon: #a0faf6;
  --r6-palette-title: #e8edf2;

  /* prefers-contrast: more */
  --r6-contrast-text-muted: #c8bfb4;
  --r6-contrast-text-dim: #a09486;
  --r6-contrast-teal-glow: #5eeae5;
  --r6-contrast-gold-glow: #f0c860;
  --r6-contrast-pink-glow: #f080a8;
  --r6-contrast-border: #2a4058;

  /* Channel triples for the rgba(var(--x-rgb), a) tints */
  --r6-bg-rgb: 10, 16, 24;
  --r6-surface-rgb: 15, 24, 34;
  --r6-surface-2-rgb: 22, 34, 48;
  --r6-gold-rgb: 212, 160, 48;
  --r6-gold-glow-rgb: 232, 184, 74;
  /* The active-item gold: a touch warmer than --r6-palette-gold */
  --r6-amber-rgb: 212, 163, 74;
  --r6-teal-glow-rgb: 72, 212, 207;
  --r6-pink-glow-rgb: 232, 106, 152;
  --r6-success-rgb: 58, 173, 92;
  --r6-toc-rgb: 180, 200, 210;
  --r6-toc-hover-rgb: 220, 235, 240;
  --r6-title-before-rgb: 200, 210, 225;
  --r6-title-after-rgb: 160, 175, 195;
  /* The title glitch's split-channel steels, in the order the keyframes first use them */
  --r6-glitch-1-rgb: 160, 175, 190;
  --r6-glitch-2-rgb: 180, 195, 210;
  --r6-glitch-3-rgb: 140, 155, 170;
  --r6-glitch-4-rgb: 210, 220, 230;
  --r6-glitch-5-rgb: 170, 185, 200;
  --r6-glitch-6-rgb: 190, 200, 215;
  --r6-glitch-7-rgb: 150, 165, 180;
  --r6-glitch-8-rgb: 220, 225, 235;
  --r6-glitch-9-rgb: 175, 185, 200;
  --r6-glitch-10-rgb: 185, 195, 210;
  --r6-glitch-11-rgb: 145, 160, 175;
  --r6-glitch-12-rgb: 210, 215, 225;
  --r6-glitch-13-rgb: 165, 180, 195;
}

/* ---------- Scales: theme independent ---------- */
:root {

  /* Type: 12 / 13 / 14 / 16 / 18 / 22 / 28 */
  --fs-xs: 0.75rem;
  --fs-sm: 0.8125rem;
  --fs-md: 0.875rem;
  --fs-lg: 1rem;
  --fs-xl: 1.125rem;
  --fs-2xl: 1.375rem;
  --fs-3xl: 1.75rem;
  --lh-tight: 1.25;
  --lh-normal: 1.5;
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;

  /* Space: a 4px grid */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  /* Radii */
  --radius-md: 8px;
  --radius-pill: 999px;

  /* Controls */
  --control-h: 36px;
  --control-h-sm: 30px;
  --label-col: 220px;
  --control-max: 520px;

  --ease: cubic-bezier(.2, .7, .2, 1);
  --dur: 140ms;
}
