/* Layout and components shared by every style. Everything visual reads a
   token; styles.css sets the tokens (and adds its own touches) per
   [data-style]. Palette colours arrive as --p-deep … --p-muted (palettes.js). */

:root {
  --bg: #fafbfc;
  --bg-2: #f1f3f6;
  --surface: #ffffff;
  --text: #0b0b0f;
  --muted: #6b7280;
  --line: rgba(15, 23, 42, 0.08);
  --primary: var(--p-primary);
  --on-primary: var(--p-on-primary);
  --accent: var(--p-accent);
  --off: #e8553a; /* discount badge: always a warm, high-contrast colour */
  --radius: 18px;
  --radius-sm: 12px;
  --img-radius: 14px;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  --shadow-hover: 0 18px 40px rgba(15, 23, 42, 0.12);
  --font: 'Tajawal', system-ui, sans-serif;
  --font-display: 'Tajawal', system-ui, sans-serif;
  --header-bg: rgba(255, 255, 255, 0.92);
  --card-bg: var(--surface);
  --chip-bg: var(--surface);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  overflow-x: hidden;
}
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
#bg { position: fixed; inset: 0; z-index: -1; pointer-events: none; }

.wrap { width: min(1240px, 100% - 32px); margin-inline: auto; }

/* boot / empty states */
.boot, .gone { min-height: 100vh; display: grid; place-items: center; text-align: center; padding: 24px; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--primary); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.preview-bar { background: #f59e0b; color: #111; text-align: center; font-weight: 800; padding: 8px 12px; font-size: 14px; }

/* header */
.site-header { position: sticky; top: 0; z-index: 20; background: var(--header-bg); border-bottom: 1px solid transparent; transition: border-color 0.2s, box-shadow 0.2s; }
.site-header.scrolled { border-bottom-color: var(--line); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.05); }
.header-row { display: flex; align-items: center; gap: 16px; height: 72px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo { width: 40px; height: 40px; border-radius: 12px; object-fit: cover; }
.logo-mark { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--primary); color: var(--on-primary); font-weight: 900; font-size: 20px; }
.brand-name { font-family: var(--font-display); font-weight: 800; font-size: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search { flex: 1; max-width: 460px; margin-inline-start: auto; display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 14px; border-radius: 999px; background: var(--chip-bg); border: 1px solid var(--line); }
.search svg { width: 18px; height: 18px; fill: var(--muted); flex: none; }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font: inherit; color: var(--text); }
.cart-btn { position: relative; width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line); background: var(--chip-bg); display: grid; place-items: center; flex: none; }
.cart-btn svg { width: 22px; height: 22px; fill: currentColor; }
.cart-btn .count { position: absolute; top: -4px; inset-inline-start: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px; background: var(--off); color: #fff; font-size: 12px; font-weight: 800; display: grid; place-items: center; }

/* hero */
.hero { padding: 56px 0 40px; }
.hero-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 40px; align-items: center; }
.eyebrow { display: inline-block; font-size: 13px; font-weight: 700; color: var(--primary); letter-spacing: 0.02em; margin-bottom: 10px; }
.hero h1 { font-family: var(--font-display); font-size: clamp(36px, 5.5vw, 68px); line-height: 1.05; margin: 0 0 16px; font-weight: 900; }
.lead { font-size: 18px; color: var(--muted); max-width: 520px; margin: 0 0 26px; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; }
.hero-art { position: relative; aspect-ratio: 1 / 0.9; }
.hero-pic { position: absolute; margin: 0; overflow: hidden; border-radius: var(--radius); box-shadow: var(--shadow-hover); }
.hero-pic img { width: 100%; height: 100%; object-fit: cover; }
/* One large photo on the reading side, two smaller ones overlapping it. */
.hp0 { top: 0; bottom: 14%; inset-inline-start: 0; inset-inline-end: 22%; z-index: 1; }
.hp1 { width: 40%; height: 42%; inset-inline-end: 0; top: 10%; z-index: 2; }
.hp2 { width: 36%; height: 38%; inset-inline-end: 12%; bottom: 0; z-index: 3; }
.hero-orb { display: none; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 50px; padding: 0 26px; border-radius: 999px; font-weight: 800; border: 1px solid transparent; transition: transform 0.18s var(--ease), box-shadow 0.18s, background 0.18s; }
.btn:active { transform: translateY(1px) scale(0.98); }
.btn-primary { background: var(--primary); color: var(--on-primary); box-shadow: 0 10px 24px color-mix(in srgb, var(--primary) 35%, transparent); }
.btn-primary:hover { transform: translateY(-2px); }
.btn-primary:disabled { opacity: 0.45; box-shadow: none; transform: none; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn.wide { width: 100%; }

/* shelves */
.shelf { padding: 36px 0; }
.shelf-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.shelf-head h2 { font-family: var(--font-display); font-size: clamp(24px, 3vw, 34px); margin: 0; font-weight: 900; }
.shelf-head p { margin: 0; color: var(--muted); font-size: 14px; }
.rail { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 260px); gap: 18px; overflow-x: auto; padding: 4px 4px 18px; scroll-snap-type: x mandatory; scrollbar-width: thin; }
.rail > * { scroll-snap-align: start; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 16px; }
.chip { flex: none; height: 38px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--chip-bg); font-weight: 700; font-size: 14px; transition: background 0.18s, color 0.18s; }
.chip.on { background: var(--primary); color: var(--on-primary); border-color: transparent; }
.empty { color: var(--muted); padding: 24px 0; text-align: center; }

