/* 
 * CODED:UK Design Tokens - 2025/26
 * OKLCH color system with semantic tokens
 * Progressive enhancement and accessibility-first
 */

:root {
  /* ================================
     COLOR SYSTEM - OKLCH
     Superior perceptual uniformity
     ================================ */
  
  /* Neutral Scale (Navy/Ink base) */
  --neutral-950: oklch(12% 0.02 250);  /* Deep navy */
  --neutral-900: oklch(16% 0.02 250);  /* Primary background */
  --neutral-800: oklch(20% 0.02 250);  /* Surface elevated */
  --neutral-700: oklch(26% 0.02 250);  /* Surface high */
  --neutral-600: oklch(35% 0.02 250);  /* Border strong */
  --neutral-500: oklch(45% 0.02 250);  /* Text muted */
  --neutral-400: oklch(55% 0.02 250);  /* Text secondary */
  --neutral-300: oklch(65% 0.02 250);  /* Text primary */
  --neutral-200: oklch(75% 0.01 250);  /* Text high contrast */
  --neutral-100: oklch(85% 0.01 250);  /* Surface light */
  --neutral-50:  oklch(95% 0.01 250);  /* Surface lightest */

  /* Brand Colors */
  --brand-primary:   oklch(72% 0.17 265);  /* Electric violet */
  --brand-secondary: oklch(62% 0.15 185);  /* Teal */
  --brand-accent:    oklch(82% 0.12 275);  /* Light violet */
  
  /* Semantic Colors */
  --success: oklch(68% 0.15 145);  /* Green */
  --warning: oklch(75% 0.12 65);   /* Orange */
  --error:   oklch(65% 0.18 25);   /* Red */
  --info:    oklch(70% 0.15 225);  /* Blue */

  /* ================================
     SEMANTIC TOKEN MAPPING
     ================================ */
  
  /* Surfaces */
  --surface-base:     var(--neutral-900);
  --surface-elevated: var(--neutral-800);
  --surface-high:     var(--neutral-700);
  --surface-overlay:  oklch(16% 0.02 250 / 0.95);
  
  /* Text */
  --text-primary:     var(--neutral-200);
  --text-secondary:   var(--neutral-400);
  --text-muted:       var(--neutral-500);
  --text-inverse:     var(--neutral-900);
  --text-brand:       var(--brand-primary);
  
  /* Borders */
  --border-default:   oklch(26% 0.02 250 / 0.3);
  --border-strong:    oklch(35% 0.02 250 / 0.5);
  --border-brand:     oklch(72% 0.17 265 / 0.4);
  
  /* Interactive States */
  --interactive-idle:    var(--brand-primary);
  --interactive-hover:   oklch(75% 0.17 265);
  --interactive-active:  oklch(68% 0.17 265);
  --interactive-focus:   oklch(72% 0.17 265 / 0.3);
  --interactive-disabled: var(--neutral-600);

  /* ================================
     TYPOGRAPHY SCALE
     Fluid, accessible sizing
     ================================ */
  
  /* Font Families */
  --font-sans: "InterVariable", "Inter", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono Variable", "JetBrains Mono", ui-monospace, "SF Mono", monospace;
  
  /* Fluid Type Scale */
  --text-xs:   clamp(0.75rem, 0.7rem + 0.2vw, 0.8rem);    /* 12-13px */
  --text-sm:   clamp(0.875rem, 0.8rem + 0.3vw, 0.95rem);  /* 14-15px */
  --text-base: clamp(1rem, 0.95rem + 0.3vw, 1.1rem);      /* 16-18px */
  --text-lg:   clamp(1.125rem, 1rem + 0.5vw, 1.3rem);     /* 18-21px */
  --text-xl:   clamp(1.25rem, 1.1rem + 0.6vw, 1.5rem);    /* 20-24px */
  --text-2xl:  clamp(1.5rem, 1.3rem + 0.8vw, 1.9rem);     /* 24-30px */
  --text-3xl:  clamp(1.875rem, 1.6rem + 1.1vw, 2.4rem);   /* 30-38px */
  --text-4xl:  clamp(2.25rem, 1.9rem + 1.4vw, 3rem);      /* 36-48px */
  --text-5xl:  clamp(3rem, 2.5rem + 2vw, 4rem);           /* 48-64px */

  /* Line Heights */
  --leading-tight: 1.25;
  --leading-snug:  1.375;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;
  --leading-loose: 1.75;

  /* Font Weights */
  --weight-light:  300;
  --weight-normal: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold:   700;

  /* ================================
     SPACING SCALE
     Consistent rhythm
     ================================ */
  
  --space-0:    0;
  --space-px:   1px;
  --space-0_5:  0.125rem;  /* 2px */
  --space-1:    0.25rem;   /* 4px */
  --space-1_5:  0.375rem;  /* 6px */
  --space-2:    0.5rem;    /* 8px */
  --space-2_5:  0.625rem;  /* 10px */
  --space-3:    0.75rem;   /* 12px */
  --space-3_5:  0.875rem;  /* 14px */
  --space-4:    1rem;      /* 16px */
  --space-5:    1.25rem;   /* 20px */
  --space-6:    1.5rem;    /* 24px */
  --space-7:    1.75rem;   /* 28px */
  --space-8:    2rem;      /* 32px */
  --space-10:   2.5rem;    /* 40px */
  --space-12:   3rem;      /* 48px */
  --space-16:   4rem;      /* 64px */
  --space-20:   5rem;      /* 80px */
  --space-24:   6rem;      /* 96px */
  --space-32:   8rem;      /* 128px */

  /* ================================
     LAYOUT & SIZING
     ================================ */
  
  /* Container Sizes */
  --container-xs:  20rem;    /* 320px */
  --container-sm:  24rem;    /* 384px */
  --container-md:  28rem;    /* 448px */
  --container-lg:  32rem;    /* 512px */
  --container-xl:  36rem;    /* 576px */
  --container-2xl: 42rem;    /* 672px */
  --container-3xl: 48rem;    /* 768px */
  --container-4xl: 56rem;    /* 896px */
  --container-5xl: 64rem;    /* 1024px */
  --container-6xl: 72rem;    /* 1152px */
  --container-7xl: 80rem;    /* 1280px */

  /* Border Radius */
  --radius-none: 0;
  --radius-sm:   0.125rem;   /* 2px */
  --radius-base: 0.25rem;    /* 4px */
  --radius-md:   0.375rem;   /* 6px */
  --radius-lg:   0.5rem;     /* 8px */
  --radius-xl:   0.75rem;    /* 12px */
  --radius-2xl:  1rem;       /* 16px */
  --radius-3xl:  1.5rem;     /* 24px */
  --radius-full: 9999px;

  /* ================================
     ELEVATION & DEPTH
     ================================ */
  
  /* Shadows */
  --shadow-xs: 0 1px 2px 0 oklch(0% 0 0 / 0.05);
  --shadow-sm: 0 1px 3px 0 oklch(0% 0 0 / 0.1), 0 1px 2px -1px oklch(0% 0 0 / 0.1);
  --shadow-base: 0 4px 6px -1px oklch(0% 0 0 / 0.1), 0 2px 4px -2px oklch(0% 0 0 / 0.1);
  --shadow-md: 0 10px 15px -3px oklch(0% 0 0 / 0.1), 0 4px 6px -4px oklch(0% 0 0 / 0.1);
  --shadow-lg: 0 20px 25px -5px oklch(0% 0 0 / 0.1), 0 8px 10px -6px oklch(0% 0 0 / 0.1);
  --shadow-xl: 0 25px 50px -12px oklch(0% 0 0 / 0.25);
  --shadow-2xl: 0 25px 50px -12px oklch(0% 0 0 / 0.25);
  
  /* Z-Index Scale */
  --z-hide:     -1;
  --z-base:     0;
  --z-docked:   10;
  --z-dropdown: 1000;
  --z-sticky:   1100;
  --z-banner:   1200;
  --z-overlay:  1300;
  --z-modal:    1400;
  --z-popover:  1500;
  --z-skip:     1600;
  --z-toast:    1700;
  --z-tooltip:  1800;
  --z-max:      2147483647;

  /* ================================
     ANIMATION & TIMING
     ================================ */
  
  /* Durations */
  --duration-instant: 0ms;
  --duration-fast:    150ms;
  --duration-normal:  250ms;
  --duration-slow:    350ms;
  --duration-slower:  500ms;

  /* Easing Functions */
  --ease-linear:     linear;
  --ease-in:         cubic-bezier(0.4, 0, 1, 1);
  --ease-out:        cubic-bezier(0, 0, 0.2, 1);
  --ease-in-out:     cubic-bezier(0.4, 0, 0.2, 1);
  --ease-back:       cubic-bezier(0.68, -0.55, 0.265, 1.55);
  --ease-spring:     cubic-bezier(0.175, 0.885, 0.32, 1.275);

  /* ================================
     ACCESSIBILITY TOKENS
     ================================ */
  
  /* Focus Ring */
  --focus-ring: 0 0 0 2px var(--interactive-focus);
  --focus-ring-offset: 0 0 0 4px var(--surface-base);
  
  /* High Contrast Multipliers */
  --contrast-low:    0.8;
  --contrast-normal: 1;
  --contrast-high:   1.2;
  --contrast-max:    1.5;
}

