/* Storefront layout + components. Reads only theme tokens (public/themes/*.css); see docs/DESIGN.md.
   Rules: no shadows, no gradients, nothing rounder than --radius, hover = color/underline only (150ms). */

/* Spacing scale (only these values) + the few tokens every theme shares. */
:root {
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px; --s9: 96px;
  --max: 1200px;
  --gutter: 24px;
  --heading-tracking: 0;
  --image-ratio: 1 / 1;
  --danger: #B42318;          /* error text only */
  --scrim: rgb(0 0 0 / 0.45); /* behind dialogs and over hero photos */
  --header-pad: var(--s4);
  --ease: 150ms ease;
}
@media (max-width: 767px) { :root { --gutter: 16px; } }

*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  container-type: inline-size; /* lets full-bleed sections use cqw = body width (100vw would include the scrollbar) */
  font: var(--font-weight-regular) 16px/1.55 var(--font-body);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--text); text-decoration-thickness: 1px; text-underline-offset: 3px; transition: color var(--ease); }
a:hover { color: var(--text-secondary); }
h1, h2, h3 { font-family: var(--font-display); color: var(--text); margin: 0 0 var(--s4); letter-spacing: var(--heading-tracking); }
h1 { font-weight: var(--font-weight-light); font-size: var(--heading-size); line-height: 1.12; }
h2 { font-weight: var(--font-weight-light); font-size: 24px; line-height: 1.2; }
h3 { font-weight: var(--font-weight-regular); font-size: 16px; }
p { margin: 0 0 var(--s4); }
small, .muted { color: var(--text-secondary); }
.pre { white-space: pre-line; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

main, .header-inner, .footer-inner { max-width: var(--max); margin: 0 auto; padding-inline: var(--gutter); }
main { padding-block: var(--s6) var(--s8); overflow-wrap: anywhere; }

/* ---------- Header: sticky, compacts after scrolling (public/header.js) ---------- */
.site-header { position: sticky; top: 0; z-index: 30; background: var(--bg); border-bottom: 1px solid var(--border); }
.header-inner { display: flex; align-items: center; gap: var(--s5); padding-block: var(--header-pad); transition: padding var(--ease); }
.site-header.is-compact { --header-pad: var(--s2); }
.brand { display: inline-flex; align-items: center; gap: var(--s3); font-family: var(--font-display); font-size: 20px;
  font-weight: var(--font-weight-brand, 600); text-decoration: none; color: var(--text); white-space: nowrap; min-width: 0; }
.brand img { max-height: 40px; width: auto; flex: none; transition: max-height var(--ease); }
.brand-name { overflow: hidden; text-overflow: ellipsis; }
.is-compact .brand img { max-height: 32px; }
@media (max-width: 767px) { .brand { font-size: 17px; gap: var(--s2); } .brand img { max-height: 32px; } }
.header-right { margin-left: auto; display: flex; align-items: center; gap: var(--s5); }
.main-nav { display: flex; gap: var(--s5); }
.main-nav a { text-decoration: none; font-size: 15px; }
.main-nav a[aria-current] { text-decoration: underline; }
.icon-button { display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; background: none;
  color: var(--text); cursor: pointer; position: relative; text-decoration: none; }
.cart-count { position: absolute; top: 2px; right: 0; min-width: 18px; height: 18px; padding: 0 var(--s1); border-radius: var(--radius);
  background: var(--text); color: var(--bg); font-size: 11px; line-height: 18px; text-align: center; }
.menu-toggle, .search-toggle { display: none; }
.signed-in-dot { position: absolute; top: 7px; right: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--text); border: 1.5px solid var(--bg); }

/* Phones: hamburger at the right of the header + off-canvas menu from the right. */
@media (max-width: 767px) {
  .menu-toggle { display: inline-grid; margin-right: calc(var(--s2) * -1); }
  .search-toggle { display: inline-grid; }
  .header-right { gap: var(--s1); }
  .header-inner { gap: var(--s2); }
  .header-right .site-search, .main-nav { display: none; }
}
.offcanvas { margin: 0; inset: 0 0 0 auto; height: 100dvh; max-height: none; width: min(320px, 86vw); padding: var(--s4) var(--s5);
  border: 0; border-left: 1px solid var(--border); background: var(--bg); color: var(--text); }
