/* Vitrine — shared styles for the store and the admin page.
   Editorial and quiet: square edges, small type, photos do the work. */

:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --sunken: #f3f2ef;
  --ink: #111111;
  --ink-2: #6b6966;
  --ink-3: #a3a09b;
  --line: rgba(17, 17, 17, 0.12);
  --on-ink: #ffffff;
  --danger: #9b3a2a;
  --scrim: rgba(17, 17, 17, 0.28);
  --shadow-sheet: 0 -8px 40px rgba(17, 17, 17, 0.1);
  --gutter: 16px;

  --font-mark: "Amiri", "Noto Naskh Arabic", "Geeza Pro", serif;
  --font-body: "IBM Plex Sans Arabic", system-ui, -apple-system, "SF Arabic", "Segoe UI", Tahoma, sans-serif;
  --font-latin: "Cormorant Garamond", "Didot", "Bodoni 72", Georgia, serif;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not(.light) {
    --bg: #0c0c0c;
    --surface: #141414;
    --sunken: #1c1c1b;
    --ink: #f1efeb;
    --ink-2: #9d9a95;
    --ink-3: #686661;
    --line: rgba(241, 239, 235, 0.14);
    --on-ink: #0c0c0c;
    --danger: #e08a78;
    --scrim: rgba(0, 0, 0, 0.55);
    --shadow-sheet: 0 -8px 40px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }
html.locked, html.locked body { overflow: hidden; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 0.875rem/1.65 var(--font-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }

:focus-visible { outline: 1px solid var(--ink); outline-offset: 3px; }

/* Text buttons: the default control. Underline marks what is active. */
.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font-size: 0.8125rem;
  text-decoration: none;
  white-space: nowrap;
  transition: opacity 120ms ease;
}
.link:active { opacity: 0.5; }

/* ---------- Top bar ---------- */

.bar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  backdrop-filter: blur(16px) saturate(160%);
  border-bottom: 1px solid transparent;
  transition: border-color 200ms ease;
}
.bar.scrolled { border-bottom-color: var(--line); }

.bar-inner {
  height: 56px;
  padding: 0 var(--gutter);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}
.bar-inner > :first-child { justify-self: start; }
.bar-inner > :last-child { justify-self: end; }

.brand {
  font: 400 1.5rem/1 var(--font-mark);
  text-decoration: none;
  white-space: nowrap;
}

.contacts { display: flex; gap: 14px; }
.contacts [hidden] { display: none; }

.bag-link { font-variant-numeric: tabular-nums; }
.bag-link .n.bump { display: inline-block; animation: bump 320ms ease-out; }
@keyframes bump { 40% { opacity: 0.2; } 100% { opacity: 1; } }

/* ---------- Category nav ---------- */

.nav {
  display: flex;
  justify-content: center;
  gap: 22px;
  overflow-x: auto;
  padding: 6px var(--gutter) 14px;
  scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }
.nav .link { padding: 4px 0; color: var(--ink-2); }
.nav .link[aria-pressed="true"] { color: var(--ink); text-decoration: underline; text-underline-offset: 7px; text-decoration-thickness: 1px; }
@media (max-width: 560px) { .nav { justify-content: flex-start; } }

/* ---------- Editorial hero ---------- */

.hero { position: relative; display: grid; gap: 2px; height: min(78svh, 760px); background: var(--bg); overflow: hidden; }
.hero img { width: 100%; height: 100%; min-height: 0; object-fit: cover; object-position: 50% 20%; background: var(--sunken); }
.hero img + img { display: none; }
@media (min-width: 900px) {
  .hero { grid-template-columns: 1fr 1fr; height: min(88svh, 900px); }
  .hero img + img { display: block; }
}
.hero-text {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  padding: 28px var(--gutter);
  color: #111;
}
.hero-text p { margin: 0; font-size: 0.8125rem; }
.hero-text h1 { margin: 2px 0 10px; font-size: 1.375rem; font-weight: 500; line-height: 1.35; }
.hero-text .link { color: #111; text-decoration: underline; text-underline-offset: 6px; text-decoration-thickness: 1px; }

/* ---------- Toolbar above the grid ---------- */

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 26px var(--gutter) 14px;
  color: var(--ink-2);
  font-size: 0.75rem;
}
.check { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); }
.check::before {
  content: "";
  width: 12px;
  height: 12px;
  border: 1px solid var(--ink);
  transition: background-color 120ms ease;
}
.check[aria-pressed="true"]::before { background: var(--ink); box-shadow: inset 0 0 0 2px var(--bg); }

