/* Raidu - Color system (Raidu Brand V3: Periwinkle)
   Implements Raidu design system v1, locked 23 September 2026 (spec:
   docs/brand/design-system-v1.md, assets/brand/raidu.tokens.json). Replaces
   Brand V2 Tanzanite. Principles: white is the brand, type does the work, one action
   colour, the record is the image, proof not claims.
   Neutrals are cool slate carrying a trace of the periwinkle hue (231deg);
   one indigo-ink (#171A2B) is both primary text and the inverse surface.
   Periwinkle (#9097C0 on ink, #5C67A3 on white) is the only action colour.
   There is no warm colour: set 2, cool slate only. Allow/flag/block keep
   their green/amber/red hues, softened to the same register, always labelled.
   Every token name is unchanged from V2; only values moved, so consuming
   products pick up the brand without component changes. Use the semantic
   aliases in product code, not the raw ramps.

   The block is declared on .raidu-dark as well as :root so that a dark
   container (a dark island in a light page) recomputes every alias from the
   dark ramp values below. Declared on :root alone, an alias such as
   --allow-tint: var(--allow-50) resolves once at the root and a dark island
   inherits the light tint. */

:root,
.raidu-dark {
  /* ---- Brand accent: Periwinkle (V3) ----
     Hue 231deg. 500 is the primary action on light surfaces (white text,
     5.35:1); --periwinkle-300 below is the action on ink. Token names kept as --violet-* for continuity; this ramp
     has already lived through a navy -> teal -> sapphire-indigo history
     under this same name. */
  --violet-50:  #F2F3F8;  /* accent tint / selected row */
  --violet-100: #E5E7F0;
  --violet-200: #CED1E3;  /* dark-mode link hover */
  --violet-300: #B7BCDA;  /* dark-mode accent hover / press */
  --violet-400: #7C84B6;  /* focus ring - dark-mode accent */
  --violet-500: #5C67A3;  /* primary */
  --violet-600: #4A5282;  /* hover - link */
  --violet-700: #373E62;  /* press - link hover */
  --violet-800: #2B3050;

  /* ---- Brand v3 additions ----
     Periwinkle #9097C0 is the founder-chosen action colour. It never carries
     white text (2.85:1): on light surfaces the action is --violet-500 with
     white text; on ink surfaces it is --periwinkle-300 with ink text. */
  --periwinkle-300: #9097C0;

  /* ---- Ink (neutral grays, washed 4% with the accent) ----
     Not flat zinc: a faint accent tint runs through the whole neutral
     scale so text and surface grays read as part of the same family
     instead of an unrelated gray dropped in next to a colored brand. */
  --ink-900: #171A2B;  /* primary text / darkest surface */
  --ink-800: #2B2F42;
  --ink-700: #3F4357;
  --ink-600: #5B5F70;  /* muted/secondary text */
  --ink-500: #767A8C;
  --ink-400: #5F6375;  /* subtle text / placeholders. Darkened from #9E9EAA,
     which measured 2.50:1 on --surface and 2.13:1 on --surface-hover - a
     straight AA failure for something used as body text in 63 components.
     #67676F clears 4.5:1 on every surface it is read on, down to the
     darkest (--surface-hover, 4.51:1). */
  --ink-300: #CDD0DA;
  --ink-200: #D9DCE4;  /* strong border */

  /* ---- Paper (cool slate surfaces, same periwinkle trace) ---- */
  --paper-white: #FFFFFF;  /* nav chrome - the one plane above the wash */
  --paper-0:  #FFFFFF;  /* raised cards */
  --paper-50: #F6F7FA;  /* app background */
  --paper-100:#EEF0F4;  /* sunken / subtle fill */
  --paper-200:#E9EBF1;  /* hover fill */
  --border:      #E3E5EC;  /* hairline */
  --border-soft: #ECEEF3;  /* softest divider */

  /* ---- Semantic: governance verdicts (fixed meanings - never recolored,
     never reused for decoration). Three shades per verdict:
       -50     tint, the fill behind a badge, alert or row
       -solid  bright, for icons, dots, bars, borders and chart series.
               Non-text only, held to 3:1 on white and on ink
       -500    deep, the only shade that carries words. 5.2:1 or better on
               its own tint, and white text on it clears 5.5:1 for solid badges
     Emerald, ochre, crimson, and slate for info so it never reads as a link.
     Contrast of -solid vs white: allow 3.64, flag 3.65 (and 3.19 and 3.20 on --surface-sunken, 3.05 and 3.07 on --surface-hover), block 4.16, info 3.70. ---- */
  --allow-500:   #1C764C;  /* allowed / verified / signed */
  --allow-solid: #249862;
  --allow-50:    #EEFBF5;  /* allow tint */
  --allow-bright:var(--allow-solid);  /* kept for older call sites */
  --flag-500:    #925C0C;  /* flagged / warning / redacted */
  --flag-solid:  #BB770F;
  --flag-50:     #FCF6EE;  /* flag tint */
  --block-500:   #BF243E;  /* blocked / denied */
  --block-solid: #E0405A;
  --block-50:    #FCEEF0;  /* block tint */
  --info-500:    #454A63;  /* neutral system info, slate */
  --info-solid:  #7F849C;
  --info-50:     #F1F2F6;  /* info tint */

  /* ============ Semantic aliases (use these in product) ============ */
  --bg:            var(--paper-50);
  --surface:       var(--paper-0);
  --surface-sunken:var(--paper-100);
  --surface-hover: var(--paper-200);
  /* Nav chrome (the rail, the mobile drawer). Deliberately NOT --surface: a
     rail painted the same tone as the cards floating in the content area reads
     as one more card rather than as chrome, and separates from --bg by a single
     8-level step. Keeping it a step above --surface gives three legible planes:
     chrome, then card, then page. */
  --surface-nav:   var(--paper-white);
  /* Nav surface tones. Distinct from --surface-nav (the chrome plane itself).
     Rail: the narrow icon-only strip. Panel: the expanded sidebar area.
     Line: the separator between nav items and sections.
     Three periwinkle-scale fills so the nav chrome reads as one coordinated
     region rather than a flat white wall laid against the content surface. */
  --nav-rail:      var(--violet-100);  /* #E5E7F0 */
  --nav-panel:     var(--violet-50);   /* #F2F3F8 */
  --nav-line:      var(--violet-200);  /* #CED1E3 */
  /* Alias, same reasoning as --error/--warning below: found undefined and
     used in 17 files (Skeleton, InputGroup, InputOTP, Diff, Collapse, etc)
     during the docs visual QA pass. Skeleton's shimmer placeholders were
     rendering as invisible blank boxes because of this. */
  --surface-raised:var(--paper-200);

  --text:          var(--ink-900);
  --text-muted:    var(--ink-600);
  --text-subtle:   var(--ink-400);
  --text-on-accent:#FFFFFF;
  /* Words on a solid -500 verdict fill. Not remapped in .raidu-dark: the
     -500s stay deep there, so white stays the right label. */
  --text-on-status:#FFFFFF;
  /* Non-text UI glyphs that should recede: inactive sort arrows, disabled
     control chevrons. Held to the 3:1 non-text threshold rather than 4.5:1,
     so it can sit quieter than --text-subtle without becoming invisible.
     Reach for this instead of a --border-* token: a border colour used as a
     foreground measured 1.14:1 and was effectively not drawn. */
  --icon-muted:    #62677A; /* 4.71:1 on the lightest grey surface; was #767B8D at 3.53:1 */

  /* Disabled controls. Deliberately a grey fill rather than the accent at
     reduced alpha: opacity preserves hue, so a dimmed primary stayed visibly
     violet and read as a pale accent button rather than an unavailable one.
     WCAG 1.4.3 exempts inactive controls from the contrast minimum, so these
     values are chosen for legibility and for reading as "off", not to clear
     a conformance bar. Label on fill measures 4.51:1 here. */
  --surface-disabled: var(--paper-200);
  --text-disabled:    var(--ink-400);

  --accent:        var(--violet-500);
  --accent-hover:  var(--violet-600);
  --accent-press:  var(--violet-700);
  --accent-tint:   var(--violet-50);

  --border-default:var(--border);
  --border-strong: var(--ink-200);
  /* Form control edge (input, select, checkbox): a UI mark that identifies the
     control, so it clears 3:1 on white (3.65) and on --bg (3.41). Decorative
     hairlines (cards, dividers) stay on --border. */
  --border-control:#80859B;
  /* focus-ring reads var(--violet-400), not the primary --violet-500 - a
     step lighter so the ring doesn't read as just "the button color again"
     wherever it shows up, and stays a clearly visible non-text indicator
     per WCAG 2.4.11. */
  --focus-ring:    var(--violet-400);

  --status-allow:  var(--allow-500);
  --status-flag:   var(--flag-500);
  --status-block:  var(--block-500);
  --status-info:   var(--info-500);
  --link:          var(--violet-600);
  --link-hover:    var(--violet-700);
  /* Alias so error/danger-flavored components (Banner, ValidationMessage,
     ErrorState, etc.) can read var(--error) directly instead of every call
     site having to know the underlying token is named --status-block. Same
     reasoning for --warning and --status-flag: found undefined and used in
     24 files (Mark, Banner, WarningMessage, Meter, StatusIndicator, etc.)
     during the docs visual QA pass, identical failure mode to --error. */
  --error:         var(--status-block);
  --warning:       var(--status-flag);
  /* Ink counterparts for the two aliases above, for use as TEXT. The --error
     and --warning aliases resolve to the -500 ramp, which does not remap for
     the dark scope, so reading them as a text colour puts a light theme value
     on a dark surface. Backgrounds, borders and color-mix inputs keep the
     originals: those are non-text and held to 3:1. */
  --error-ink:   var(--block-ink);
  --warning-ink: var(--flag-ink);
  --success-ink: var(--allow-ink);
  /* Same failure mode again, found via a full-package audit after --warning:
     43 undefined custom properties total, used across 28 (!) files for
     --success alone down to single-file stragglers. Bare semantic-name and
     short-name aliases: */
  --success:       var(--status-allow);
  --allow:         var(--status-allow);
  --block:         var(--status-block);
  --flag:          var(--status-flag);
  --info:          var(--status-info);
  --warn:          var(--status-flag);
  --safe:          var(--status-allow);
  --success-bright:var(--allow-bright);
  --background:    var(--bg);
  --border-subtle: var(--border-soft);
  --surface-muted: var(--surface-sunken);
  --surface-inverse: var(--ink-900);
  /* Text on --surface-inverse. Constant across themes: the inverse surface
     itself (ink-900 = #171A2B) does not flip in dark mode, so neither does
     the text that sits on it. Contrast vs --surface-inverse: 12.4:1. */
  --text-on-inverse: #F6F7FA;
  --accent-subtle: var(--accent-tint);
  --accent-100:    var(--violet-100);
  --error-subtle:  var(--block-50);
  --status-allow-tint:  var(--allow-50);
  --status-allow-text:  var(--allow-text);
  --status-allow-solid: var(--allow-solid);
  --status-block-tint:  var(--block-50);
  --status-block-text:  var(--block-text);
  --status-block-solid: var(--block-solid);
  --status-flag-tint:   var(--flag-50);
  --status-flag-text:   var(--flag-text);
  --status-flag-solid:  var(--flag-solid);
  --status-info-tint:   var(--info-50);
  --status-info-text:   var(--info-text);
  --status-info-solid:  var(--info-solid);
  /* Verdict convenience aliases. Apps name the shade by role, not by number.
       -tint  the fill behind a badge, chip, or alert row (the -50 step)
       -text  the shade that carries words; 5.2:1+ on its own tint (the -500 step)
       -mark  icons, dots, bars, borders; non-text, 3:1+ (the solid step) */
  --allow-tint: var(--allow-50);
  --allow-text: var(--allow-500);
  --allow-mark: var(--allow-solid);
  --flag-tint:  var(--flag-50);
  --flag-text:  var(--flag-500);
  --flag-mark:  var(--flag-solid);
  --block-tint: var(--block-50);
  --block-text: var(--block-500);
  --block-mark: var(--block-solid);
  --info-tint:  var(--info-50);
  --info-text:  var(--info-500);
  --info-mark:  var(--info-solid);
  /* Numbered tint/shade steps nobody built for allow/block/flag/info beyond
     -50/-500: proxy the lighter steps to -50 and the darker steps to -500
     rather than inventing four more real ramps for a handful of call sites. */
  --allow-100: var(--allow-50);
  --allow-300: var(--allow-solid);
  --allow-600: var(--allow-500);
  --allow-700: var(--allow-500);
  --block-100: var(--block-50);
  --block-300: var(--block-solid);
  --block-600: var(--block-500);
  --block-700: var(--block-500);
  --flag-100:  var(--flag-50);
  --flag-300:  var(--flag-solid);
  --flag-600:  var(--flag-500);
  --flag-700:  var(--flag-500);
  --info-100:  var(--info-50);
  --info-300:  var(--info-solid);
  --info-600:  var(--info-500);
  --info-700:  var(--info-500);
  /* Ink for text sitting on a governance -50 tint (a chip, a badge), not the
     base -500 fill itself. Light-mode ink is just the base -500 here (or a
     one-step darker variant where -500 itself clips the 4.5:1 floor); dark
     mode below swaps in brighter variants instead. */
  --allow-ink: var(--allow-500);
  --info-ink:  var(--info-500);
  --flag-ink:  var(--flag-500);
  --block-ink: var(--block-500);

  /* Brand v3 roles */
  --accent-on-inverse:      var(--periwinkle-300); /* primary action on ink */
  --text-on-accent-inverse: var(--ink-900);        /* its label, 6.05:1 */
  --highlight:              var(--violet-100);     /* periwinkle tint, one headline highlight per view */
  --surface-data:           var(--paper-50);       /* Wheelhouse / data surfaces, light slate */
  --surface-ai:             var(--ink-900);        /* Tower / AI surfaces */

  /* Brand chrome */
  --brand-tile:    var(--ink-900);              /* dark tile behind white lion mark */
  --header-bg:     rgba(255,255,255,0.82);      /* sticky site header (translucent) */

  /* Code / JSON syntax token colors.
     Used in tool-call-card and any other component that pretty-prints JSON.
     Chosen to be visually distinct from each other and from the surrounding text,
     while staying harmonious with the periwinkle palette. Not verdict colors:
     these are functional coloring for readability, not governance status. */
  --code-key:  var(--text);           /* JSON object keys, same weight as surrounding text */
  --code-str:  #0f7b6c;               /* JSON string values, teal-green */
  --code-num:  #a05210;               /* JSON numbers, amber - 4.97:1 on --surface-sunken */
  --code-lit:  var(--accent);         /* JSON literals (true/false/null), periwinkle */
}

