/* ============================================================
   LAMSA — base.css
   Design tokens, reset, typography, buttons, forms, utilities.
   RTL-friendly: layout uses logical properties throughout.
   ============================================================ */

:root {
  /* ============================================================
     LAMSA palette — premium streetwear, five colours only.
       Primary Black   #111111
       Warm Off-White  #F5F5F2
       Charcoal Gray   #777777
       Soft Stone      #B7A99A
       Pure White      #FFFFFF
     Legacy token names are kept (remapped) so every existing
     component continues to resolve without markup changes.
     ============================================================ */
  --ink: #111111;
  --charcoal: #111111;
  /* Raw channels of --ink, so translucent tints follow the theme:
     rgb(var(--ink-rgb) / 0.06) is a black wash in light mode and a
     white wash in dark mode. */
  --ink-rgb: 17 17 17;
  --bg-rgb: 245 245 242;
  /* Channels of --paper: the frosted plates that sit over product
     photography are white in light mode and near-black in dark mode. */
  --paper-rgb: 255 255 255;
  --graphite: rgba(17, 17, 17, 0.22);
  --graphite-soft: rgba(17, 17, 17, 0.34);
  --ivory: #F5F5F2;
  --paper: #FFFFFF;
  --terra: #111111;          /* former accent → primary black */
  --terra-soft: #6E6E6E;     /* hover / secondary accent (AA on #F5F5F2) */
  --terra-deep: #111111;
  --clay: #B7A99A;           /* soft stone */
  --success: #2E7D4F;
  --danger: #B3322B;
  --warning: #A8791C;
  --focus-ring: #111111;

  /* Typography */
  --font-display: "Playfair Display", "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --font-sans: "Inter", "Manrope", -apple-system, "Segoe UI", system-ui, sans-serif;
  --font-arabic: "Cairo", "Inter", "Manrope", "Segoe UI", Tahoma, sans-serif;

  /* Spacing */
  --space: 0.25rem;
  --container: 1440px;
  --gutter: clamp(1.25rem, 4vw, 3rem);
  --section-y: clamp(4rem, 10vw, 8rem);

  /* Motion */
  --ease-expo: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-soft: cubic-bezier(0.33, 0.6, 0.24, 1);
  --dur-fast: 160ms;
  --dur-mid: 350ms;
  --dur-slow: 650ms;

  /* Elevation — deliberately restrained */
  --shadow-float: 0 18px 50px rgba(17, 17, 17, 0.12);
  --shadow-card: 0 6px 24px rgba(17, 17, 17, 0.07);
  --glass: rgba(245, 245, 242, 0.88);

  /* Surfaces — light by default */
  --bg: #F5F5F2;
  --bg-elev: #FFFFFF;
  --bg-card: #FFFFFF;
  /* Stone wash: #B7A99A laid over #F5F5F2 at 16% — still inside the palette.
     Kept as a wash (not a hex) so the band can never drift out of the five
     colours: on #F5F5F2 this renders #EBE9E4, and over any other surface it
     stays the same tint instead of turning into a separate grey. */
  --bg-stone: rgba(183, 169, 154, 0.16);
  --border: rgba(17, 17, 17, 0.12);
  --text: #111111;
  /* #777777 on #F5F5F2 is 4.10:1 — below WCAG AA for body/small text.
     #6E6E6E keeps the same neutral family at 4.67:1. */
  --text-muted: #6E6E6E;
  --text-faint: rgba(17, 17, 17, 0.62);
}

/* Dark surfaces (footer, announcement, image lightboxes) */
.theme-dark {
  --bg: #111111;
  --bg-elev: #111111;
  --bg-card: #111111;
  --border: rgba(255, 255, 255, 0.14);
  --text: #FFFFFF;
  --text-muted: #B7A99A;
  --text-faint: rgba(255, 255, 255, 0.55);
  --graphite: rgba(255, 255, 255, 0.22);
  --graphite-soft: rgba(255, 255, 255, 0.34);
  --terra-soft: #FFFFFF;
  color: var(--text);
}

