/* ────────────────────────────────────────────────────────────────────
 * AROOGA Design System — Tokens
 *
 * Warm Palette v2 (Midnight Bloom · Vintage Paper · Sunset Horizon · Starry Night)
 * Market skins: default (TR/base), US (clean), AE (premium gold)
 *
 * Usage:
 *   <body data-market="us|ae|tr">  (omit = default TR)
 *
 * Every colour in the --color-* namespace is resolved from a semantic token,
 * NEVER referenced by raw hex in component CSS. This keeps market skins
 * swappable without touching components.
 * ──────────────────────────────────────────────────────────────────── */

:root {
  /* ── RAW PALETTE (Warm Palette v2 — canonical) ─────────────────── */

  /* Midnight Bloom */
  --raw-midnight:           #0c0a1d;
  --raw-midnight-deep:      #050314;
  --raw-dark-violet:        #1a1530;
  --raw-deep-indigo:        #3730a3;
  --raw-periwinkle:         #6366f1;
  --raw-indigo-700:         #4338ca;  /* darker periwinkle — focus ring on sand surfaces */

  /* Vintage Paper */
  --raw-warm-white:         #f5f0e8;
  --raw-cream:              #ebe4d0;
  --raw-sand:               #d8d0b8;
  --raw-khaki:              #a8a070;
  --raw-deep-midnight:      #1a1520;
  --raw-warm-grey:          #6b6560;

  /* Sunset Horizon */
  --raw-crimson:            #b91c1c;
  --raw-ruby:               #991b1b;
  --raw-warm-coral:         #f08868;
  --raw-amber:              #f59e0b;

  /* Starry Night */
  --raw-golden-amber:       #d8b060;
  --raw-gold-deep:          #b8934e;
  --raw-steel-blue:         #4858a0;
  --raw-olive-steel:        #686830;

  /* ── SEMANTIC TOKENS (reference raw) ───────────────────────────── */

  /* Surfaces */
  --color-bg:               var(--raw-warm-white);
  --color-surface-1:        var(--raw-cream);
  --color-surface-2:        var(--raw-sand);
  --color-bg-dark:          var(--raw-midnight);
  --color-surface-dark-1:   var(--raw-dark-violet);
  --color-surface-dark-2:   #221c3d;

  /* Text on light */
  --color-text-primary:     var(--raw-deep-midnight);
  --color-text-secondary:   var(--raw-warm-grey);
  --color-text-muted:       #8a847e;
  --color-text-inverse:     var(--raw-warm-white);

  /* Text on dark */
  --color-text-on-dark:     var(--raw-warm-white);
  --color-text-on-dark-2:   #c8c0b0;

  /* Accents */
  --color-primary:          var(--raw-deep-indigo);
  --color-primary-hover:    #2e2782;
  --color-primary-light:    var(--raw-periwinkle);
  --color-accent:           var(--raw-crimson);
  --color-accent-hover:     var(--raw-ruby);
  --color-warm:             var(--raw-khaki);

  /* Borders */
  --color-border:           rgba(26, 21, 32, 0.10);
  --color-border-strong:    rgba(26, 21, 32, 0.20);
  --color-border-on-dark:   rgba(245, 240, 232, 0.12);

  /* Focus + a11y — dark indigo on light surfaces passes WCAG 2.4.11 3:1
   * against sand surface-2; gold on dark passes trivially. */
  --color-focus-ring:       var(--raw-indigo-700);
  --color-focus-ring-on-dark: var(--raw-golden-amber);

  /* Product accents (stable across skins — product identity) */
  --color-product-copilot:  var(--raw-periwinkle);
  --color-product-cortex:   var(--raw-steel-blue);
  --color-product-scribe:   var(--raw-warm-coral);

  /* State colours (semantic, not skin-dependent) */
  --color-success:          #556b2f;
  --color-warning:          var(--raw-amber);
  --color-danger:           var(--raw-crimson);
  --color-info:             var(--raw-steel-blue);

  /* Glow / hero mesh gradients (defaults — overridden per skin) */
  --glow-1: rgba(99, 102, 241, 0.28);
  --glow-2: rgba(72, 88, 160, 0.22);
  --glow-3: rgba(216, 176, 96, 0.14);

  /* ── TYPOGRAPHY SCALE (modular, base 16 · ratio 1.250 Major Third) ── */

  --font-family-body:    "Inter", "Inter Variable", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-family-display: "Inter Tight", "Inter Tight Variable", "Inter", system-ui, sans-serif;
  --font-family-mono:    "JetBrains Mono", "Space Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --text-2xs:  0.6875rem;  /* 11px */
  --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.5625rem;  /* 25px */
  --text-3xl:  1.953125rem;/* 31.25px */
  --text-4xl:  2.44140625rem;  /* 39px */
  --text-5xl:  3.0517578125rem;/* 48.8px */
  --text-6xl:  3.814697265625rem;/* 61px */
  --text-7xl:  4.76837158203125rem;/* 76.3px */

  /* Line heights */
  --leading-tight:   1.1;
  --leading-snug:    1.25;
  --leading-normal:  1.5;
  --leading-relaxed: 1.65;

  /* Letter spacing */
  --tracking-tight:   -0.025em;
  --tracking-snug:    -0.015em;
  --tracking-normal:  0;
  --tracking-wide:    0.04em;
  --tracking-widest:  0.12em;

  /* Font weights (Inter Variable exposes 100-900) */
  /* All weights are exact integers so a narrowed 300-700 variable axis ships,
   * saving ~30KB vs full 100-900 axis. (performance CoV: unbounded axis = 60KB) */
  --font-weight-regular:  400;
  --font-weight-medium:   500;
  --font-weight-semibold: 600;
  --font-weight-display:  600; /* display headings default — integer, subset-safe */
  --font-weight-bold:     700;

  /* ── SPACING (4-pt grid) ───────────────────────────────────────── */

  --space-0:    0;
  --space-1:    0.25rem;    /* 4  */
  --space-2:    0.5rem;     /* 8  */
  --space-3:    0.75rem;    /* 12 */
  --space-4:    1rem;       /* 16 */
  --space-5:    1.25rem;    /* 20 */
  --space-6:    1.5rem;     /* 24 */
  --space-8:    2rem;       /* 32 */
  --space-10:   2.5rem;     /* 40 */
  --space-12:   3rem;       /* 48 */
  --space-16:   4rem;       /* 64 */
  --space-20:   5rem;       /* 80 */
  --space-24:   6rem;       /* 96 */
  --space-32:   8rem;       /* 128 */
  --space-40:   10rem;      /* 160 */

  /* Layout */
  --container-max:        1200px;
  --container-narrow:     760px;
  --container-wide:       1440px;
  --section-py-mobile:    var(--space-16);
  --section-py-desktop:   var(--space-24);

  /* ── RADIUS ────────────────────────────────────────────────────── */

  --radius-xs:    4px;
  --radius-sm:    6px;
  --radius-md:    10px;
  --radius-lg:    14px;
  --radius-xl:    20px;
  --radius-2xl:   28px;
  --radius-full:  9999px;

  /* ── SHADOWS (warm-tinted, not pure black) ─────────────────────── */

  --shadow-xs:  0 1px 2px rgba(26, 21, 32, 0.06);
  --shadow-sm:  0 2px 4px rgba(26, 21, 32, 0.06), 0 1px 2px rgba(26, 21, 32, 0.04);
  --shadow-md:  0 6px 16px -4px rgba(26, 21, 32, 0.10), 0 2px 4px rgba(26, 21, 32, 0.05);
  --shadow-lg:  0 14px 32px -10px rgba(26, 21, 32, 0.14), 0 4px 8px rgba(26, 21, 32, 0.06);
  --shadow-xl:  0 28px 56px -16px rgba(26, 21, 32, 0.20), 0 8px 16px rgba(26, 21, 32, 0.08);
  --shadow-focus: 0 0 0 3px rgba(99, 102, 241, 0.35);
  --shadow-inset: inset 0 1px 2px rgba(26, 21, 32, 0.06);

  /* ── MOTION ────────────────────────────────────────────────────── */

  --duration-instant: 80ms;
  --duration-fast:    150ms;
  --duration-base:    200ms;
  --duration-slow:    300ms;
  --duration-slower:  450ms;

  --ease-linear:  linear;
  --ease-out:     cubic-bezier(0.22, 1, 0.36, 1);       /* entry */
  --ease-in:      cubic-bezier(0.64, 0, 0.78, 0);       /* exit */
  --ease-in-out:  cubic-bezier(0.76, 0, 0.24, 1);
  --ease-spring:  cubic-bezier(0.32, 0.72, 0, 1);       /* snappy */
  --ease-soft:    cubic-bezier(0.4, 0, 0.2, 1);         /* material */

  /* ── Z-INDEX ───────────────────────────────────────────────────── */

  --z-base:     0;
  --z-raised:   10;
  --z-sticky:   100;
  --z-overlay:  500;
  --z-modal:    1000;
  --z-toast:    9999;
}

