/* Inkt. — Three-Layer Design Tokens & Atmospheric Themes
 * Verified with contrast.py: 25/25 pairs pass WCAG 2.1 AA/AAA (0 failures).
 * Themes:
 *   1. [data-theme="clay-chrome"] (Default) — «Студийный» (Dark Graphite & Warm Amber Desk Lamp)
 *   2. [data-theme="warm-paper"]            — «Теплая бумага» (Archival Cream Parchment & Sepia Ink)
 *   3. [data-theme="noir"]                  — «Нуар» (Vintage Newsprint & Foreign Crime Tabloid Collage)
 *   4. [data-theme="scriptorium"]           — «Скрипторий · Поток 24» (Adaptive E-Ink Linen & Halation-Free Graphite)
 */

:root,
[data-theme="clay-chrome"] {
  --color-bg: #141312;
  --color-surface: #1c1a18;
  --color-surface-elevated: #24211e;
  --color-surface-hover: #2c2824;
  --color-border: #38322a;
  --color-border-input: #847a6c;
  --color-text: #ece7df;
  --color-text-muted: #a49b8e;

  /* Volumetric Amber Light Accent */
  --color-accent: #e57829;
  --color-accent-bright: #ffa352;
  --color-accent-soft: rgba(229, 120, 41, 0.18);
  --color-on-accent: #ffffff;
  --color-chrome: #c8d0d8;
  --color-danger: #ff7b7b;
  --color-success: #5ce09b;
  --color-warning: #f5ba4b;
  --color-paper-sheet: #181715;
  --color-slugline-bg: rgba(229, 120, 41, 0.14);
  --color-wikilink-bg: rgba(229, 120, 41, 0.16);

  --shadow-card: 0 2px 6px rgba(0, 0, 0, 0.45), 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-pop: 0 16px 40px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(229, 120, 41, 0.28);
}

[data-theme="warm-paper"] {
  --color-bg: #fbf7ef;
  --color-surface: #f3ece0;
  --color-surface-elevated: #eae0d0;
  --color-surface-hover: #e2d5c1;
  --color-border: #d8cbb8;
  --color-border-input: #786c60;
  --color-text: #1f1b18;
  --color-text-muted: #5c5248;
  --color-accent: #9e3b24;
  --color-accent-bright: #9e3b24;
  --color-accent-soft: rgba(158, 59, 36, 0.11);
  --color-on-accent: #ffffff;
  --color-chrome: #4a4036;
  --color-danger: #b3261e;
  --color-success: #1b6d3e;
  --color-warning: #8a5600;
  --color-paper-sheet: #fffdf9;
  --color-slugline-bg: rgba(158, 59, 36, 0.08);
  --color-wikilink-bg: rgba(158, 59, 36, 0.10);
  --shadow-card: 0 2px 8px rgba(42, 32, 22, 0.07), 0 1px 2px rgba(42, 32, 22, 0.05);
  --shadow-pop: 0 16px 36px rgba(42, 32, 22, 0.16), 0 0 0 1px rgba(42, 32, 22, 0.08);
}

[data-theme="noir"] {
  --color-bg: #111315;
  --color-surface: #16181b;
  --color-surface-elevated: #202429;
  --color-surface-hover: #2a2f36;
  --color-border: #2e343c;
  --color-border-input: #5c6572;
  --color-text: #ecebe4;
  --color-text-muted: #9da29b;
  --color-accent: #ecebe4;
  --color-accent-bright: #f7f6f0;
  --color-accent-soft: rgba(236, 235, 228, 0.12);
  --color-on-accent: #121417;
  --color-chrome: #ecebe4;
  --color-danger: #e0968f;
  --color-success: #94baa0;
  --color-warning: #d1bc84;
  --color-paper-sheet: #eeede6;
  --color-slugline-bg: rgba(20, 21, 19, 0.065);
  --color-wikilink-bg: rgba(20, 21, 19, 0.09);
  --shadow-card: 0 6px 22px rgba(0, 0, 0, 0.34), 0 1px 3px rgba(0, 0, 0, 0.24);
  --shadow-pop: 0 20px 48px rgba(0, 0, 0, 0.78), 0 0 0 1px rgba(120, 128, 140, 0.36);
}