.offcanvas::backdrop { background: var(--scrim); }
.offcanvas-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s4); }
.offcanvas nav { display: grid; margin-top: var(--s4); }
.offcanvas nav a { padding: var(--s3) 0; border-bottom: 1px solid var(--border); text-decoration: none; font-size: 18px; }
.offcanvas nav a[aria-current] { text-decoration: underline; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); color: var(--text-secondary); font-size: 14px; }
.footer-inner { display: grid; gap: var(--s5); grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); padding-block: var(--s7); }
.site-footer strong { color: var(--text); font-weight: var(--font-weight-regular); }
.site-footer a { color: var(--text-secondary); }
.footer-nav { display: flex; flex-wrap: wrap; gap: var(--s4); align-content: start; }

/* ---------- Buttons & inputs ---------- */
.button { display: inline-block; font: inherit; color: var(--text); background: none; border: 0; padding: 0;
  text-decoration: underline; cursor: pointer; } /* secondary action = text link */
.button.primary { background: var(--accent); color: var(--on-accent); border-radius: var(--radius); padding: var(--s3) var(--s5);
  text-decoration: none; text-align: center; }
.button.primary:hover { color: var(--on-accent); }
.button.block { display: block; width: 100%; }
.button:disabled { opacity: .45; cursor: not-allowed; }
button.link { font: inherit; color: var(--text); background: none; border: 0; padding: 0; text-decoration: underline; cursor: pointer; }
input:not([type=checkbox]):not([type=radio]), select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  min-height: 44px; padding: var(--s2) var(--s3); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.error { color: var(--danger); border: 1px solid currentColor; border-radius: var(--radius); padding: var(--s3) var(--s4); }
.error p { margin: var(--s1) 0; }
.notice { border: 1px solid var(--border); background: var(--surface-alt); border-radius: var(--radius); padding: var(--s3) var(--s4); }
.stack { display: grid; gap: var(--s4); }
.stack label { display: grid; gap: var(--s1); font-size: 14px; }
.narrow { max-width: 480px; }
.prose { max-width: 680px; }
.hp { position: absolute; left: -9999px; }

/* ---------- Prices ---------- */
.price { font-weight: var(--font-weight-light); font-size: var(--price-size); }
.card .price { font-size: 16px; font-weight: var(--font-weight-regular); }
.price s { color: var(--text-muted); margin-right: var(--s1); }
.sale-label { margin-left: var(--s2); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-secondary); }

/* ---------- Shop grid & cards (not boxed) ---------- */
.grid { display: grid; gap: var(--s6) var(--s5); grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.card { display: grid; gap: var(--s1); text-decoration: none; color: var(--text); align-content: start; }
.card h3 { margin: var(--s2) 0 0; font-size: 15px; }
.card-media, .img-placeholder { display: block; aspect-ratio: var(--image-ratio); background: var(--surface-alt); border-radius: var(--radius); overflow: hidden; }
.card-media img { width: 100%; height: 100%; object-fit: cover; }
.card:hover h3 { text-decoration: underline; }

/* ---------- Category filter: uniform squared boxes; current = strong border ---------- */
.category-nav { display: grid; gap: var(--s2); margin-bottom: var(--s6); }
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.chip { font-size: 14px; line-height: 1.2; padding: var(--s2) var(--s3); border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); text-decoration: none; transition: border-color var(--ease); }
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip[aria-current] { border-color: var(--border-strong); text-decoration: underline; }
.chips.sub .chip { background: transparent; }
.pager { display: flex; gap: var(--s4); justify-content: center; margin-top: var(--s7); }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s4); }

/* ---------- Product page: same markup, areas arranged per theme ---------- */
.product { display: grid; gap: var(--s5) var(--s7); grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  grid-template-areas: "gallery head" "gallery details"; grid-template-rows: auto 1fr; align-items: start; }
.product-head { grid-area: head; }
.gallery { grid-area: gallery; display: grid; gap: var(--s2); align-items: start; }
.details { grid-area: details; display: grid; gap: var(--s4); min-width: 0; }
.product > * { min-width: 0; }
@media (max-width: 767px) { .product { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "gallery" "details"; grid-template-rows: none; } }
.product-head h1 { margin: 0; }
.eyebrow { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-secondary); margin: 0 0 var(--s2); }
.eyebrow a { color: inherit; text-decoration: none; }

