/* Empire Apps · design tokens · Issue II · MMXXVI
 * One source of truth for color, typography, motion, space.
 * Every folio @import's this before its own per-app CSS.
 */

:root {
  color-scheme: dark;

  /* --- Tier 1: raw dark base --- */
  --midnight-paper:       oklch(11% 0.03 280);
  --midnight-paper-up:    oklch(14% 0.04 280);
  --midnight-paper-card:  oklch(16% 0.05 280);
  --midnight-paper-deep:  oklch(8% 0.025 280);
  --midnight-surface-2:   oklch(19% 0.045 280);
  --midnight-ink:         oklch(96% 0.02 80);
  --midnight-ink-dim:     oklch(78% 0.04 80 / 0.78);
  --midnight-ink-faint:   oklch(60% 0.04 80 / 0.58);
  --midnight-ink-ghost:   oklch(48% 0.03 80 / 0.42);
  --midnight-rule:        oklch(28% 0.05 280 / 0.5);
  --midnight-rule-hair:   oklch(35% 0.05 280 / 0.28);

  /* --- Tier 1: raw theme grounds --- */
  --archive-paper:     oklch(96% 0.01 80);
  --archive-surface:   oklch(99% 0.006 82);
  --archive-graphite:  oklch(24% 0.012 70);
  --imprint-bone:      oklch(97.5% 0.008 84);
  --imprint-ink:       oklch(14% 0.006 75);
  --terminal-black:    oklch(12% 0.01 60);
  --pit-black:         oklch(9% 0.025 35);
  --console-charcoal:  oklch(14% 0.01 250);
  --ceramic-paper:     oklch(96.8% 0.007 75);
  --ceramic-surface:   oklch(99.5% 0.003 80);
  --ceramic-graphite:  oklch(22% 0.008 60);
  --instrument-brass:  oklch(66% 0.115 70);
  --white:             oklch(100% 0 0);

  /* --- Compatibility surface aliases --- */
  --paper:       var(--bg);
  --paper-up:    var(--bg-raised);
  --paper-card:  var(--surface);
  --paper-deep:  var(--bg-deep);

  /* --- Compatibility ink aliases --- */
  --ink:         var(--text);
  --ink-dim:     var(--text-dim);
  --ink-faint:   var(--text-faint);
  --ink-ghost:   var(--midnight-ink-ghost);
  --rule:        var(--border);
  --rule-hair:   var(--border-hair);

  /* --- Editorial swatches (per-folio accents) --- */
  --saffron:     oklch(78% 0.16 65);
  --gold:        oklch(82% 0.16 85);
  --champagne:   oklch(90% 0.07 85);
  --copper:      oklch(72% 0.13 60);
  --forest:      oklch(58% 0.14 145);
  --moon:        oklch(82% 0.02 250);
  --sage:        oklch(72% 0.13 165);
  --coral:       oklch(68% 0.16 28);
  --brass:       oklch(72% 0.13 80);
  --maroon:      oklch(58% 0.18 22);
  --peach:       oklch(82% 0.10 60);
  --bone:        oklch(92% 0.02 85);
  --ivory:       oklch(94% 0.04 85);
  --parchment:   oklch(88% 0.05 85);
  --oxblood:     oklch(48% 0.18 25);
  --moonstone:   oklch(85% 0.03 240);
  --bahi-red:    oklch(54% 0.17 20);
  --emerald:     oklch(56% 0.16 155);
  --indigo-mid:  oklch(36% 0.08 270);
  --clinic-green: oklch(64% 0.13 158);
  --pearl:       oklch(86% 0.025 250);
  --inkwell:     oklch(18% 0.05 280);
  --amber-seal:  oklch(64% 0.13 60);

  /* --- Per-folio bindings (accent + accent-2) --- */
  --plate-hisaab:   var(--bahi-red);
  --plate-khazaana: var(--gold);
  --plate-aramgah:  var(--moonstone);
  --plate-almari:   var(--copper);
  --plate-sehat:    var(--clinic-green);
  --plate-dial:     var(--oxblood);
  --plate-tankhwah: var(--forest);
  --plate-wasiyat:  var(--pearl);

  /* --- Tier 2: semantic roles --- */
  --bg:           var(--midnight-paper);
  --bg-deep:      var(--midnight-paper-deep);
  --bg-raised:    var(--midnight-paper-up);
  --surface:      var(--midnight-paper-card);
  --surface-2:    var(--midnight-surface-2);
  --text:         var(--midnight-ink);
  --text-dim:     var(--midnight-ink-dim);
  --text-faint:   var(--midnight-ink-faint);
  --border:       var(--midnight-rule);
  --border-hair:  var(--midnight-rule-hair);
  --accent:       var(--saffron);
  --accent-2:     var(--gold);
  --accent-ink:   var(--midnight-paper-deep);
  --ok:           var(--emerald);
  --warn:         var(--saffron);
  --err:          var(--coral);
  --focus-ring:   0 0 0 3px color-mix(in oklch, var(--accent) 40%, transparent);
  --shadow-1:     0 6px 30px color-mix(in oklch, var(--saffron) 12%, transparent);
  --shadow-2:     0 12px 48px color-mix(in oklch, var(--saffron) 35%, transparent);
  --control-bg:   var(--accent);
  --control-ink:  var(--accent-ink);
  --result-accent: var(--accent);

  /* --- Typography (variable) --- */
  --hindi:    'Tiro Devanagari Hindi', 'Mukta', serif;
  --display:  'Cormorant Garamond', 'EB Garamond', Georgia, serif;
  --display-2:'EB Garamond', 'Cormorant Garamond', Georgia, serif;
  --font-sans: 'Geist', 'Mona Sans', 'Hanken Grotesk', system-ui, sans-serif;
  --font-body: var(--display);
  --mono:     'JetBrains Mono', 'Space Mono', ui-monospace, monospace;
  --number-font: var(--mono);
  --hand:     'Caveat', 'Brush Script MT', cursive;

  /* --- Type scale (clamp, container-relative) --- */
  --t-display: clamp(58px, 14cqw, 132px);
  --t-h1:      clamp(40px, 8cqw, 68px);
  --t-h2:      clamp(30px, 5.4cqw, 44px);
  --t-h3:      clamp(22px, 3.6cqw, 30px);
  --t-lede:    clamp(20px, 3.2cqw, 26px);
  --t-body:    18px;
  --t-small:   15.5px;
  --t-mono:    10.5px;

  /* --- Space scale --- */
  --s-0: 0px;
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  --s-8: 64px;
  --s-9: 96px;

  /* --- Motion --- */
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out:    cubic-bezier(0.32, 0.72, 0, 1);
  --ease-in:     cubic-bezier(0.4, 0, 1, 1);

  --dur-quick:   180ms;
  --dur-base:    280ms;
  --dur-meander: 380ms;
  --dur-slow:    560ms;

  /* --- Radii (deliberately tiny — broadsheet, not bubblegum) --- */
  --r-0: 0px;
  --r-1: 1px;
  --r-2: 2px;
  --r-4: 4px;

  /* --- Shadow --- */
  --shadow-card: var(--shadow-1);
  --shadow-mark: var(--shadow-2);
}

