/* ==========================================================================
   LUXORA — base.css (owner: SHELL)
   Reset · fonts · document · type scale · links/focus · layout (container,
   section, product grid) · a11y helpers · utilities · reveal/line-mask.
   Tokens only (public/css/tokens.css). Logical properties everywhere.

   TABLE OF CONTENTS
   01  Font fallbacks (metric-compatible local faces)
   02  Reset
   03  Document (html/body, selection, scrollbar gutter)
   04  Icons (.icon, sizes, RTL flip)
   05  Type scale classes + heading defaults
   06  Links · focus ring
   07  Layout: containers · section · section head · editorial grid
   08  Product grid (.grid-products)
   09  Accessibility helpers (skip link, visually-hidden)
   10  Utilities (divider, stack, cluster, text, tabular, full-bleed)
   11  Motion: scroll reveal · line-mask · view transitions
   ========================================================================== */

/* --------------------------------------------------------------------------
   01  Font fallbacks — keep CLS < 0.02 while Google faces swap in
   -------------------------------------------------------------------------- */
@font-face {
  font-family: 'Amiri Fallback';
  src: local('Noto Naskh Arabic'), local('Traditional Arabic');
  size-adjust: 104%;
  ascent-override: 92%;
  descent-override: 48%;
}
@font-face {
  font-family: 'Almarai Fallback';
  src: local('Segoe UI'), local('Tahoma');
  size-adjust: 98%;
}
html[lang="ar"] {
  --font-display: 'Amiri', 'Amiri Fallback', 'Cormorant Garamond', 'Noto Naskh Arabic', 'Traditional Arabic', serif;
  --font-body: 'Almarai', 'Almarai Fallback', 'Jost', 'Segoe UI', Tahoma, sans-serif;
}

/* --------------------------------------------------------------------------
   02  Reset
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { min-block-size: 100svh; }
h1, h2, h3, h4, h5, h6 { font-size: inherit; font-weight: inherit; overflow-wrap: break-word; }
p, blockquote, figure, dl, dd { overflow-wrap: break-word; }
ul, ol { padding-inline-start: 1.25em; }
img, picture, svg, video, canvas { display: block; max-inline-size: 100%; block-size: auto; }
img { font-style: italic; color: var(--muted); }               /* alt text renders quietly if a photo fails */
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; text-align: inherit; }
button:disabled { cursor: not-allowed; }
a { color: inherit; text-decoration: none; }
hr { border: 0; }
table { border-collapse: collapse; border-spacing: 0; }
fieldset { border: 0; padding: 0; min-inline-size: 0; }
legend { padding: 0; }
address { font-style: normal; }
[hidden] { display: none; }
/* the hidden attribute must beat single-class display rules on page components (accordion panels animate instead) */
html [hidden]:not(.accordion__panel) { display: none; }
[inert] { pointer-events: none; }
:target { scroll-margin-block-start: calc(var(--header-h-scrolled) + var(--sp-5)); }

/* --------------------------------------------------------------------------
   03  Document
   -------------------------------------------------------------------------- */
html {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 100%;
  line-height: var(--lh-body);
  scrollbar-gutter: stable;          /* body lock (overflow:hidden) never shifts the page */
  scroll-behavior: smooth;
  overflow-x: clip;
}
body {
  background: var(--bg);
  color: var(--ink);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  overflow-x: clip;                  /* clip, not hidden — keeps position: sticky working */
  text-rendering: optimizeLegibility;
}
::selection { background: var(--ink); color: var(--bg); }
::placeholder { color: var(--muted); opacity: 1; }
main { display: block; }

/* Numbers / Latin model names inside Arabic */
.num, [data-num] { font-family: var(--font-numeric); font-variant-numeric: lining-nums tabular-nums; unicode-bidi: isolate; }
.latin { font-family: var(--font-latin-display); vertical-align: baseline; unicode-bidi: isolate; }
html[lang="ar"] .latin { font-size: 1.08em; }

/* --------------------------------------------------------------------------
   04  Icons — 24×24 viewBox, 1.5 stroke, currentColor
   -------------------------------------------------------------------------- */
