/* ============================================
   DESIGN SYSTEM — CSS Custom Properties
   Advanced: oklch color space, fluid type,
   container queries, custom easing
   ============================================ */

/* --- Color System (oklch for perceptual uniformity) --- */
:root {
  /* Brand palette */
  --brand-hue: 250;
  --brand-sat: 0.3;

  /* Fluid type scale (clamp for perfect scaling) */
  --text-xs:   clamp(0.7rem, 0.65rem + 0.25vw, 0.8rem);
  --text-sm:   clamp(0.8rem, 0.75rem + 0.3vw, 0.9rem);
  --text-base: clamp(0.95rem, 0.9rem + 0.3vw, 1.1rem);
  --text-lg:   clamp(1.1rem, 1rem + 0.5vw, 1.3rem);
  --text-xl:   clamp(1.3rem, 1.1rem + 0.8vw, 1.7rem);
  --text-2xl:  clamp(1.6rem, 1.3rem + 1.2vw, 2.2rem);
  --text-3xl:  clamp(2rem, 1.5rem + 2vw, 3rem);
  --text-4xl:  clamp(2.5rem, 1.8rem + 3vw, 4.5rem);
  --text-hero: clamp(2.5rem, 1.5rem + 3.5vw, 5.5rem);

  /* Spacing scale */
  --space-2xs: clamp(0.25rem, 0.2rem + 0.15vw, 0.35rem);
  --space-xs:  clamp(0.5rem, 0.4rem + 0.3vw, 0.7rem);
  --space-sm:  clamp(0.75rem, 0.6rem + 0.5vw, 1rem);
  --space-md:  clamp(1rem, 0.8rem + 0.8vw, 1.5rem);
  --space-lg:  clamp(1.5rem, 1.2rem + 1.2vw, 2.5rem);
  --space-xl:  clamp(2rem, 1.5rem + 2vw, 3.5rem);
  --space-2xl: clamp(3rem, 2rem + 3vw, 5rem);
  --space-3xl: clamp(4rem, 3rem + 4vw, 8rem);

  /* Layout */
  --content-width: 72rem;
  --narrow-width: 48rem;
  --gutter: var(--space-md);

  /* Borders & Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.5rem;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-color: 0 0% 0%;

  /* Easing (custom cubic-bezier for premium feel) */
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-in-out-quint: cubic-bezier(0.83, 0, 0.17, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);

  /* Transitions */
  --transition-fast: 150ms var(--ease-out-expo);
  --transition-base: 300ms var(--ease-out-expo);
  --transition-slow: 500ms var(--ease-out-expo);
  --transition-slower: 800ms var(--ease-out-quart);

  /* Z-index scale */
  --z-base: 1;
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-overlay: 300;
  --z-modal: 400;
  --z-cursor: 500;
  --z-grain: 600;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-serif: 'Playfair Display', Georgia, serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --line-height-tight: 1.1;
  --line-height-snug: 1.3;
  --line-height-base: 1.6;
  --line-height-relaxed: 1.8;
  --letter-spacing-tight: -0.03em;
  --letter-spacing-normal: 0;
  --letter-spacing-wide: 0.05em;
  --letter-spacing-wider: 0.1em;
}

/* --- Dark Theme (default) — Blood Crimson --- */
[data-theme="dark"] {
  --bg-primary:    #080607;
  --bg-secondary:  #0f0a0b;
  --bg-tertiary:   #1a1214;
  --bg-elevated:   #201518;
  --bg-glass:      rgba(15, 10, 12, 0.75);
  --bg-glass-hover: rgba(40, 22, 26, 0.9);

  --text-primary:   #f2eeef;
  --text-secondary: #b0a0a5;
  --text-tertiary:  #9b8b90;
  --text-inverse:   #080607;

  --accent:         #e63946;
  --accent-hover:   #ff4d5a;
  --accent-subtle:  rgba(230, 57, 70, 0.12);
  --accent-glow:    rgba(230, 57, 70, 0.35);

  --purple:         #8b1a2b;
  --purple-glow:    rgba(139, 26, 43, 0.3);
  --purple-subtle:  rgba(139, 26, 43, 0.12);

  --border:         rgba(255, 255, 255, 0.06);
  --border-hover:   rgba(255, 255, 255, 0.12);
  --border-accent:  rgba(230, 57, 70, 0.35);

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.5);
  --shadow-xl: 0 16px 50px rgba(0,0,0,0.6);
  --shadow-glow: 0 0 40px var(--accent-glow);
  --shadow-purple: 0 0 40px var(--purple-glow);

  --mesh-1: #e63946;
  --mesh-2: #8b1a2b;
  --mesh-3: #6b0f1a;

  --code-bg: #0e0a0b;
  --code-border: rgba(230, 57, 70, 0.1);

  --scrollbar-track: var(--bg-secondary);
  --scrollbar-thumb: #2a1518;
  --scrollbar-thumb-hover: var(--accent);

  --ink-color: rgba(230, 57, 70, 0.08);
  --ink-color-strong: rgba(230, 57, 70, 0.15);}

/* --- Light Theme — Warm Blood Crimson --- */
[data-theme="light"] {
  --bg-primary:    #fdf8f8;
  --bg-secondary:  #f5eeee;
  --bg-tertiary:   #ebe0e0;
  --bg-elevated:   #ffffff;
  --bg-glass:      rgba(255, 255, 255, 0.78);
  --bg-glass-hover: rgba(255, 255, 255, 0.92);

  --text-primary:   #1a0e10;
  --text-secondary: #5a4048;
  --text-tertiary:  #7a6068;
  --text-inverse:   #fdf8f8;

  --accent:         #c2223b;
  --accent-hover:   #a81d33;
  --accent-subtle:  rgba(194, 34, 59, 0.08);
  --accent-glow:    rgba(194, 34, 59, 0.18);

  --purple:         #7a1525;
  --purple-glow:    rgba(122, 21, 37, 0.15);
  --purple-subtle:  rgba(122, 21, 37, 0.08);

  --border:         rgba(0, 0, 0, 0.06);
  --border-hover:   rgba(0, 0, 0, 0.12);
  --border-accent:  rgba(194, 34, 59, 0.3);

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.1);
  --shadow-xl: 0 16px 50px rgba(0,0,0,0.12);
  --shadow-glow: 0 0 40px var(--accent-glow);
  --shadow-purple: 0 0 40px var(--purple-glow);

  --mesh-1: #e63946;
  --mesh-2: #8b1a2b;
  --mesh-3: #6b0f1a;

  --code-bg: #faf5f5;
  --code-border: rgba(230, 57, 70, 0.08);

  --scrollbar-track: var(--bg-secondary);
  --scrollbar-thumb: var(--bg-tertiary);
  --scrollbar-thumb-hover: var(--accent);

  --ink-color: rgba(194, 34, 59, 0.05);
  --ink-color-strong: rgba(194, 34, 59, 0.1);}

/* --- Reset & Base --- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  hanging-punctuation: first last;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--line-height-base);
  color: var(--text-primary);
  background: var(--bg-primary);
  overflow-x: hidden;
  transition: background-color 500ms var(--ease-smooth),
              color 500ms var(--ease-smooth);
}

/* Selection */
::selection {
  background: var(--accent);
  color: white;
}

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}
::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: var(--radius-full);
  transition: background var(--transition-fast);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

/* Focus styles */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* Image defaults */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  border: none;
  background: none;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

/* Utility: visually hidden */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