.theme-archive {
  color-scheme: light;

  --bg:           var(--archive-paper);
  --bg-deep:      oklch(89% 0.018 78);
  --bg-raised:    oklch(98% 0.008 82);
  --surface:      var(--archive-surface);
  --surface-2:    oklch(93% 0.012 78);
  --text:         var(--archive-graphite);
  --text-dim:     oklch(44% 0.014 70);
  --text-faint:   oklch(56% 0.012 70 / 0.68);
  --border:       oklch(84% 0.014 76);
  --border-hair:  oklch(76% 0.014 76 / 0.42);
  --accent:       var(--amber-seal);
  --accent-2:     var(--oxblood);
  --accent-ink:   var(--white);
  --ok:           oklch(48% 0.12 150);
  --warn:         var(--amber-seal);
  --err:          var(--oxblood);
  --focus-ring:   0 0 0 3px color-mix(in oklch, var(--accent) 32%, transparent);
  --shadow-1:     0 8px 24px color-mix(in oklch, var(--text) 10%, transparent);
  --shadow-2:     0 18px 52px color-mix(in oklch, var(--text) 14%, transparent);
  --font-body:    var(--display-2);
}

.theme-imprint {
  color-scheme: light;

  --bg:           var(--imprint-bone);
  --bg-deep:      oklch(91% 0.01 84);
  --bg-raised:    oklch(99% 0.004 86);
  --surface:      oklch(99.2% 0.003 86);
  --surface-2:    oklch(94% 0.008 84);
  --text:         var(--imprint-ink);
  --text-dim:     oklch(38% 0.008 75);
  --text-faint:   oklch(52% 0.008 75 / 0.62);
  --border:       oklch(82% 0.008 80);
  --border-hair:  oklch(70% 0.008 80 / 0.34);
  --accent:       oklch(42% 0.09 35);
  --accent-2:     oklch(42% 0.09 35);
  --accent-ink:   var(--white);
  --ok:           oklch(42% 0.11 148);
  --warn:         oklch(54% 0.11 65);
  --err:          oklch(42% 0.09 35);
  --focus-ring:   0 0 0 2px color-mix(in oklch, var(--accent) 36%, transparent);
  --shadow-1:     0 2px 10px color-mix(in oklch, var(--text) 6%, transparent);
  --shadow-2:     0 8px 28px color-mix(in oklch, var(--text) 10%, transparent);
  --font-body:    var(--display-2);
  --r-1:          0px;
  --r-2:          1px;
  --r-4:          2px;
}

