/* ==========================================================================
   MergeGrid Design System — Design Tokens
   --------------------------------------------------------------------------
   Primitive tokens are raw palette values. Semantic tokens map primitives to
   intent and are the ONLY values components are allowed to consume. Override
   semantic tokens under [data-theme="dark"] to retheme the whole product.
   ========================================================================== */

:root {
  color-scheme: light;

  /* ---------- Primitive: Brand (Indigo / Violet) ---------- */
  --brand-50:  #eef2ff;
  --brand-100: #e0e7ff;
  --brand-200: #c7d2fe;
  --brand-300: #a5b4fc;
  --brand-400: #818cf8;
  --brand-500: #6366f1;
  --brand-600: #4f46e5;
  --brand-700: #4338ca;
  --brand-800: #3730a3;
  --brand-900: #312e81;
  --brand-950: #1e1b4b;

  /* ---------- Primitive: Accent (Cyan / Sky) ---------- */
  --accent-50:  #ecfeff;
  --accent-100: #cffafe;
  --accent-200: #a5f3fc;
  --accent-300: #67e8f9;
  --accent-400: #22d3ee;
  --accent-500: #06b6d4;
  --accent-600: #0891b2;
  --accent-700: #0e7490;
  --accent-800: #155e75;
  --accent-900: #164e63;

  /* ---------- Primitive: Neutral ---------- */
  --neutral-0:   #ffffff;
  --neutral-50:  #f8fafc;
  --neutral-100: #f1f5f9;
  --neutral-200: #e2e8f0;
  --neutral-300: #cbd5e1;
  --neutral-400: #94a3b8;
  --neutral-500: #64748b;
  --neutral-600: #475569;
  --neutral-700: #334155;
  --neutral-800: #1e293b;
  --neutral-900: #0f172a;
  --neutral-950: #020617;

  /* ---------- Primitive: Semantic ---------- */
  --success-50:  #ecfdf5;
  --success-500: #059669;
  --success-700: #047857;
  --warning-50:  #fffbeb;
  --warning-500: #d97706;
  --warning-700: #b45309;
  --error-50:    #fef2f2;
  --error-500:   #dc2626;
  --error-700:   #b91c1c;
  --info-50:     #f0f9ff;
  --info-500:    #0284c7;
  --info-700:    #0369a1;

  /* ---------- Typography ---------- */
  --font-family-base: "Plus Jakarta Sans", "Inter", system-ui, -apple-system,
    "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-family-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo,
    Consolas, monospace;

  /* Fluid type scale (min at 320px, max at 1200px viewport) */
  --font-size-2xs:  0.6875rem; /* 11px */
  --font-size-xs:   0.75rem;   /* 12px */
  --font-size-sm:   0.875rem;  /* 14px */
  --font-size-base: 1rem;      /* 16px */
  --font-size-md:   clamp(1.0625rem, 1rem + 0.25vw, 1.125rem);
  --font-size-lg:   clamp(1.125rem, 1.05rem + 0.4vw, 1.25rem);
  --font-size-xl:   clamp(1.375rem, 1.2rem + 0.8vw, 1.75rem);
  --font-size-2xl:  clamp(1.75rem, 1.5rem + 1.2vw, 2.5rem);
  --font-size-3xl:  clamp(2.25rem, 1.8rem + 2vw, 3.5rem);
  --font-size-4xl:  clamp(2.75rem, 2rem + 3vw, 4.5rem);

  --font-weight-regular: 400;
  --font-weight-medium:  500;
  --font-weight-semibold: 600;
  --font-weight-bold:    700;
  --font-weight-extrabold: 800;
  --line-height-tight: 1.15;
  --line-height-snug:  1.35;
  --line-height-normal: 1.6;
  --letter-spacing-tight: -0.03em;
  --letter-spacing-wide:  0.08em;

  /* ---------- 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-20: 5rem;
  --space-24: 6rem;

  /* ---------- Radii ---------- */
  --radius-xs:  4px;
  --radius-sm:  8px;
  --radius-md:  12px;
  --radius-lg:  16px;
  --radius-xl:  24px;
  --radius-2xl: 32px;
  --radius-full: 9999px;

  /* ---------- Elevation ---------- */
  --shadow-xs: 0 1px 2px rgb(15 23 42 / 0.05);
  --shadow-sm: 0 1px 3px rgb(15 23 42 / 0.08), 0 1px 2px rgb(15 23 42 / 0.04);
  --shadow-md: 0 4px 6px -1px rgb(15 23 42 / 0.08), 0 2px 4px -2px rgb(15 23 42 / 0.06);
  --shadow-lg: 0 10px 15px -3px rgb(15 23 42 / 0.10), 0 4px 6px -4px rgb(15 23 42 / 0.08);
  --shadow-xl: 0 20px 25px -5px rgb(15 23 42 / 0.12), 0 8px 10px -6px rgb(15 23 42 / 0.08);
  --shadow-glow: 0 0 0 4px rgb(79 70 229 / 0.15);

  /* ---------- Motion ---------- */
  --duration-fast: 120ms;
  --duration-base: 200ms;
  --duration-slow: 320ms;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);

  /* ---------- Layout ---------- */
  --layout-max-width: 1200px;
  --layout-content-width: 760px;
  --layout-gutter: clamp(1rem, 4vw, 2.5rem);

  /* ======================================================================
     Semantic tokens — LIGHT theme (default)
     ====================================================================== */
  --bg: var(--neutral-50);
  --bg-subtle: var(--neutral-100);
  --surface: var(--neutral-0);
  --surface-raised: var(--neutral-0);
  --surface-sunken: var(--neutral-100);
  --border: var(--neutral-200);
  --border-strong: var(--neutral-300);

  --text: var(--neutral-900);
  --text-muted: var(--neutral-600);
  --text-subtle: var(--neutral-500);
  --text-inverse: var(--neutral-0);

  --primary: var(--brand-600);
  --primary-hover: var(--brand-700);
  --primary-active: var(--brand-800);
  --primary-subtle: var(--brand-50);
  --primary-subtle-text: var(--brand-700);
  --on-primary: var(--neutral-0);

  --accent: var(--accent-600);
  --accent-subtle: var(--accent-50);
  --accent-subtle-text: var(--accent-800);
  --on-accent: var(--neutral-0);

  --success: var(--success-500);
  --success-subtle: var(--success-50);
  --success-text: var(--success-700);
  --warning: var(--warning-500);
  --warning-subtle: var(--warning-50);
  --warning-text: var(--warning-700);
  --error: var(--error-500);
  --error-subtle: var(--error-50);
  --error-text: var(--error-700);
  --info: var(--info-500);
  --info-subtle: var(--info-50);
  --info-text: var(--info-700);

  --focus-ring: var(--brand-500);
  --overlay: rgb(15 23 42 / 0.55);

  /* Board / game surface tokens */
  --board-bg: var(--neutral-200);
  --cell-bg: rgb(255 255 255 / 0.45);
  --board-gap: clamp(8px, 2vw, 14px);
}

