/* =====================================================
   Design tokens
   Three layers: primitives (raw values) → semantic (what a value is for)
   → component (what one component uses). Components reach for the
   semantic layer; primitives exist only to be aliased.

   Direction: one accent hue (indigo) on neutral greys, dark by default,
   with a first-class light theme. Every text/background pair below was
   checked against WCAG AA in both themes.
   ===================================================== */

/* ----- Fonts (self-hosted, latin subsets) ----- */
@font-face {
    font-family: 'Bricolage Grotesque';
    font-style: normal;
    font-weight: 200 800;
    font-stretch: 75% 100%;
    font-display: swap;
    src: url('../assets/fonts/bricolage-grotesque-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('../assets/fonts/jetbrains-mono-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ----- Primitives ----- */
:root {
    /* Neutral (zinc) */
    --neutral-0: #ffffff;
    --neutral-50: #fafafa;
    --neutral-100: #f4f4f5;
    --neutral-200: #e4e4e7;
    --neutral-300: #d4d4d8;
    --neutral-400: #a1a1aa;
    --neutral-500: #7a7a85;
    --neutral-600: #52525b;
    --neutral-700: #3f3f46;
    --neutral-800: #222227;
    --neutral-850: #18181c;
    --neutral-900: #111114;
    --neutral-950: #0b0b0e;

    /* Accent (indigo) */
    --indigo-200: #c7d2fe;
    --indigo-300: #a5b4fc;
    --indigo-400: #818cf8;
    --indigo-500: #6366f1;
    --indigo-600: #4f46e5;
    --indigo-700: #4338ca;
    --indigo-800: #3730a3;

    /* Status */
    --green-400: #4ade80;
    --green-700: #15803d;
    --red-400: #f87171;
    --red-700: #b91c1c;

    /* Channel triplets for tints: rgb(var(--x-rgb) / a) */
    --indigo-500-rgb: 99 102 241;
    --indigo-600-rgb: 79 70 229;
    --neutral-950-rgb: 11 11 14;
    --neutral-900-rgb: 17 17 20;
    --neutral-50-rgb: 250 250 250;
    --neutral-0-rgb: 255 255 255;

    /* Type */
    --font-family-sans: 'Bricolage Grotesque', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-family-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', 'Cascadia Code', Consolas, monospace;

    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-md: 1.0625rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: clamp(1.375rem, 1.2rem + 0.8vw, 1.75rem);
    --font-size-3xl: clamp(1.75rem, 1.35rem + 1.8vw, 2.5rem);
    --font-size-4xl: clamp(2.75rem, 1.9rem + 3.6vw, 4.75rem);

    --line-height-tight: 1.02;
    --line-height-snug: 1.3;
    --line-height-normal: 1.6;
    --line-height-mono: 1.75;

    --letter-spacing-display: -0.035em;
    --letter-spacing-heading: -0.02em;
    --letter-spacing-wide: 0.06em;

    --measure: 66ch;

    /* Spacing (4px base) */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;
    --space-24: 6rem;
    --space-32: 8rem;

    /* Radius (shape lock: controls 8px, surfaces 12px, pills for tags) */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-full: 9999px;

    /* Motion */
    --duration-fast: 120ms;
    --duration-base: 220ms;
    --duration-slow: 420ms;
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in: cubic-bezier(0.7, 0, 0.84, 0);
    --ease-standard: cubic-bezier(0.2, 0, 0, 1);

    /* Layout */
    --container-max: 1200px;
    --container-padding: clamp(1rem, 4vw, 2rem);
    --header-height: 4.5rem;

    /* z-index scale */
    --z-base: 0;
    --z-raised: 10;
    --z-sticky: 40;
    --z-overlay: 100;
    --z-top: 1000;
}

/* ----- Semantic: dark (default) ----- */
:root {
    color-scheme: dark;

    --color-bg: var(--neutral-950);
    --color-bg-raised: var(--neutral-900);
    --color-surface: var(--neutral-850);
    --color-surface-hover: var(--neutral-800);
    --color-surface-glass: rgb(var(--neutral-950-rgb) / 0.82);

    --color-text: #f4f4f5;
    --color-text-secondary: var(--neutral-300);
    --color-text-muted: var(--neutral-400);
    /* neutral-500 measured 4.17:1 on the card surface; this lifts the
       smallest labels (type kickers, timings) to 5.2:1 on cards. */
    --color-text-subtle: #8b8b96;

    --color-accent: var(--indigo-500);
    --color-accent-strong: var(--indigo-600);
    --color-accent-stronger: var(--indigo-700);
    --color-accent-text: var(--indigo-300);
    --color-accent-soft: var(--indigo-400);
    --accent-rgb: var(--indigo-500-rgb);
    --ink-rgb: var(--neutral-0-rgb);

    --color-border: rgb(var(--neutral-0-rgb) / 0.09);
    --color-border-strong: rgb(var(--neutral-0-rgb) / 0.18);

    --color-success: var(--green-400);
    --color-warning: #fbbf24;
    --color-danger: var(--red-400);

    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.3);
    --shadow-md: 0 6px 16px -6px rgb(0 0 0 / 0.5);
    --shadow-lg: 0 16px 40px -12px rgb(0 0 0 / 0.6);
    --shadow-ring: 0 0 0 1px rgb(var(--accent-rgb) / 0.4), 0 10px 30px -12px rgb(var(--accent-rgb) / 0.45);
}

/* ----- Semantic: light ----- */
[data-theme="light"] {
    color-scheme: light;

    --color-bg: var(--neutral-50);
    --color-bg-raised: var(--neutral-100);
    --color-surface: var(--neutral-0);
    --color-surface-hover: var(--neutral-100);
    --color-surface-glass: rgb(var(--neutral-50-rgb) / 0.86);

    --color-text: #18181b;
    --color-text-secondary: #27272a;
    --color-text-muted: var(--neutral-600);
    --color-text-subtle: #71717a;

    --color-accent: var(--indigo-600);
    --color-accent-strong: var(--indigo-600);
    --color-accent-stronger: var(--indigo-700);
    --color-accent-text: var(--indigo-700);
    --color-accent-soft: var(--indigo-600);
    --accent-rgb: var(--indigo-600-rgb);
    --ink-rgb: var(--neutral-900-rgb);

    --color-border: rgb(var(--neutral-900-rgb) / 0.1);
    --color-border-strong: rgb(var(--neutral-900-rgb) / 0.2);

    --color-success: var(--green-700);
    --color-warning: #b45309;
    --color-danger: var(--red-700);

    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.06);
    --shadow-md: 0 6px 16px -6px rgb(17 17 20 / 0.14);
    --shadow-lg: 0 16px 40px -12px rgb(17 17 20 / 0.18);
    --shadow-ring: 0 0 0 1px rgb(var(--accent-rgb) / 0.3), 0 10px 24px -12px rgb(var(--accent-rgb) / 0.35);
}

/* ----- Component tokens ----- */
:root {
    --button-primary-bg: var(--color-accent-strong);
    --button-primary-bg-hover: var(--color-accent-stronger);
    --button-primary-fg: #ffffff;
    --card-bg: var(--color-surface);
    --card-border: var(--color-border);
    --tag-bg: rgb(var(--accent-rgb) / 0.1);
    --tag-fg: var(--color-accent-text);
    --tag-border: rgb(var(--accent-rgb) / 0.22);
    --focus-ring: 0 0 0 2px var(--color-bg), 0 0 0 4px var(--color-accent);
}