.theme-terminal {
  color-scheme: dark;

  --bg:           var(--terminal-black);
  --bg-deep:      oklch(8% 0.008 60);
  --bg-raised:    oklch(15% 0.014 65);
  --surface:      oklch(17% 0.016 68);
  --surface-2:    oklch(21% 0.018 70);
  --text:         oklch(90% 0.035 85);
  --text-dim:     oklch(72% 0.04 85 / 0.78);
  --text-faint:   oklch(56% 0.04 85 / 0.56);
  --border:       oklch(55% 0.09 85 / 0.44);
  --border-hair:  oklch(72% 0.12 85 / 0.26);
  --accent:       var(--gold);
  --accent-2:     var(--champagne);
  --accent-ink:   var(--terminal-black);
  --ok:           oklch(68% 0.13 145);
  --warn:         var(--gold);
  --err:          oklch(64% 0.16 30);
  --focus-ring:   0 0 0 2px color-mix(in oklch, var(--accent) 52%, transparent);
  --shadow-1:     0 8px 28px color-mix(in oklch, black 36%, transparent);
  --shadow-2:     0 0 40px color-mix(in oklch, var(--accent) 18%, transparent);
  --font-body:    var(--font-sans);
}

.theme-pit {
  color-scheme: dark;

  --bg:           var(--pit-black);
  --bg-deep:      oklch(6% 0.022 35);
  --bg-raised:    oklch(12% 0.035 35);
  --surface:      oklch(15% 0.044 35);
  --surface-2:    oklch(20% 0.052 38);
  --text:         oklch(95% 0.025 78);
  --text-dim:     oklch(78% 0.04 70 / 0.78);
  --text-faint:   oklch(62% 0.05 65 / 0.56);
  --border:       oklch(38% 0.08 45 / 0.55);
  --border-hair:  oklch(60% 0.12 45 / 0.28);
  --accent:       oklch(70% 0.19 45);
  --accent-2:     oklch(78% 0.16 65);
  --accent-ink:   oklch(8% 0.018 35);
  --ok:           oklch(72% 0.14 145);
  --warn:         oklch(70% 0.19 45);
  --err:          oklch(68% 0.18 25);
  --focus-ring:   0 0 0 3px color-mix(in oklch, var(--accent) 58%, transparent);
  --shadow-1:     0 0 28px color-mix(in oklch, var(--accent) 18%, transparent);
  --shadow-2:     0 0 70px color-mix(in oklch, var(--accent) 32%, transparent);
  --font-body:    var(--font-sans);
}

.theme-console {
  color-scheme: dark;

  --bg:           var(--console-charcoal);
  --bg-deep:      oklch(9% 0.008 250);
  --bg-raised:    oklch(17% 0.012 250);
  --surface:      oklch(20% 0.014 250);
  --surface-2:    oklch(25% 0.016 250);
  --text:         oklch(88% 0.018 80);
  --text-dim:     oklch(70% 0.018 80 / 0.76);
  --text-faint:   oklch(54% 0.018 80 / 0.56);
  --border:       oklch(42% 0.02 250 / 0.6);
  --border-hair:  oklch(58% 0.025 250 / 0.28);
  --accent:       oklch(60% 0.16 45);
  --accent-2:     oklch(74% 0.11 70);
  --accent-ink:   oklch(10% 0.008 250);
  --ok:           oklch(64% 0.12 150);
  --warn:         oklch(68% 0.14 65);
  --err:          oklch(62% 0.16 28);
  --focus-ring:   0 0 0 3px color-mix(in oklch, var(--accent) 45%, transparent);
  --shadow-1:     0 10px 34px color-mix(in oklch, black 34%, transparent);
  --shadow-2:     0 20px 60px color-mix(in oklch, black 44%, transparent);
  --font-body:    var(--font-sans);
}

.theme-instrument {
  color-scheme: light;

  --bg:           var(--ceramic-paper);
  --bg-deep:      oklch(91.5% 0.008 75);
  --bg-raised:    oklch(98% 0.005 78);
  --surface:      var(--ceramic-surface);
  --surface-2:    oklch(94.5% 0.006 75);
  --text:         var(--ceramic-graphite);
  --text-dim:     oklch(52% 0.01 60);
  --text-faint:   oklch(62% 0.008 60 / 0.62);
  --border:       oklch(90% 0.006 70);
  --border-hair:  oklch(84% 0.006 70 / 0.42);
  --accent:       var(--instrument-brass);
  --accent-2:     var(--text);
  --accent-ink:   var(--white);
  --ok:           oklch(54% 0.11 150);
  --warn:         var(--instrument-brass);
  --err:          oklch(52% 0.13 28);
  --focus-ring:   0 0 0 3px color-mix(in oklch, var(--accent) 36%, transparent);
  --shadow-1:     0 8px 20px color-mix(in oklch, var(--text) 8%, transparent);
  --shadow-2:     0 18px 42px color-mix(in oklch, var(--text) 12%, transparent);
  --control-bg:   var(--text);
  --control-ink:  var(--white);
  --result-accent: var(--accent);
  --font-body:    var(--font-sans);
  --number-font:  var(--mono);
  --r-2:          4px;
  --r-4:          8px;
}

::selection { background: var(--accent); color: var(--accent-ink); }

@property --shimmer-x { syntax: '<percentage>'; inherits: false; initial-value: 0%; }
@property --accent-glow { syntax: '<percentage>'; inherits: false; initial-value: 0%; }