/* ==========================================================================
   Semantic tokens — DARK theme
   ========================================================================== */
[data-theme="dark"] {
  color-scheme: dark;

  --bg: var(--neutral-950);
  --bg-subtle: var(--neutral-900);
  --surface: var(--neutral-900);
  --surface-raised: var(--neutral-800);
  --surface-sunken: var(--neutral-950);
  --border: var(--neutral-700);
  --border-strong: var(--neutral-600);

  --text: var(--neutral-50);
  --text-muted: var(--neutral-300);
  --text-subtle: var(--neutral-400);
  --text-inverse: var(--neutral-900);

  --primary: var(--brand-400);
  --primary-hover: var(--brand-300);
  --primary-active: var(--brand-200);
  --primary-subtle: rgb(79 70 229 / 0.18);
  --primary-subtle-text: var(--brand-200);
  --on-primary: var(--brand-950);

  --accent: var(--accent-400);
  --accent-subtle: rgb(6 182 212 / 0.15);
  --accent-subtle-text: var(--accent-200);
  --on-accent: var(--accent-950, #083344);

  --success-subtle: rgb(5 150 105 / 0.15);
  --success-text: #6ee7b7;
  --warning-subtle: rgb(217 119 6 / 0.15);
  --warning-text: #fcd34d;
  --error-subtle: rgb(220 38 38 / 0.15);
  --error-text: #fca5a5;
  --info-subtle: rgb(2 132 199 / 0.15);
  --info-text: #7dd3fc;

  --focus-ring: var(--brand-300);
  --overlay: rgb(2 6 23 / 0.75);

  --board-bg: var(--neutral-800);
  --cell-bg: rgb(255 255 255 / 0.06);
}
