/* ==========================================================================
   OTIUM & NOVA Design System — Tokens
   Single source of truth for palette, semantic surfaces, spacing, radii,
   typography, and Apple-grade motion curves.
   Token architecture inspired by Astryx (MIT, Meta Platforms, Inc. 2026).
   ========================================================================== */

:root {
  /* ------------------------------------------------------------------------
     1. Brand Palette (Raw Stops — Theme Layer Only)
     ------------------------------------------------------------------------ */
  --otium-night: #101223;
  --otium-surface: #16192E;
  --otium-indigo: #1C2040;
  --otium-sun: #FFE9A8;
  --otium-sun-ink: #8A6510;
  --otium-ivory: #F4F1EA;
  --otium-ivory-raised: #FAF8F3;
  --otium-muted-dark: #98989A;
  --otium-muted-light: #525568;
  --otium-border-dark: rgba(244, 241, 234, 0.11);
  --otium-border-dark-solid: #2D2F3D;
  --otium-border-light: rgba(16, 18, 35, 0.12);
  --otium-border-light-solid: #D8D5CE;

  /* Restrained Semantic Status Palette */
  --otium-pass-dark: #34D399;
  --otium-pass-light: #15803D;
  --otium-warn-dark: #F59E0B;
  --otium-warn-light: #B45309;
  --otium-danger-dark: #F87171;
  --otium-danger-light: #B91C1C;

  /* ------------------------------------------------------------------------
     2. Spacing Scale (4px / 0.25rem Base Grid)
     ------------------------------------------------------------------------ */
  --space-0: 0;
  --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-14: 3.5rem;   /* 56px */
  --space-16: 4rem;     /* 64px */
  --space-20: 5rem;     /* 80px */
  --space-24: 6rem;     /* 96px */

  /* ------------------------------------------------------------------------
     3. Concentric Radii Ladder
     ------------------------------------------------------------------------ */
  --radius-none: 0px;
  --radius-control: 8px;
  --radius-card: 16px;
  --radius-still-card: 20px;
  --radius-panel: 24px;
  --radius-pill: 9999px;

  /* ------------------------------------------------------------------------
     4. Typography & Mixed-Script Stacks
     ------------------------------------------------------------------------ */
  --font-sans: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, "Noto Sans KR", "Apple SD Gothic Neo", sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", ui-monospace, SFMono-Regular,
    Menlo, Consolas, "Pretendard Variable", "Noto Sans KR", monospace;

  --text-xs: 0.75rem;     /* 12px */
  --text-sm: 0.875rem;    /* 14px */
  --text-base: 1rem;      /* 16px */
  --text-lg: 1.125rem;    /* 18px */
  --text-xl: 1.25rem;     /* 20px */
  --text-2xl: 1.5rem;     /* 24px */
  --text-3xl: 2rem;       /* 32px */
  --text-4xl: 2.5rem;     /* 40px */
  --text-display: clamp(2.25rem, 4.5vw, 3.5rem);

  --leading-tight: 1.2;
  --leading-snug: 1.35;
  --leading-normal: 1.6;
  --leading-relaxed: 1.75;

  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  --tracking-tight: -0.02em;
  --tracking-normal: 0;
  --tracking-wide: 0.04em;
  --tracking-label: 0.08em;

  /* ------------------------------------------------------------------------
     5. Motion Curves & Durations (Apple Deceleration Standard)
     ------------------------------------------------------------------------ */
  --ease-apple: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-exit: cubic-bezier(0.4, 0, 1, 1);

  --dur-fast: 160ms;
  --dur-base: 320ms;
  --dur-slow: 540ms;
  --dur-eclipse: 2400ms;

  /* ------------------------------------------------------------------------
     6. Layout & Focus Geometry
     ------------------------------------------------------------------------ */
  --container-max: 1160px;
  --container-narrow: 840px;
  --border-width: 1px;
  --focus-width: 2px;
  --focus-offset: 3px;

  /* ------------------------------------------------------------------------
     7. Default Semantic Surface Roles (Dark Nocturnal Default)
     ------------------------------------------------------------------------ */
  --color-bg-canvas: var(--otium-night);
  --color-bg-surface: var(--otium-surface);
  --color-bg-elevated: var(--otium-indigo);
  --color-bg-card: var(--otium-surface);
  --color-bg-interactive: rgba(244, 241, 234, 0.06);
  --color-bg-interactive-hover: rgba(244, 241, 234, 0.11);

  --color-text-primary: var(--otium-ivory);
  --color-text-secondary: var(--otium-muted-dark);
  --color-text-accent: var(--otium-sun);
  --color-on-accent: var(--otium-night);

  --color-border-subtle: var(--otium-border-dark);
  --color-border-strong: rgba(244, 241, 234, 0.22);
  --color-border-control: rgba(244, 241, 234, 0.26);

  --color-accent: var(--otium-sun);
  --color-accent-muted: rgba(255, 233, 168, 0.14);

  --color-success: var(--otium-pass-dark);
  --color-success-muted: rgba(52, 211, 153, 0.14);
  --color-warning: var(--otium-warn-dark);
  --color-warning-muted: rgba(245, 158, 11, 0.15);
  --color-danger: var(--otium-danger-dark);
  --color-danger-muted: rgba(248, 113, 113, 0.15);

  --color-focus-ring: var(--otium-sun);
  --shadow-low: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-med: 0 12px 32px rgba(4, 6, 18, 0.45);

  /* Semantic Chart Palette (Dark Default) */
  --color-chart-1: #FFE9A8;
  --color-chart-2: #34D399;
  --color-chart-3: #60A5FA;
  --color-chart-4: #F59E0B;
  --color-chart-5: #C084FC;
  --color-chart-6: #F87171;
  --color-chart-grid: rgba(244, 241, 234, 0.11);
  --color-chart-axis: #98989A;
  --color-chart-band-1: rgba(255, 233, 168, 0.18);
  --color-chart-band-2: rgba(96, 165, 250, 0.18);
  --color-chart-surface: #121528;
  --color-chart-map-bg: #1A1E36;
}

