/* ═══════════════════════════════════════════════════════════════
   EvolvedSense design tokens (2026-11-24)
   The single source of colour, type, spacing, radius, shadow and motion for every
   web surface: product websites and the account servers. Products set only their
   brand colour (--brand, --brand-hover, --brand-soft) in the page head; everything
   else derives from these tokens. Light by default; dark with
   <html data-theme="dark"> or the visitor's system preference when data-theme="auto".
   Legacy names used by older stylesheets are aliased at the bottom — new CSS must
   use the --es-* names.
   ═══════════════════════════════════════════════════════════════ */

:root {
  /* Brand (overridden per product) */
  --brand:        #1677E6;
  --brand-hover:  #1262BF;
  --brand-soft:   #EFF6FF;
  --brand-contrast: #FFFFFF;

  /* Neutral scale (slate) */
  --es-gray-0:   #FFFFFF;
  --es-gray-25:  #FCFDFE;
  --es-gray-50:  #F8FAFC;
  --es-gray-100: #F1F5F9;
  --es-gray-200: #E2E8F0;
  --es-gray-300: #CBD5E1;
  --es-gray-400: #94A3B8;
  --es-gray-500: #64748B;
  --es-gray-600: #475569;
  --es-gray-700: #334155;
  --es-gray-800: #1E293B;
  --es-gray-900: #0F172A;
  --es-gray-950: #020617;

  /* Semantic surfaces and text */
  --es-bg:            var(--es-gray-50);
  --es-surface:       var(--es-gray-0);
  --es-surface-2:     var(--es-gray-100);
  --es-surface-inverse: var(--es-gray-900);
  --es-border:        var(--es-gray-200);
  --es-border-strong: var(--es-gray-300);
  --es-text:          var(--es-gray-900);
  --es-text-2:        var(--es-gray-600);
  --es-text-3:        var(--es-gray-500);
  --es-text-inverse:  var(--es-gray-0);
  --es-focus:         color-mix(in srgb, var(--brand) 45%, transparent);

  /* Status */
  --es-success: #059669;  --es-success-soft: #ECFDF5;
  --es-warning: #D97706;  --es-warning-soft: #FFFBEB;
  --es-danger:  #DC2626;  --es-danger-soft:  #FEF2F2;
  --es-info:    #2563EB;  --es-info-soft:    #EFF6FF;

  /* Type */
  --es-font: 'Inter', 'Segoe UI Variable', 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  --es-font-mono: 'Cascadia Code', 'JetBrains Mono', ui-monospace, Consolas, monospace;
  --es-text-xs:   0.75rem;
  --es-text-sm:   0.875rem;
  --es-text-md:   1rem;
  --es-text-lg:   1.125rem;
  --es-text-xl:   1.25rem;
  --es-text-2xl:  1.5rem;
  --es-text-3xl:  1.875rem;
  --es-text-4xl:  2.25rem;
  --es-text-5xl:  clamp(2.25rem, 4vw + 1rem, 3.5rem);
  --es-leading-tight: 1.2;
  --es-leading: 1.6;

  /* Spacing (4px grid) */
  --es-space-1: 0.25rem;  --es-space-2: 0.5rem;   --es-space-3: 0.75rem;
  --es-space-4: 1rem;     --es-space-5: 1.25rem;  --es-space-6: 1.5rem;
  --es-space-8: 2rem;     --es-space-10: 2.5rem;  --es-space-12: 3rem;
  --es-space-16: 4rem;    --es-space-20: 5rem;    --es-space-24: 6rem;

  /* Radius, shadow, motion, layers */
  --es-radius-sm: 6px;  --es-radius: 10px;  --es-radius-lg: 14px;  --es-radius-xl: 20px;  --es-radius-full: 9999px;
  --es-shadow-xs: 0 1px 2px rgb(15 23 42 / 0.05);
  --es-shadow-sm: 0 1px 3px rgb(15 23 42 / 0.08), 0 1px 2px rgb(15 23 42 / 0.04);
  --es-shadow-md: 0 6px 16px -4px rgb(15 23 42 / 0.10), 0 2px 6px -2px rgb(15 23 42 / 0.06);
  --es-shadow-lg: 0 18px 40px -12px rgb(15 23 42 / 0.18);
  --es-ease: cubic-bezier(0.4, 0, 0.2, 1);
  --es-fast: 120ms;  --es-normal: 200ms;
  --es-z-header: 100;  --es-z-dropdown: 200;  --es-z-modal: 400;  --es-z-toast: 500;

  /* Layout */
  --es-container: 1200px;
  --es-container-narrow: 760px;
  --es-header-h: 64px;
  --es-sidebar-w: 260px;

  color-scheme: light;
}

:root[data-theme="dark"] {
  --es-bg:            #0B1220;
  --es-surface:       #111A2B;
  --es-surface-2:     #172236;
  --es-surface-inverse: var(--es-gray-50);
  --es-border:        #24324A;
  --es-border-strong: #33435F;
  --es-text:          #E6EDF7;
  --es-text-2:        #A9B6CA;
  --es-text-3:        #7F8DA3;
  --es-text-inverse:  var(--es-gray-900);
  --brand-soft:       color-mix(in srgb, var(--brand) 18%, transparent);
  --es-success-soft: rgb(5 150 105 / 0.15);
  --es-warning-soft: rgb(217 119 6 / 0.15);
  --es-danger-soft:  rgb(220 38 38 / 0.15);
  --es-info-soft:    rgb(37 99 235 / 0.15);
  --es-shadow-sm: 0 1px 3px rgb(0 0 0 / 0.4);
  --es-shadow-md: 0 8px 20px -6px rgb(0 0 0 / 0.5);
  --es-shadow-lg: 0 20px 44px -12px rgb(0 0 0 / 0.6);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --es-bg:            #0B1220;
    --es-surface:       #111A2B;
    --es-surface-2:     #172236;
    --es-surface-inverse: var(--es-gray-50);
    --es-border:        #24324A;
    --es-border-strong: #33435F;
    --es-text:          #E6EDF7;
    --es-text-2:        #A9B6CA;
    --es-text-3:        #7F8DA3;
    --es-text-inverse:  var(--es-gray-900);
    --brand-soft:       color-mix(in srgb, var(--brand) 18%, transparent);
    --es-success-soft: rgb(5 150 105 / 0.15);
    --es-warning-soft: rgb(217 119 6 / 0.15);
    --es-danger-soft:  rgb(220 38 38 / 0.15);
    --es-info-soft:    rgb(37 99 235 / 0.15);
    color-scheme: dark;
  }
}

@media (prefers-reduced-motion: reduce) {
  :root { --es-fast: 0ms; --es-normal: 0ms; }
}

/* Legacy aliases (older stylesheets). Do not use in new CSS. */
:root, :root[data-theme] {
  --primary:        var(--brand);
  --primary-hover:  var(--brand-hover);
  --primary-light:  var(--brand-soft);
  --text:           var(--es-text);
  --text-secondary: var(--es-text-2);
  --text-muted:     var(--es-text-3);
  --bg:             var(--es-bg);
  --surface:        var(--es-surface);
  --card-bg:        var(--es-surface);
  --border:         var(--es-border);
  --success:        var(--es-success);
  --danger:         var(--es-danger);
  --error:          var(--es-danger);
  --error-bg:       var(--es-danger-soft);
  --success-bg:     var(--es-success-soft);
  --info-bg:        var(--es-info-soft);
  --font:           var(--es-font);
  --font-sans:      var(--es-font);
}
