/* ==========================================================================
   ReflexBuddy design tokens — Phase 2 design system
   Every colour, size and timing used by the interface comes from here.
   Older --rb-* names used by layout.css / games.css are kept as aliases so
   existing pages keep rendering until they are redesigned (Phases 3–6).
   ========================================================================== */

/* Inter 4.0 (SIL OFL 1.1), self-hosted, Latin subset, four weights only. */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/inter/inter-400-latin.woff") format("woff"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2190-2199, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/inter/inter-600-latin.woff") format("woff"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2190-2199, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 700; font-display: swap; src: url("../fonts/inter/inter-700-latin.woff") format("woff"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2190-2199, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 800; font-display: swap; src: url("../fonts/inter/inter-800-latin.woff") format("woff"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2190-2199, U+2212, U+2215, U+FEFF, U+FFFD; }

/* ---------- Theme-independent tokens ---------- */
:root {
    /* Approved brand palette (raw values — prefer the semantic tokens below). */
    --rb-brand-indigo: #3730a3;
    --rb-brand-violet: #7c3aed;
    --rb-brand-cyan: #06b6d4;
    --rb-brand-navy: #111827;
    --rb-brand-gradient: linear-gradient(120deg, #3730a3 0%, #5b21b6 55%, #7c3aed 100%); /* white text ≥ 5.7:1 at every stop */
    --rb-brand-gradient-cool: linear-gradient(120deg, #7c3aed 0%, #06b6d4 100%);

    /* Typography */
    --rb-font-sans: "Inter", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
    --rb-font-mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, monospace;
    --rb-font: var(--rb-font-sans);
    --rb-font-heading: var(--rb-font-sans);
    --rb-fw-regular: 400;
    --rb-fw-semibold: 600;
    --rb-fw-bold: 700;
    --rb-fw-extrabold: 800;
    /* Fluid type scale: 320px → 1280px viewport. */
    --rb-fs-xs: .75rem;                                    /* 12 */
    --rb-fs-sm: .875rem;                                   /* 14 */
    --rb-fs-base: 1rem;                                    /* 16 */
    --rb-fs-md: 1.125rem;                                  /* 18 */
    --rb-fs-lg: clamp(1.25rem, 1.15rem + .5vw, 1.5rem);    /* 20 → 24 */
    --rb-fs-xl: clamp(1.5rem, 1.3rem + .9vw, 2rem);        /* 24 → 32 */
    --rb-fs-2xl: clamp(1.875rem, 1.5rem + 1.6vw, 2.75rem); /* 30 → 44 */
    --rb-fs-3xl: clamp(2.25rem, 1.7rem + 2.6vw, 3.75rem);  /* 36 → 60 */
    --rb-lh-tight: 1.08;
    --rb-lh-snug: 1.25;
    --rb-lh-normal: 1.6;
    --rb-lh-relaxed: 1.75;
    --rb-tracking-tight: -.035em;
    --rb-tracking-tighter: -.05em;
    --rb-tracking-caps: .12em;
    --rb-measure: 68ch;

    /* Spacing (4px base) */
    --rb-space-0: 0;
    --rb-space-1: .25rem;
    --rb-space-2: .5rem;
    --rb-space-3: .75rem;
    --rb-space-4: 1rem;
    --rb-space-5: 1.25rem;
    --rb-space-6: 1.5rem;
    --rb-space-8: 2rem;
    --rb-space-10: 2.5rem;
    --rb-space-12: 3rem;
    --rb-space-16: 4rem;
    --rb-space-20: 5rem;
    --rb-section-y: clamp(3rem, 2rem + 4vw, 5.5rem);

    /* Radii */
    --rb-radius-xs: 8px;
    --rb-radius-sm: 12px;
    --rb-radius-md: 16px;
    --rb-radius-lg: 24px;
    --rb-radius-xl: 32px;
    --rb-radius-pill: 999px;

    /* Layout */
    --rb-container: 1180px;
    --rb-container-narrow: 760px;
    --rb-container-wide: 1320px;
    --rb-gutter: clamp(1rem, .6rem + 2vw, 2rem);
    --rb-header-height: 68px;
    --rb-touch-min: 44px;   /* absolute minimum hit area */
    --rb-touch: 48px;       /* default for primary controls */

    /* Layers */
    --rb-z-base: 1;
    --rb-z-header: 50;
    --rb-z-dropdown: 60;
    --rb-z-tooltip: 70;
    --rb-z-toast: 80;
    --rb-z-skip: 1000;

    /* Motion */
    --rb-duration-fast: 120ms;
    --rb-duration: 180ms;
    --rb-duration-slow: 280ms;
    --rb-ease: cubic-bezier(.2, .7, .2, 1);
    --rb-transition: 180ms ease;
}

/* ---------- Light theme (default) ---------- */
:root,
:root[data-theme="light"] {
    color-scheme: light;

    --rb-bg: #f8fafc;
    --rb-surface: #ffffff;
    --rb-surface-soft: #f1f5f9;
    --rb-surface-sunken: #eef2f7;
    --rb-surface-violet: #eef2ff;
    --rb-overlay: rgba(17, 24, 39, .48);

    --rb-text: #111827;
    --rb-text-muted: #64748b;      /* approved Muted: 4.76:1 on white, 4.55:1 on --rb-bg — not on tinted fills */
    --rb-text-secondary: #475569;  /* 7.6:1 on white; use on soft / tinted surfaces */
    --rb-text-subtle: #8491a5;     /* decorative / large text only */
    --rb-text-inverse: #ffffff;

    --rb-border: #e5e7eb;
    --rb-border-strong: #cbd5e1;

    --rb-primary: #3730a3;
    --rb-primary-strong: #312e81;
    --rb-primary-soft: #eef2ff;
    --rb-on-primary: #ffffff;
    --rb-violet: #7c3aed;
    --rb-violet-soft: #f3e8ff;
    --rb-cyan: #0891b2;            /* existing text cyan; fills use --rb-brand-cyan */
    --rb-cyan-strong: #0e7490;     /* 5.4:1 — cyan body text */
    --rb-cyan-soft: #ecfeff;
    --rb-amber: #b45309;
    --rb-green: #047857;
    --rb-teal: #0f766e;
    --rb-blue: #2563eb;

    --rb-success: #047857;  --rb-success-bg: #ecfdf5;  --rb-success-border: #a7f3d0;
    --rb-warning: #b45309;  --rb-warning-bg: #fffbeb;  --rb-warning-border: #fde68a;
    --rb-danger: #b91c1c;   --rb-danger-bg: #fef2f2;   --rb-danger-border: #fecaca;
    --rb-info: #0e7490;     --rb-info-bg: #ecfeff;     --rb-info-border: #a5f3fc;

    --rb-shadow-xs: 0 1px 2px rgba(15, 23, 42, .06);
    --rb-shadow-sm: 0 2px 8px rgba(15, 23, 42, .045);
    --rb-shadow-card: 0 12px 30px rgba(15, 23, 42, .07);
    --rb-shadow-pop: 0 20px 44px rgba(49, 46, 129, .16);
    --rb-shadow-primary: 0 8px 20px rgba(55, 48, 163, .22);

    --rb-header: rgba(255, 255, 255, .9);
    --rb-footer: #f1f5f9;
    --rb-focus: rgba(124, 58, 237, .34);   /* soft halo (legacy) */
    --rb-focus-ring: #7c3aed;              /* solid ring, 5.7:1 on white */
    --rb-skeleton: #e8edf3;
    --rb-skeleton-shine: #f6f8fb;
}

/* ---------- Dark theme ---------- */
:root[data-theme="dark"] {
    color-scheme: dark;

    --rb-bg: #0b1120;
    --rb-surface: #111827;
    --rb-surface-soft: #1e293b;
    --rb-surface-sunken: #0f172a;
    --rb-surface-violet: #24224a;
    --rb-overlay: rgba(2, 6, 23, .66);

    --rb-text: #f8fafc;
    --rb-text-muted: #cbd5e1;
    --rb-text-secondary: #cbd5e1;
    --rb-text-subtle: #94a3b8;
    --rb-text-inverse: #111827;

    --rb-border: #263247;
    --rb-border-strong: #3b4a63;

    --rb-primary: #a5b4fc;
    --rb-primary-strong: #c7d2fe;
    --rb-primary-soft: #1e1b4b;
    --rb-on-primary: #111827;
    --rb-violet: #c4b5fd;
    --rb-violet-soft: #2e1065;
    --rb-cyan: #67e8f9;
    --rb-cyan-strong: #67e8f9;
    --rb-cyan-soft: #083344;
    --rb-amber: #fbbf24;
    --rb-green: #6ee7b7;
    --rb-teal: #5eead4;
    --rb-blue: #93c5fd;

    --rb-success: #6ee7b7;  --rb-success-bg: #052e22;  --rb-success-border: #065f46;
    --rb-warning: #fcd34d;  --rb-warning-bg: #2d1b05;  --rb-warning-border: #78350f;
    --rb-danger: #fca5a5;   --rb-danger-bg: #2c0b0e;   --rb-danger-border: #7f1d1d;
    --rb-info: #67e8f9;     --rb-info-bg: #062530;     --rb-info-border: #155e75;

    --rb-shadow-xs: 0 1px 2px rgba(0, 0, 0, .3);
    --rb-shadow-sm: 0 2px 14px rgba(0, 0, 0, .18);
    --rb-shadow-card: 0 14px 34px rgba(0, 0, 0, .3);
    --rb-shadow-pop: 0 20px 50px rgba(0, 0, 0, .45);
    --rb-shadow-primary: 0 8px 22px rgba(129, 140, 248, .18);

    --rb-header: rgba(11, 17, 32, .9);
    --rb-footer: #111827;
    --rb-focus: rgba(196, 181, 253, .48);
    --rb-focus-ring: #c4b5fd;              /* 10.6:1 on --rb-surface */
    --rb-skeleton: #1e293b;
    --rb-skeleton-shine: #283548;
}

/* ---------- Bootstrap 5.3 bridge: Bootstrap components follow the active theme ---------- */
:root,
:root[data-theme="light"],
:root[data-theme="dark"] {
    --bs-body-font-family: var(--rb-font-sans);
    --bs-body-bg: var(--rb-bg);
    --bs-body-color: var(--rb-text);
    --bs-emphasis-color: var(--rb-text);
    --bs-secondary-color: var(--rb-text-muted);
    --bs-tertiary-bg: var(--rb-surface-soft);
    --bs-border-color: var(--rb-border);
    --bs-focus-ring-color: var(--rb-focus);
    --bs-heading-color: var(--rb-text);
}

@media (prefers-reduced-motion: reduce) {
    :root { scroll-behavior: auto; }
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
