/* ============================================================================
   avx-tokens.css
   ============================================================================
   Brand tokens, dark theme overrides, and global resets.

   Extracted verbatim from index.html lines 14–102. CSS custom properties
   declared on :root pierce shadow DOM boundaries, so any component that
   imports this stylesheet (or where this is loaded on the host page)
   gets full access to the design system tokens.

   Host pages must include this stylesheet ONCE per page. Components
   reference tokens via var(--brand-blue) etc. and never redeclare them.
   ============================================================================ */

:root {
  --brand-blue: #006C9B;
  --brand-blue-dark: #00567B;
  --brand-blue-soft: #BBDEEE;
  --brand-blue-tint: #E8F4F9;
  --brand-orange: #EA7723;
  --brand-orange-soft: #FBE0CB;

  --ink-50:#F7F9FB;  --ink-75:#F1F4F7; --ink-100:#E6EAEF; --ink-150:#D8DEE5;
  --ink-200:#C7CFD9; --ink-300:#A8B3C0; --ink-400:#7E8A99; --ink-500:#5C6878;
  --ink-600:#42505F; --ink-700:#2F3B48; --ink-800:#1E2935; --ink-900:#0D1520;

  /* Named surface tokens — introduced for dark mode support. In light
     mode these are white/near-white; dark mode overrides them below. */
  --surface:         #FFFFFF;  /* cards, panels, sidebar, header */
  --surface-alt:     #FAFBFC;  /* subtle-contrast surface (hover rows) */
  --surface-elevated:#FFFFFF;  /* floating overlays (tooltips, menus) */
  --surface-muted:   #F7F9FB;  /* page / canvas background */
  --text-primary:    #0D1520;  /* ink-900 by default */
  --text-secondary:  #5C6878;  /* ink-500 */
  --border:          #E6EAEF;  /* ink-100 */

  --success:#047857;      --success-soft:#D1FAE5;
  --warning:#B45309;      --warning-soft:#FEF3C7;  --warning-tint:#FEFBEB;
  --danger:#B91C1C;       --danger-soft:#FEE2E2;
  --info:#0369A1;         --info-soft:#E0F2FE;

  /* Alarm severity scale — first-class operational concept (dashboard, alarm rings,
     legends). 5 distinct hues, worst→least: CRITICAL MAJOR MINOR WARNING INFO. */
  --sev-critical:#B91C1C;
  --sev-major:#EA7723;
  --sev-minor:#D97706;
  --sev-warning:#CA8A04;
  --sev-info:#0369A1;

  /* Class colors — match Registry + Template Designer */
  --class-topology:#1E40AF;
  --class-connectivity:#92400E;
  --class-dependency:#9D174D;
  --class-commercial:#9F1239;
  --class-governance:#5B21B6;
  --class-lifecycle:#065F46;

  --radius-sm:4px; --radius-md:8px; --radius-lg:10px;
  --shadow-xs:0 1px 2px rgba(15,23,42,0.04);
  --shadow-sm:0 1px 2px rgba(15,23,42,0.06), 0 1px 3px rgba(15,23,42,0.05);
  --shadow-md:0 4px 10px rgba(15,23,42,0.06), 0 2px 4px rgba(15,23,42,0.04);
  --shadow-lg:0 12px 32px rgba(15,23,42,0.10), 0 4px 8px rgba(15,23,42,0.06);
  --ring-focus:0 0 0 3px rgba(0,108,155,0.25);
  --t-fast:120ms ease;

  --font-sans:'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono:'JetBrains Mono', 'SF Mono', ui-monospace, Menlo, monospace;
}

/* ── Dark theme override ──────────────────────────────────────────────
   Activated by data-theme="dark" on <html> or <body>. Inverts the ink
   scale (light text on dark surfaces) and provides dark-tuned surfaces.
   Brand colors stay the same — they were picked to read on both light
   and dark backgrounds (blue hue, not pure saturated). */
[data-theme="dark"] {
  /* Inverted ink scale — lower numbers = darker, same as light.
     Dark surfaces use ink-100 through ink-300; text uses ink-700+ */
  --ink-50:#0A0F14;   --ink-75:#0D1419;  --ink-100:#121920; --ink-150:#1A232C;
  --ink-200:#242E39;  --ink-300:#36424F; --ink-400:#5B6775; --ink-500:#8A95A5;
  --ink-600:#A8B3C0;  --ink-700:#C8D0DB; --ink-800:#DFE5EC; --ink-900:#F0F3F7;

  /* Surfaces — neutral near-black tones, not pure black (easier on eyes) */
  --surface:         #1A232C;
  --surface-alt:     #121920;
  --surface-elevated:#242E39;
  --surface-muted:   #0D1419;
  --text-primary:    #F0F3F7;
  --text-secondary:  #A8B3C0;
  --border:          #242E39;

  /* Brand tints adjusted for dark backgrounds */
  --brand-blue-tint: rgba(0, 108, 155, 0.12);
  --brand-blue-soft: rgba(0, 108, 155, 0.25);
  --brand-orange-soft: rgba(234, 119, 35, 0.18);

  /* Status softs — dark-mode friendly versions */
  --success-soft: rgba(4, 120, 87, 0.18);
  --warning-soft: rgba(180, 83, 9, 0.18);
  --warning-tint: rgba(180, 83, 9, 0.08);
  --danger-soft:  rgba(185, 28, 28, 0.18);
  --info-soft:    rgba(3, 105, 161, 0.18);

  /* Severity scale — slightly brightened for dark backgrounds */
  --sev-critical:#EF4444;
  --sev-major:#F97316;
  --sev-minor:#F59E0B;
  --sev-warning:#EAB308;
  --sev-info:#38BDF8;

  /* Shadows look terrible on dark — reduce or switch to subtle glows */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.30);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.35);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.45);
  --shadow-lg: 0 16px 40px rgba(0,0,0,0.55);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: var(--font-sans); font-size: 14px; color: var(--text-primary); background: var(--surface-muted); line-height: 1.5; -webkit-font-smoothing: antialiased; transition: background 180ms ease, color 180ms ease; }

/* Toast — global because toast() appends to document.body (light DOM, not a shadow root).
   Ported from the frozen reference; adds a .warning variant (flow-trace uses it). */
.toast { position: fixed; bottom: 24px; right: 24px; padding: 11px 16px; border-radius: var(--radius-md, 8px); color: #FFFFFF; font-size: 12.5px; box-shadow: var(--shadow-lg); z-index: 2000; display: flex; align-items: center; gap: 10px; animation: toastSlide 0.3s cubic-bezier(0.2,0,0.2,1); }
@keyframes toastSlide { from { transform: translateY(10px); opacity: 0; } }
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast.info    { background: var(--brand-blue); }
.toast.warning { background: var(--warning); }