/* product card */
.card { background: var(--card-bg); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); box-shadow: var(--shadow); cursor: pointer; transition: transform 0.28s var(--ease), box-shadow 0.28s; }
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); }
.card-media { position: relative; aspect-ratio: 4 / 5; background: var(--bg-2); overflow: hidden; }
.card-media img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.6s var(--ease); }
.card:hover .card-media img { transform: scale(1.06); }
.card.is-out .card-media img { filter: grayscale(0.9); opacity: 0.6; }
.noimg { width: 100%; height: 100%; display: grid; place-items: center; font-size: 64px; font-weight: 900; color: var(--on-primary); background: linear-gradient(135deg, var(--primary), var(--accent)); }
.noimg.big { aspect-ratio: 1; font-size: 120px; border-radius: var(--img-radius); }
.noimg.sm { width: 56px; height: 56px; font-size: 0; border-radius: 10px; }
.badge-off, .badge-out, .badge-low { position: absolute; top: 12px; padding: 4px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 900; }
.badge-off { inset-inline-start: 12px; background: var(--off); color: #fff; }
.badge-off.inline { position: static; }
.badge-out { inset-inline-end: 12px; background: #111; color: #fff; }
.badge-low { inset-inline-end: 12px; background: #fff; color: #b45309; }
.card-body { padding: 12px 14px 16px; }
.card-cat { font-size: 12px; color: var(--muted); font-weight: 700; }
.card-name { font-size: 16px; line-height: 1.35; margin: 2px 0 8px; font-weight: 800; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.price { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.price .now { font-weight: 900; font-size: 17px; color: var(--text); }
.price .was { color: var(--muted); text-decoration: line-through; font-size: 14px; }
.price.big .now { font-size: 28px; }
.card-sizes { margin-top: 6px; font-size: 12.5px; color: var(--muted); }

/* reveal on scroll (styles choose the motion) */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity 0.6s var(--ease), transform 0.6s var(--ease); transition-delay: calc(var(--i, 0) * 40ms); }
.reveal.in { opacity: 1; transform: none; }

/* modal & drawer */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(5, 8, 15, 0.55); z-index: 40; animation: fade 0.2s; }
@keyframes fade { from { opacity: 0; } }
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; pointer-events: none; }
.modal-card { pointer-events: auto; position: relative; width: min(980px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); color: var(--text); border-radius: calc(var(--radius) + 6px); display: grid; grid-template-columns: 1.05fr 1fr; gap: 28px; padding: 22px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35); transform: translateY(20px) scale(0.98); opacity: 0; transition: transform 0.28s var(--ease), opacity 0.28s; }
.modal.open .modal-card { transform: none; opacity: 1; }
.modal-media img#main-pic { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; border-radius: var(--img-radius); }
.thumbs { display: flex; gap: 8px; margin-top: 10px; overflow-x: auto; }
.thumbs button { flex: none; width: 64px; height: 64px; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: none; }
.thumbs img { width: 100%; height: 100%; object-fit: cover; }
.modal-info h2 { font-family: var(--font-display); font-size: 30px; line-height: 1.2; margin: 4px 0 10px; }
.desc { color: var(--muted); }
.size-group { margin: 16px 0; }
.size-title { font-weight: 800; margin-bottom: 8px; }
.sizes { display: flex; flex-wrap: wrap; gap: 8px; }
.size { min-width: 56px; height: 46px; padding: 0 14px; border-radius: var(--radius-sm); border: 1.5px solid var(--line); background: var(--chip-bg); font-weight: 800; position: relative; transition: border-color 0.15s, background 0.15s; }
.size i { position: absolute; top: -8px; inset-inline-end: -6px; font-style: normal; font-size: 10px; background: #fef3c7; color: #92400e; border-radius: 999px; padding: 0 6px; }
.size.on { border-color: var(--primary); background: var(--primary); color: var(--on-primary); }
.size:disabled { opacity: 0.35; text-decoration: line-through; cursor: not-allowed; }
.stock-line { font-weight: 700; color: var(--muted); }
.modal-info .btn { margin-top: 18px; }
.x { position: absolute; top: 12px; inset-inline-end: 12px; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); z-index: 2; }
.drawer { position: fixed; top: 0; bottom: 0; inset-inline-end: 0; z-index: 50; width: min(420px, 100%); background: var(--surface); color: var(--text); box-shadow: -20px 0 60px rgba(0, 0, 0, 0.25); padding: 20px; display: flex; flex-direction: column; gap: 14px; transform: translateX(-100%); transition: transform 0.28s var(--ease); overflow: auto; }
[dir='rtl'] .drawer { transform: translateX(-100%); }
.drawer.open { transform: none; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; }
.drawer-head h3 { margin: 0; font-size: 22px; }
.drawer-head .x { position: static; }
.lines { display: flex; flex-direction: column; gap: 12px; }
.line { display: flex; gap: 12px; align-items: center; }
.line img { width: 56px; height: 56px; object-fit: cover; border-radius: 10px; }
.line-info { flex: 1; display: flex; flex-direction: column; font-size: 14px; min-width: 0; }
.line-info span { color: var(--muted); }
.qty { display: flex; align-items: center; gap: 8px; }
.qty button { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line); background: var(--chip-bg); }
.order-form { display: grid; gap: 8px; }
.order-form input { height: 44px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--chip-bg); color: var(--text); font: inherit; }
.total { display: flex; justify-content: space-between; font-size: 18px; padding-top: 8px; border-top: 1px solid var(--line); }