.gallery button { border: 0; padding: 0; background: var(--surface-alt); cursor: zoom-in; display: block; width: 100%; border-radius: var(--radius); overflow: hidden; }
.gallery-main img { width: 100%; aspect-ratio: var(--image-ratio); object-fit: cover; }
.gallery > .img-placeholder { width: 100%; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: var(--s2); }
.thumbs img { width: 100%; aspect-ratio: 1; object-fit: cover; }

/* Variant selector: fixed-width boxes; selected = strong border; unavailable = muted + struck, still clickable. */
.variant { border: 0; margin: 0; padding: 0; }
.variant legend { font-size: 14px; color: var(--text-secondary); margin-bottom: var(--s2); padding: 0; }
.variant-options { display: flex; flex-wrap: wrap; gap: var(--s2); }
.variant-box { position: relative; cursor: pointer; }
.variant-box input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.variant-box span { display: grid; place-items: center; min-width: 56px; min-height: 44px; padding: 0 var(--s3); font-size: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); transition: border-color var(--ease); }
.variant-box:hover span { border-color: var(--text-muted); }
.variant-box input:checked + span { border-color: var(--border-strong); color: var(--text); }
.variant-box input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.variant-box[data-unavailable] span { color: var(--text-muted); text-decoration: line-through; }
.stock { color: var(--text-secondary); font-size: 14px; margin: 0; }

.buy { display: grid; gap: var(--s3); grid-template-columns: minmax(0, 1fr); grid-template-areas: "qty" "button"; align-items: center; }
.buy .qty-field { grid-area: qty; } .buy .button { grid-area: button; } .buy-price { grid-area: price; }
.qty-field { display: grid; gap: var(--s1); font-size: 14px; color: var(--text-secondary); }
.qty-field input { width: 80px; }
.buy-price { display: none; }

.specs { margin: 0; border-top: 1px solid var(--border); font-size: 14px; }
.specs > div { display: grid; grid-template-columns: 120px 1fr; gap: var(--s4); padding: var(--s3) 0; border-bottom: 1px solid var(--border); }
.specs dt { color: var(--text-secondary); }
.specs dd { margin: 0; }
.specs .spec-price { display: none; }

.description.clamped { max-height: 12em; overflow: hidden; } /* Read more toggle in public/readmore.js; no fade (no gradients) */
.read-more { justify-self: start; }

/* Lightbox */
.lightbox { border: 0; padding: 0; background: transparent; max-width: 100vw; max-height: 100vh; width: 100vw; height: 100vh; }
.lightbox::backdrop { background: rgb(0 0 0 / .9); }
.lightbox[open] { display: grid; place-items: center; }
.lightbox img { max-width: 92vw; max-height: 86vh; object-fit: contain; touch-action: pan-y; user-select: none; -webkit-user-drag: none; }
.lightbox button { position: fixed; border: 0; background: var(--bg); color: var(--text); font-size: 24px; line-height: 1;
  width: 44px; height: 44px; border-radius: var(--radius); cursor: pointer; }
