/* ==========================================================================
   BenchAudit Design Tokens (web/tokens.css)
   Single source of truth for surfaces, borders, text hierarchy, brand accent,
   semantic tiers (S–D), 4-factor colors (D1–D4), 4px spacing scale,
   8-step type scale, radii, control heights, shadows, z-layers, and motion.
   ========================================================================== */

:root {
  /* 1. Surfaces & Elevation */
  --surface-canvas: #f8fafc;
  --surface-primary: #ffffff;
  --surface-subtle: #f1f5f9;
  --surface-hover: #f8fafc;
  --surface-inverse: #0f172a;
  --surface-backdrop: rgba(15, 23, 42, 0.36);

  /* 2. Borders & Dividers */
  --border-subtle: #f1f5f9;
  --border-default: #e2e8f0;
  --border-strong: #cbd5e1;
  --border-focus: #0f766e;

  /* 3. Text Hierarchy */
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;
  --text-inverse: #ffffff;
  --text-inverse-muted: #cbd5e1;

  /* 4. Brand Accent & Semantic Interactive States */
  --accent-primary: #0f766e;
  --accent-hover: #0d625b;
  --accent-bright: #0d9488;
  --accent-soft: #f0fdfa;
  --accent-soft-border: #99f6e4;
  --focus-ring: 0 0 0 3px rgba(15, 118, 110, 0.2);

  /* Danger / Destructive */
  --danger-text: #b91c1c;
  --danger-accent: #dc2626;
  --danger-bg: #fff1f2;
  --danger-border: #fecdd3;
  --danger-hover-bg: #ffe4e6;
  --danger-hover-border: #f87171;

  /* Warning / Info Callout */
  --warn-text: #9a3412;
  --warn-accent: #ea580c;
  --warn-bg: #fff7ed;
  --warn-border: #fed7aa;

  /* 5. Semantic Integrity Tier Tokens (S -> D) */
  --tier-s-text: #14532d;
  --tier-s-accent: #16a34a;
  --tier-s-bg: #bbf7d0;
  --tier-s-border: #4ade80;
  --tier-s-wash: rgba(22, 163, 74, 0.06);

  --tier-a-text: #0f766e;
  --tier-a-accent: #14b8a6;
  --tier-a-bg: #f0fdfa;
  --tier-a-border: #99f6e4;
  --tier-a-wash: rgba(20, 184, 166, 0.045);

  --tier-b-text: #92400e;
  --tier-b-accent: #f59e0b;
  --tier-b-bg: #fffbeb;
  --tier-b-border: #fde68a;
  --tier-b-wash: rgba(245, 158, 11, 0.045);

  --tier-c-text: #9a3412;
  --tier-c-accent: #f97316;
  --tier-c-bg: #fff7ed;
  --tier-c-border: #fed7aa;
  --tier-c-wash: rgba(249, 115, 22, 0.045);

  --tier-d-text: #991b1b;
  --tier-d-accent: #f43f5e;
  --tier-d-bg: #fff1f2;
  --tier-d-border: #fecdd3;
  --tier-d-wash: rgba(244, 63, 94, 0.045);

  /* 6. Four-Factor Chart & Meter Colors (D1 - D4) */
  --factor-d1: #0891b2;
  --factor-d2: #2563eb;
  --factor-d3: #d97706;
  --factor-d4: #059669;

  /* 7. Spacing Scale (Strict 4px Grid + 2px Micro-Step) */
  --space-0: 0px;
  --space-0-5: 2px;
  --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;
  --space-14: 56px;

  /* 8. Typography Scale (8 Consolidated Steps) */
  --font-sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --text-2xs: 0.6875rem;   /* 11px */
  --text-xs: 0.75rem;      /* 12px */
  --text-sm: 0.8125rem;    /* 13px */
  --text-base: 0.875rem;   /* 14px */
  --text-md: 1rem;         /* 16px */
  --text-lg: 1.125rem;     /* 18px */
  --text-xl: 1.375rem;     /* 22px */
  --text-2xl: clamp(1.625rem, 3vw, 2.125rem); /* 26-34px */

  --leading-tight: 1.2;
  --leading-snug: 1.35;
  --leading-normal: 1.5;
  --leading-relaxed: 1.6;

  --tracking-tight: -0.02em;
  --tracking-wide: 0.04em;
  --tracking-wider: 0.06em;

  /* 9. Radii, Control Sizing, Elevation, Layers & Motion */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --radius-full: 9999px;

  --control-h-sm: 32px;
  --control-h-md: 36px;
  --control-h-lg: 40px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.14);

  --z-sticky: 10;
  --z-dropdown: 30;
  --z-backdrop: 40;
  --z-drawer: 50;
  --z-tooltip: 60;

  --duration-fast: 120ms;
  --duration-base: 180ms;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  --container-max: 1240px;

  /* Backward-compatible semantic aliases */
  --bg-page: var(--surface-canvas);
  --bg-surface: var(--surface-primary);
  --bg-subtle: var(--surface-subtle);
  --bg-hover: var(--surface-hover);
  --border: var(--border-default);
  --ink: var(--text-primary);
  --ink-secondary: var(--text-secondary);
  --ink-muted: var(--text-muted);
  --accent: var(--accent-primary);
  --accent-light: var(--accent-bright);
  --d1: var(--factor-d1);
  --d2: var(--factor-d2);
  --d3: var(--factor-d3);
  --d4: var(--factor-d4);
  --tier-s-fg: var(--tier-s-text);
  --tier-a-fg: var(--tier-a-text);
  --tier-b-fg: var(--tier-b-text);
  --tier-c-fg: var(--tier-c-text);
  --tier-d-fg: var(--tier-d-text);
}
