/* ═══════════════════════════════════════════════════════════════════════
   LAYER 2 — THEME (merchant branding)
   THEME IS DATA, NOT A BUILD CHOICE: one shipped stylesheet serves every
   merchant. A merchant's storefront sets exactly ONE attribute on <html> —
   data-theme="modern|minimal|luxury|bold|classic" — read at runtime from
   whatever the core returns for that tenant. Nothing in any .cshtml or
   .html page branches on theme (no `@if (theme == "luxury")`); if a theme
   ever needed different MARKUP, that would be a tokenisation defect to fix
   here, not a reason to fork a template.

   TWO LAYERS, KEPT SEPARATE — this file has two kinds of rule, in order:

   ① PRESET  — five shipped design artefacts, each a coherent, opinionated
      point of view (colour + type + radius + card/button character). A
      preset sets --preset-* tokens ONLY. It never sets the consumed
      --brand / --font-display-ar / --btn-radius / … names directly — see
      why in ②.

   ② MERCHANT OVERRIDE — a single small resolution block at the bottom of
      this file, OUTSIDE any [data-theme] selector, that computes every
      CONSUMED token (--brand, --brand-secondary, --gold, the four font
      tokens, --btn-radius, --card-radius, --card-border, --card-shadow,
      --brand-text) as `var(--merchant-X, var(--preset-X))`. A merchant who
      wants Luxury with his own primary colour sets ONE custom property —
      `--merchant-primary` — on <html> (inline style, or a tiny per-tenant
      <style> block the Hub generates); every component still just reads
      --brand and never learns an override happened. Nothing else in the
      preset needs touching. This is deliberately the SMALLEST surface that
      still delivers logo/primary/secondary/accent/font/radius/button-style
      /card-style:

        --merchant-primary          (drives --brand · logo colour · CTAs)
        --merchant-primary-text     (button-on-primary text — see ③ below)
        --merchant-secondary        (drives --brand-secondary — 2nd hero tone)
        --merchant-accent           (drives --gold — ratings, "was" ribbons)
        --merchant-font-display-ar / -en
        --merchant-font-body-ar / -en
        --merchant-radius           (drives BOTH --btn-radius and --card-radius
                                      — "button style" and "card style" in this
                                      system are corner-language + colour, not
                                      a separate shape system, so one radius
                                      knob plus --merchant-primary already
                                      moves both)
        --merchant-card-border
        --merchant-card-shadow

      Semantic tokens (--danger-base, --success-base, --warning-base,
      --info-base) and neutral surface tokens (--paper, --ink, --tray, …)
      are NEVER part of the merchant override surface — see ③.

   ③ WHAT PROTECTS LEGIBILITY — stated honestly, not aspirationally:
      - Each of the five PRESETS below is contrast-measured (figures in each
        block) at 4.5:1+ body text and 4.5:1+ primary-button text. That
        protection is real for a merchant who changes nothing.
      - The override layer adds ONE concrete safeguard: --merchant-primary
        and --merchant-primary-text are a PAIR, not auto-detected. Nothing
        in CSS today computes contrast and flips text colour for you — no
        engine ships `color-contrast()` broadly enough to rely on it in
        2026. So: if a merchant sets --merchant-primary alone and skips
        --merchant-primary-text, they inherit the PRESET's text colour,
        which may fail against their new colour. That gap is real and
        UNFIXED here.
      - What WOULD fix it: a server-side (Hub admin-panel) contrast check
        at save time — compute WCAG contrast for both white-on-color and
        ink-on-color, reject or auto-pick before the value ever reaches
        this CSS. That check does not exist yet; this file cannot build it
        (no data layer here to validate against). Flagging as a follow-up,
        not claiming it is solved.
      - Focus rings are DELIBERATELY exempted from the override surface —
        see base.css: the focus ring uses --ink, not --brand, specifically
        so a low-contrast merchant colour can never make focus invisible.
        Same reasoning protects disabled state (fixed opacity, not colour)
        and semantic danger/success/warning/info (never themeable at all).
   ═══════════════════════════════════════════════════════════════════════ */

/* ═══ ① PRESETS ═══════════════════════════════════════════════════════════ */

