/*
 * Dark Theme — B · Operational SaaS (hardened), EPIC #990 Phase 3
 *
 * Direction B palette (jury pick, #990) with the approved hardening grafts:
 * semantic signal colors (cyan = live · amber = caution/TX · red = fault ·
 * green = nominal) and blue reserved strictly for wayfinding (accent).
 * This is the DEFAULT theme, so values are set on :root.
 */

:root,
[data-theme="dark"] {
  /* === Surface Colors (B elevation ramp: page → panel → elevated → control) === */
  --theme-surface-page: #0b0e12;
  --theme-surface-panel: #12161c;
  --theme-surface-elevated: #171c23;
  /* Recessed filled CONTROLS — toggle track, button/list-row hover, tab segment.
     NOT text fields: those use --theme-surface-field below (#686). */
  --theme-surface-input: #1e242c;
  --theme-surface-overlay: rgba(0, 0, 0, 0.85);
  /* Recessed PLANE surface (#990 N2b) — the full-bleed instrument devplane sits
     ONE plane deeper than the app bar (panel): darker than panel, just above the
     page floor, so an edge-to-edge toolbar reads as a recessed shelf under the
     raised app chrome. NOT a control fill (--theme-surface-input) and NOT an
     elevation (--theme-surface-elevated). */
  --theme-surface-inset: #0d1116;

  /* === Text-field surfaces (#686) ===
     Dark reads correctly when the live field (#1e242c) is LIGHTER than its
     panel (#12161c) — recessed but live — so the enabled value keeps that
     relation under the B ramp. A dead field drops back to the elevated plane:
     flatter than a live one, the same direction of travel as light's gray slab. */
  --theme-surface-field: #1e242c;
  --theme-surface-field-disabled: #171c23;
  --theme-text-field-disabled: #7a8793;

  /* === Border Colors (B neutral slate ramp) === */
  --theme-border-default: #242b34;
  --theme-border-subtle: #1a1f26;
  /* Focus follows the accent (B idiom: accent-led focus, not a brighter gray). */
  --theme-border-focus: #4d8bfb;
  /* WCAG 1.4.11: the field boundary must clear 3:1 vs BOTH neighbours. Dark does
     NOT lean on fill contrast — field #1e242c vs panel #12161c is only 1.16:1, so
     the fill delta carries nothing; the border carries the edge, same as light.
     #6b7583 = 3.35 on the field fill #1e242c, 3.89 on the panel #12161c, 4.14 on
     the page #0b0e12 — all >=3.0. Floored in BOTH themes by theme-integrity.test. */
  --theme-border-field: #6b7583;

  /* Hover scrim — the SINGLE owner of "a pointer is over this control" (#685).
     A light ink scrim on a near-black surface: 0.08 already reads ~1.222:1, so
     dark keeps this weight (B's lighter .05 scrim is below the perceptible
     floor the nav e2e enforces). See light.css for why this cannot be one
     shared alpha across themes. */
  --theme-hover-scrim: rgba(255, 255, 255, 0.08);

  /* === Text Colors (B cool grays; muted clears WCAG 4.5:1 on EVERY text
     surface incl. elevated — enforced by theme-integrity.test, jury graft #4) === */
  --theme-text-primary: #e9edf2;
  --theme-text-secondary: #97a1ac;
  --theme-text-muted: #7a8793;
  --theme-text-inverse: #0b0e12;

  /* === Accent Colors (B wayfinding blue — strictly navigation/selection/marks,
     never a status meaning; statuses own their semantic hues below; the solid
     affirmative ACTION owns the theme-invariant --color-action-* in tokens.css).
     B's accent is BRIGHT so it reads as marks/links on the near-black ground.
     -contrast is the WHITE mark on a solid accent fill (checkbox tick, toggle knob
     — NON-TEXT UI, 3:1 bar: white on #4d8bfb = 3.28 ✓; floored on the base accent
     by theme-integrity.test). -dim/-dark stay BRIGHTER-on-dark: they serve accent
     hover/pressed states (toggle + checkbox fill hover, accent-mark borders) — the
     B "hover lightens on dark" idiom. (The primary-button ink-flip that first
     demanded dark -contrast is gone — the button now owns --color-action-*.) === */
  --theme-accent-primary: #4d8bfb;
  --theme-accent-primary-dim: #6ea3ff;
  --theme-accent-primary-dark: #85b4ff;
  --theme-accent-primary-contrast: #ffffff;
  --theme-accent-secondary: #4d8bfb;
  --theme-accent-info: #f3b24a;

  /* === Status Colors (hardening graft: C's semantic signal palette in B's
     minimalist execution — cyan=live, amber=caution, red=fault, green=nominal.
     `active` moves off wayfinding blue onto live-cyan; `scanning` deliberately
     KEEPS purple for now — the #647 lab-teal-vs-scanning-purple map legibility
     rationale still holds; revisit with the owner at the fleet/spectrum slice.) === */
  --theme-status-success: #3ecf8e;
  --theme-status-error: #f06067;
  --theme-status-warning: #f3b24a;
  --theme-status-active: #38bdf8;
  /* Status TEXT inks — the deepened, text-safe (>=4.5) counterparts of the four
     signal hues above (base = signal: dots/fills/borders, 3:1; -ink = body text).
     On dark the signal hues already clear 4.5 as text, so -ink == base (page/panel:
     success 9.69/9.09, error 6.06/5.68, warning 10.39/9.75, active 9.03/8.47). */
  --theme-status-success-ink: #3ecf8e;
  --theme-status-error-ink: #f06067;
  --theme-status-warning-ink: #f3b24a;
  --theme-status-active-ink: #38bdf8;
  --theme-status-scanning: #a855f7;
  --theme-status-offline: #7a8793;
  --theme-role-lab: #2dd4bf;

  /* === Threat Classification Colors (domain contract — NOT part of the B
     re-theme; operators are trained on these meanings) === */
  --theme-threat-enemy: #fe0502;
  --theme-threat-friend: #38bdf8;
  --theme-threat-protected: #4ade80;
  --theme-threat-unknown: #ffffff;
  --theme-threat-fm-radio: #38bdf8;

  /* === Threat Background Colors (flat translucent row tints — OsdLogsModal) === */
  --theme-threat-enemy-bg: rgba(254, 5, 2, 0.35);
  --theme-threat-friend-bg: rgba(56, 189, 248, 0.35);
  --theme-threat-protected-bg: rgba(74, 222, 128, 0.35);
  --theme-threat-unknown-bg: rgba(255, 255, 255, 0.35);
  --theme-threat-fm-radio-bg: rgba(56, 189, 248, 0.35);

  /* === Threat RGB Values (for layered rgba() usage) === */
  --theme-threat-enemy-rgb: 254, 5, 2;
  --theme-threat-friend-rgb: 56, 189, 248;
  --theme-threat-protected-rgb: 74, 222, 128;
  --theme-threat-unknown-rgb: 255, 255, 255;
  /* Canvas FILL — on dark the ink already sits above the trace palette, so the
     fill matches it. */
  --theme-threat-unknown-fill-rgb: 255, 255, 255;
  --theme-threat-fm-radio-rgb: 56, 189, 248;

  /* === Spectrum sweep glow ===
   * Bright sky-blue chosen for high luminance against the near-black page
   * surface; the wayfinding accent (#4d8bfb) is too dim for the sweep tail.
   * Light theme uses the same RGB so the glow remains readable over the white
   * panel as well. */
  --theme-spectrum-glow-rgb: 56, 189, 248;

  /* === Chart chrome === (same values as --theme-text-muted; the dark grid is
   * already correct — the token exists so light can diverge, see light.css) */
  --theme-chart-grid-rgb: 122, 135, 147;
  --theme-chart-axis-tick: #7a8793;

  /* === Shadow Tokens (B: one hairline + one modal float, no glows) === */
  --theme-shadow-panel: 0 1px 2px rgba(0, 0, 0, 0.5);
  --theme-shadow-focus: 0 0 0 2px rgba(77, 139, 251, 0.35);
  --theme-shadow-hover: 0 2px 4px rgba(0, 0, 0, 0.2);
  --theme-shadow-hover-strong: 0 4px 8px rgba(0, 0, 0, 0.25);
  --theme-shadow-modal: 0 16px 40px -12px rgba(0, 0, 0, 0.66), 0 2px 8px rgba(0, 0, 0, 0.4);
  --theme-shadow-error: 0 0 0 2px rgba(240, 96, 103, 0.3);
  --theme-shadow-active: 0 0 0 2px rgba(77, 139, 251, 0.4);

  /* === Overlay Colors === */
  --theme-dim-overlay: rgba(0, 0, 0, 0.35);
  --theme-scrim: rgba(0, 0, 0, 0.5);

  /* === RGB Values (for rgba() usage) === */
  --theme-accent-primary-rgb: 77, 139, 251;
  --theme-accent-secondary-rgb: 77, 139, 251;
  --theme-accent-info-rgb: 243, 178, 74;  /* matches --theme-accent-info */
  --theme-status-success-rgb: 62, 207, 142;
  --theme-status-error-rgb: 240, 96, 103;
  --theme-status-warning-rgb: 243, 178, 74;
  --theme-status-active-rgb: 56, 189, 248;
  --theme-status-scanning-rgb: 168, 85, 247;
  --theme-role-lab-rgb: 45, 212, 191;
  --theme-border-default-rgb: 36, 43, 52;
  --theme-text-primary-rgb: 233, 237, 242;
  --theme-text-secondary-rgb: 151, 161, 172;
  --theme-text-muted-rgb: 122, 135, 147;
  --theme-text-inverse-rgb: 11, 14, 18;
  --theme-surface-page-rgb: 11, 14, 18;
  --theme-surface-panel-rgb: 18, 22, 28;
  --theme-surface-elevated-rgb: 23, 28, 35;
  --theme-surface-input-rgb: 30, 36, 44;
  --theme-surface-inset-rgb: 13, 17, 22;

  /* === Dim/hover variants of status colors === */
  --theme-status-error-dim: #d84e55;
  --theme-status-warning-dim: #dd9c33;

  /* === TRANSMIT button + CRT-effect palette (always-dark visual concept;
     deliberately outside the B re-theme) === */
  --theme-transmit-button-bg: #dc2626;
  --theme-transmit-trace: #b91c1c;
  --theme-transmit-trace-rgb: 185, 28, 28;
  --theme-crt-tube-bg: #3a3a3a;
  --theme-crt-tube-bg-active: #4a4a4a;
  --theme-crt-tube-bg-error: #4a2020;
  --theme-crt-scanline-rgb: 255, 255, 255;
  --theme-crt-scanline-warning-rgb: 255, 100, 100;

  /* === Spectrum-Sweep gradient (cold → hot, slider tracks; canvas surfaces use
     spectrumPalette.ts — this MIRRORS that ramp and moves with it, not with the
     B re-theme; the JS-palette bridge is a later #990 slice) === */
  --theme-gradient-spectrum-sweep:
    rgb(15, 23, 42) 0%,
    rgb(56, 189, 248) 25%,
    rgb(74, 222, 128) 50%,
    rgb(251, 191, 36) 75%,
    rgb(248, 113, 113) 100%;
}