/* ---------- Product grid: edge to edge, hairline gaps ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 26px 2px;
  padding-bottom: 64px;
}
@media (min-width: 900px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 36px 2px; } }

.card {
  display: block;
  align-self: start;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  text-align: start;
}
.media { position: relative; aspect-ratio: 3 / 4; overflow: hidden; background: var(--sunken); }
.media img { width: 100%; height: 100%; object-fit: cover; transition: opacity 200ms ease; }
.card:active .media img { opacity: 0.85; }
.card.out .media img { opacity: 0.5; }

.card-info { padding: 10px 12px 0; }
.card-name, .card-price, .card-status { margin: 0; font-size: 0.8125rem; line-height: 1.5; }
.card-price { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.card-status { margin-top: 2px; color: var(--ink-3); font-size: 0.75rem; }

.empty { padding: 64px var(--gutter); color: var(--ink-3); text-align: center; }

.foot {
  display: grid;
  gap: 18px;
  padding: 32px var(--gutter) calc(36px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 0.75rem;
}
@media (min-width: 720px) { .foot { grid-template-columns: 1fr auto; align-items: end; } }
.foot p { margin: 0; max-width: 46ch; }
.foot .made a { text-decoration: none; font: 500 0.875rem/1 var(--font-latin); letter-spacing: 0.2em; color: var(--ink); }

/* ---------- Sheets ---------- */

.sheet-root { position: fixed; inset: 0; z-index: 50; }
.scrim { position: absolute; inset: 0; background: var(--scrim); opacity: 0; }

.sheet {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  max-width: 600px;
  max-height: 94dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  border-radius: 12px 12px 0 0;
  background: var(--surface);
  box-shadow: var(--shadow-sheet);
  transform: translate3d(0, 100%, 0);
  will-change: transform;
}

.sheet-grab { flex: none; padding: 8px var(--gutter) 4px; touch-action: none; cursor: grab; }
.grabber { width: 36px; height: 4px; margin: 0 auto 8px; border-radius: 2px; background: var(--line); }
.sheet-title { display: flex; align-items: center; justify-content: space-between; min-height: 32px; }
.sheet-title h2 { margin: 0; font-size: 0.9375rem; font-weight: 500; }

.close-btn { padding: 4px 0; border: 0; background: none; color: var(--ink); font-size: 0.8125rem; text-decoration: underline; text-underline-offset: 5px; text-decoration-thickness: 1px; }
.close-btn:active { opacity: 0.5; }

.sheet-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px var(--gutter) calc(20px + env(safe-area-inset-bottom));
}

/* ---------- Product detail ---------- */

.gallery {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  margin: 0 calc(var(--gutter) * -1);
  scrollbar-width: none;
}
.gallery::-webkit-scrollbar { display: none; }
.gallery .media { flex: 0 0 100%; aspect-ratio: auto; height: min(62dvh, 640px); scroll-snap-align: center; }
.gallery .media img { object-position: 50% 25%; }

