/**
 * Design tokens — the single source of truth for color, type, spacing,
 * radius, shadow and motion. Every other stylesheet consumes these custom
 * properties instead of hard-coded values, so the whole design system can
 * be re-themed by editing this one file.
 */

:root {
    /* ---- Brand color ramp ---- */
    --color-primary-50:  #eff6ff;
    --color-primary-100: #dbeafe;
    --color-primary-200: #bfdbfe;
    --color-primary-300: #93c5fd;
    --color-primary-400: #60a5fa;
    --color-primary-500: #3b82f6;
    --color-primary-600: #2563eb;
    --color-primary-700: #1d4ed8;
    --color-primary-800: #1e40af;
    --color-primary-900: #1e3a8a;

    --color-secondary-500: #14b8a6;
    --color-secondary-600: #0d9488;
    --color-secondary-700: #0f766e;

    --color-accent-500: #f59e0b;
    --color-accent-600: #d97706;

    /* ---- Semantic aliases (what components should actually reference) ---- */
    --color-primary: var(--color-primary-600);
    --color-primary-hover: var(--color-primary-700);
    --color-primary-active: var(--color-primary-800);
    --color-on-primary: #ffffff;

    --color-secondary: var(--color-secondary-600);
    --color-secondary-hover: var(--color-secondary-700);
    --color-on-secondary: #ffffff;

    --color-accent: var(--color-accent-500);
    --color-accent-hover: var(--color-accent-600);

    --color-success: #16a34a;
    --color-success-bg: #f0fdf4;
    --color-warning: #d97706;
    --color-warning-bg: #fffbeb;
    --color-danger: #dc2626;
    --color-danger-bg: #fef2f2;
    --color-info: #0284c7;
    --color-info-bg: #f0f9ff;

    /* ---- Surfaces & text (light mode defaults) ---- */
    --color-background: #ffffff;
    --color-surface: #f8fafc;
    --color-surface-raised: #ffffff;
    --color-border: #e2e8f0;
    --color-border-strong: #cbd5e1;

    --color-text: #0f172a;
    --color-text-secondary: #475569;
    /* Prompt #12 fix: #94a3b8 on this theme's backgrounds measured 2.45-2.56:1
       — well under WCAG AA's 4.5:1 for normal text — yet was used for real
       body copy (.text-muted, form help text, tag counts), not just
       decoration. #64748b clears AA (~4.6:1 on white). */
    --color-text-muted: #64748b;
    --color-text-on-dark: #f8fafc;

    --color-overlay: rgba(15, 23, 42, 0.5);

    /* ---- Typography ---- */
    --font-heading: 'Sora', 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

    --text-xs:   0.75rem;
    --text-sm:   0.875rem;
    --text-base: 1rem;
    --text-lg:   1.125rem;
    --text-xl:   1.25rem;
    --text-2xl:  1.5rem;
    --text-3xl:  1.875rem;
    --text-4xl:  2.25rem;
    --text-5xl:  3rem;

    --leading-tight: 1.2;
    --leading-normal: 1.5;
    --leading-relaxed: 1.7;

    --weight-normal: 400;
    --weight-medium: 500;
    --weight-semibold: 600;
    --weight-bold: 700;

    /* ---- Spacing scale (4px base unit) ---- */
    --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-20: 5rem;
    --space-24: 6rem;

    /* ---- Radius ---- */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* ---- Shadows (soft, layered) ---- */
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);
    --shadow-xl: 0 24px 48px rgba(15, 23, 42, 0.16);
    --shadow-focus: 0 0 0 3px var(--color-primary-200);

    /* ---- Motion ---- */
    --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);
    --duration-fast: 120ms;
    --duration-base: 200ms;
    --duration-slow: 320ms;

    /* ---- Layout ---- */
    --container-max: 1280px;
    --header-height: 72px;
    --z-header: 100;
    --z-dropdown: 200;
    --z-modal-overlay: 300;
    --z-modal: 310;
    --z-toast: 400;
}

/* ---- Dark mode: explicit override, driven by data-theme on <html> ---- */
:root[data-theme="dark"] {
    --color-background: #0b1220;
    --color-surface: #111a2e;
    --color-surface-raised: #16213a;
    --color-border: #24304a;
    --color-border-strong: #33415f;

    --color-text: #e2e8f0;
    --color-text-secondary: #a8b4c8;
    /* Prompt #12 fix: #6b7a99 measured 4.34:1 on this theme's #0b1220
       background — just under WCAG AA's 4.5:1. #7d8cab clears it (~4.9:1). */
    --color-text-muted: #7d8cab;

    --color-overlay: rgba(2, 6, 15, 0.65);

    --color-success-bg: #0d2818;
    --color-warning-bg: #2a1e08;
    --color-danger-bg: #2a1111;
    --color-info-bg: #0b2233;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 24px 56px rgba(0, 0, 0, 0.6);
    --shadow-focus: 0 0 0 3px var(--color-primary-800);
}

/* Respect the OS preference on first visit, before JS/localStorage decides. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;
}