/* footer */
.site-footer { margin-top: 40px; padding: 32px 0; border-top: 1px solid var(--line); }
.footer-row { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.footer-row p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.footer-row .btn { margin-inline-start: auto; height: 44px; }
.powered { width: 100%; font-size: 12px; color: var(--muted); }

@media (max-width: 820px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-art { max-width: 460px; width: 100%; margin-inline: auto; }
  .modal-card { grid-template-columns: 1fr; }
  .header-row { gap: 10px; }
  .brand-name { font-size: 17px; }
}
@media (max-width: 560px) {
  .search { order: 3; max-width: none; flex-basis: 100%; }
  .header-row { flex-wrap: wrap; height: auto; padding: 10px 0; }
  .cart-btn { margin-inline-start: auto; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .rail { grid-auto-columns: 62%; }
  .card-body { padding: 10px 10px 12px; }
  .card-name { font-size: 14px; }
  .price .now { font-size: 15px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .reveal { opacity: 1; transform: none; }
}

/* Still frame for HQ's style thumbnails (?shot=1): everything already in
   place, and a shorter hero so products show in the same frame. */
.shot .reveal { opacity: 1 !important; transform: none !important; filter: none !important; transition: none !important; }
.shot .hero { padding: 28px 0 8px; }
.shot .hero-art { aspect-ratio: 1 / 0.62; }
.shot .hero h1 { font-size: 54px; }