/* Explicit Dark Surface Scope */
[data-surface="dark"] {
  color-scheme: dark;
  --color-bg-canvas: var(--otium-night);
  --color-bg-surface: var(--otium-surface);
  --color-bg-elevated: var(--otium-indigo);
  --color-bg-card: var(--otium-surface);
  --color-bg-interactive: rgba(244, 241, 234, 0.06);
  --color-bg-interactive-hover: rgba(244, 241, 234, 0.11);

  --color-text-primary: var(--otium-ivory);
  --color-text-secondary: var(--otium-muted-dark);
  --color-text-accent: var(--otium-sun);
  --color-on-accent: var(--otium-night);

  --color-border-subtle: var(--otium-border-dark);
  --color-border-strong: rgba(244, 241, 234, 0.22);
  --color-border-control: rgba(244, 241, 234, 0.26);

  --color-accent: var(--otium-sun);
  --color-accent-muted: rgba(255, 233, 168, 0.14);

  --color-success: var(--otium-pass-dark);
  --color-success-muted: rgba(52, 211, 153, 0.14);
  --color-warning: var(--otium-warn-dark);
  --color-warning-muted: rgba(245, 158, 11, 0.15);
  --color-danger: var(--otium-danger-dark);
  --color-danger-muted: rgba(248, 113, 113, 0.15);

  --color-focus-ring: var(--otium-sun);
  --shadow-low: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-med: 0 12px 32px rgba(4, 6, 18, 0.45);

  --color-chart-1: #FFE9A8;
  --color-chart-2: #34D399;
  --color-chart-3: #60A5FA;
  --color-chart-4: #F59E0B;
  --color-chart-5: #C084FC;
  --color-chart-6: #F87171;
  --color-chart-grid: rgba(244, 241, 234, 0.11);
  --color-chart-axis: #98989A;
  --color-chart-band-1: rgba(255, 233, 168, 0.18);
  --color-chart-band-2: rgba(96, 165, 250, 0.18);
  --color-chart-surface: #121528;
  --color-chart-map-bg: #1A1E36;
}

/* Explicit Light Editorial Surface Scope */
[data-surface="light"] {
  color-scheme: light;
  --color-bg-canvas: var(--otium-ivory);
  --color-bg-surface: var(--otium-ivory-raised);
  --color-bg-elevated: #FFFFFF;
  --color-bg-card: var(--otium-ivory-raised);
  --color-bg-interactive: rgba(16, 18, 35, 0.04);
  --color-bg-interactive-hover: rgba(16, 18, 35, 0.08);

  --color-text-primary: var(--otium-night);
  --color-text-secondary: var(--otium-muted-light);
  --color-text-accent: var(--otium-sun-ink);
  --color-on-accent: var(--otium-ivory-raised);

  --color-border-subtle: var(--otium-border-light);
  --color-border-strong: rgba(16, 18, 35, 0.24);
  --color-border-control: rgba(16, 18, 35, 0.32);

  --color-accent: var(--otium-sun-ink);
  --color-accent-muted: rgba(138, 101, 16, 0.11);

  --color-success: var(--otium-pass-light);
  --color-success-muted: rgba(21, 128, 61, 0.10);
  --color-warning: var(--otium-warn-light);
  --color-warning-muted: rgba(180, 83, 9, 0.11);
  --color-danger: var(--otium-danger-light);
  --color-danger-muted: rgba(185, 28, 28, 0.10);

  --color-focus-ring: var(--otium-sun-ink);
  --shadow-low: 0 1px 2px rgba(16, 18, 35, 0.06);
  --shadow-med: 0 12px 28px rgba(16, 18, 35, 0.09);

  --color-chart-1: #1D4ED8;
  --color-chart-2: #15803D;
  --color-chart-3: #8A6510;
  --color-chart-4: #B45309;
  --color-chart-5: #7C3AED;
  --color-chart-6: #B91C1C;
  --color-chart-grid: rgba(16, 18, 35, 0.12);
  --color-chart-axis: #525568;
  --color-chart-band-1: rgba(29, 78, 216, 0.14);
  --color-chart-band-2: rgba(21, 128, 61, 0.14);
  --color-chart-surface: #FFFFFF;
  --color-chart-map-bg: #E5E7EB;
}

/* Tabular Numerals Utility Token Class */
.tabular-nums {
  font-variant-numeric: tabular-nums;
}

/* Reduced Motion Override Contract */
@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-fast: 0.01ms;
    --dur-base: 0.01ms;
    --dur-slow: 0.01ms;
    --dur-eclipse: 0ms;
  }
}