.lb-close { top: var(--s4); right: var(--s4); } .lb-prev { left: var(--s4); top: 50%; } .lb-next { right: var(--s4); top: 50%; }
.lb-count { position: fixed; bottom: var(--s4); left: 0; right: 0; text-align: center; color: #fff; margin: 0; }

/* ---------- Cart, thanks, account ---------- */
.cart-lines { list-style: none; padding: 0; margin: 0 0 var(--s5); border-top: 1px solid var(--border); }
.cart-lines li { display: flex; gap: var(--s4); align-items: center; padding: var(--s4) 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.cart-lines img, .cart-lines .img-placeholder { width: 64px; height: 64px; object-fit: cover; border-radius: var(--radius); aspect-ratio: 1; }
.cart-line-info { flex: 1 1 12rem; display: grid; min-width: 0; }
.qty { display: flex; gap: var(--s2); align-items: center; } .qty input { width: 72px; }
.totals { display: grid; grid-template-columns: 1fr auto; gap: var(--s2) var(--s6); max-width: 360px; margin: 0 0 0 auto; }
.totals dd { margin: 0; text-align: right; }
.totals .total { font-size: 20px; font-weight: var(--font-weight-light); }
.coupon { margin: var(--s5) 0; }
.coupon-form { display: flex; gap: var(--s3); align-items: end; flex-wrap: wrap; justify-content: flex-end; }
.coupon-form label { display: grid; gap: var(--s1); font-size: 14px; }
.coupon-form .error { flex-basis: 100%; }
.checkout-form { display: grid; justify-items: end; gap: var(--s3); margin-top: var(--s5); }
.checkout-form .button.primary { min-width: 240px; }

/* ---------- Page sections ---------- */
.hero { /* full-bleed: breaks out of main's max-width */
  position: relative; margin: calc(var(--s6) * -1) calc(50% - 50cqw) var(--s8); min-height: min(78vh, 704px); display: grid; align-items: center;
  background: var(--surface-alt) center / cover; color: var(--text); }
.hero.has-image { background-image: var(--hero-img); color: #fff; }
.hero.has-image::before { content: ""; position: absolute; inset: 0; background: var(--scrim); } /* flat tint for legible text, no gradient */
.hero-inner { position: relative; width: 100%; max-width: var(--max); margin: 0 auto; padding: var(--s8) var(--gutter); }
.hero h1 { color: inherit; font-size: max(var(--heading-size), 40px); max-width: 14ch; }
.hero p { font-size: 18px; max-width: 36rem; }
.product-grid-section { margin: var(--s8) 0; }
.story { margin: var(--s8) 0; display: grid; gap: var(--s6); max-width: 760px; }
.story.with-image { max-width: none; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); align-items: center; }
.story img { border-radius: var(--radius); }
.cta { padding: var(--s7) var(--s5); background: var(--surface-alt); border-radius: var(--radius); margin: var(--s7) 0; }
.contact-page { display: grid; gap: var(--s7); grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.contact-page > * { min-width: 0; }
.contact-form textarea { width: 100%; }
.map { width: 100%; border: 1px solid var(--border); border-radius: var(--radius); }

/* ---------- Header search + suggestions (border, no shadow) ---------- */
.site-search { position: relative; width: clamp(180px, 22vw, 280px); }
.site-search input { width: 100%; min-height: 40px; }
.search-results { position: absolute; top: calc(100% + var(--s1)); left: 0; right: 0; z-index: 40; background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius); max-height: min(70vh, 420px); overflow-y: auto; padding: var(--s1); min-width: 280px; }
.search-item { display: grid; grid-template-columns: 44px 1fr auto; gap: var(--s3); align-items: center; padding: var(--s1) var(--s2);
  border-radius: var(--radius); text-decoration: none; color: var(--text); }
.search-item img, .search-item .img-placeholder { width: 44px; height: 44px; object-fit: cover; border-radius: var(--radius); aspect-ratio: 1; }
.search-name { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-meta { font-size: 13px; color: var(--text-secondary); white-space: nowrap; }
.search-all { display: block; padding: var(--s2); border-top: 1px solid var(--border); margin-top: var(--s1); font-size: 14px; }
.search-item[aria-selected=true], .search-all[aria-selected=true], .search-item:hover, .search-all:hover { background: var(--surface-alt); color: var(--text); }
.search-empty { margin: 0; padding: var(--s3); color: var(--text-secondary); font-size: 14px; }

/* Descriptor line (e.g. "Organic cotton · Black") and tags */
.descriptor { margin: var(--s2) 0 0; color: var(--text-secondary); }
.card-descriptor { display: none; font-size: 14px; color: var(--text-secondary); }
.tags { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s3); }

/* ================= Theme-specific notes (docs/DESIGN.md) ================= */

/* A — Soft Gallery: wide-tracked uppercase store name. */
[data-theme="gallery"] .brand { text-transform: uppercase; letter-spacing: .2em; font-size: 16px; }

/* B — Warm Paper: price sits beside the add-to-cart button. */
[data-theme="paper"] .price-row { display: none; }
[data-theme="paper"] .card-descriptor { display: block; }
[data-theme="paper"] .buy { grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "qty qty" "price button"; column-gap: var(--s5); }
[data-theme="paper"] .buy-price { display: block; }

/* C — Cool Studio: oversized name spans the full width; details as label/value rows. Store name keeps the case the owner typed. */
[data-theme="studio"] .brand { font-size: 22px; }
[data-theme="studio"] .product { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "head head" "gallery details"; grid-template-rows: none; }
@media (max-width: 767px) { [data-theme="studio"] .product { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "gallery" "details"; } }
[data-theme="studio"] .price-row { display: none; }
[data-theme="studio"] .specs .spec-price { display: grid; }
[data-theme="studio"] .specs { order: -1; }

/* D — Swiss / Grid: black rules, filled selected variant, arrowed button, no light weights. */
[data-theme="swiss"] h1, [data-theme="swiss"] h2 { font-weight: 500; }
[data-theme="swiss"] .product-head { border-top: 1px solid var(--border); padding-top: var(--s3); }
[data-theme="swiss"] .price-row { border-top: 1px solid var(--border); padding-top: var(--s3); }
[data-theme="swiss"] .variant-box input:checked + span { background: var(--text); color: var(--bg); }
[data-theme="swiss"] .button.primary::after { content: " →"; }
[data-theme="swiss"] .card h3 { border-top: 1px solid var(--border); padding-top: var(--s2); font-weight: 500; }
[data-theme="swiss"] .hero h1 { font-size: 56px; }

/* Off-canvas menu slides in (not a hover effect, so the 150ms hover rule doesn't apply). */
.offcanvas[open] { animation: menu-in 260ms cubic-bezier(.22, 1, .36, 1); }
.offcanvas[open]::backdrop { animation: menu-fade 200ms ease-out; }
@keyframes menu-in { from { transform: translateX(100%); } }
@keyframes menu-fade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .offcanvas[open], .offcanvas[open]::backdrop { animation: none; } }

/* Phones: full-screen search overlay (search icon in the header). Results fill the screen instead of a dropdown. */
.search-overlay { margin: 0; inset: 0; width: 100%; max-width: none; height: 100dvh; max-height: none; padding: var(--s3) var(--gutter);
  border: 0; background: var(--bg); color: var(--text); }
.search-overlay::backdrop { background: var(--bg); }
.search-overlay-head { display: flex; gap: var(--s2); align-items: start; }
.search-overlay .site-search { flex: 1; width: auto; }
.search-overlay .site-search input { min-height: 48px; font-size: 18px; } /* 16px+ stops iOS zooming in */
.search-overlay .search-results { position: static; margin-top: var(--s3); border: 0; padding: 0; max-height: none; min-width: 0; }
.search-overlay .search-item { padding: var(--s2) 0; border-bottom: 1px solid var(--border); border-radius: 0; }
.search-overlay .search-all { border-top: 0; padding: var(--s4) 0; }
.search-overlay[open] { animation: menu-fade 160ms ease-out; }
@media (prefers-reduced-motion: reduce) { .search-overlay[open] { animation: none; } }

/* Swiss: strict 12-column grid (gallery spans 7, text 5) and numbered category labels ("01 — Apparel"). */
[data-theme="swiss"] .product { grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--s5);
  grid-template-areas: none; }
[data-theme="swiss"] .product-head { grid-column: 8 / -1; grid-row: 1; }
[data-theme="swiss"] .gallery { grid-column: 1 / 8; grid-row: 1 / span 2; }
[data-theme="swiss"] .details { grid-column: 8 / -1; grid-row: 2; }
@media (max-width: 767px) {
  [data-theme="swiss"] .product-head, [data-theme="swiss"] .gallery, [data-theme="swiss"] .details { grid-column: 1 / -1; grid-row: auto; }
}
[data-theme="swiss"] .chips:first-child { counter-reset: cat; }
[data-theme="swiss"] .chips:first-child .chip:not(:first-child)::before { counter-increment: cat; content: counter(cat, decimal-leading-zero) " — "; }
