/* ═══════════════════════════════════════════════════════════════════════
   LAYER 3 — BASE
   Reset, typography defaults, logical-property RTL/LTR foundation, focus
   rings, and the two accessibility media hooks (reduced motion, colour
   scheme). Nothing here is theme- or page-specific.

   RTL is the storefront's native direction (Arabic, dir="rtl" on <html>),
   but every rule in this whole system is written with LOGICAL properties
   (margin-inline, padding-inline, inset-inline, border-inline, text-align:
   start/end) — never left/right or ltr-only shorthand. That is what lets
   design-system.html flip <html dir="ltr"> and have the entire page mirror
   correctly with zero CSS forked per direction. Verified live — see
   mission report.
   ═══════════════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; }

html {
    scroll-behavior: smooth;
}

/* ── Language resolution ─────────────────────────────────────────────────
   theme.css hands every preset FOUR font tokens (display/body × ar/en) and
   tokens.css hands two leading multipliers per role. This is the one place
   that turns those into the plain --font-display / --font-body / --leading-*
   names every other file already writes — components never test :lang()
   themselves. Default is Arabic (this storefront's native language, and
   its <html lang="ar">); an English page/subtree gets :lang(en) instead.
   Nesting is real: an Arabic page can carry an English SKU code inline
   (`<span lang="en">SKU-2201</span>`) and that span alone gets Latin
   metrics without a wrapper class. ────────────────────────────────────── */
:root {
    --font-display: var(--font-display-ar);
    --font-body:    var(--font-body-ar);
    --leading-tight:   var(--leading-tight-ar);
    --leading-snug:    var(--leading-snug-ar);
    --leading-normal:  var(--leading-normal-ar);
    --leading-relaxed: var(--leading-relaxed-ar);
}
:lang(en) {
    --font-display: var(--font-display-en);
    --font-body:    var(--font-body-en);
    --leading-tight:   var(--leading-tight-en);
    --leading-snug:    var(--leading-snug-en);
    --leading-normal:  var(--leading-normal-en);
    --leading-relaxed: var(--leading-relaxed-en);
}

body {
    margin: 0;
    font-family: var(--font-body);
    font-size: var(--text-md);
    background: var(--paper);
    color: var(--ink);
    line-height: var(--leading-normal);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    margin: 0;
    line-height: var(--leading-tight);
}

p { margin: 0; }

img, svg { max-width: 100%; display: block; }
button { font-family: inherit; }
a { color: inherit; }
fieldset { border: 0; margin: 0; padding: 0; }
legend { padding: 0; }

input, select, textarea, button {
    font-family: inherit;
    color: inherit;
}

/* ── Focus — visible on every interactive element, never on mouse click ──
   Deliberately keyed to --ink, NOT --brand: --brand is merchant-overridable
   (theme.css ②) and a merchant could pick a colour that nearly matches
   --paper, which would make a --brand-coloured focus ring disappear right
   when a keyboard user needs it most. --ink/--paper is contrast-checked at
   12.8:1–18:1 across all five presets (theme.css ①) and is NEVER part of
   the override surface, so this ring stays visible under every theme and
   every merchant colour choice, unconditionally. ─────────────────────── */
:focus-visible {
    outline: 3px solid var(--ink);
    outline-offset: 2px;
    border-radius: 2px;
}
:focus:not(:focus-visible) {
    outline: none;
}

/* Off-canvas via a horizontal inset-inline-start push (the classic "-9999px"
   trick) drags the box thousands of pixels past the inline-end edge in RTL,
   which — even though visually hidden — still contributes to the document's
   scrollable overflow (measured live: 12–67px of horizontal overflow on
   every page, worst at narrow widths). Vertical offset hides it just as
   completely without ever touching the inline axis, so it cannot overflow
   horizontally at any viewport width. */
.skip-link {
    position: absolute;
    inset-inline-start: var(--space-4);
    top: -48px;
    background: var(--ink);
    color: var(--paper);
    padding: var(--space-3) var(--space-5);
    border-radius: 0 0 8px 8px;
    z-index: var(--z-toast);
    text-decoration: none;
    transition: top var(--duration-fast) var(--ease-standard);
}
.skip-link:focus { top: 0; }

/* ── Icon primitive ── ONE family for every inline <svg> in the storefront
   (unify-icons audit, 2026-08-25). Line icons only — stroke, never a filled
   shape, never a coloured tile behind them (Q24: the comp is intentionally
   light, coloured icon backgrounds are the "heavy" look being removed). ── */
.icon {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex: 0 0 auto;
    vertical-align: middle; /* never lets a decorative icon shift the text baseline */
}
.icon--sm { width: 16px; height: 16px; }
.icon--lg { width: 24px; height: 24px; }

/* Defensive fallback — any bare <svg> rendered inside one of these
   interactive/decorative containers renders as the unified primitive above
   even when the markup is missing class="icon" (audit found none missing
   today — this exists so a future page-by-page addition can't regress it).
   :where() carries zero specificity, so it never outranks .icon itself or
   a component's own size variant (.benefits__icon, .icon--sm/--lg, the
   16px product-card wishlist heart, …) — it only fills the gap when
   nothing more specific targets the element. */
:where(.btn, .icon-btn, .mobile-nav__item, .benefits__cell, .utility-bar, .product-card) svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex: 0 0 auto;
    vertical-align: middle;
}

/* ── Reduced motion — kills every transition/animation, honours the OS
   preference rather than the storefront's own taste (WCAG 2.3.3) ──────── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
        scroll-behavior: auto !important;
    }
}

/* ── Colour-scheme hook — the storefront ships one light identity per
   merchant theme today (theme.css owns the palette contract); this block
   is the hook a future dark variant plugs into without touching any
   component rule — only the neutral-ramp aliases below would gain a
   parallel dark block once a merchant asks for it. Demonstrated narrowly
   here (surface tone only) so the hook is provably wired, not aspirational
   dead CSS (Q46). ──────────────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
    :root[data-theme="modern"] {
        color-scheme: dark light;
    }
}
