/* ═══════════════════════════════════════════════════════════════
   Miras Design System — Tokens v2 (Hallmark Redesign)
   Stat-Led · Editorial · Islamic Green + Muted Gold
   4pt grid · Sora + DM Sans · Light + Dark tema
   ═══════════════════════════════════════════════════════════════ */

:root,
:root[data-theme="light"] {
  color-scheme: light;

  /* ── Paper (emerald-tinted warm white) ── */
  --paper:    #f6f8f6;
  --paper-2:  #eef1ee;
  --paper-3:  #e4e8e3;

  /* ── Ink (emerald-tinted dark) ── */
  --ink:      #1a1f1c;
  --ink-2:    #2d332f;
  --ink-3:    #404843;

  /* ── Brand: Emerald ── */
  --brand-50:  #ecf7f2;
  --brand-100: #d3ede1;
  --brand-200: #a9dbc5;
  --brand-300: #76c2a3;
  --brand-400: #46a481;
  --brand-500: #1f8a64;
  --brand-600: #14704f;
  --brand-700: #105a41;
  --brand-800: #0e4433;
  --brand-900: #0a2c22;

  /* ── Accent: Muted Gold ── */
  --gold-50:  #fdf8ed;
  --gold-100: #faf3df;
  --gold-200: #f3e5b6;
  --gold-300: #e8cf8f;
  --gold-400: #d8b45c;
  --gold-500: #c29b3f;
  --gold-600: #a37f2e;
  --gold-700: #84651f;

  /* ── Semantic: Negative ── */
  --rose-50:  #fdf2f3;
  --rose-100: #fce4e7;
  --rose-500: #e2566a;
  --rose-600: #cf3f54;
  --rose-800: #7a1e2e;

  /* ── Semantic: Warning ── */
  --amber-50:  #fff8ec;
  --amber-100: #ffedc4;
  --amber-400: #f0b83a;
  --amber-500: #d9a521;
  --amber-700: #a36a1a;

  /* ── Semantic: Info ── */
  --sky-50:  #eff7fc;
  --sky-100: #dceefb;
  --sky-500: #3b82c4;
  --sky-600: #2f6ba4;

  /* ── Neutrals (emerald-tinted) ── */
  --neutral-0:   #ffffff;
  --neutral-50:  #f6f8f6;
  --neutral-100: #eef1ee;
  --neutral-200: #e0e4df;
  --neutral-300: #cdd3cb;
  --neutral-400: #a8b0a5;
  --neutral-500: #7d857a;
  --neutral-600: #5c635a;
  --neutral-700: #434a41;
  --neutral-800: #2d332f;
  --neutral-900: #1a1f1c;

  /* ── Semantic surfaces ── */
  --bg:            var(--paper);
  --surface:       var(--neutral-0);
  --surface-2:     var(--paper-2);
  --surface-3:     var(--paper-3);
  --text:          var(--ink);
  --text-soft:     var(--neutral-600);
  --text-faint:    var(--neutral-500);
  --border:        var(--neutral-200);
  --border-strong: var(--neutral-300);

  --positive:  var(--brand-500);
  --negative:  var(--rose-500);
  --warning:   var(--amber-400);
  --info:      var(--sky-500);

  /* ── Text on colored backgrounds ── */
  --text-on-brand: var(--neutral-0);
  --text-on-rose:  var(--rose-800);
  --text-on-gold:  var(--gold-700);

  /* ── Skeleton shimmer ── */
  --shimmer-color: var(--paper-3);

  /* ═══ Typography ═══ */
  --font-display: 'Sora', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-body:    'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-serif:   'Amiri', 'Traditional Arabic', serif;
  --font-arabic:  -apple-system, BlinkMacSystemFont, 'SF Arabic', 'SF Pro', 'Segoe UI', Tahoma, 'Noto Naskh Arabic', sans-serif;
  --font-mono:    'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;

  /* Major Third scale (1.25) */
  --text-2xs:   0.64rem;
  --text-xs:    0.8rem;
  --text-sm:    0.875rem;
  --text-base:  1rem;
  --text-md:    1.125rem;
  --text-lg:    1.25rem;
  --text-xl:    1.5625rem;
  --text-2xl:   1.9531rem;
  --text-3xl:   2.4414rem;
  --text-4xl:   3.0518rem;
  --text-display: clamp(2.25rem, 4vw + 0.5rem, 3.5rem);

  --lh-tight:  1.15;
  --lh-snug:   1.3;
  --lh-normal: 1.55;

  --fw-light:    300;
  --fw-normal:   400;
  --fw-medium:   500;
  --fw-semibold: 600;
  --fw-bold:     700;

  /* ═══ Spacing (4pt base, Hallmark 9-step) ═══ */
  --space-3xs: 0.125rem;
  --space-2xs: 0.25rem;
  --space-xs:  0.5rem;
  --space-sm:  0.75rem;
  --space-md:  1rem;
  --space-lg:  1.5rem;
  --space-xl:  2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;
  --space-4xl: 6rem;

  /* Legacy aliases */
  --space-1: var(--space-2xs);
  --space-2: var(--space-xs);
  --space-3: var(--space-sm);
  --space-4: var(--space-md);
  --space-5: var(--space-lg);
  --space-6: var(--space-xl);
  --space-7: var(--space-2xl);
  --space-8: var(--space-3xl);
  --space-9: var(--space-4xl);

  /* ═══ Radius ═══ */
  --radius-sm:   6px;
  --radius:      10px;
  --radius-lg:   14px;
  --radius-xl:   20px;
  --radius-pill: 999px;

  /* ═══ Elevation ═══ */
  --shadow-xs:   0 1px 2px oklch(20% 0.01 160 / 0.04);
  --shadow-sm:   0 1px 3px oklch(20% 0.01 160 / 0.06), 0 1px 2px oklch(20% 0.01 160 / 0.04);
  --shadow-md:   0 4px 12px -2px oklch(20% 0.01 160 / 0.08), 0 2px 4px -1px oklch(20% 0.01 160 / 0.04);
  --shadow-lg:   0 12px 32px -4px oklch(20% 0.01 160 / 0.12), 0 4px 8px -2px oklch(20% 0.01 160 / 0.04);
  --shadow-focus: 0 0 0 3px oklch(50% 0.15 160 / 0.2);
  --focus-ring:  oklch(50% 0.15 160 / 0.35);

  /* ═══ Motion ═══ */
  --ease-out:    cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in:     cubic-bezier(0.7, 0, 0.84, 0);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease:        var(--ease-in-out);

  --dur-instant: 80ms;
  --dur-fast:    150ms;
  --dur:         200ms;
  --dur-slow:    300ms;
  --dur-slower:  400ms;

  /* ═══ Layout ═══ */
  --header-h: 60px;
  --container: 1200px;
  --container-narrow: 720px;

  /* ═══ Z-index ═══ */
  --z-base:     1;
  --z-raised:   10;
  --z-dropdown: 100;
  --z-sticky:   200;
  --z-modal:    400;
  --z-toast:    500;
  --z-tooltip:  600;
}