/* ================================
   LIGHT THEME OVERRIDES
   ================================ */

@media (prefers-color-scheme: light) {
  :root {
    /* Neutral Scale - Inverted for light */
    --surface-base:     oklch(98% 0.01 250);
    --surface-elevated: oklch(95% 0.01 250);
    --surface-high:     oklch(92% 0.01 250);
    --surface-overlay:  oklch(98% 0.01 250 / 0.95);
    
    --text-primary:     oklch(20% 0.02 250);
    --text-secondary:   oklch(45% 0.02 250);
    --text-muted:       oklch(55% 0.02 250);
    --text-inverse:     oklch(95% 0.01 250);
    
    --border-default:   oklch(75% 0.01 250 / 0.3);
    --border-strong:    oklch(65% 0.02 250 / 0.5);
  }
}

/* ================================
   HIGH CONTRAST MODE
   ================================ */

@media (prefers-contrast: high) {
  :root {
    --text-primary: oklch(98% 0.01 250);
    --text-secondary: oklch(90% 0.01 250);
    --border-default: oklch(50% 0.02 250);
    --border-strong: oklch(70% 0.02 250);
    --contrast-multiplier: var(--contrast-high);
  }
}

@media (prefers-contrast: high) and (prefers-color-scheme: light) {
  :root {
    --text-primary: oklch(10% 0.02 250);
    --text-secondary: oklch(25% 0.02 250);
    --border-default: oklch(40% 0.02 250);
    --border-strong: oklch(20% 0.02 250);
  }
}