.icon {
  inline-size: var(--icon);
  block-size: var(--icon);
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: var(--icon-stroke);
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: middle;
  display: inline-block;
}
.icon--sm { inline-size: var(--icon-sm); block-size: var(--icon-sm); }
.icon--lg { inline-size: var(--icon-lg); block-size: var(--icon-lg); }
[dir="rtl"] .icon--flip { transform: scaleX(-1); }   /* the one permitted mirror */

/* --------------------------------------------------------------------------
   05  Type scale — DESIGN §3.3 (Amiri never < 20px; Cormorant 300 only ≥ 44px)
   -------------------------------------------------------------------------- */
.display-1, .display-2, .h1, .h2, .h3 {
  font-family: var(--font-display);
  color: var(--ink);
  letter-spacing: var(--ls-display);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.display-1 { font-size: var(--fs-display-1); font-weight: var(--fw-display); line-height: var(--lh-display); }
.display-2 { font-size: var(--fs-display-2); font-weight: var(--fw-display-sm); line-height: var(--lh-display); }
.h1 { font-size: var(--fs-h1); font-weight: var(--fw-display-sm); line-height: var(--lh-heading); }
.h2 { font-size: var(--fs-h2); font-weight: var(--fw-display-sm); line-height: var(--lh-heading); }
.h3 { font-size: var(--fs-h3); font-weight: var(--fw-display-sm); line-height: var(--lh-heading); }
.h4 { font-family: var(--font-body); font-size: var(--fs-h4); font-weight: var(--fw-medium); line-height: 1.35; color: var(--ink); }
@media (min-width: 768px) { .display-2 { font-weight: var(--fw-display); } }   /* ≥44px from 768 */
/* Amiri ascenders/descenders need air; never clip them */
html[lang="ar"] :is(.display-1, .display-2, .h1, .h2, .h3, .section__title) { padding-block: .1em; overflow: visible; }

.body-lg { font-size: var(--fs-body-lg); line-height: var(--lh-body); color: var(--ink-2); }
html[lang="ar"] .body-lg { font-weight: 300; }
.body { font-size: var(--fs-body); line-height: var(--lh-body); }
.small { font-size: var(--fs-small); line-height: 1.5; }
html[lang="ar"] .small { line-height: 1.65; }
.caption { font-size: var(--fs-caption); line-height: 1.4; color: var(--muted); }

/* Eyebrow: kicker with the 24px gold hairline before it */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
  font-family: var(--font-body);
  font-size: var(--fs-eyebrow);
  font-weight: var(--fw-medium);
  letter-spacing: var(--ls-eyebrow);
  text-transform: var(--tt-caps);
  line-height: 1;
  color: var(--accent);
}
.eyebrow::before { content: ''; inline-size: var(--rule-eyebrow-w); block-size: 1px; background: var(--gold); flex: none; }
.eyebrow--plain::before { display: none; }

/* Sensible defaults for bare headings (modals, prose); pages refine */
h1, h2, h3 { font-family: var(--font-display); font-weight: var(--fw-display-sm); line-height: var(--lh-heading); color: var(--ink); letter-spacing: var(--ls-display); }
h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); }
h4, h5, h6 { font-family: var(--font-body); font-size: var(--fs-h4); font-weight: var(--fw-medium); line-height: 1.35; }
html[lang="ar"] :is(h1, h2, h3) { padding-block: .1em; }
.prose > * + * { margin-block-start: 1em; }
.prose { max-inline-size: 62ch; color: var(--ink-2); }
html[lang="ar"] .prose { max-inline-size: 34rem; }

/* --------------------------------------------------------------------------
   06  Links · focus
   -------------------------------------------------------------------------- */
a { transition: color var(--dur-2) var(--ease-out); }
.link, .prose a {
  color: var(--ink);
  background-image: linear-gradient(currentColor, currentColor), linear-gradient(var(--line-strong), var(--line-strong));
  background-repeat: no-repeat;
  background-size: 0% 1px, 100% 1px;
  background-position: var(--underline-origin) 100%, 0 100%;
  transition: background-size var(--dur-3) var(--ease-out), color var(--dur-2);
  padding-block-end: 1px;
}
.link:hover, .prose a:hover { background-size: 100% 1px, 100% 1px; }
.link--accent:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
:focus:not(:focus-visible) { outline: none; }