/* Dark theme scope - full app/site dark mode.
   Apply class="raidu-dark" on <html> (or any container). Remaps both the raw
   ramp values used directly and the semantic aliases, so components flip cleanly. */
.raidu-dark {
  color-scheme: dark;

  /* raw ramp used directly by some components - same periwinkle trace applied
     to the dark neutral scale as the light one above. */
  --paper-0:  #20253F;
  --paper-50: #0F1222;
  --paper-100:#0B0E1A;
  --paper-200:#22263A;
  /* On dark the relationship inverts: "above the page" means lighter, so nav
     chrome is a step up from the card tone rather than pure white, which would
     blow out at this luminance. */
  --paper-white: #22263A;
  --border:      #3A4059;
  --border-soft: #323859;
  --ink-200:  #3A3F55;
  --ink-300:  #3A3F55;

  /* governance tints, darkened so badges read on dark */
  --allow-50: #1E392C;
  --flag-50:  #3E2F19;
  --block-50: #3A1D22;
  --info-50:  #252731;

  /* semantic aliases */
  --bg:            #0F1222;
  --surface:       #20253F;
  --surface-sunken:#0B0E1A;
  --surface-hover: #2A3050;
  --surface-nav:   #22263A;
  /* Nav surface tones, dark. On dark the fills invert to the deep violet end.
     Rail (#1C2038) sits one step above the page; panel (#141627) recedes behind
     the rail; line (#2B3050) is a visible separator on dark nav surfaces. */
  --nav-rail:      #1C2038;
  --nav-panel:     #141627;
  --nav-line:      #2B3050;
  --text:          #F4F5F8;
  --text-muted:    #A6AABB;
  /* Lightened from #71717A (3.58:1 on --surface, 3.15:1 on --surface-hover).
     Clears 4.5:1 on every dark surface, down to 4.50:1 on --surface-hover. */
  --text-subtle:   #959AAB;
  --accent:        #9097C0;
  /* Periwinkle cannot carry white text (2.85:1), so on dark the action label
     flips to ink: 6.05:1 on --accent, 7.73:1 on hover, 5.61:1 on press. */
  --text-on-accent:#171A2B;
  --accent-hover:  #A6ACCF;
  /* Lightened from #7E78A3, which measured 4.40:1 on --accent-tint - the
     near-miss wheelhouse's contrast walk flagged. Now 4.54:1 at its worst
     pairing (--surface-nav) and 5.41:1 on the tint itself. */
  --accent-press:  #A0A6CC;
  --accent-tint:   #303860;
  /* The old --text-subtle value, reused deliberately: exactly the weight a
     receding UI glyph wants on dark, and it clears 3:1 everywhere. */
  --icon-muted:    #7A7F91;

  /* On dark the fill steps up rather than down, same inversion as --paper-white.
     --ink-300 is remapped to #40404A in this scope so it cannot double as the
     ink here; #AEAEB6 is the lightest step on the ramp's hue that still clears
     4.5:1 on the fill (4.65:1). */
  --surface-disabled: #3A3F55;
  --text-disabled:    #AEB2C2;

  --border-default:#3A4059;
  --border-strong: #4B526C;
  /* Form control edge: 3.83:1 on --surface, the UI-mark floor (WCAG 1.4.11). */
  --border-control:#737995;
  --focus-ring:    #CED1E3;
  --link:          #CED1E3;
  --link-hover:    #E5E7F0;
  /* The -500 text shades are too deep to read on ink, so dark mode gives
     each verdict a bright ink for its words, measured at 6:1 or better on
     its own dark tint above. The -solid shades carry over unchanged: every
     one clears 4:1 on --surface here. */
  --flag-ink:  #EEA12D;
  --block-ink: #E88797;
  --allow-ink: #30CC83;
  --info-ink:  #B4B8CC;

  /* Verdict text aliases, dark overrides. The -500 steps stay as deep fills
     in dark mode and cannot carry words on ink surfaces. Remap -text to the
     bright -ink variants (6:1+ on their dark tint, defined above). */
  --allow-text: var(--allow-ink);
  --flag-text:  var(--flag-ink);
  --block-text: var(--block-ink);
  --info-text:  var(--info-ink);

  --brand-tile:    #22263A;
  --header-bg:     rgba(15,18,34,0.82);

  /* Code syntax, dark overrides - brighter tints that read on dark surfaces */
  --code-str:  #5fd4b8;
  --code-num:  #f2a65a;
  /* --code-key and --code-lit inherit from :root; --text and --accent already
     remap for dark mode above, so these two resolve correctly without overrides. */
}