/* Light surfaces (kept for editorial blocks) */
.theme-light {
  --bg: #FFFFFF;
  --text: #111111;
  --text-muted: #6E6E6E;
  --text-faint: rgba(17, 17, 17, 0.62);
  --border: rgba(17, 17, 17, 0.12);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

/* Arabic typography
   Playfair Display has no Arabic glyphs, so on an RTL page the serif stack
   would silently fall back to a system serif for every heading. Pointing the
   display and sans variables at the Arabic stack means an Arabic page loads
   Cairo only (plus Inter for the Latin words and digits inside it, selected
   by unicode-range) and a Latin page never loads Cairo. */
[dir="rtl"] {
  --font-display: var(--font-arabic);
  --font-sans: var(--font-arabic);
}

[dir="rtl"] body,
[dir="rtl"] .input,
[dir="rtl"] button,
[dir="rtl"] input,
[dir="rtl"] select,
[dir="rtl"] textarea {
  font-family: var(--font-arabic);
  letter-spacing: 0 !important;
}

/* Money is Latin digits plus a Latin currency code ("399.00 MAD"). Inside an
   RTL paragraph the bidi algorithm flips that run and customers read
   "MAD 399.00", so each price is pinned to its own LTR island while keeping
   its RTL place in the row. Same for the "-33%" sale badge, whose minus
   otherwise jumps to the wrong end. */
[dir="rtl"] .product-card__sale,
[dir="rtl"] .product-card__old,
[dir="rtl"] .badge--sale,
[dir="rtl"] .pdp-media__counter,
[dir="rtl"] .pdp-price__now,
[dir="rtl"] .pdp-price__old,
[dir="rtl"] .pdp-sticky__price,
[dir="rtl"] .product-info__price,
[dir="rtl"] .product-info__price-now,
[dir="rtl"] .product-info__price-old,
[dir="rtl"] .cart-line__price,
[dir="rtl"] .order-item__price,
[dir="rtl"] .summary-item__price,
[dir="rtl"] [data-cart-subtotal],
[dir="rtl"] [data-cart-total],
[dir="rtl"] .cart-summary__row > span:last-child,
[dir="rtl"] .summary-row > span:last-child {
  direction: ltr;
  unicode-bidi: isolate;
}

img,
svg,
video {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 500;
  line-height: 1.15;
  color: var(--text);
}

[dir="rtl"] h1,
[dir="rtl"] h2,
[dir="rtl"] h3 {
  font-family: var(--font-arabic);
  font-weight: 700;
}

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

[hidden] {
  display: none !important;
}

/* ---------- Typography helpers ---------- */

.eyebrow {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 1rem;
}

[dir="rtl"] .eyebrow {
  letter-spacing: 0.08em;
}

.section__title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.75rem, 4vw, 3rem);
  line-height: 1.08;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

/* ---------- Layout utilities ---------- */

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* Reading pages (about, FAQ, shipping, returns, terms, privacy, custom made,
   wishlist) ship with this modifier but it had no rule, so every paragraph
   ran the full 1400 px container: around 150 characters per line, twice the
   comfortable measure. 820 px keeps ~85 characters while staying wide enough
   for the wishlist's product grid. */
.container--narrow {
  max-width: 820px;
}

.section {
  padding-block: var(--section-y);
}

.section--dark {
  /* One continuous off-white field: the white cards are what lift off it. */
  background: var(--bg);
  color: var(--text);
}

/* A subtle stone band — used sparingly to separate the product rails from the
   editorial sections without introducing a second surface colour. */
.section--stone {
  background: var(--bg-stone);
  color: var(--text);
}

.section__head {
  margin-bottom: clamp(2rem, 5vw, 3.5rem);
}

.section__head--row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  padding-block-end: 1.1rem;
  border-block-end: 1px solid var(--border);
}

.section__head--center {
  text-align: center;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 1rem 1.9rem;
  border: 1px solid transparent;
  border-radius: 2px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transition: background var(--dur-mid) var(--ease-soft), color var(--dur-mid) var(--ease-soft), transform var(--dur-mid) var(--ease-soft), border-color var(--dur-mid) var(--ease-soft);
  user-select: none;
  line-height: 1;
}

[dir="rtl"] .btn {
  letter-spacing: 0.03em;
}

.btn:active {
  transform: scale(0.98);
}

.btn--primary {
  background: var(--ink);
  color: var(--paper);
}

.btn--primary:hover {
  background: var(--bg-elev);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
}

.btn--dark {
  background: var(--ink);
  color: var(--paper);
}