/* ═══════════════════════════════════════════════════════════════
   Dark Theme
   ═══════════════════════════════════════════════════════════════ */
:root[data-theme="dark"] {
  color-scheme: dark;

  /* Paper: dark green-charcoal */
  --paper:    #131614;
  --paper-2:  #1a1e1b;
  --paper-3:  #222723;

  /* Ink: light green-tinted */
  --ink:      #e8ede9;
  --ink-2:    #c8d0c9;
  --ink-3:    #a0aa9f;

  /* Brand: lighter for dark mode */
  --brand-50:  #0c231c;
  --brand-100: #12332a;
  --brand-200: #1a4a3a;
  --brand-300: #2c9170;
  --brand-400: #3fbb90;
  --brand-500: #52cfa4;
  --brand-600: #74dbb8;
  --brand-700: #a0e8cc;
  --brand-800: #233f36;
  --brand-900: #0e1f18;

  /* Gold: warmer for dark */
  --gold-50:   #1e1a0e;
  --gold-100:  #2a2414;
  --gold-200:  #3d3520;
  --gold-300:  #8a7330;
  --gold-400:  #d8b45c;
  --gold-500:  #e8cf8f;
  --gold-600:  #f0dca8;
  --gold-700:  #a37f2e;

  /* Rose */
  --rose-50:   #1e0f12;
  --rose-100:  #2a1418;
  --rose-500:  #f0637a;
  --rose-600:  #ff7d92;
  --rose-800:  #9e3040;

  /* Amber */
  --amber-50:  #1e180e;
  --amber-100: #2a2014;
  --amber-400: #f0b83a;
  --amber-500: #f5c94d;
  --amber-700: #8a5e10;

  /* Sky */
  --sky-50:    #0e1820;
  --sky-100:   #14202a;
  --sky-500:   #5c9fe0;
  --sky-600:   #7ab4ea;

  /* Neutrals (dark, emerald-tinted) */
  --neutral-0:   #131614;
  --neutral-50:  #1a1e1b;
  --neutral-100: #222723;
  --neutral-200: #2b312d;
  --neutral-300: #384039;
  --neutral-400: #4a544c;
  --neutral-500: #6b766d;
  --neutral-600: #8a948c;
  --neutral-700: #a8b2aa;
  --neutral-800: #c8d0c9;
  --neutral-900: #e8ede9;

  /* Semantic surfaces */
  --bg:            var(--paper);
  --surface:       var(--paper-2);
  --surface-2:     var(--paper-3);
  --surface-3:     var(--neutral-300);
  --text:          var(--ink);
  --text-soft:     var(--neutral-600);
  --text-faint:    var(--neutral-500);
  --border:        var(--neutral-300);
  --border-strong: var(--neutral-400);

  --positive:  var(--brand-400);
  --negative:  var(--rose-500);
  --warning:   var(--amber-400);
  --info:      var(--sky-500);

  /* Text on colored backgrounds */
  --text-on-brand: var(--neutral-900);
  --text-on-rose:  var(--neutral-900);
  --text-on-gold:  var(--neutral-900);

  /* Skeleton shimmer */
  --shimmer-color: var(--neutral-400);

  /* Elevation: lighter shadows for dark */
  --shadow-xs:   0 1px 2px oklch(5% 0.01 160 / 0.3);
  --shadow-sm:   0 1px 3px oklch(5% 0.01 160 / 0.4), 0 1px 2px oklch(5% 0.01 160 / 0.3);
  --shadow-md:   0 4px 12px -2px oklch(5% 0.01 160 / 0.4), 0 2px 4px -1px oklch(5% 0.01 160 / 0.3);
  --shadow-lg:   0 12px 32px -4px oklch(5% 0.01 160 / 0.5), 0 4px 8px -2px oklch(5% 0.01 160 / 0.3);
  --shadow-focus: 0 0 0 3px oklch(50% 0.15 160 / 0.35);
  --focus-ring:  oklch(50% 0.15 160 / 0.5);
}

/* ═══ Theme transitions ═══ */
@media (prefers-reduced-motion: no-preference) {
  body,
  .card, .card-header, .card-body, .card-footer,
  .btn, .input, .select, .textarea,
  .badge, .chip, .tab-btn,
  .heir-body, .heir-barriers, .heir-bar-head,
  .kpi, .guide-card, .source-card, .stat-card,
  .guide-stat, .site-header, .site-footer {
    transition: background-color var(--dur-fast) var(--ease),
                border-color var(--dur-fast) var(--ease),
                color var(--dur-fast) var(--ease),
                box-shadow var(--dur-fast) var(--ease);
  }
}
