/* =========================================================
   Awall — Shared Design Tokens
   Single source of truth for colors, typography, spacing,
   radius, shadows, and motion. Loaded BEFORE app-specific
   stylesheets in every template.
   ========================================================= */

:root {
  /* ── Colors: surfaces & text ───────────────────────────── */
  /* Mirror palettes.css [data-palette="p1"] so any surface that
     does not load palettes.css (the landing) reads identical
     values to the dashboard. */
  --color-bg:           #F5F6F8;
  --color-surface:      #ECEDF0;
  --color-elevated:     #ffffff;
  --color-border:       #dee0e5;
  --color-border-soft:  rgba(222, 224, 229, 0.6);

  --color-text-heading: #1f2937;
  --color-text-body:    #475569;
  --color-text-muted:   #656b78;  /* F4 #189: AA-tuned (was #6b7280, <4.5:1 on surface) */

  /* ── Colors: primary (brand blue) ──────────────────────── */
  /* Defaults match the P1 (Slate Comfort) ship hue so any surface
     that paints before [data-palette] is set still reads on-brand.
     palettes.css P1 overrides these with identical values. */
  --color-primary:       #3b66d4;
  --color-primary-hover: #2d52bd;
  --color-primary-light: #dde7fb;
  --color-primary-soft:        rgba(59, 102, 212, 0.08);
  --color-primary-ring:        rgba(59, 102, 212, 0.25);
  --color-primary-ring-strong: rgba(59, 102, 212, 0.30);
  --color-primary-glow:        rgba(59, 102, 212, 0.40);
  --color-primary-glow-faint:  rgba(59, 102, 212, 0.05);
  --color-primary-focus-ring:  rgba(59, 102, 212, 0.12);
  --color-primary-border-soft: rgba(59, 102, 212, 0.20);
  /* Text and icons on a --color-primary fill. White on the light theme's
     blue; the dark theme's primary is a light teal and takes ink instead. */
  --color-on-primary:    #ffffff;

  /* ── Colors: accent (brand purple) ─────────────────────── */
  --color-accent:             #8B5CF6;
  --color-accent-hover:       #7c3aed;
  --color-accent-soft:        rgba(139, 92, 246, 0.10);
  --color-accent-ring:        rgba(139, 92, 246, 0.25);
  --color-accent-glow:        rgba(139, 92, 246, 0.40);
  --color-accent-border-soft: rgba(139, 92, 246, 0.22);
  --color-accent-bg:          #ede9fe;
  /* Strong-Semantic Rule companion: text on --color-accent-bg uses
     --color-accent-strong so the AWall-LLM trigger chip clears AA. */
  --color-accent-strong:      #5b21b6;

  /* ── Colors: semantic ──────────────────────────────────── */
  --color-danger-soft:        rgba(220, 38, 38, 0.08);
  --color-danger-border-soft: rgba(220, 38, 38, 0.20);
  --color-success-border-soft:rgba(22, 163, 74, 0.20);
  --color-warning-border-soft:rgba(245, 158, 11, 0.30);

  /* Jailbreak family (teal) — fifth distinct guardrail-chip hue, sits
     outside danger/warning/accent so the five categories stay readable
     side-by-side. ~7.5:1 contrast (AAA). */
  --color-jailbreak-bg:          #f0fdfa;
  --color-jailbreak-strong:      #0f766e;
  --color-jailbreak-border-soft: rgba(13, 148, 136, 0.22);

  --color-pre-bg:   #0F172A;
  --color-pre-text: #e2e8f0;

  --color-overlay-modal: rgba(15, 23, 42, 0.48);
  --color-overlay-panel: rgba(15, 23, 42, 0.35);

  /* Sidebar, light theme ("raised surface"): a stone tone one step below
     the content surface (#ECEDF0), a hairline right edge, Reading Ink rows,
     a section label tuned to 4.5:1 on that tone, and the active row on a
     12% primary tint behind the 3px primary marker. The dark theme keeps
     Sidebar Charcoal (see [data-theme="dark"] below). */
  --color-sidebar-bg:          #e4e6ea;
  --color-sidebar-edge:        #d5d8df;
  --color-sidebar-text:        var(--color-text-body);
  --color-sidebar-text-strong: var(--color-text-heading);
  --color-sidebar-text-hover:  var(--color-text-heading);
  --color-sidebar-brand-text:  var(--color-text-heading);
  --color-sidebar-section:     #5b6170;
  --color-sidebar-active-text: var(--color-primary-hover);
  --color-sidebar-active-bg:   rgba(59, 102, 212, 0.12);
  --color-sidebar-hover-bg:    rgba(31, 41, 55, 0.05);
  --color-sidebar-hover-border:rgba(31, 41, 55, 0.20);
  --color-sidebar-brand-border:#d5d8df;
  --color-sidebar-glow-soft:   transparent;
  --color-sidebar-avatar-text: var(--color-primary-hover);
  --color-sidebar-danger:      var(--color-danger-strong);
  --color-sidebar-danger-soft: var(--color-danger-soft);

  --color-success:        #16a34a;
  --color-success-bg:     #f0fdf4;
  --color-success-strong: #15803d;
  --color-danger:         #dc2626;
  --color-danger-bg:      #fef2f2;
  --color-danger-strong:  #b91c1c;
  --color-warning:        #f59e0b;
  --color-warning-bg:     #fffbeb;
  --color-warning-strong: #92400e;
  --color-info-bg:        #eff6ff;
  --color-info-strong:    #1e40af;
  --color-monitor-bg:     #fef3c7;
  --color-monitor-text:   #92400e;

  /* ── Typography ────────────────────────────────────────── */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', 'Fira Mono', ui-monospace, monospace;

  /* ── Spacing scale (4px base) ─────────────────────────── */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-7:  28px;
  --space-8:  32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-14: 56px;
  --space-16: 64px;

  /* ── Touch target floor (WCAG 2.5.5) ──────────────────── */
  --touch-target-min: 40px;

  /* ── Radius ────────────────────────────────────────────── */
  --radius-tag:   4px;
  --radius-btn:   6px;
  --radius-input: 8px;
  --radius-card:  12px;
  --radius-pill:  9999px;

  /* ── Shadows ───────────────────────────────────────────── */
  --shadow-card:   0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-modal:  0 4px 12px rgba(15, 23, 42, 0.10);
  --shadow-lift:   0 8px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg:     0 8px 24px rgba(15, 23, 42, 0.12);

  /* ── Motion ────────────────────────────────────────────── */
  --transition-fast: 120ms ease;
  --transition-base: 200ms ease;
  --ease-out:        cubic-bezier(0.22, 1, 0.36, 1);

  /* ── Breakpoints (F1 #186) ─────────────────────────────── */
  /* Canonical responsive ladder. NOTE: CSS custom properties CANNOT be used
     inside @media query conditions — author @media against the px values
     documented in DESIGN.md → "Responsive breakpoints". These tokens exist
     for JS reads and future container queries. F5 (#190) standardises on them. */
  --bp-xs: 30rem;     /* 480px  — tight mobile             */
  --bp-sm: 37.5rem;   /* 600px  — compact / single column  */
  --bp-md: 48rem;     /* 768px  — mobile↔desktop, drawer   */
  --bp-lg: 68.75rem;  /* 1100px — multi-column grid reflow */

  /* ── Z-index scale (F1 #186) ───────────────────────────── */
  /* Semantic ladder — never use arbitrary z values (no 999 / 9999). */
  --z-base:     1;
  --z-dropdown: 100;
  --z-sticky:   200;
  --z-drawer:   300;
  --z-overlay:  400;
  --z-modal:    500;
  --z-toast:    600;
  --z-tooltip:  700;

  /* ── Focus ring (F1 #186 — consumed by F4 a11y, #189) ──── */
  /* --color-primary-focus-ring is theme-aware (overridden under
     [data-theme="dark"]); --focus-ring resolves it at use time. */
  --focus-ring-width:  3px;
  --focus-ring-offset: 2px;
  --focus-ring: 0 0 0 var(--focus-ring-width) var(--color-primary-focus-ring);
}