/* --------------------------------------------------------------------------
   07  Layout
   -------------------------------------------------------------------------- */
.container {
  inline-size: 100%;
  max-inline-size: calc(var(--w-site) + var(--gutter) * 2);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.container--narrow { max-inline-size: calc(var(--w-narrow) + var(--gutter) * 2); }
.container--medium { max-inline-size: calc(var(--w-medium) + var(--gutter) * 2); }
.container--wide { max-inline-size: calc(var(--w-wide) + var(--gutter) * 2); }
.container .container { padding-inline: 0; }   /* gutters are set once, never nested */

.section { padding-block: var(--section-y); }
.section--tight { padding-block: var(--section-y-tight); }
.section--flush { padding-block: 0; }
.section--hair { border-block-start: var(--hair); }

/* Section head: eyebrow / title + "View all" on the title baseline */
.section__head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: 'eyebrow eyebrow' 'title link';
  align-items: end;
  column-gap: var(--sp-6);
  margin-block-end: var(--head-gap);
}
.section__head > .eyebrow { grid-area: eyebrow; margin-block-end: var(--sp-2); }
.section__title {
  grid-area: title;
  font-family: var(--font-display);
  font-size: var(--fs-h1);
  font-weight: var(--fw-display-sm);
  line-height: var(--lh-heading);
  letter-spacing: var(--ls-display);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
html[data-page="home"] .section__title, .section__head--display .section__title {
  font-size: var(--fs-display-2);
  line-height: var(--lh-display);
}
@media (min-width: 768px) {
  html[data-page="home"] .section__title, .section__head--display .section__title { font-weight: var(--fw-display); }
}
.section__link {
  grid-area: link;
  align-self: end;
  font-size: var(--fs-small);
  color: var(--ink);
  white-space: nowrap;
  padding-block-end: .35em;
  background-image: linear-gradient(currentColor, currentColor), linear-gradient(var(--line-strong), var(--line-strong));
  background-repeat: no-repeat;
  background-size: 0% 1px, 100% 1px;
  background-position: var(--underline-origin) 100%, 0 100%;
  transition: background-size var(--dur-3) var(--ease-out);
}
.section__link:hover { background-size: 100% 1px, 100% 1px; }
.section__link .num { color: var(--muted); }
@media (max-width: 767.98px) {
  .section__head { grid-template-columns: 1fr; grid-template-areas: 'eyebrow' 'title' 'link'; }
  .section__link { justify-self: start; margin-block-start: var(--sp-3); }
}

/* 12-column editorial grid */
.grid-12 { display: grid; grid-template-columns: repeat(var(--grid-cols), minmax(0, 1fr)); column-gap: var(--grid-gap); }

/* --------------------------------------------------------------------------
   08  Product grid — DESIGN §4.4 (tight columns, generous rows = a shelf)
   -------------------------------------------------------------------------- */
.grid-products {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: var(--grid-col-gap);
  row-gap: var(--grid-row-gap);
}
@media (min-width: 768px)  { .grid-products { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .grid-products { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
/* density hooks (page JS sets data-density; rail layouts use 3) */
@media (max-width: 767.98px) { .grid-products[data-density="1"] { grid-template-columns: minmax(0, 1fr); } }
@media (min-width: 1024px) {
  .grid-products[data-density="3"], .has-rail .grid-products { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 1536px) {
  .grid-products[data-density="6"] { grid-template-columns: repeat(6, minmax(0, 1fr)); column-gap: var(--sp-4); row-gap: 40px; }
}

/* --------------------------------------------------------------------------
   09  Accessibility helpers
   -------------------------------------------------------------------------- */
.skip-link {
  position: absolute;
  inset-block-start: var(--sp-4);
  inset-inline-start: var(--sp-4);
  z-index: var(--z-skip);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--r-pill);
  background: var(--ink);
  color: var(--bg);
  font-size: var(--fs-small);
  translate: 0 calc(-100% - var(--sp-6));
  opacity: 0;
  transition: translate var(--dur-2) var(--ease-out), opacity var(--dur-2);
}
.skip-link:focus-visible { translate: 0 0; opacity: 1; outline-color: var(--bg); outline-offset: -4px; }
.visually-hidden:not(:focus):not(:active) {
  position: absolute;
  inline-size: 1px; block-size: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* --------------------------------------------------------------------------
   10  Utilities
   -------------------------------------------------------------------------- */
.divider { border: 0; border-block-start: var(--hair); margin-block: var(--sp-6); }
.divider--gold { inline-size: var(--rule-eyebrow-w); border-block-start-color: var(--gold); margin-inline: 0; }
.divider--tight { margin-block: var(--sp-4); }
.stack > * + * { margin-block-start: var(--stack, var(--sp-4)); }
.stack--sm { --stack: var(--sp-2); }
.stack--lg { --stack: var(--sp-6); }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--cluster, var(--sp-3)); }
.cluster--between { justify-content: space-between; }
.text-muted { color: var(--muted); }
.text-ink-2 { color: var(--ink-2); }
.text-accent { color: var(--accent); }
.text-center { text-align: center; }
.text-start { text-align: start; }
.tabular { font-family: var(--font-latin-body); font-variant-numeric: lining-nums tabular-nums; }
.nowrap { white-space: nowrap; }
.full-bleed { inline-size: 100vw; margin-inline: calc(50% - 50vw); }
.plate { background: var(--plate); box-shadow: var(--plate-inset); }
.ratio-4-5 { aspect-ratio: 4 / 5; }
.ratio-3-4 { aspect-ratio: 3 / 4; }
.ratio-16-10 { aspect-ratio: 16 / 10; }
.ratio-21-9 { aspect-ratio: 21 / 9; }
.object-cover { inline-size: 100%; block-size: 100%; object-fit: cover; }
.object-contain { inline-size: 100%; block-size: 100%; object-fit: contain; }
.hide-mobile { display: none; }
@media (min-width: 1024px) { .hide-mobile { display: revert; } .hide-desktop { display: none; } }
/* horizontal scrollers (mobile card rows): snap + hidden scrollbar */
.scroller {
  display: flex;
  gap: var(--grid-col-gap);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: var(--gutter);
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.scroller::-webkit-scrollbar { display: none; }
.scroller > * { scroll-snap-align: start; flex: none; }
.dots { display: flex; gap: var(--sp-1); }
.dots__dot { inline-size: 24px; block-size: 1px; background: var(--line-strong); transition: background-color var(--dur-2); }
.dots__dot.is-active { background: var(--accent); }

/* --------------------------------------------------------------------------
   11  Motion — reveal, line-mask, page transitions (all reduced-motion safe)
   -------------------------------------------------------------------------- */
[data-reveal] {
  opacity: 0;
  translate: 0 var(--reveal-y);
  transition: opacity var(--dur-5) var(--ease-out), translate var(--dur-5) var(--ease-out);
}
[data-reveal].is-visible { opacity: 1; translate: 0 0; }
img[data-reveal], picture[data-reveal], [data-reveal="fade"] { translate: none; }
[data-reveal-delay="1"] { transition-delay: calc(1 * var(--stagger)); }
[data-reveal-delay="2"] { transition-delay: calc(2 * var(--stagger)); }
[data-reveal-delay="3"] { transition-delay: calc(3 * var(--stagger)); }
[data-reveal-delay="4"] { transition-delay: calc(4 * var(--stagger)); }
[data-reveal-delay="5"] { transition-delay: calc(5 * var(--stagger)); }
[data-reveal-delay="6"] { transition-delay: calc(6 * var(--stagger)); }

/* line-mask headline reveal: <span class="line"><span class="line__in">…</span></span> */
.line { display: block; overflow: hidden; padding-block: .1em; margin-block: -.1em; }
.line__in { display: block; translate: 0 110%; }
.is-visible .line__in, .fonts-loaded .is-visible .line__in {
  translate: 0 0;
  transition: translate var(--dur-line) var(--ease-expo) calc(var(--i, 0) * var(--stagger-line));
}

/* image fade-in over the plate (no blur-up) */
.img-fade { opacity: 0; transition: opacity 240ms var(--ease-out); }
.img-fade.is-loaded { opacity: 1; }

/* progressive page transitions */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 250ms; animation-timing-function: var(--ease-in-out); }
.header { view-transition-name: header; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .skip-link, [data-reveal], .line__in { transition: none; }
}