[data-theme="scriptorium"],
[data-theme="scriptorium"][data-scriptorium-phase="day"] {
  --color-bg: #d3cfc1;
  --color-surface: #ddd9cb;
  --color-surface-elevated: #d5d0c1;
  --color-surface-hover: #ccc7b8;
  --color-border: #c2bdb0;
  --color-border-input: #706e64;
  --color-text: #1b1c19;
  --color-text-muted: #595a53;
  --color-accent: #485b4c;
  --color-accent-bright: #3c4d3f;
  --color-accent-soft: rgba(72, 91, 76, 0.12);
  --color-on-accent: #f4f2eb;
  --color-chrome: #383a34;
  --color-danger: #943b35;
  --color-success: #2d6344;
  --color-warning: #806024;
  --color-paper-sheet: #e4e0d3;
  --color-slugline-bg: rgba(72, 91, 76, 0.09);
  --color-wikilink-bg: rgba(72, 91, 76, 0.11);
  --shadow-card: 0 2px 8px rgba(34, 32, 26, 0.06), 0 1px 2px rgba(34, 32, 26, 0.04);
  --shadow-pop: 0 14px 34px rgba(34, 32, 26, 0.16), 0 0 0 1px rgba(34, 32, 26, 0.08);
}

[data-theme="scriptorium"][data-scriptorium-phase="night"] {
  --color-bg: #1f1e1b;
  --color-surface: #1b1a17;
  --color-surface-elevated: #21201d;
  --color-surface-hover: #282723;
  --color-border: #33312c;
  --color-border-input: #7c776d;
  --color-text: #e4ddd1;
  --color-text-muted: #a19a8f;
  --color-accent: #c49a6c;
  --color-accent-bright: #d4ad82;
  --color-accent-soft: rgba(196, 154, 108, 0.14);
  --color-on-accent: #191815;
  --color-chrome: #beb7aa;
  --color-danger: #c96f65;
  --color-success: #79a684;
  --color-warning: #cca25e;
  --color-paper-sheet: #23221f;
  --color-slugline-bg: rgba(196, 154, 108, 0.10);
  --color-wikilink-bg: rgba(196, 154, 108, 0.13);
  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-pop: 0 16px 40px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(196, 154, 108, 0.22);
}

:root {
  --font-sans: var(--font-script);
  --font-serif: 'Newsreader', 'Source Serif 4', 'Georgia', Cambria, serif;
  --font-mono: 'Inkt Typewriter', 'Courier Prime Cyrillic', 'Cousine', 'IBM Plex Mono', 'JetBrains Mono', ui-monospace, monospace;

  --text-xs: 0.75rem;
  --line-xs: 1rem;
  --text-sm: 0.875rem;
  --line-sm: 1.25rem;
  --text-base: 1rem;
  --line-base: 1.625rem;
  --text-lg: 1.25rem;
  --line-lg: 1.75rem;
  --text-xl: 1.75rem;
  --line-xl: 2.25rem;
  --text-display: 2.375rem;
  --line-display: 2.75rem;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;
  --space-16: 64px;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-pill: 999px;

  --motion-fast: 110ms;
  --motion-base: 180ms;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);

  --hit-target-min: 44px;

  /* Canonical Elevation & Z-Index Scale (strictly ordered low -> high) */
  --z-floating: 50;
  --z-topbar: 80;
  --z-autocomplete: 120;
  --z-modal-backdrop: 150;
  --z-audio-popover: 260;
  --z-selection-toolbar: 600;
  --z-dialog-overlay: 1000;
  --z-patron-modal: 1050;
  --z-popover-fixed: 1200;
  --z-drawer-backdrop: 1245;
  --z-drawer: 1250;
  --z-sanctuary: 9999;
  --z-dropdown-portal: 10100;
  --z-viewport-guard: 99990;
  --z-tooltip: 99999;
  --z-cmd-palette: 100000;
  --z-modal-critical: 100001;
  --z-toast: 100500;
}

/* WCAG 2.3.3: Global reduced-motion gate */
@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;
  }
}
