/* ==========================================================================
   GOLDEN QUIET THINGS — 3-Layer OKLCH Design Tokens
   Warm Archival Songbook ("Porch Morning" Default) & Candlelit Walnut ("Lantern Night")
   ========================================================================== */

:root {
  /* --- 1. PRIMITIVE TOKENS (Warm Candlelit Walnut, Parchment & Honey Amber) --- */
  --ref-petrol-950: #0f0c09;
  --ref-petrol-900: #16120e;
  --ref-petrol-850: #1f1914;
  --ref-petrol-800: #29211a;
  --ref-petrol-700: #382d23;
  --ref-petrol-600: #4c3d30;

  --ref-amber-200: #f5dfb0;
  --ref-amber-300: #ecc87c;
  --ref-amber-400: #e2b45b;
  --ref-amber-500: #cc983f;
  --ref-amber-600: #b48030;
  --ref-amber-700: #8c5d19;
  --ref-amber-800: #6d460f;

  --ref-parchment-50: #fbf7f0;
  --ref-parchment-100: #f5eee1;
  --ref-parchment-200: #ebe1cf;
  --ref-parchment-300: #ddd0b9;

  --ref-slate-300: #d5c7b2;
  --ref-slate-400: #a89882;
  --ref-slate-500: #8a7964;
  --ref-ink-900: #221a13;
  --ref-ink-700: #4e4033;
  --ref-ink-500: #756452;

  /* --- TYPOGRAPHY LADDER (Strict 5-Step Scale) --- */
  --font-display: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;

  --text-xs: 0.75rem;                         /* 12px — archival labels, timestamps */
  --text-sm: 0.875rem;                        /* 14px — secondary UI, captions */
  --text-base: 1.0625rem;                     /* 17px — narrative prose & liner notes */
  --text-xl: clamp(1.65rem, 2.5vw, 2.2rem);   /* 26-35px — chapter & section heads */
  --text-display: clamp(2.45rem, 4.1vw, 3.75rem); /* 39-60px — 2-3 lines max, >2.2x jump */

  /* --- SPACING RHYTHM SCALE --- */
  --space-xs: 0.25rem;   /* 4px */
  --space-sm: 0.5rem;    /* 8px */
  --space-md: 1rem;      /* 16px */
  --space-lg: 1.5rem;    /* 24px */
  --space-xl: 2rem;      /* 32px */
  --space-2xl: 3rem;     /* 48px */
  --space-3xl: 4.5rem;   /* 72px */
  --space-4xl: 7rem;     /* 112px */

  /* --- VARIED BORDER-RADIUS SCALE --- */
  --radius-sm: 4px;      /* inputs, filter chips, badges */
  --radius-md: 8px;      /* buttons, album sleeves, thumbnails */
  --radius-lg: 14px;     /* screening aperture, featured panels */
  --radius-pill: 9999px;

  /* --- MOTION & EASING TOKENS --- */
  --motion-fast: 120ms;
  --motion-base: 200ms;
  --motion-medium: 280ms;
  --motion-slow: 400ms;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-emphasized: cubic-bezier(0.2, 0, 0, 1);

  /* --- Z-INDEX SEMANTIC SCALE --- */
  --z-base: 1;
  --z-sticky: 20;
  --z-drawer: 30;
  --z-modal: 40;
  --z-toast: 50;
}

@supports (color: oklch(0% 0 0)) {
  :root {
    /* Warm Roasted Walnut & Mahogany Ramp (Hue 62°–68° instead of cold 218°) */
    --ref-petrol-950: oklch(15% 0.014 62);
    --ref-petrol-900: oklch(18.5% 0.018 64);
    --ref-petrol-850: oklch(22% 0.022 65);
    --ref-petrol-800: oklch(25.5% 0.025 66);
    --ref-petrol-700: oklch(30% 0.028 66);
    --ref-amber-300: oklch(84% 0.118 80);
    --ref-amber-400: oklch(79% 0.130 76);
    --ref-amber-500: oklch(71% 0.128 72);
    --ref-amber-600: oklch(63% 0.118 70);
    --ref-amber-700: oklch(51% 0.114 66);
    --ref-parchment-50: oklch(97.5% 0.014 84);
    --ref-parchment-100: oklch(94.5% 0.021 82);
    --ref-parchment-200: oklch(89.5% 0.026 80);
  }
}

@media (color-gamut: p3) {
  @supports (color: oklch(0% 0 0)) {
    :root {
      --ref-amber-400: oklch(79% 0.145 76);
      --ref-amber-700: oklch(51% 0.130 66);
    }
  }
}

/* --- 2. SEMANTIC THEME TOKENS: PORCH MORNING (Warm Archival Songbook — DEFAULT) --- */
:root,
[data-theme="morning"] {
  color-scheme: light;
  --surface-primary: var(--ref-parchment-100);
  --surface-secondary: var(--ref-parchment-200);
  --surface-elevated: var(--ref-parchment-50);
  --surface-glass: rgba(245, 238, 225, 0.88);
  --surface-tint: rgba(140, 93, 25, 0.07);
  --surface-hover: rgba(34, 26, 19, 0.05);

  --text-primary: var(--ref-ink-900);
  --text-secondary: var(--ref-ink-700);
  --text-tertiary: var(--ref-ink-500);
  --text-muted: var(--ref-ink-500);
  --text-on-accent: var(--ref-parchment-50);

  --accent-primary: var(--ref-amber-700);
  --accent-hover: var(--ref-amber-800);
  --accent-subtle: rgba(140, 93, 25, 0.12);

  --border-hairline: rgba(34, 26, 19, 0.12);
  --border-accent: rgba(140, 93, 25, 0.32);
  --img-outline: rgba(34, 26, 19, 0.10);

  --shadow-elevated: 0 10px 28px -8px rgba(34, 26, 19, 0.10), 0 2px 6px rgba(34, 26, 19, 0.05);
  --lantern-glow: radial-gradient(circle at 72% 34%, rgba(204, 152, 63, 0.15) 0%, rgba(140, 93, 25, 0.04) 48%, transparent 70%);
}

/* --- 2B. SEMANTIC THEME TOKENS: LANTERN NIGHT (Warm Candlelit Walnut & Velvet) --- */
[data-theme="night"] {
  color-scheme: dark;
  --surface-primary: var(--ref-petrol-900);
  --surface-secondary: var(--ref-petrol-850);
  --surface-elevated: var(--ref-petrol-800);
  --surface-glass: rgba(22, 18, 14, 0.86);
  --surface-tint: rgba(226, 180, 91, 0.08);
  --surface-hover: rgba(245, 238, 225, 0.05);

  --text-primary: var(--ref-parchment-100);
  --text-secondary: var(--ref-slate-300);
  --text-tertiary: var(--ref-slate-400);
  --text-muted: var(--ref-slate-400);
  --text-on-accent: var(--ref-petrol-950);

  --accent-primary: var(--ref-amber-400);
  --accent-hover: var(--ref-amber-300);
  --accent-subtle: rgba(226, 180, 91, 0.15);

  --border-hairline: rgba(245, 238, 225, 0.11);
  --border-accent: rgba(226, 180, 91, 0.34);
  --img-outline: rgba(245, 238, 225, 0.10);

  --shadow-elevated: 0 0 0 1px rgba(245, 238, 225, 0.07), 0 20px 44px -12px rgba(8, 6, 4, 0.72);
  --lantern-glow: radial-gradient(circle at 72% 34%, rgba(226, 180, 91, 0.17) 0%, rgba(180, 128, 48, 0.06) 45%, transparent 72%);
}

/* --- REDUCED MOTION CONTRACT --- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
