/* =============================================================================
   DESIGN TOKENS — Modern advanced color system + spacing + typography scale
   ============================================================================= */

:root {

  /* ---------------------------------------------------------------------------
     COLOR PALETTE — Indigo-Violet primary with Cyan accent
     Inspired by premium editorial publications
  --------------------------------------------------------------------------- */

  /* Brand Primary — Deep Indigo to Violet gradient */
  --color-primary-50:  #EEF2FF;
  --color-primary-100: #E0E7FF;
  --color-primary-200: #C7D2FE;
  --color-primary-300: #A5B4FC;
  --color-primary-400: #818CF8;
  --color-primary-500: #6366F1;   /* Main brand color */
  --color-primary-600: #4F46E5;   /* Hover state */
  --color-primary-700: #4338CA;   /* Active/pressed */
  --color-primary-800: #3730A3;
  --color-primary-900: #312E81;

  /* Brand Secondary — Violet */
  --color-violet-400: #A78BFA;
  --color-violet-500: #8B5CF6;
  --color-violet-600: #7C3AED;

  /* Accent — Cyan / Teal for CTA highlights */
  --color-accent-400: #22D3EE;
  --color-accent-500: #06B6D4;
  --color-accent-600: #0891B2;

  /* Emerald — Success, tags, badges */
  --color-emerald-400: #34D399;
  --color-emerald-500: #10B981;
  --color-emerald-600: #059669;

  /* Amber — Warnings, featured */
  --color-amber-400: #FBBF24;
  --color-amber-500: #F59E0B;

  /* Rose — Error, alerts */
  --color-rose-400: #FB7185;
  --color-rose-500: #F43F5E;

  /* ---------------------------------------------------------------------------
     SEMANTIC COLORS — Light Theme (default)
  --------------------------------------------------------------------------- */

  /* Backgrounds */
  --color-bg:           #F8FAFF;   /* Slightly blue-tinted white — premium feel */
  --color-bg-secondary: #F1F5F9;   /* Section backgrounds */
  --color-surface:      #FFFFFF;   /* Cards, panels */
  --color-surface-hover:#F5F7FF;   /* Card hover background */
  --color-surface-raised: #FFFFFF; /* Elevated surfaces with shadow */

  /* Text */
  --color-text:         #0F172A;   /* Slate-900, near black */
  --color-text-secondary: #334155; /* Slate-700 */
  --color-text-muted:   #64748B;   /* Slate-500 */
  --color-text-disabled: #94A3B8;  /* Slate-400 */
  --color-text-inverse: #FFFFFF;

  /* Brand usage */
  --color-brand:        var(--color-primary-500);
  --color-brand-hover:  var(--color-primary-600);
  --color-brand-active: var(--color-primary-700);
  --color-brand-subtle: var(--color-primary-50);
  --color-brand-text:   var(--color-primary-600);

  /* Accent usage */
  --color-accent:       var(--color-accent-500);
  --color-accent-hover: var(--color-accent-600);

  /* Borders */
  --color-border:       #E2E8F0;   /* Slate-200 */
  --color-border-strong:#CBD5E1;   /* Slate-300 */
  --color-border-brand: var(--color-primary-300);

  /* Focus ring */
  --color-focus:        var(--color-primary-500);

  /* Gradients */
  --gradient-brand:     linear-gradient(135deg, var(--color-primary-500) 0%, var(--color-violet-500) 100%);
  --gradient-brand-hover: linear-gradient(135deg, var(--color-primary-600) 0%, var(--color-violet-600) 100%);
  --gradient-hero:      linear-gradient(135deg, #0F172A 0%, #1E1B4B 50%, #312E81 100%);
  --gradient-card-top:  linear-gradient(180deg, var(--color-primary-50) 0%, transparent 100%);
  --gradient-accent:    linear-gradient(90deg, var(--color-accent-500) 0%, var(--color-primary-500) 100%);
  --gradient-text:      linear-gradient(135deg, var(--color-primary-600) 0%, var(--color-violet-500) 100%);

  /* Glow effects */
  --glow-brand:         0 0 40px rgba(99, 102, 241, 0.25);
  --glow-accent:        0 0 30px rgba(6, 182, 212, 0.2);

  /* ---------------------------------------------------------------------------
     SHADOWS — Multi-layer, natural feeling
  --------------------------------------------------------------------------- */

  --shadow-xs:   0 1px 2px 0 rgba(15, 23, 42, 0.05);
  --shadow-sm:   0 1px 3px 0 rgba(15, 23, 42, 0.08), 0 1px 2px -1px rgba(15, 23, 42, 0.06);
  --shadow-md:   0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.06);
  --shadow-lg:   0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.05);
  --shadow-xl:   0 20px 25px -5px rgba(15, 23, 42, 0.08), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
  --shadow-2xl:  0 25px 50px -12px rgba(15, 23, 42, 0.18);
  --shadow-inner: inset 0 2px 4px 0 rgba(15, 23, 42, 0.06);

  /* Brand-tinted shadow for cards on hover */
  --shadow-brand: 0 20px 40px -12px rgba(99, 102, 241, 0.2), 0 8px 16px -8px rgba(99, 102, 241, 0.15);
  --shadow-accent: 0 10px 30px -8px rgba(6, 182, 212, 0.3);

  /* Header glass shadow */
  --shadow-header: 0 1px 0 rgba(15, 23, 42, 0.05), 0 2px 20px rgba(15, 23, 42, 0.06);

  /* ---------------------------------------------------------------------------
     TYPOGRAPHY
  --------------------------------------------------------------------------- */

  --font-sans:   'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-serif:  'Playfair Display', 'Georgia', ui-serif, serif;
  --font-mono:   'JetBrains Mono', 'Fira Code', ui-monospace, monospace;

  /* Fluid type scale — clamp(min, preferred, max) */
  --text-xs:    clamp(0.69rem, 0.66rem + 0.18vw, 0.75rem);
  --text-sm:    clamp(0.83rem, 0.78rem + 0.24vw, 0.938rem);
  --text-base:  clamp(1rem, 0.95rem + 0.24vw, 1.125rem);
  --text-lg:    clamp(1.2rem, 1.1rem + 0.5vw, 1.4rem);
  --text-xl:    clamp(1.44rem, 1.28rem + 0.8vw, 1.75rem);
  --text-2xl:   clamp(1.73rem, 1.5rem + 1.15vw, 2.25rem);
  --text-3xl:   clamp(2.07rem, 1.8rem + 1.35vw, 2.75rem);
  --text-4xl:   clamp(2.49rem, 2.1rem + 1.9vw, 3.5rem);
  --text-5xl:   clamp(3rem, 2.5rem + 2.5vw, 4.5rem);

  /* Line heights */
  --leading-none:   1;
  --leading-tight:  1.2;
  --leading-snug:   1.375;
  --leading-normal: 1.5;
  --leading-relaxed: 1.75;  /* Optimal for long-form reading */
  --leading-loose:  2;

  /* Letter spacing */
  --tracking-tight:  -0.025em;
  --tracking-normal:  0em;
  --tracking-wide:    0.025em;
  --tracking-wider:   0.05em;
  --tracking-widest:  0.1em;

  /* Font weights */
  --font-normal:    400;
  --font-medium:    500;
  --font-semibold:  600;
  --font-bold:      700;
  --font-extrabold: 800;

  /* ---------------------------------------------------------------------------
     SPACING — 4px base unit system
  --------------------------------------------------------------------------- */

  --space-1:   0.25rem;   /*  4px */
  --space-2:   0.5rem;    /*  8px */
  --space-3:   0.75rem;   /* 12px */
  --space-4:   1rem;      /* 16px */
  --space-5:   1.25rem;   /* 20px */
  --space-6:   1.5rem;    /* 24px */
  --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
  --------------------------------------------------------------------------- */

  --content-width:      720px;   /* Optimal reading width ~65-70 chars */
  --content-wide:       1024px;  /* Wide content, featured sections */
  --container-max:      1280px;  /* Page max-width */
  --sidebar-width:      300px;

  /* ---------------------------------------------------------------------------
     BORDERS & RADII
  --------------------------------------------------------------------------- */

  --radius-sm:   4px;
  --radius-md:   8px;
  --radius-lg:   12px;
  --radius-xl:   16px;
  --radius-2xl:  24px;
  --radius-full: 9999px;

  /* ---------------------------------------------------------------------------
     TRANSITIONS
  --------------------------------------------------------------------------- */

  --transition-fast:    150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base:    250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow:    400ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce:  500ms cubic-bezier(0.34, 1.56, 0.64, 1);

  /* ---------------------------------------------------------------------------
     Z-INDEX SCALE
  --------------------------------------------------------------------------- */

  --z-below:    -1;
  --z-base:      0;
  --z-raised:   10;
  --z-dropdown: 100;
  --z-sticky:   200;
  --z-overlay:  300;
  --z-modal:    400;
  --z-toast:    500;

  /* ---------------------------------------------------------------------------
     HEADER
  --------------------------------------------------------------------------- */

  --header-height:        60px;
  --header-height-scroll: 52px;
  --header-bg:            rgba(248, 250, 255, 0.85);
  --header-border:        rgba(226, 232, 240, 0.8);
}