.detail-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin: 20px 0 0; }
.detail-head h3 { margin: 0; font-size: 1rem; font-weight: 500; line-height: 1.4; }
.detail-price { margin: 0; font-size: 0.9375rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.detail-meta { margin: 2px 0 0; color: var(--ink-2); font-size: 0.75rem; }
.detail-meta .share { color: var(--ink); font-size: 0.75rem; text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px; }
.detail-desc { margin: 16px 0 0; color: var(--ink-2); }

.field-label { display: block; margin: 22px 0 10px; color: var(--ink); font-size: 0.75rem; font-weight: 500; }
.options { display: flex; flex-wrap: wrap; gap: 6px; }

/* Size and colour boxes: square, outlined, filled when chosen. */
.chip {
  min-width: 48px;
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-size: 0.8125rem;
  white-space: nowrap;
  transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease;
}
.chip:active { border-color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }

.hint { min-height: 1.5em; margin: 10px 0 0; color: var(--danger); font-size: 0.75rem; }

/* ---------- Buttons ---------- */

.btn {
  width: 100%;
  height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--ink);
  color: var(--on-ink);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: opacity 120ms ease;
}
.btn:active { opacity: 0.8; }
.btn[disabled] { background: transparent; color: var(--ink-3); border-color: var(--line); pointer-events: none; }
.btn svg { width: 18px; height: 18px; }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.small { width: auto; height: 40px; padding: 0 18px; font-size: 0.8125rem; }

.sticky-action {
  position: sticky;
  bottom: calc(-20px - env(safe-area-inset-bottom));
  margin: 24px calc(var(--gutter) * -1) calc(-20px - env(safe-area-inset-bottom));
  padding: 12px var(--gutter) calc(12px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--line);
}

/* ---------- Bag ---------- */

.line {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 14px;
  align-items: start;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.line .media { width: 72px; }
.line-name, .line-meta, .line-price { margin: 0; font-size: 0.8125rem; }
.line-meta { color: var(--ink-2); font-size: 0.75rem; }
.line-price { margin-top: 6px; font-variant-numeric: tabular-nums; }

.stepper { display: flex; align-items: center; border: 1px solid var(--line); }
.stepper button { width: 32px; height: 32px; border: 0; background: transparent; font-size: 1rem; line-height: 1; }
.stepper button:active { background: var(--sunken); }
.stepper span { min-width: 20px; text-align: center; font-size: 0.8125rem; font-variant-numeric: tabular-nums; }

.total { display: flex; justify-content: space-between; align-items: baseline; padding: 18px 0 4px; font-weight: 500; }
.total strong { font-weight: 500; font-variant-numeric: tabular-nums; }
.fine { margin: 0; color: var(--ink-3); font-size: 0.75rem; }

/* Fields: a single hairline, like a printed form. */
.form { display: grid; gap: 18px; margin-top: 26px; }
.input-wrap label { display: block; color: var(--ink-2); font-size: 0.75rem; }
.input {
  width: 100%;
  height: 42px;
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  font-size: 0.9375rem;
  transition: border-color 140ms ease;
}
textarea.input { height: auto; min-height: 64px; padding-top: 10px; resize: vertical; }
select.input { -webkit-appearance: none; appearance: none; }
.input:focus { outline: none; border-bottom-color: var(--ink); }
.input-wrap.invalid .input { border-bottom-color: var(--danger); }
.input-wrap .err { margin: 6px 0 0; color: var(--danger); font-size: 0.75rem; }

.done { padding: 36px 0 8px; }
.done h3 { margin: 0 0 6px; font-size: 1rem; font-weight: 500; }
.done p { margin: 0 0 24px; color: var(--ink-2); }

/* ---------- Stores that sell routines and take prepayment ---------- */

.ref-bar { margin: 0; padding: 8px var(--gutter); background: var(--ink); color: var(--on-ink); font-size: 0.75rem; text-align: center; }

.section-title { margin: 0 0 14px; font-size: 0.9375rem; font-weight: 500; }

/* Trust photos under the hero: four small frames, one line each. */
.trust {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 2px;
  padding-top: 2px;
}
@media (max-width: 720px) { .trust { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 2px; } }
.trust figure { margin: 0; }
.trust .media { aspect-ratio: 4 / 3; }
.trust figcaption { padding: 8px 12px 0; color: var(--ink-2); font-size: 0.75rem; line-height: 1.5; }
.trust figcaption b { display: block; color: var(--ink); font-weight: 500; font-size: 0.8125rem; }

.routines { display: grid; gap: 2px; padding: 40px 0 8px; }
.routines .section-title { padding: 0 var(--gutter); }
.routine { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0; background: var(--sunken); }
@media (max-width: 720px) { .routine { grid-template-columns: 1fr; } }
.routine-imgs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px; }
.routine-imgs .media { aspect-ratio: 1; }
.routine-text { padding: 22px var(--gutter); display: flex; flex-direction: column; align-items: flex-start; }
.routine-text h3 { margin: 0; font-size: 1rem; font-weight: 500; }
.routine-for { margin: 2px 0 0; color: var(--ink-2); font-size: 0.75rem; }
.routine-steps { list-style: none; margin: 16px 0 0; padding: 0; width: 100%; }
.routine-steps li { display: flex; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 0.8125rem; }
.routine-steps span { min-width: 64px; color: var(--ink-2); font-size: 0.75rem; }
.routine-tip { margin: 14px 0 0; color: var(--ink-2); font-size: 0.75rem; max-width: 52ch; }
.routine-price { margin: 16px 0 14px; font-variant-numeric: tabular-nums; }
.routine-price strong { font-weight: 500; font-size: 0.9375rem; }
.routine-price s { margin-inline-start: 8px; color: var(--ink-3); font-size: 0.8125rem; }