/* ────────────────────────────────────────────────────────────────────
 * MARKET SKINS
 * Override semantic tokens per market. Raw palette untouched.
 * Apply via <body data-market="us|ae|tr">. Default body = TR (warm).
 * ──────────────────────────────────────────────────────────────────── */

/* ── US skin: clean, productive — WARMTH preserved from Warm v2.
 *    Differentiation is motion + density, NOT colour temperature.
 *    (brand-guardian CoV: cold #ffffff makes us indistinguishable from Stripe.) */
[data-market="us"] {
  --color-bg:               #faf7f0;  /* warm-white-lite — NOT cold white */
  --color-surface-1:        #f2ede1;
  --color-surface-2:        #e6dfc8;
  --color-bg-dark:          #0a0818;
  --color-surface-dark-1:   #15112a;
  --color-surface-dark-2:   #1d1838;

  --color-text-primary:     #0f0d18;
  --color-text-secondary:   #5a5650;
  --color-text-muted:       #807b75;

  --color-primary:          #3730a3;
  --color-primary-hover:    #2d2682;
  --color-accent:           #b91c1c;
  --color-accent-hover:     #991414;

  --color-border:           rgba(15, 13, 24, 0.08);
  --color-border-strong:    rgba(15, 13, 24, 0.16);

  --glow-1: rgba(99, 102, 241, 0.30);
  --glow-2: rgba(55, 48, 163, 0.20);
  --glow-3: rgba(185, 28, 28, 0.10);

  /* Motion: sharp + fast for productivity / developer feel */
  --duration-base:          150ms;
  --duration-slow:          250ms;
}

