/* Design tokens · UI/UX Design Specification v1.0
   Layer 1 = primitives (raw values). Layer 2 = semantic roles (use these in components).
   Never reference a primitive from a component; always go through a semantic token. */

:root {
  /* ---------- Primitives · neutral ---------- */
  --gray-0:   #FFFFFF;
  --gray-25:  #FAFAFA;
  --gray-50:  #F7F7F7;  /* canvas: sampled */
  --gray-75:  #F5F5F5;  /* sunken panel: sampled */
  --gray-100: #EFEFEF;  /* rails and rules: sampled */
  --gray-150: #EBEBEB;
  --gray-200: #E5E5E5;
  --gray-250: #DDDDDD;  /* frame border: sampled */
  --gray-300: #D4D4D4;
  --gray-400: #A3A3A3;
  --gray-450: #8F8F8F;  /* 3:1 on white: checkbox and radio outlines */
  --gray-500: #878787;  /* soft display text: sampled */
  --gray-600: #707070;  /* 4.5:1 on canvas */
  --gray-650: #666666;  /* secondary text: sampled */
  --gray-700: #525252;
  --gray-800: #2E2E2E;
  --gray-850: #232323;
  --gray-900: #171717;  /* ink and primary action: sampled */
  --gray-950: #0A0A0A;  /* tooltip and announcement bar: sampled */

  /* ---------- Primitives · accent (gold) ---------- */
  --gold-50:  #FBF7EE;
  --gold-100: #F6EFE1;
  --gold-300: #E0A83A;
  --gold-500: #B7800F;  /* dots, bars, active markers (3:1+) */
  --gold-600: #8C600B;  /* accent text (4.5:1+ on canvas) */
  --gold-900: #2A2110;

  /* ---------- Primitives · status ---------- */
  --green-50: #EAF6EE;  --green-500: #22A35A;  --green-600: #15803D;  --green-300: #3DD68C;
  --amber-50: #FDF4E4;  --amber-500: #E29A10;  --amber-600: #B45309;  --amber-300: #F5B54A;
  --red-50:   #FDECEA;  --red-500:   #E5484D;  --red-600:   #C4271B;  --red-300:   #FF7A70;
  --blue-50:  #EAF1FD;  --blue-500:  #1F6FE5;  --blue-600:  #1D5FC9;  --blue-300:  #6FA8FF;

  /* ---------- Primitives · data visualisation (validated order) ---------- */
  --viz-1: #1F6FE5;  /* blue   */
  --viz-2: #B7800F;  /* gold   */
  --viz-3: #2493CB;  /* sky    */
  --viz-4: #E1334D;  /* rose   */
  --viz-5: #7357D6;  /* violet */
  --viz-6: #17956A;  /* green  */
  --viz-muted: #D4D4D4;  /* previous period, "Other" */

  /* ---------- Typography ---------- */
  --font-sans: "Geist", "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;   /* numbers only, never headings */

  --text-display-xl: 500 64px/1.0 var(--font-sans);   --tracking-display-xl: -0.035em;
  --text-display-l:  500 48px/1.05 var(--font-sans);  --tracking-display-l:  -0.03em;
  --text-heading-1:  500 40px/1.1 var(--font-sans);   --tracking-heading-1:  -0.025em;
  --text-heading-2:  500 32px/1.2 var(--font-sans);   --tracking-heading-2:  -0.02em;
  --text-heading-3:  500 24px/1.25 var(--font-sans);  --tracking-heading-3:  -0.015em;
  --text-lead:       400 22px/1.32 var(--font-sans);  --tracking-lead:       -0.01em;
  --text-title:      500 17px/1.4 var(--font-sans);   --tracking-title:      -0.01em;
  --text-body-l:     400 16px/1.6 var(--font-sans);
  --text-body:       400 15px/1.5 var(--font-sans);
  --text-ui:         400 14px/1.43 var(--font-sans);
  --text-caption:    400 13px/1.38 var(--font-sans);
  --text-label:      500 12px/1.33 var(--font-sans);
  --text-micro:      400 11px/1.27 var(--font-sans);
  --text-mono:       400 12px/1.5 var(--font-mono);

  /* ---------- Spacing (4px base) ---------- */
  --space-0-5: 2px;   --space-1: 4px;    --space-1-5: 6px;  --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-16: 64px;
  --space-20: 80px;   --space-24: 96px;  --space-32: 128px;

  /* ---------- Radius ---------- */
  --radius-xs: 4px;   /* badges in tables, checkbox */
  --radius-sm: 6px;   /* chips, small buttons, menu items */
  --radius-md: 8px;   /* buttons, inputs, pills */
  --radius-lg: 12px;  /* cards, panels, popovers, tooltips */
  --radius-xl: 16px;  /* modals, large feature tiles */
  --radius-2xl: 20px; /* outer bezel = inner radius + bezel padding */
  --radius-full: 9999px;

  /* ---------- Layout ---------- */
  --container-max: 1200px;
  --announce-h: 36px;
  --nav-h: 60px;
  --bento-gap: 6px;
  --section-pad: 96px;
  --app-sidebar: 232px;
  --app-header: 52px;

  /* ---------- Motion ---------- */
  --dur-instant: 80ms;
  --dur-fast: 120ms;
  --dur-base: 180ms;
  --dur-slow: 240ms;
  --dur-slower: 360ms;
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);

  /* ---------- Layers ---------- */
  --z-raised: 10;  --z-sticky: 100;  --z-dropdown: 1000;  --z-overlay: 1100;
  --z-modal: 1200; --z-toast: 1300;  --z-tooltip: 1400;
}