.card-badge { margin: 0 0 2px; color: var(--ink-2); font-size: 0.6875rem; letter-spacing: 0.02em; }
.card-badge::before { content: "● "; font-size: 0.5rem; vertical-align: 2px; }

.specs { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 0; }
.specs span { padding: 2px 8px; border: 1px solid var(--line); font-size: 0.75rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.usage { margin-top: 4px; }
.usage ul { margin: 0; padding-inline-start: 18px; color: var(--ink); font-size: 0.8125rem; }
.usage li + li { margin-top: 4px; }
.warning { margin: 12px 0 0; padding: 10px 12px; border-inline-start: 2px solid var(--danger); background: var(--sunken); color: var(--danger); font-size: 0.8125rem; }

/* A routine in the bag shows its items as a 2×2 tile. */
.line .stack { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; height: 100%; }
.line .stack img { width: 100%; height: 100%; object-fit: cover; }

.sums { padding-top: 14px; }
.sum-row { display: flex; justify-content: space-between; padding: 3px 0; color: var(--ink-2); font-size: 0.8125rem; font-variant-numeric: tabular-nums; }
.sum-row.minus span:last-child { color: var(--ink); }
.sums .total { padding-top: 10px; margin-top: 6px; border-top: 1px solid var(--line); }
.sums .fine { margin: 2px 0 4px; }
.err-text { color: var(--danger); }

.pay-options { display: grid; gap: 6px; }
.pay-option { display: grid; gap: 2px; padding: 12px 14px; border: 1px solid var(--line); background: transparent; text-align: start; }
.pay-option b { font-weight: 500; font-size: 0.875rem; }
.pay-option span { color: var(--ink-2); font-size: 0.75rem; }
.pay-option[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.pay-option[disabled] { opacity: 0.45; cursor: not-allowed; }

.eyebrow-s { margin: 18px 0 2px; color: var(--ink-2); font-size: 0.75rem; font-variant-numeric: tabular-nums; }
.pay-title { margin: 0 0 18px; font-size: 1.125rem; font-weight: 500; font-variant-numeric: tabular-nums; }
.wallet { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px; background: var(--sunken); }
.wallet div { display: grid; gap: 2px; }
.wallet span { color: var(--ink-2); font-size: 0.75rem; }
.wallet strong { font-weight: 500; font-size: 1.125rem; letter-spacing: 0.06em; font-variant-numeric: tabular-nums; text-align: right; }
.pay-steps { margin: 18px 0 0; padding-inline-start: 18px; font-size: 0.8125rem; }
.pay-steps li + li { margin-top: 4px; }
.link.underline { text-decoration: underline; text-underline-offset: 5px; text-decoration-thickness: 1px; }
.sticky-action .back { display: block; margin: 12px auto 0; color: var(--ink-2); }

/* ---------- Marketer page ---------- */

.m-wrap { max-width: 960px; margin: 0 auto; padding: 0 var(--gutter) 56px; }
.m-head { padding: 28px 0 22px; }
.m-head h1 { margin: 0; font-size: 1.5rem; font-weight: 500; }
.m-stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 2px; background: var(--bg); }
@media (max-width: 720px) { .m-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } .m-stats > :first-child { grid-column: 1 / -1; } }
.m-stats div { display: grid; gap: 4px; padding: 16px; background: var(--sunken); }
.m-stats span { color: var(--ink-2); font-size: 0.75rem; }
.m-stats strong { font-weight: 500; font-size: 1.375rem; font-variant-numeric: tabular-nums; }
.m-block { padding-top: 36px; }
.copy-row { display: flex; gap: 8px; margin-bottom: 8px; }
.copy-row code { flex: 1; min-width: 0; padding: 10px 12px; border: 1px solid var(--line); font: 400 0.8125rem/1.5 ui-monospace, Menlo, monospace; text-align: left; overflow-wrap: anywhere; }
.copy-row .btn { flex: none; height: auto; }
.terms { margin: 14px 0 0; padding-inline-start: 18px; color: var(--ink-2); font-size: 0.8125rem; }
.terms li + li { margin-top: 4px; }
.table-wrap { overflow-x: auto; }
.m-table { width: 100%; border-collapse: collapse; font-size: 0.8125rem; font-variant-numeric: tabular-nums; }
.m-table th { padding: 8px 10px 8px 0; color: var(--ink-2); font-weight: 400; font-size: 0.75rem; text-align: start; border-bottom: 1px solid var(--ink); white-space: nowrap; }
.m-table td { padding: 11px 10px 11px 0; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: top; }
.m-table td.wrap { white-space: normal; min-width: 180px; }
.tag { margin-inline-start: 4px; padding: 0 6px; border: 1px solid var(--line); color: var(--ink-2); font-size: 0.6875rem; }
.state { font-size: 0.75rem; }
.state::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-inline-end: 6px; border-radius: 50%; background: currentColor; vertical-align: 1px; }
.state.pending, .state.holding { color: var(--ink-2); }
.state.ready { color: #2f6b4a; }
.state.paid { color: var(--ink-3); }
.posts { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 2px; }
.post { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; padding: 16px; background: var(--sunken); font-size: 0.8125rem; }
.post p { margin: 0; }
.post-link { color: var(--ink-2); font-size: 0.75rem; overflow-wrap: anywhere; }
.post .link { margin-top: auto; }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  z-index: 80;
  inset-inline: var(--gutter);
  bottom: calc(16px + env(safe-area-inset-bottom));
  max-width: 420px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  background: var(--ink);
  color: var(--on-ink);
  font-size: 0.8125rem;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 200ms ease, transform 260ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.toast.show { opacity: 1; transform: none; pointer-events: auto; }
.toast button { border: 0; background: none; color: inherit; padding: 0; text-decoration: underline; text-underline-offset: 4px; }

/* ---------- Accessibility preferences ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; }
  .toast { transform: none; }
}
@media (prefers-reduced-transparency: reduce) {
  .bar { background: var(--bg); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@media (prefers-contrast: more) {
  :root { --line: rgba(17, 17, 17, 0.45); --ink-2: #3c3a37; }
}

/* The order as the customer will paste it, so they can see it and copy it by hand if needed. */
.order-text { margin: 0 0 16px; padding: 12px 14px; max-height: 220px; overflow: auto; background: var(--sunken); font: 400 0.8125rem/1.7 var(--font-body); white-space: pre-wrap; user-select: all; -webkit-user-select: all; }
