/* Webift storefront base: mobile-first mechanics shared by every theme.
   Visual identity (type, colour, shape, rhythm) lives in each theme's theme.css via CSS variables. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
html.locked { overflow: hidden; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 16px/1.55 var(--font-body), system-ui, sans-serif; -webkit-font-smoothing: antialiased; overflow-x: hidden; }
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
h1, h2, h3, p, ul, dl, dd, figure { margin: 0; }
ul { padding: 0; list-style: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.wrap { width: 100%; max-width: var(--max, 1280px); margin: 0 auto; padding-inline: var(--gutter, 16px); }
.muted { color: var(--muted); }
.skip { position: absolute; left: -999px; top: 0; background: var(--ink); color: var(--bg); padding: 12px 16px; z-index: 100; }
.skip:focus { left: 8px; top: 8px; }

/* media: fixed aspect ratio => zero layout shift */
.media { position: relative; overflow: hidden; background: var(--surface); aspect-ratio: var(--ratio, 4/5); }
.media img, .media svg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 22px; border: 1px solid var(--ink); border-radius: var(--radius, 0); font-weight: 600; letter-spacing: var(--btn-track, .02em); transition: background .15s, color .15s, opacity .15s; text-align: center; }
.btn:hover { background: var(--ink); color: var(--bg); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn.ghost { border-color: var(--line); }
.btn.ghost:hover { background: var(--surface); color: var(--ink); border-color: var(--ink); }
.btn.block { display: flex; width: 100%; }
.btn.lg { min-height: 56px; font-size: 1.0625rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.link { text-decoration: underline; text-underline-offset: 3px; color: var(--muted); min-height: 44px; padding: 0 4px; font-size: .875rem; }

/* product grid + card (2-up on phones) */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--grid-gap, 24px 12px); }
@media (min-width: 720px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 32px 20px; } }
@media (min-width: 1040px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 40px 24px; } }
.card { position: relative; display: flex; flex-direction: column; min-width: 0; }
.card-media { position: relative; display: block; }
.card-body { padding-top: 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.card-body h3 { font-size: 1rem; line-height: 1.3; }
.card-body .sub { font-size: .875rem; }
.card .price { margin-top: 4px; font-variant-numeric: tabular-nums; font-weight: 600; }
.card .quick { margin-top: 10px; min-height: 44px; padding: 0 12px; font-size: .9375rem; }
.tag { position: absolute; left: 8px; top: 8px; z-index: 2; background: var(--bg); color: var(--ink); font-size: .6875rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; padding: 5px 8px; }
.tag.inline { position: static; display: inline-block; align-self: flex-start; margin-bottom: 0; }
.wish { position: absolute; right: 4px; top: 4px; z-index: 3; width: 44px; height: 44px; display: grid; place-items: center; color: var(--ink); }
.wish svg { filter: drop-shadow(0 0 3px rgba(255,255,255,.7)); }
.wish.on svg { fill: currentColor; color: var(--accent); }
.wish.static { position: static; width: 56px; height: 56px; border: 1px solid var(--line); border-radius: var(--radius, 0); flex: none; }

/* toolbar / chips / headings */
.page-head { padding-block: 28px 20px; }
.page-head h1 { font: var(--h1, 600 2rem/1.1 var(--font-display)); }
.page-head .lead { margin-top: 10px; max-width: 60ch; }
.eyebrow { font-size: .75rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; font-weight: 600; }
.toolbar { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin-inline: calc(var(--gutter, 16px) * -1); padding-inline: var(--gutter, 16px); -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; display: inline-flex; align-items: center; min-height: 44px; padding: 0 18px; border: 1px solid var(--line); border-radius: var(--chip-radius, 999px); font-size: .9375rem; white-space: nowrap; }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.sort { display: flex; align-items: center; gap: 10px; font-size: .9375rem; color: var(--muted); }
.sort select { min-height: 44px; border: 1px solid var(--line); background: var(--bg); padding: 0 12px; flex: 1; }
@media (min-width: 720px) { .toolbar { flex-direction: row; justify-content: space-between; align-items: center; } .chips { margin: 0; padding: 0; flex-wrap: wrap; overflow: visible; } .sort select { flex: none; } }
.count { margin-top: 28px; text-align: center; font-size: .875rem; }
.block-gap { margin-top: 64px; }
.sec-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 20px; }
.sec-head h2 { font: var(--h2, 600 1.75rem/1.15 var(--font-display)); }
.empty { padding: 48px 0; text-align: center; display: grid; gap: 14px; justify-items: center; }
.lead { font-size: 1.0625rem; line-height: 1.6; }

