/* ============================================================
   Base — reset + body + a11y + utilities.
   Loaded on platform surfaces AFTER tokens.css + compat.css.
   Loaded on storefront AFTER tokens-storefront.css.
   Falls back to safe defaults if no tokens are loaded.
   ============================================================ */

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
}

body {
  font-family: var(--font-body, var(--store-font, system-ui, sans-serif));
  font-size:   var(--text-body, 1rem);
  line-height: var(--lh-body, 1.6);
  color:       var(--color-text, var(--store-text, #0E1B1A));
  background:  var(--color-bg, var(--store-bg, #FFFFFF));
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Headings */
h1, h2, h3, h4, h5, h6 {
  line-height: var(--lh-snug, 1.25);
  font-weight: var(--fw-semi, 600);
  color: var(--color-text, var(--store-text));
}
:lang(en) h1, :lang(en) h2 { letter-spacing: -0.02em; }
:lang(ar) h1, :lang(ar) h2, :lang(ar) h3 {
  letter-spacing: normal;
  text-transform: none;
}

/* Default body link — components style their own. */
a {
  color: var(--color-primary, var(--store-primary, #0B6E66));
  text-decoration: none;
}
/* Button-styled anchors own their colour in every state — don't let the
   generic link-hover repaint their text (it caused green-text-on-green-bg). */
a:not([class*="btn"]):hover { color: var(--color-primary-hover, var(--store-primary-hover)); }

/* Images don't overflow their containers. */
img, svg, video, canvas {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Tables: numbers right-aligned by default in LTR, start-aligned in RTL
   stays numeric-aligned via the font's tabular-nums. */
.tabular-nums,
.price,
.order-id,
table td.numeric,
table th.numeric {
  font-variant-numeric: tabular-nums;
}

/* Focus ring — visible only on keyboard navigation. */
:focus { outline: none; }
:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 3px color-mix(
      in srgb,
      var(--color-focus-ring, var(--store-focus-ring, #0E7E74)) 35%,
      transparent
    );
  border-radius: var(--radius-sm, 6px);
}

/* Skip link for keyboard users */
.skip-link {
  position: absolute;
  inset-inline-start: -9999px;
  inset-block-start: 0;
  z-index: 1000;
  padding: var(--space-3, 12px) var(--space-4, 16px);
  background: var(--color-primary, var(--store-primary, #0B6E66));
  color: #fff;
  text-decoration: none;
  border-radius: 0 0 var(--radius-md, 10px) var(--radius-md, 10px);
  font-weight: var(--fw-semi, 600);
}
.skip-link:focus { inset-inline-start: 0; }

/* Container */
.container {
  width: 100%;
  max-width: var(--container-max, 1200px);
  margin-inline: auto;
  padding-inline: var(--gutter-mobile, 16px);
}
.container--wide { max-width: var(--container-wide-max, 1400px); }

@media (min-width: 768px)  { .container { padding-inline: var(--gutter-tablet, 24px); } }
@media (min-width: 1024px) { .container { padding-inline: var(--gutter-desktop, 32px); } }

/* Directional icons mirror in RTL (chevrons, arrows, "back"). */
[dir="rtl"] .icon--directional,
[dir="rtl"] .icon-directional {
  transform: scaleX(-1);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Screen-reader only */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* Hidden but kept in tab order is sometimes wanted: use `hidden` attr instead. */

/* Stack utilities — flow with consistent vertical rhythm */
.flow > * + *      { margin-block-start: var(--space-4, 16px); }
.stack-1 > * + *   { margin-block-start: var(--space-1, 4px); }
.stack-2 > * + *   { margin-block-start: var(--space-2, 8px); }
.stack-3 > * + *   { margin-block-start: var(--space-3, 12px); }
.stack-4 > * + *   { margin-block-start: var(--space-4, 16px); }
.stack-5 > * + *   { margin-block-start: var(--space-5, 20px); }
.stack-6 > * + *   { margin-block-start: var(--space-6, 24px); }
.stack-8 > * + *   { margin-block-start: var(--space-8, 32px); }

/* Inline cluster — horizontal grouping with wrap */
.cluster {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3, 12px);
  align-items: center;
}

/* Numbers / Latin runs inside Arabic text should stay LTR.
   Apply with: <bdi>123</bdi> or class. */
.bidi-isolate { unicode-bidi: isolate; }