/* ---------------------------------------------------------------------------
   HEADER HEIGHT — desktop override
--------------------------------------------------------------------------- */

@media (min-width: 1024px) {
  :root {
    --header-height:        72px;
    --header-height-scroll: 60px;
  }
}

/* ---------------------------------------------------------------------------
   DARK MODE — system preference (skipped when user forces light via data-theme)
--------------------------------------------------------------------------- */

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --color-bg:            #0B0F1A;
    --color-bg-secondary:  #111827;
    --color-surface:       #161D2F;
    --color-surface-hover: #1E2840;
    --color-surface-raised:#1A2235;

    --color-text:          #F1F5F9;
    --color-text-secondary:#CBD5E1;
    --color-text-muted:    #94A3B8;
    --color-text-disabled: #64748B;

    --color-border:        #1E293B;
    --color-border-strong: #334155;
    --color-border-brand:  rgba(129, 140, 248, 0.4);

    /* Brand colors — brighter in dark mode for contrast */
    --color-brand:         #818CF8;   /* indigo-400 — visible on dark bg */
    --color-brand-hover:   #A5B4FC;   /* indigo-300 */
    --color-brand-text:    #A5B4FC;   /* indigo-300 — readable on dark surface */
    --color-brand-subtle:  rgba(99, 102, 241, 0.15);

    --shadow-sm:    0 1px 3px 0 rgba(0, 0, 0, 0.4);
    --shadow-md:    0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg:    0 10px 15px -3px rgba(0, 0, 0, 0.4);
    --shadow-xl:    0 20px 25px -5px rgba(0, 0, 0, 0.5);
    --shadow-brand: 0 20px 40px -12px rgba(99, 102, 241, 0.35);

    --header-bg:     rgba(11, 15, 26, 0.9);
    --header-border: rgba(30, 41, 59, 0.9);

    --gradient-hero: linear-gradient(135deg, #060912 0%, #0F0E2A 50%, #1A1545 100%);
  }
}