/* ── AE (Gulf) skin: premium, enterprise + government — gold accents ── */
[data-market="ae"] {
  --color-bg:               #f5f0e4;
  --color-surface-1:        #ebe4d0;
  --color-surface-2:        #d8cfb0;
  --color-bg-dark:          #050314;
  --color-surface-dark-1:   #0f0a22;
  --color-surface-dark-2:   #1a1330;

  --color-text-primary:     #14101c;
  --color-text-secondary:   #5c564a;

  --color-primary:          #2e2782;                    /* deeper indigo — restraint */
  --color-primary-hover:    #241d62;
  --color-primary-light:    #6366f1;
  --color-accent:           #991b1b;                    /* refined ruby instead of crimson */
  --color-accent-hover:     #7a1414;
  --color-warm:             var(--raw-gold-deep);       /* gold dominates */

  /* Focus ring on DARK surfaces: golden amber (WCAG 2.4.11 clears 3:1 on dark bg).
   * Focus ring on LIGHT surfaces: must be darker gold to clear 3:1 vs surface-2 sand.
   * (a11y-reviewer CoV: #d8b060 vs #d8cfb0 is ~1.3:1 — fails non-text contrast.) */
  --color-focus-ring:       #7a5a14;              /* dark gold, 4.5:1 on --surface-2 */
  --color-focus-ring-on-dark: var(--raw-golden-amber);

  --color-border:           rgba(20, 16, 28, 0.10);
  --color-border-strong:    rgba(20, 16, 28, 0.22);

  /* Gold-tinted glow — premium hero */
  --glow-1: rgba(216, 176, 96, 0.28);
  --glow-2: rgba(72, 88, 160, 0.22);
  --glow-3: rgba(46, 39, 130, 0.18);

  --shadow-md: 0 6px 16px -4px rgba(20, 16, 28, 0.12), 0 2px 4px rgba(216, 176, 96, 0.06);
  --shadow-lg: 0 14px 32px -10px rgba(20, 16, 28, 0.18), 0 4px 8px rgba(216, 176, 96, 0.08);

  /* Motion: slower, deliberate — premium pacing */
  --duration-base:          250ms;
  --duration-slow:          400ms;
}

/* ── TR skin: warm, energetic (default = identical to :root Warm v2) ── */
[data-market="tr"] {
  /* Inherits :root Warm Palette v2. Minor coral-forward tweak on accent. */
  --color-accent:           #b91c1c;
  --color-warm:             var(--raw-warm-coral);

  --glow-1: rgba(240, 136, 104, 0.25);
  --glow-2: rgba(99, 102, 241, 0.22);
  --glow-3: rgba(216, 176, 96, 0.18);
}

/* ────────────────────────────────────────────────────────────────────
 * DARK SECTIONS — drop these tokens when inside a .surface-dark block
 * (Hero sections, dark bands, etc.) Tokens redefined so text utilities
 * "just work" without per-section overrides.
 * ──────────────────────────────────────────────────────────────────── */

.surface-dark {
  --color-bg:             var(--color-bg-dark);
  --color-surface-1:      var(--color-surface-dark-1);
  --color-surface-2:      var(--color-surface-dark-2);
  --color-text-primary:   var(--color-text-on-dark);
  --color-text-secondary: var(--color-text-on-dark-2);
  --color-text-muted:     rgba(245, 240, 232, 0.55);
  --color-border:         var(--color-border-on-dark);
  --color-border-strong:  rgba(245, 240, 232, 0.22);
  --color-focus-ring:     var(--color-focus-ring-on-dark);

  background-color: var(--color-bg);
  color: var(--color-text-primary);
}

/* ────────────────────────────────────────────────────────────────────
 * REDUCED-MOTION
 * ──────────────────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  :root {
    --duration-instant: 0ms;
    --duration-fast:    0ms;
    --duration-base:    0ms;
    --duration-slow:    0ms;
    --duration-slower:  0ms;
  }
}

/* ────────────────────────────────────────────────────────────────────
 * FORCED-COLORS MODE (Windows High Contrast Mode, accessibility)
 * System palette wins. We only keep semantic shape, not colour.
 * ──────────────────────────────────────────────────────────────────── */

@media (forced-colors: active) {
  :root {
    --color-focus-ring:         Highlight;
    --color-focus-ring-on-dark: Highlight;
    --color-border:             CanvasText;
    --color-border-strong:      CanvasText;
    --color-border-on-dark:     CanvasText;
    --shadow-focus:             0 0 0 3px Highlight;
  }
}
