/* ==========================================================================
   Flare IT — Theme variable system
   --------------------------------------------------------------------------
   Six combinations: {red, rose, blue} x {light, dark}.

   The active combination is applied as `data-theme` on <html>:
       <html data-theme="red-light">
       <html data-theme="blue-dark">   ...

   Everything else in the stylesheet reads from these custom properties, so a
   theme switch is a pure variable swap — instant, no reload, no flash.

   Layering:
     :root                     -> shared tokens (radii, spacing, type, easing)
     [data-mode="light"]       -> neutral surfaces & text
     [data-mode="dark"]        -> neutral surfaces & text
     [data-accent="red"|...]   -> the brand hue ramp
   The two axes multiply, which keeps 6 combinations down to 2 small blocks
   instead of 6 copy-pasted ones.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Shared design tokens (theme independent)
   -------------------------------------------------------------------------- */
:root {
    /* Brand hues — one ramp per accent colour */
    --red-50: #fef2f2;
    --red-100: #fee2e2;
    --red-200: #fecdd0;
    --red-300: #fca5a5;
    --red-400: #f87171;
    --red-500: #ef4444;
    --red-600: #dc2626;
    --red-700: #b91c1c;
    --red-800: #991b1b;
    --red-900: #7f1d1d;

    --rose-50: #fff1f5;
    --rose-100: #ffe4eb;
    --rose-200: #fecdd9;
    --rose-300: #fda4b9;
    --rose-400: #fb7290;
    --rose-500: #f43f6b;
    --rose-600: #e11d55;
    --rose-700: #be185d;
    --rose-800: #9d174d;
    --rose-900: #831843;

    --blue-50: #eff6ff;
    --blue-100: #dbeafe;
    --blue-200: #bfdbfe;
    --blue-300: #93c5fd;
    --blue-400: #60a5fa;
    --blue-500: #3b82f6;
    --blue-600: #2563eb;
    --blue-700: #1d4ed8;
    --blue-800: #1e40af;
    --blue-900: #1e3a8a;

    /* Typography */
    --font-display: "Space Grotesk", "Segoe UI", system-ui, -apple-system,
        "Helvetica Neue", sans-serif;
    --font-body: "Inter", "Segoe UI", system-ui, -apple-system,
        "Helvetica Neue", Arial, sans-serif;
    --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;

    /* Type scale (mobile-first, rem-based) */
    --fs-display: clamp(2.5rem, 1.6rem + 4.2vw, 4.5rem);
    --fs-h1: clamp(2.05rem, 1.45rem + 2.6vw, 3.25rem);
    --fs-h2: clamp(1.6rem, 1.25rem + 1.5vw, 2.3rem);
    --fs-h3: clamp(1.28rem, 1.14rem + 0.6vw, 1.6rem);
    --fs-h4: clamp(1.1rem, 1.04rem + 0.28vw, 1.25rem);
    --fs-body-lg: 1.075rem;
    --fs-body: 1rem;
    --fs-sm: 0.9125rem;
    --fs-xs: 0.8125rem;
    --fs-eyebrow: 0.75rem;

    --lh-tight: 1.08;
    --lh-snug: 1.24;
    --lh-normal: 1.65;
    --lh-relaxed: 1.78;

    --tracking-eyebrow: 0.16em;
    --tracking-tight: 0;

    /* Spacing scale */
    --sp-1: 0.25rem;
    --sp-2: 0.5rem;
    --sp-3: 0.75rem;
    --sp-4: 1rem;
    --sp-5: 1.5rem;
    --sp-6: 2rem;
    --sp-7: 3rem;
    --sp-8: 4rem;
    --sp-9: 6rem;
    --section-y: clamp(3.75rem, 2.6rem + 4.6vw, 7rem);
    --container: 1200px;
    --container-narrow: 800px;
    --gutter: clamp(1.15rem, 0.6rem + 2.4vw, 2.5rem);

    /* Radii, borders, shadows */
    --r-xs: 6px;
    --r-sm: 10px;
    --r-md: 14px;
    --r-lg: 20px;
    --r-xl: 28px;
    --r-full: 999px;

    --border-w: 1px;

    /* Motion */
    --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --t-fast: 160ms;
    --t-base: 220ms;
    --t-slow: 420ms;
    --t-reveal: 560ms;

    /* Layout constants */
    --nav-h: 66px;
    --tap: 44px;
}