[data-theme="dark"] {
  /* Mirror palettes.css [data-palette="p1"][data-theme="dark"].
     "Library at Night", after the dark variant of the Se-Guru cockpit's
     theme (se-guru packages/shared/src/themePalettes.ts, SEGURU_THEME dark):
     its hues and lightness steps at about a third of the chroma, so the
     panel reads as a charcoal grey with a green cast, parchment ink and one
     soft teal for action and focus. */
  --color-bg:           #1a211f;
  --color-surface:      #242d2b;
  --color-elevated:     #2d3734;
  --color-border:       #3c4a46;
  --color-border-soft:  rgba(60, 74, 70, 0.7);

  --color-text-heading: #f1f0ec;
  --color-text-body:    #d2d7d5;
  --color-text-muted:   #adb5b2;  /* 5.9:1 on elevated */

  --color-primary:       #71c3b1;
  --color-primary-hover: #91d8c7;
  --color-primary-light:       rgba(113, 195, 177, 0.18);
  --color-primary-soft:        rgba(113, 195, 177, 0.12);
  --color-primary-ring:        rgba(113, 195, 177, 0.35);
  --color-primary-ring-strong: rgba(113, 195, 177, 0.45);
  --color-primary-glow:        rgba(113, 195, 177, 0.50);
  --color-primary-glow-faint:  rgba(113, 195, 177, 0.10);
  --color-primary-focus-ring:  rgba(113, 195, 177, 0.22);
  --color-primary-border-soft: rgba(113, 195, 177, 0.32);
  --color-on-primary:    #1a211f;  /* 7.9:1 on the teal */

  --color-accent:             #8B5CF6;
  --color-accent-hover:       #a78bfa;
  --color-accent-soft:        rgba(139, 92, 246, 0.16);
  --color-accent-ring:        rgba(139, 92, 246, 0.40);
  --color-accent-glow:        rgba(139, 92, 246, 0.55);
  --color-accent-border-soft: rgba(139, 92, 246, 0.35);
  --color-accent-bg:          rgba(139, 92, 246, 0.18);
  --color-accent-strong:      #c4b5fd;

  --color-danger-soft:        rgba(239, 68, 68, 0.12);
  --color-danger-border-soft: rgba(239, 68, 68, 0.30);
  --color-success-border-soft:rgba(34, 197, 94, 0.30);
  --color-warning-border-soft:rgba(245, 158, 11, 0.40);

  --color-jailbreak-bg:          #0a2e2c;
  --color-jailbreak-strong:      #5eead4;
  --color-jailbreak-border-soft: rgba(94, 234, 212, 0.30);

  --color-pre-bg:   #121615;
  --color-pre-text: #ccd3d0;

  --color-overlay-modal: rgba(0, 0, 0, 0.62);
  --color-overlay-panel: rgba(0, 0, 0, 0.55);

  /* The sidebar sits on the night canvas, one step below the page surface,
     as the light sidebar sits one step below its own. */
  --color-sidebar-bg:          #1a211f;
  --color-sidebar-edge:        transparent;
  --color-sidebar-text:        #adb5b2;
  --color-sidebar-text-strong: #f1f0ec;
  --color-sidebar-text-hover:  #f1f0ec;
  --color-sidebar-brand-text:  #f1f0ec;
  --color-sidebar-section:     var(--color-sidebar-text);
  --color-sidebar-active-text: #f1f0ec;
  --color-sidebar-active-bg:   rgba(113, 195, 177, 0.20);
  --color-sidebar-hover-bg:    rgba(255, 255, 255, 0.04);
  --color-sidebar-hover-border:rgba(255, 255, 255, 0.12);
  --color-sidebar-brand-border:rgba(255, 255, 255, 0.06);
  --color-sidebar-glow-soft:   rgba(113, 195, 177, 0.28);
  --color-sidebar-avatar-text: var(--color-primary);
  --color-sidebar-danger:      #fca5a5;
  --color-sidebar-danger-soft: rgba(252, 165, 165, 0.10);

  --color-success:        #22c55e;
  --color-success-bg:     #052e16;
  --color-success-strong: #4ade80;
  --color-danger:         #ef4444;
  --color-danger-bg:      #2d0a0a;
  --color-danger-strong:  #fca5a5;
  --color-warning:        #f59e0b;
  --color-warning-bg:     #1c1200;
  --color-warning-strong: #fbbf24;
  --color-info-bg:        #1e3a5f;
  --color-info-strong:    #93c5fd;
  --color-monitor-bg:     #2d1f00;
  --color-monitor-text:   #fbbf24;

  --shadow-card:  0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-modal: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lift:  0 12px 28px rgba(0, 0, 0, 0.45);
  --shadow-lg:    0 8px 24px rgba(0, 0, 0, 0.5);
}