/* ================================
   REDUCED MOTION
   ================================ */

@media (prefers-reduced-motion: reduce) {
  :root {
    --duration-fast: 0ms;
    --duration-normal: 0ms;
    --duration-slow: 0ms;
    --duration-slower: 0ms;
  }
}

/* ================================
   THEME OVERRIDE CLASSES
   Force themes regardless of system preference
   ================================ */

.theme-light {
  color-scheme: light;
  --surface-base: oklch(98% 0.01 250);
  --surface-elevated: oklch(95% 0.01 250);
  --surface-high: oklch(92% 0.01 250);
  --text-primary: oklch(20% 0.02 250);
  --text-secondary: oklch(45% 0.02 250);
  --text-muted: oklch(55% 0.02 250);
  --border-default: oklch(75% 0.01 250 / 0.3);
  --border-strong: oklch(65% 0.02 250 / 0.5);
}

.theme-dark {
  color-scheme: dark;
  --surface-base: var(--neutral-900);
  --surface-elevated: var(--neutral-800);
  --surface-high: var(--neutral-700);
  --text-primary: var(--neutral-200);
  --text-secondary: var(--neutral-400);
  --text-muted: var(--neutral-500);
  --border-default: oklch(26% 0.02 250 / 0.3);
  --border-strong: oklch(35% 0.02 250 / 0.5);
}

.theme-high-contrast {
  --text-primary: oklch(100% 0 0);
  --text-secondary: oklch(90% 0 0);
  --border-default: oklch(70% 0 0);
  --border-strong: oklch(85% 0 0);
  --surface-elevated: oklch(0% 0 0);
}