/* ---------------------------------------------------------------------------
   DARK MODE — manual override via JS toggle (data-theme="dark" on <html>)
   Identical vars to the media query above so both paths render the same.
--------------------------------------------------------------------------- */

html[data-theme="dark"] {
  --color-bg:            #0B0F1A;
  --color-bg-secondary:  #111827;
  --color-surface:       #161D2F;
  --color-surface-hover: #1E2840;
  --color-surface-raised:#1A2235;

  --color-text:          #F1F5F9;
  --color-text-secondary:#CBD5E1;
  --color-text-muted:    #94A3B8;
  --color-text-disabled: #64748B;

  --color-border:        #1E293B;
  --color-border-strong: #334155;
  --color-border-brand:  rgba(129, 140, 248, 0.4);

  --color-brand:         #818CF8;
  --color-brand-hover:   #A5B4FC;
  --color-brand-text:    #A5B4FC;
  --color-brand-subtle:  rgba(99, 102, 241, 0.15);

  --shadow-sm:    0 1px 3px 0 rgba(0, 0, 0, 0.4);
  --shadow-md:    0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg:    0 10px 15px -3px rgba(0, 0, 0, 0.4);
  --shadow-xl:    0 20px 25px -5px rgba(0, 0, 0, 0.5);
  --shadow-brand: 0 20px 40px -12px rgba(99, 102, 241, 0.35);

  --header-bg:     rgba(11, 15, 26, 0.9);
  --header-border: rgba(30, 41, 59, 0.9);

  --gradient-hero: linear-gradient(135deg, #060912 0%, #0F0E2A 50%, #1A1545 100%);
}

/* ---------------------------------------------------------------------------
   LIGHT MODE — manual override via JS toggle (forces light even on dark OS)
--------------------------------------------------------------------------- */

html[data-theme="light"] {
  --color-bg:           #F8FAFF;
  --color-bg-secondary: #F1F5F9;
  --color-surface:      #FFFFFF;
  --color-surface-hover:#F5F7FF;
  --color-surface-raised: #FFFFFF;

  --color-text:         #0F172A;
  --color-text-secondary: #334155;
  --color-text-muted:   #64748B;
  --color-text-disabled: #94A3B8;

  --color-border:       #E2E8F0;
  --color-border-strong:#CBD5E1;
  --color-border-brand: var(--color-primary-300);

  --color-brand:        var(--color-primary-500);
  --color-brand-hover:  var(--color-primary-600);
  --color-brand-text:   var(--color-primary-600);
  --color-brand-subtle: var(--color-primary-50);

  --shadow-sm:   0 1px 3px 0 rgba(15, 23, 42, 0.08), 0 1px 2px -1px rgba(15, 23, 42, 0.06);
  --shadow-md:   0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.06);
  --shadow-lg:   0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.05);
  --shadow-xl:   0 20px 25px -5px rgba(15, 23, 42, 0.08), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
  --shadow-brand: 0 20px 40px -12px rgba(99, 102, 241, 0.2), 0 8px 16px -8px rgba(99, 102, 241, 0.15);

  --header-bg:     rgba(248, 250, 255, 0.85);
  --header-border: rgba(226, 232, 240, 0.8);
}