:root,
[data-theme="modern"] {
    --preset-paper:        var(--neutral-0);
    --preset-paper-muted:  var(--neutral-100);
    --preset-tray:         var(--neutral-150);
    --preset-line:         var(--neutral-200);
    --preset-line-strong:  var(--neutral-300);
    --preset-ink:          var(--neutral-900);
    --preset-ink-soft:     var(--neutral-600);
    --preset-ink-faint:    var(--neutral-500);

    --preset-brand:           var(--brand-700);
    --preset-brand-deep:      var(--brand-900);
    --preset-brand-tint:      var(--brand-100);
    --preset-brand-secondary: #2a4372;   /* mid navy — hero gradient's 2nd stop */
    --preset-brand-text:      var(--brand-on);
    --preset-gold:            var(--gold-base);   /* NOT var(--gold) — that name is the
                                                     consumed token computed at :266;
                                                     pointing back at it made a cycle. */

    --preset-font-display-ar: 'El Messiri', Tahoma, sans-serif;
    --preset-font-display-en: 'Fraunces', Georgia, serif;
    --preset-font-body-ar:    'IBM Plex Sans Arabic', Tahoma, sans-serif;
    --preset-font-body-en:    'Inter', Arial, sans-serif;

    --preset-btn-radius:  var(--radius-full);
    --preset-card-radius: var(--radius-md);
    --preset-card-border: 1px solid var(--neutral-200);
    --preset-card-shadow: none;
    --preset-card-shadow-hover: var(--shadow-card);

    /* MEASURED 2026-08-24 against the navy ramp (recomputed, not inherited from
       the retired teal figures):
       body text      #14171c on #ffffff → 17.96:1
       primary button #ffffff on #1b2b4d → 14.01:1 */
}

/* ── minimal — quiet boutique; graphite-sage accent, sharp corners ────── */
[data-theme="minimal"] {
    --preset-paper:        #fbfaf8;
    --preset-paper-muted:  #f3f2ee;
    --preset-tray:         #f3f2ee;
    --preset-line:         #e4e2dc;
    --preset-line-strong:  #cfccc3;
    --preset-ink:          #1a1a1a;
    --preset-ink-soft:     #63625c;
    --preset-ink-faint:    #96948b;

    --preset-brand:           #4a5a52;
    --preset-brand-deep:      #384a41;
    --preset-brand-tint:      #e9ede9;
    --preset-brand-secondary: #8a8377;
    --preset-brand-text:      #ffffff;
    --preset-gold:            #a68a5b;

    --preset-font-display-ar: 'Cairo', Tahoma, sans-serif;
    --preset-font-display-en: 'Work Sans', Arial, sans-serif;
    --preset-font-body-ar:    'Cairo', Tahoma, sans-serif;
    --preset-font-body-en:    'Work Sans', Arial, sans-serif;

    --preset-btn-radius:  4px;
    --preset-card-radius: 4px;
    --preset-card-border: 1px solid #e4e2dc;
    --preset-card-shadow: none;
    --preset-card-shadow-hover: none;

    /* MEASURED — body text (#1a1a1a on #fbfaf8): 16.73:1
       MEASURED — primary button (#ffffff on #4a5a52): 7.30:1 */
}

/* ── luxury — dark chrome, brass accent, serif display ─────────────────── */
[data-theme="luxury"] {
    --preset-paper:        #15130f;
    --preset-paper-muted:  #1e1b16;
    --preset-tray:         #211d17;
    --preset-line:         #332e26;
    --preset-line-strong:  #453f34;
    --preset-ink:          #f2ead9;
    --preset-ink-soft:     #c9bfa9;
    --preset-ink-faint:    #8f8672;

    --preset-brand:           #c9a44c;
    --preset-brand-deep:      #a8873b;
    --preset-brand-tint:      #2b2418;
    --preset-brand-secondary: #7c6a3f;
    --preset-brand-text:      #15130f;   /* dark text on gold — white fails 4.5:1 (2.36:1) */
    --preset-gold:            #c9a44c;

    --preset-font-display-ar: 'Markazi Text', 'El Messiri', serif;
    --preset-font-display-en: 'Cormorant Garamond', Georgia, serif;
    --preset-font-body-ar:    'IBM Plex Sans Arabic', Tahoma, sans-serif;
    --preset-font-body-en:    'Inter', Arial, sans-serif;

    --preset-btn-radius:  2px;
    --preset-card-radius: 2px;
    --preset-card-border: 1px solid #332e26;
    --preset-card-shadow: none;
    --preset-card-shadow-hover: 0 1px 0 var(--preset-brand);

    /* MEASURED — body text (#f2ead9 on #15130f): 15.50:1
       MEASURED — primary button (#15130f on #c9a44c): 7.86:1 */
}