/* --------------------------------------------------------------------------
   2. Mode axis — light and dark neutrals
   -------------------------------------------------------------------------- */
[data-mode="light"] {
    color-scheme: light;

    --bg: #fcfcfd;
    --bg-alt: #f4f4f7;
    --bg-deep: #0b0b0f;
    --surface: #ffffff;
    --surface-2: #f8f8fa;
    --surface-3: #eeeef2;
    --surface-inset: #f5f5f8;

    --text: #14141a;
    --text-soft: #43434f;
    --text-muted: #6c6c7b;
    --text-faint: #9a9aa8;
    --text-inverse: #ffffff;

    --border: #e6e6ec;
    --border-strong: #d3d3dd;
    --border-subtle: #eeeef3;

    --shadow-xs: 0 1px 2px rgba(18, 18, 28, 0.05);
    --shadow-sm: 0 2px 8px rgba(18, 18, 28, 0.06);
    --shadow-md: 0 10px 26px -12px rgba(18, 18, 28, 0.22);
    --shadow-lg: 0 26px 54px -26px rgba(18, 18, 28, 0.32);

    --scrim: rgba(12, 12, 20, 0.5);
    --glass: rgba(255, 255, 255, 0.72);
    --glass-border: rgba(20, 20, 30, 0.07);

    --code-bg: #14141c;
    --code-text: #e8e8f0;
    --selection: rgba(0, 0, 0, 0.85);
    --selection-text: #ffffff;
}

[data-mode="dark"] {
    color-scheme: dark;

    --bg: #0a0a0f;
    --bg-alt: #0f0f16;
    --bg-deep: #050508;
    --surface: #14141d;
    --surface-2: #1a1a25;
    --surface-3: #23232f;
    --surface-inset: #101018;

    --text: #f4f4f8;
    --text-soft: #c2c2ce;
    --text-muted: #9090a1;
    --text-faint: #6a6a7a;
    --text-inverse: #0a0a0f;

    --border: #262634;
    --border-strong: #34344a;
    --border-subtle: #1d1d29;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.45);
    --shadow-md: 0 12px 30px -14px rgba(0, 0, 0, 0.7);
    --shadow-lg: 0 30px 60px -28px rgba(0, 0, 0, 0.85);

    --scrim: rgba(0, 0, 0, 0.65);
    --glass: rgba(16, 16, 24, 0.72);
    --glass-border: rgba(255, 255, 255, 0.09);

    --code-bg: #0c0c12;
    --code-text: #e6e6f0;
    --selection: rgba(255, 255, 255, 0.9);
    --selection-text: #0a0a0f;
}

/* --------------------------------------------------------------------------
   3. Accent axis — the brand hue
   Light mode leans on the darker end of each ramp for AA text contrast;
   dark mode leans on the lighter end.
   -------------------------------------------------------------------------- */
[data-accent="red"] {
    --brand-50: var(--red-50);
    --brand-100: var(--red-100);
    --brand-200: var(--red-200);
    --brand-300: var(--red-300);
    --brand-400: var(--red-400);
    --brand-500: var(--red-500);
    --brand-600: var(--red-600);
    --brand-700: var(--red-700);
    --brand-800: var(--red-800);
    --brand-900: var(--red-900);
    --brand-rgb: 230, 57, 70;
}

[data-accent="rose"] {
    --brand-50: var(--rose-50);
    --brand-100: var(--rose-100);
    --brand-200: var(--rose-200);
    --brand-300: var(--rose-300);
    --brand-400: var(--rose-400);
    --brand-500: var(--rose-500);
    --brand-600: var(--rose-600);
    --brand-700: var(--rose-700);
    --brand-800: var(--rose-800);
    --brand-900: var(--rose-900);
    --brand-rgb: 225, 29, 85;
}

[data-accent="blue"] {
    --brand-50: var(--blue-50);
    --brand-100: var(--blue-100);
    --brand-200: var(--blue-200);
    --brand-300: var(--blue-300);
    --brand-400: var(--blue-400);
    --brand-500: var(--blue-500);
    --brand-600: var(--blue-600);
    --brand-700: var(--blue-700);
    --brand-800: var(--blue-800);
    --brand-900: var(--blue-900);
    --brand-rgb: 37, 99, 235;
}