/* ---------- Semantic roles · light (default) ---------- */
:root {
  color-scheme: light;
  --color-canvas: var(--gray-50);
  --color-surface: var(--gray-0);
  --color-surface-subtle: var(--gray-25);
  --color-surface-sunken: var(--gray-75);
  --color-surface-inverse: var(--gray-900);
  --color-surface-overlay: var(--gray-950);

  --color-text: var(--gray-900);
  --color-text-secondary: var(--gray-650);
  --color-text-tertiary: var(--gray-600);
  --color-text-soft: var(--gray-500);       /* display sizes (24px+) only */
  --color-text-disabled: var(--gray-400);
  --color-text-inverse: var(--gray-0);
  --color-text-inverse-secondary: var(--gray-400);

  --color-rule: var(--gray-100);
  --color-border-subtle: var(--gray-150);
  --color-border: var(--gray-200);
  --color-border-strong: var(--gray-250);
  --color-border-control: var(--gray-300);
  --color-border-check: var(--gray-450);

  --color-action: var(--gray-900);
  --color-action-hover: #262626;
  --color-action-active: var(--gray-950);
  --color-action-text: var(--gray-0);
  --color-secondary-hover: var(--gray-25);
  --color-secondary-active: #F2F2F2;
  --color-ghost-hover: rgba(0, 0, 0, 0.04);

  --color-accent: var(--gold-500);
  --color-accent-text: var(--gold-600);
  --color-accent-soft: var(--gold-100);

  --color-success: var(--green-500);  --color-success-text: var(--green-600);  --color-success-bg: var(--green-50);
  --color-warning: var(--amber-500);  --color-warning-text: var(--amber-600);  --color-warning-bg: var(--amber-50);
  --color-error:   var(--red-500);    --color-error-text:   var(--red-600);    --color-error-bg:   var(--red-50);
  --color-info:    var(--blue-500);   --color-info-text:    var(--blue-600);   --color-info-bg:    var(--blue-50);

  --color-focus: var(--gray-900);

  /* Depth: measured edge profiles, rebuilt as layered shadows */
  --shadow-xs: 0 0 0 1px rgba(0, 0, 0, 0.06), 0 1px 1px 0 rgba(0, 0, 0, 0.10), 0 2px 5px -1px rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04), 0 2px 8px -2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 1px 2px rgba(0, 0, 0, 0.05), 0 8px 24px -6px rgba(0, 0, 0, 0.14);
  --shadow-lg: 0 2px 4px rgba(0, 0, 0, 0.04), 0 24px 56px -12px rgba(0, 0, 0, 0.22);
  --shadow-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.10);
  --shadow-focus: 0 0 0 2px var(--color-canvas), 0 0 0 4px var(--color-focus);
}

/* ---------- Semantic roles · dark (proposed; references are light-only) ---------- */
:root[data-theme="dark"] {
  color-scheme: dark;
  --color-canvas: #0A0A0A;
  --color-surface: #111111;
  --color-surface-subtle: #151515;
  --color-surface-sunken: #0E0E0E;
  --color-surface-inverse: #EDEDED;
  --color-surface-overlay: #1C1C1C;
  --color-text: #EDEDED;
  --color-text-secondary: #A3A3A3;
  --color-text-tertiary: #8A8A8A;
  --color-text-soft: #7A7A7A;
  --color-text-disabled: #525252;
  --color-text-inverse: #0A0A0A;
  --color-text-inverse-secondary: #525252;
  --color-rule: #1A1A1A;
  --color-border-subtle: #1F1F1F;
  --color-border: #232323;
  --color-border-strong: #333333;
  --color-border-control: #3D3D3D;
  --color-border-check: #6B6B6B;
  --color-action: #EDEDED;
  --color-action-hover: #FFFFFF;
  --color-action-active: #D4D4D4;
  --color-action-text: #0A0A0A;
  --color-secondary-hover: #1A1A1A;
  --color-secondary-active: #202020;
  --color-ghost-hover: rgba(255, 255, 255, 0.06);
  --color-accent: var(--gold-300);
  --color-accent-text: var(--gold-300);
  --color-accent-soft: var(--gold-900);
  --color-success: var(--green-300);  --color-success-text: var(--green-300);  --color-success-bg: #0F2A1B;
  --color-warning: var(--amber-300);  --color-warning-text: var(--amber-300);  --color-warning-bg: #2B200C;
  --color-error:   var(--red-300);    --color-error-text:   var(--red-300);    --color-error-bg:   #2E1412;
  --color-info:    var(--blue-300);   --color-info-text:    var(--blue-300);   --color-info-bg:    #10213D;
  --viz-1: #3B82F6;  --viz-2: #C08A1A;  --viz-3: #2A9BD6;
  --viz-4: #E5485E;  --viz-5: #8C76EA;  --viz-6: #1E9E6A;  --viz-muted: #3D3D3D;
  --color-focus: #EDEDED;
  --shadow-xs: 0 0 0 1px rgba(255, 255, 255, 0.08);
  --shadow-sm: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 2px 8px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 8px 24px -6px rgba(0, 0, 0, 0.7);
  --shadow-lg: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 24px 56px -12px rgba(0, 0, 0, 0.8);
  --shadow-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* Reduced motion: keep feedback, drop travel */
@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-base: 1ms;
    --dur-slow: 1ms;
    --dur-slower: 1ms;
  }
}