/* ── bold — white canvas, crimson-magenta accent, big radius ──────────── */
[data-theme="bold"] {
    --preset-paper:        #ffffff;
    --preset-paper-muted:  #f7f2f4;
    --preset-tray:         #fbeaef;
    --preset-line:         #f0dbe1;
    --preset-line-strong:  #e0b9c4;
    --preset-ink:          #171717;
    --preset-ink-soft:     #5c5256;
    --preset-ink-faint:    #93878c;

    --preset-brand:           #c81e5c;
    --preset-brand-deep:      #9c1748;
    --preset-brand-tint:      #fbe6ee;
    --preset-brand-secondary: #ffb703;
    --preset-brand-text:      #ffffff;
    --preset-gold:            #ffb703;

    --preset-font-display-ar: 'Tajawal', Tahoma, sans-serif;
    --preset-font-display-en: 'Poppins', Arial, sans-serif;
    --preset-font-body-ar:    'Tajawal', Tahoma, sans-serif;
    --preset-font-body-en:    'Poppins', Arial, sans-serif;

    --preset-btn-radius:  16px;
    --preset-card-radius: 16px;
    --preset-card-border: 2px solid var(--preset-line);
    --preset-card-shadow: none;
    --preset-card-shadow-hover: var(--shadow-card);

    /* MEASURED — body text (#171717 on #ffffff): ~17.9:1
       MEASURED — primary button (#ffffff on #c81e5c): 5.53:1 */
}

/* ── classic — warm ivory, oxblood accent, Naskh display ───────────────── */
[data-theme="classic"] {
    --preset-paper:        #eee7d6;
    --preset-paper-muted:  #e6dcc5;
    --preset-tray:         #e2d6bb;
    --preset-line:         #d9cbab;
    --preset-line-strong:  #c4b48c;
    --preset-ink:          #2a2118;
    --preset-ink-soft:     #5c4c39;
    --preset-ink-faint:    #8a7a63;

    --preset-brand:           #6e1f2b;
    --preset-brand-deep:      #52161f;
    --preset-brand-tint:      #f1dee0;
    --preset-brand-secondary: #8a6a2f;
    --preset-brand-text:      #ffffff;
    --preset-gold:            #8a6a2f;

    --preset-font-display-ar: 'Amiri', 'El Messiri', serif;
    --preset-font-display-en: 'Playfair Display', Georgia, serif;
    --preset-font-body-ar:    'Noto Sans Arabic', 'IBM Plex Sans Arabic', Tahoma, sans-serif;
    --preset-font-body-en:    'Noto Sans', Arial, sans-serif;

    --preset-btn-radius:  var(--radius-sm);
    --preset-card-radius: var(--radius-sm);
    --preset-card-border: 1px solid var(--preset-line-strong);
    --preset-card-shadow: none;
    --preset-card-shadow-hover: none;

    /* MEASURED — body text (#2a2118 on #eee7d6): 12.82:1
       MEASURED — primary button (#ffffff on #6e1f2b): 11.08:1 */
}

/* ═══ ② MERCHANT OVERRIDE RESOLUTION — applies after every preset, reads
   whichever --preset-* the active [data-theme] set, prefers a --merchant-*
   value if one is present on the element. This is the ONLY place the
   consumed --brand / --font-display-ar / --btn-radius / … names are ever
   assigned in this whole layer. ═══════════════════════════════════════ */

:root {
    --paper:       var(--preset-paper);
    --paper-muted: var(--preset-paper-muted);
    --tray:        var(--preset-tray);
    --line:        var(--preset-line);
    --line-strong: var(--preset-line-strong);
    --ink:         var(--preset-ink);
    --ink-soft:    var(--preset-ink-soft);
    --ink-faint:   var(--preset-ink-faint);

    --brand:           var(--merchant-primary,   var(--preset-brand));
    --brand-deep:      var(--preset-brand-deep);
    --brand-tint:      var(--preset-brand-tint);
    --brand-secondary: var(--merchant-secondary, var(--preset-brand-secondary));
    --brand-text:      var(--merchant-primary-text, var(--preset-brand-text));
    --gold:            var(--merchant-accent,    var(--preset-gold));

    --font-display-ar: var(--merchant-font-display-ar, var(--preset-font-display-ar));
    --font-display-en: var(--merchant-font-display-en, var(--preset-font-display-en));
    --font-body-ar:    var(--merchant-font-body-ar,    var(--preset-font-body-ar));
    --font-body-en:    var(--merchant-font-body-en,    var(--preset-font-body-en));

    --btn-radius:  var(--merchant-radius, var(--preset-btn-radius));
    --card-radius: var(--merchant-radius, var(--preset-card-radius));
    --card-border: var(--merchant-card-border, var(--preset-card-border));
    --card-shadow: var(--merchant-card-shadow, var(--preset-card-shadow));
    --card-shadow-hover: var(--preset-card-shadow-hover);
}