/* cat tiles */
.cat-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .cat-grid { grid-template-columns: repeat(3, 1fr); } }
.cat-tile { position: relative; display: block; --ratio: 4/5; }
.cat-tile span { position: absolute; left: 0; right: 0; bottom: 0; padding: 40px 16px 16px; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.6)); display: grid; gap: 2px; }
.cat-tile em { font-style: normal; font-size: .875rem; opacity: .9; }

/* product page */
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; font-size: .8125rem; color: var(--muted); padding: 14px 0; }
.crumbs i { font-style: normal; opacity: .5; }
.crumbs span { color: var(--ink); }
.pdp-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
@media (min-width: 900px) { .pdp-grid { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 56px; align-items: start; } .gallery { position: sticky; top: 96px; } }
.gallery { position: relative; margin-inline: calc(var(--gutter, 16px) * -1); }
@media (min-width: 900px) { .gallery { margin-inline: 0; } }
.track { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
.track::-webkit-scrollbar { display: none; }
.slide { flex: 0 0 100%; scroll-snap-align: center; }
.slide .media { --ratio: var(--pdp-ratio, 4/5); max-height: 78svh; width: 100%; }
.dots { display: flex; justify-content: center; gap: 2px; margin-top: 4px; }
.dot { width: 32px; height: 32px; display: grid; place-items: center; }
.dot::after { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--line); transition: background .2s, transform .2s; }
.dot.on::after { background: var(--ink); transform: scale(1.25); }
.pdp-info { display: flex; flex-direction: column; gap: 14px; }
.pdp-info h1 { font: var(--h1, 600 2rem/1.1 var(--font-display)); }
.price.big { font-size: 1.5rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.stock { font-size: .875rem; color: var(--muted); }
.stock.low { color: #a3481c; font-weight: 600; }
.stock.out { color: #b3261e; font-weight: 600; }
.opts { border: 0; padding: 0; margin: 0; }
.opts legend { font-size: .8125rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; padding: 0; font-weight: 600; }
.opts div { display: flex; flex-wrap: wrap; gap: 8px; }
.opt { min-width: 52px; min-height: 48px; padding: 0 16px; border: 1px solid var(--line); border-radius: var(--radius, 0); }
.opt.on { border-color: var(--ink); background: var(--ink); color: var(--bg); }
.buy { display: flex; gap: 10px; align-items: stretch; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--bg); padding: 10px 0 calc(10px + env(safe-area-inset-bottom)); padding-inline: var(--gutter, 16px); border-top: 1px solid var(--line); }
/* On phones the purchase bar is FIXED (a sticky element cannot leave its column, so on short screens it
   would sit on top of the title). The page reserves room for it so nothing is ever hidden underneath. */
@media (min-width: 900px) { .buy { position: static; padding: 0; border: 0; } }
.buy .grow { flex: 1; min-height: 56px; }
.assure { display: grid; gap: 8px; font-size: .875rem; border-block: 1px solid var(--line); padding: 14px 0; }
.assure li { display: grid; grid-template-columns: 74px 1fr; gap: 8px; }
.assure b { font-size: .75rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding-top: 2px; }
.wa-btn svg { width: 20px; height: 20px; }
.acc details { border-bottom: 1px solid var(--line); }
.acc summary { min-height: 52px; display: flex; align-items: center; justify-content: space-between; cursor: pointer; font-weight: 600; list-style: none; }
.acc summary::-webkit-details-marker { display: none; }
.acc summary::after { content: "+"; font-size: 1.25rem; font-weight: 400; }
.acc details[open] summary::after { content: "−"; }
.acc details p { padding-bottom: 16px; color: var(--muted); }

/* quantity */
.qty { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: var(--radius, 0); }
.qty button { width: 44px; height: 44px; font-size: 1.25rem; display: grid; place-items: center; }
.qty button:disabled { opacity: .3; }
.qty output { min-width: 32px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.qty.lg button { width: 48px; height: 54px; }

/* drawer / overlays */
#scrim { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.45); opacity: 0; pointer-events: none; transition: opacity .2s; }
#scrim.open { opacity: 1; pointer-events: auto; }
#drawer { position: fixed; z-index: 70; top: 0; right: 0; bottom: 0; width: min(440px, 100%); background: var(--bg); display: flex; flex-direction: column; transform: translateX(100%); visibility: hidden; transition: transform .25s ease, visibility 0s .25s; }
#drawer.open { transform: none; visibility: visible; transition: transform .25s ease; }
#drawer header { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 6px var(--gutter, 16px); border-bottom: 1px solid var(--line); min-height: 60px; }
#drawer header h2 { font: var(--h3, 600 1.25rem/1.2 var(--font-display)); }
.x { width: 48px; height: 48px; display: grid; place-items: center; }
#drawer-body { flex: 1; overflow-y: auto; padding: 8px var(--gutter, 16px); overscroll-behavior: contain; }
#drawer-foot { padding: 14px var(--gutter, 16px) calc(16px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); display: grid; gap: 12px; background: var(--bg); }
.lines { display: grid; }
.line { display: grid; grid-template-columns: 76px 1fr auto; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.line .thumb .media { --ratio: 3/4; }
.line-main { display: grid; gap: 4px; align-content: start; min-width: 0; }
.line-name { font-weight: 600; line-height: 1.3; }
.line-main .qty { justify-self: start; margin-top: 4px; }
.line-side { display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between; }
.totals { display: grid; gap: 6px; }
.totals div { display: flex; justify-content: space-between; gap: 12px; font-variant-numeric: tabular-nums; }
.totals dt { color: var(--muted); }
.totals .grand { font-weight: 700; font-size: 1.125rem; padding-top: 8px; border-top: 1px solid var(--line); margin-top: 4px; }
.totals .grand dt { color: var(--ink); }
.ship-bar { font-size: .875rem; display: grid; gap: 6px; }
.ship-bar span { height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; }
.ship-bar i { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.fine { font-size: .8125rem; color: var(--muted); }

#search { position: fixed; z-index: 70; top: 0; left: 0; right: 0; max-height: 90svh; overflow-y: auto; background: var(--bg); padding: 8px var(--gutter, 16px) 20px; transform: translateY(-110%); visibility: hidden; transition: transform .22s ease, visibility 0s .22s; }
#search.open { transform: none; visibility: visible; transition: transform .22s ease; }
#search form { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--ink); }
#search input { flex: 1; min-width: 0; border: 0; background: none; min-height: 56px; font-size: 1.125rem; outline: none; }
#search-results { padding-top: 16px; display: grid; gap: 12px; max-width: 640px; margin-inline: auto; }
#search-results li a { display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: center; min-height: 64px; }
#search-results .thumb .media { --ratio: 1/1; }
#search-results em { display: block; font-style: normal; font-size: .875rem; color: var(--muted); }
#search-results i { font-style: normal; font-weight: 600; }
#search-form { max-width: 640px; margin-inline: auto; }

#mnav { position: fixed; z-index: 70; top: 0; left: 0; bottom: 0; width: min(88vw, 380px); background: var(--bg); transform: translateX(-100%); visibility: hidden; transition: transform .25s ease, visibility 0s .25s; display: flex; flex-direction: column; overflow-y: auto; }
#mnav.open { transform: none; visibility: visible; transition: transform .25s ease; }

#toast { position: fixed; z-index: 90; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); background: var(--ink); color: var(--bg); padding: 12px 18px; font-size: .9375rem; opacity: 0; pointer-events: none; transition: .2s; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.wa-fab { position: fixed; right: 14px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 40; width: 56px; height: 56px; border-radius: 50%; background: #1f9d55; color: #fff; display: grid; place-items: center; box-shadow: 0 6px 18px rgba(0,0,0,.25); }
html.on-pdp .wa-fab { bottom: calc(96px + env(safe-area-inset-bottom)); }
@media (min-width: 900px) { html.on-pdp .wa-fab { bottom: calc(16px + env(safe-area-inset-bottom)); } }

/* checkout */
.co-grid { display: grid; gap: 28px; padding-bottom: 56px; }
@media (min-width: 900px) { .co-grid { grid-template-columns: 1.3fr 1fr; gap: 56px; align-items: start; } .summary { position: sticky; top: 96px; } }
#co fieldset { border: 0; padding: 0; margin: 0 0 28px; display: grid; gap: 14px; }
#co legend { font: var(--h3, 600 1.25rem/1.2 var(--font-display)); padding: 0; margin-bottom: 14px; }
#co label:not(.radio) { display: grid; gap: 6px; font-size: .875rem; font-weight: 600; }
.opt-note { font-weight: 400; color: var(--muted); }
#co input:not([type=radio]), #co select { width: 100%; min-height: 54px; padding: 0 14px; border: 1px solid var(--line); border-radius: var(--radius, 0); background: var(--bg); font-size: 1rem; font-weight: 400; }
#co input:focus, #co select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.eta { font-size: .875rem; color: var(--muted); margin-top: -4px; }
.radio { display: flex; gap: 14px; align-items: center; min-height: 64px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius, 0); cursor: pointer; }
.radio:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.radio input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
.radio span { display: grid; gap: 1px; }
.radio b { font-weight: 600; }
.radio em { font-style: normal; font-size: .875rem; color: var(--muted); }
.summary { background: var(--surface); padding: 20px var(--gutter, 16px); }
.summary h2 { font: var(--h3, 600 1.25rem/1.2 var(--font-display)); margin-bottom: 8px; }
.notice { margin-top: 10px; display: inline-block; background: var(--surface); padding: 8px 12px; font-size: .875rem; }
.done { text-align: center; padding-block: 56px; display: grid; justify-items: center; gap: 14px; }

#app.in { animation: fade .25s ease; }
@keyframes fade { from { opacity: .0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
@media (min-width: 900px) { :root { --gutter: 32px; } }

.pdp-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.pdp-head .wish.static { width: 48px; height: 48px; margin: -4px -8px 0 0; border: 0; }
.buy .qty.lg button { width: 42px; }
.buy .btn { white-space: normal; line-height: 1.15; padding: 0 10px; min-width: 0; font-size: clamp(.875rem, 4vw, 1rem); letter-spacing: .02em; }
@media (max-width: 359px) { .buy .qty.lg button { width: 40px; } }

/* ---- live-store additions ---- */
.was { color: var(--muted); font-weight: 400; font-size: .85em; margin-left: 4px; }
.code-row { display: flex; gap: 8px; }
.code-row input { flex: 1; min-width: 0; }
.code-row .btn { flex: none; min-height: 54px; }
.legend-sm { font-size: .8125rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 10px 0 2px; font-weight: 600; }
.notice.err { background: #fbeaea; color: #8a1c14; }
.notice p { margin: 0 0 4px; }
.center-note { text-align: center; }
.radio.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
#co label.radio { display: flex; }
#co [hidden] { display: none !important; }
.media:empty::after { content: ""; position: absolute; inset: 0; background: linear-gradient(135deg, var(--surface), var(--line)); }
select { max-width: 100%; }

/* ---- robustness against merchant-supplied text (long names, URLs, no spaces) ---- */
h1, h2, h3, p, li, dd, dt, summary, legend, label, .line-name, .lead, .notice, .card-body a { overflow-wrap: anywhere; }
.card, .card-body, .line-main, .pdp-info, .pdp-head, .sec-head > * { min-width: 0; }
.pdp-head h1 { flex: 1; min-width: 0; }
/* the floating WhatsApp button must never sit on top of form fields */
html.on-checkout .wa-fab { display: none; }
/* desktop: the product page already has an inline "Ask on WhatsApp" button, and the floating one can cover "Add to bag" */
@media (min-width: 900px) { html.on-pdp .wa-fab { display: none; } }

/* room for the fixed purchase bar, reserved at the END of the page (not mid-content) */
@media (max-width: 899px) { html.on-pdp .lg-foot { padding-bottom: calc(180px + env(safe-area-inset-bottom)); } }