.btn--dark:hover {
  background: var(--bg-elev);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
}

.btn--ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--graphite);
}

.btn--ghost:hover {
  border-color: var(--ink);
  color: var(--text);
}

.btn--block {
  width: 100%;
}

/* ---------- Links ---------- */

.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--ink);
  padding-bottom: 0.3rem;
  color: var(--text);
  transition: opacity var(--dur-fast);
}

.link-arrow:hover {
  color: var(--text);
  opacity: 0.6;
}

/* The label carries its own arrow and leans forward on hover — a nudge,
   not a slide. Drawn in CSS so every link-arrow gets it, including the
   ones inside collection tiles. */
.link-arrow::after {
  content: "→";
  font-size: 0.95em;
  line-height: 1;
  transition: transform var(--dur-fast) var(--ease-soft);
}

.link-arrow:hover::after {
  transform: translateX(3px);
}

[dir="rtl"] .link-arrow::after {
  content: "←";
}

[dir="rtl"] .link-arrow:hover::after {
  transform: translateX(-3px);
}

/* Inside a row header the section rule already draws the line. */
.section__head--row .link-arrow {
  border-block-end: 0;
  padding-block-end: 0;
}

[dir="rtl"] .link-arrow svg {
  transform: scaleX(-1);
}

.wa-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--terra-soft);
  font-weight: 600;
  font-size: 0.9rem;
}

/* ---------- Icon button ---------- */

.icon-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 2px;
  color: var(--text);
  transition: color var(--dur-fast), background var(--dur-fast);
}

.icon-btn:hover {
  color: var(--text);
  background: rgb(var(--ink-rgb) / 0.06);
}

.badge-dot {
  position: absolute;
  inset-block-start: 2px;
  inset-inline-end: 0;
  min-width: 16px;
  height: 16px;
  padding-inline: 4px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.75rem;
  font-weight: 800;
  line-height: 16px;
  text-align: center;
}

/* ---------- Badges & swatches ---------- */

.badge {
  display: inline-block;
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: var(--ink);
  color: var(--paper);
  border-radius: 1px;
}

.badge--terra {
  background: var(--clay);
  color: var(--ink);
}

.badge--sale {
  background: var(--ink);
  color: var(--paper);
}

.swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--swatch, #ccc);
  border: 1px solid rgb(var(--ink-rgb) / 0.25);
  display: inline-block;
}

/* ---------- Forms ---------- */

.input,
select.input,
textarea.input {
  width: 100%;
  padding: 0.95rem 1.1rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 2px;
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  transition: border-color var(--dur-fast);
}

.input::placeholder {
  color: var(--text-muted);
}

.input.is-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 1px var(--danger);
}

.input:focus {
  outline: none;
  border-color: var(--terra);
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1.1rem;
}

.form-field__label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.form-field__error {
  color: var(--danger);
  font-size: 0.82rem;
}

.form-field__hint {
  font-size: 0.78rem;
  color: var(--text-faint);
  margin: 0;
}

/* ---------- Animations (progressive, reduced-motion aware) ---------- */

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes kenburns {
  from { transform: scale(1.05); }
  to { transform: scale(1.18); }
}

/* Two micro-motions: the cart count pops when it changes and the heart
   compresses before it fills. Both are one-shot and reduced-motion aware. */
@keyframes badgePop {
  0% { transform: scale(1); }
  38% { transform: scale(1.28); }
  100% { transform: scale(1); }
}

@keyframes heartPop {
  0% { transform: scale(1); }
  35% { transform: scale(0.78); }
  70% { transform: scale(1.14); }
  100% { transform: scale(1); }
}

[data-reveal] {
  opacity: 0;
}

/* app.js writes --reveal-delay on each element as it enters, so items that
   arrive together (a grid, a hero block) cascade instead of snapping. */
.revealed {
  opacity: 1;
  animation: fadeUp var(--dur-slow) var(--ease-expo) both;
  animation-delay: var(--reveal-delay, 0ms);
}

.badge-dot.is-pop {
  animation: badgePop 420ms var(--ease-expo);
}

.product-card__wishlist.is-pop svg {
  animation: heartPop 380ms var(--ease-expo);
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  [data-reveal] {
    opacity: 1;
    transform: none;
  }
  .hero__media {
    animation: none !important;
  }
}