/* Accent + mode → the semantic tokens every component actually uses. */
[data-accent="red"][data-mode="light"],
[data-accent="rose"][data-mode="light"],
[data-accent="blue"][data-mode="light"] {
    --primary: var(--brand-600);
    --primary-hover: var(--brand-700);
    --primary-active: var(--brand-800);
    --primary-text: #ffffff;
    --primary-soft: var(--brand-50);
    --primary-soft-text: var(--brand-700);
    --primary-border: var(--brand-200);
    --on-primary: #ffffff;
}

[data-accent="red"][data-mode="dark"],
[data-accent="rose"][data-mode="dark"],
[data-accent="blue"][data-mode="dark"] {
    --primary: var(--brand-500);
    --primary-hover: var(--brand-400);
    --primary-active: var(--brand-300);
    --primary-text: #ffffff;
    --primary-soft: rgba(var(--brand-rgb), 0.14);
    --primary-soft-text: var(--brand-300);
    --primary-border: rgba(var(--brand-rgb), 0.36);
    --on-primary: #ffffff;
}

/* Gradient stops used by the brand blocks, hero glow and CTA banner. */
[data-accent="red"] {
    --grad-brand: linear-gradient(135deg, #f97362 0%, #e63946 46%, #b21f2f 100%);
    --grad-brand-soft: linear-gradient(140deg, #fff1f0 0%, #ffe0e2 100%);
    --glow: 0 0 0 1px rgba(var(--brand-rgb), 0.18), 0 18px 44px -18px rgba(var(--brand-rgb), 0.42);
}

[data-accent="rose"] {
    --grad-brand: linear-gradient(135deg, #fb7290 0%, #e11d55 48%, #9d174d 100%);
    --grad-brand-soft: linear-gradient(140deg, #fff4f7 0%, #ffe0eb 100%);
    --glow: 0 0 0 1px rgba(var(--brand-rgb), 0.18), 0 18px 44px -18px rgba(var(--brand-rgb), 0.42);
}

[data-accent="blue"] {
    --grad-brand: linear-gradient(135deg, #60a5fa 0%, #2563eb 48%, #1e3a8a 100%);
    --grad-brand-soft: linear-gradient(140deg, #eff6ff 0%, #dbeafe 100%);
    --glow: 0 0 0 1px rgba(var(--brand-rgb), 0.18), 0 18px 44px -18px rgba(var(--brand-rgb), 0.42);
}

[data-mode="dark"] {
    --grad-brand-soft: linear-gradient(
        140deg,
        rgba(var(--brand-rgb), 0.2) 0%,
        rgba(var(--brand-rgb), 0.04) 100%
    );
}

/* --------------------------------------------------------------------------
   4. Forced theme when the user has not chosen yet
   The inline script in <head> writes data-mode before first paint, so this
   block is only a safety net for browsers with JS disabled.
   -------------------------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
    html:not([data-mode]) {
        color-scheme: dark;

        --bg: #0a0a0f;
        --bg-alt: #0f0f16;
        --bg-deep: #050508;
        --surface: #14141d;
        --surface-2: #1a1a25;
        --surface-3: #23232f;
        --surface-inset: #101018;
        --text: #f4f4f8;
        --text-soft: #c2c2ce;
        --text-muted: #9090a1;
        --text-faint: #6a6a7a;
        --text-inverse: #0a0a0f;
        --border: #262634;
        --border-strong: #34344a;
        --border-subtle: #1d1d29;
        --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
        --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.45);
        --shadow-md: 0 12px 30px -14px rgba(0, 0, 0, 0.7);
        --shadow-lg: 0 30px 60px -28px rgba(0, 0, 0, 0.85);
        --scrim: rgba(0, 0, 0, 0.65);
        --glass: rgba(16, 16, 24, 0.72);
        --glass-border: rgba(255, 255, 255, 0.09);
        --code-bg: #0c0c12;
        --code-text: #e6e6f0;
        --selection: rgba(255, 255, 255, 0.9);
        --selection-text: #0a0a0f;

        --primary: var(--brand-500);
        --primary-hover: var(--brand-400);
        --primary-active: var(--brand-300);
        --primary-soft: rgba(var(--brand-rgb), 0.14);
        --primary-soft-text: var(--brand-300);
        --primary-border: rgba(var(--brand-rgb), 0.36);
        --primary-text: #ffffff;
    }
}
