/* SpreadFront base styles — themes provide the CSS variables. */
@font-face {
  font-family: 'Bricolage';
  src: url('/fonts/bricolage.woff2') format('woff2');
  font-weight: 200 800;
  font-display: swap;
}
*, *::before, *::after { box-sizing: border-box; }
/* The hidden attribute must always win, even over classes that set display
   (e.g. .btn's inline-flex) — without this, "hidden" buttons render. */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
.page-links { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; flex-wrap: wrap; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg, #fafafa);
  color: var(--fg, #1a1a1a);
  line-height: 1.55;
}
a { color: var(--accent, #2563eb); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1, h2, h3, h4 { line-height: 1.2; font-family: 'Bricolage', system-ui, sans-serif; letter-spacing: -0.02em; }
.icon { vertical-align: -0.18em; flex-shrink: 0; }
:focus-visible { outline: 2px solid var(--accent, #2563eb); outline-offset: 2px; border-radius: 4px; }

.container { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.container.narrow { max-width: 640px; }
.center-page { padding-top: 15vh; text-align: center; }

/* Buttons & forms */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--border, #ddd); background: var(--card, #fff); color: var(--fg, #1a1a1a);
  font-size: 15px; font-weight: 600; text-decoration: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}
.btn:hover { text-decoration: none; filter: brightness(0.97); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08); }
.btn:active { transform: translateY(0); box-shadow: none; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--accent, #2563eb); border-color: var(--accent, #2563eb); color: #fff; }
.btn-small { padding: 4px 10px; font-size: 13px; }
.btn-big { padding: 14px 28px; font-size: 18px; }
.inline-form { display: inline; }

input, select, textarea {
  width: 100%; padding: 9px 10px; margin-top: 4px;
  border: 1px solid var(--border, #ccc); border-radius: 8px;
  background: var(--card, #fff); color: var(--fg, #1a1a1a); font: inherit;
}
textarea { min-height: 70px; resize: vertical; }
/* Placeholders must read as hints, never as prefilled values. */
::placeholder { color: color-mix(in srgb, var(--fg, #1a1a1a) 45%, var(--bg, #fff)); font-style: italic; opacity: 1; }

/* Toggle-switch styling for checkboxes with .switch */
input[type='checkbox'].switch {
  appearance: none; width: 42px; height: 24px; border-radius: 999px; position: relative;
  background: var(--border, #ccc); cursor: pointer; transition: background 0.15s ease; margin: 0; flex-shrink: 0;
}
input[type='checkbox'].switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transition: left 0.15s ease;
}
input[type='checkbox'].switch:checked { background: var(--accent, #16a34a); }
input[type='checkbox'].switch:checked::after { left: 21px; }
.switch-row { display: flex; align-items: center; gap: 10px; }
label { display: block; margin: 12px 0; font-size: 14px; font-weight: 600; }
label.radio { font-weight: 400; display: flex; gap: 8px; align-items: center; }
label.radio input { width: auto; margin: 0; }
fieldset { border: 1px solid var(--border, #ddd); border-radius: 8px; margin: 14px 0; padding: 6px 14px 12px; }
legend { font-size: 14px; font-weight: 700; padding: 0 6px; }

.card { background: var(--card, #fff); border: 1px solid var(--border, #e5e5e5); border-radius: 12px; padding: 18px; }
.form-card { max-width: 560px; }

/* Storefront header/footer */
.store-header {
  background: var(--card, #fff); border-bottom: 1px solid var(--border, #e5e5e5);
  position: sticky; top: 0; z-index: 20;
}
/* Horizontal padding comes from .container; adding it here too inset the header
   from the page content below it (misaligned left/right edges on all widths). */
.header-row {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  /* horizontal padding must survive (the 0 here once glued the logo to the screen edge) */
  padding: 12px max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
}
.search-form { position: relative; }
.search-form .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); opacity: 0.45; pointer-events: none; }
.search-form input { padding-left: 36px; border-radius: 999px; }
.cart-link { display: inline-flex; align-items: center; gap: 6px; }
.store-brand { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 800; color: var(--fg); }
.store-brand:hover { text-decoration: none; }
.store-logo { height: 34px; width: 34px; object-fit: cover; border-radius: 8px; }
.search-form { flex: 1; min-width: 140px; }
.search-form input { margin: 0; }
.cart-link { font-weight: 700; white-space: nowrap; }
.cart-badge:not(:empty) {
  background: var(--accent, #2563eb); color: #fff; border-radius: 999px;
  padding: 1px 8px; font-size: 13px; margin-left: 2px;
}
.store-banner { width: 100%; border-radius: 12px; margin-top: 16px; max-height: 280px; object-fit: cover; }
.store-description { max-width: 720px; opacity: 0.85; }
.store-footer {
  margin-top: 48px; border-top: 1px solid var(--border, #e5e5e5); padding: 18px 0 30px;
  font-size: 14px; color: color-mix(in srgb, var(--fg) 80%, var(--bg));
}
.store-footer .container { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.powered-by { font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }

/* Filters */
.results-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--card, #fff); border: 1px solid var(--border, #e5e5e5); border-radius: 10px;
  padding: 10px 14px; margin: 16px 0 4px; font-size: 14.5px;
}
.filter-chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 18px 0 6px; }
.chip {
  padding: 5px 13px; border-radius: 999px; font-size: 14px;
  border: 1px solid var(--border, #ddd); background: var(--card, #fff); color: var(--fg);
}
.chip.active { background: var(--accent, #2563eb); border-color: var(--accent); color: #fff; }
.chip:hover { text-decoration: none; }
.brand-filter { display: flex; gap: 8px; align-items: center; margin: 8px 0 4px; max-width: 320px; }
.brand-filter select { margin: 0; }

/* Product grid */
.product-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 16px; margin: 20px 0;
}
.product-card {
  background: var(--card, #fff); border: 1px solid var(--border, #e5e5e5);
  border-radius: 14px; overflow: hidden; display: flex; flex-direction: column;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}
.product-card:hover { transform: translateY(-3px); box-shadow: 0 12px 32px rgba(0, 0, 0, 0.1); }
/* Sold-out: signal via grayscale photo, never by fading text below WCAG contrast. */
.product-card.unavailable .card-media img { filter: grayscale(1); opacity: 0.7; }
.product-card.unavailable .card-title { opacity: 0.85; }
.card-media { position: relative; display: block; aspect-ratio: 1; background: var(--bg-soft, #f0f0f0); overflow: hidden; }
.card-media img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.25s ease; }
.product-card:hover .card-media img { transform: scale(1.04); }
.card-tag {
  /* fg-on-bg inversion: guaranteed WCAG-passing contrast in every theme */
  position: absolute; top: 8px; left: 8px; background: var(--fg, #1a1a1a);
  color: var(--bg, #fff); font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px;
}
.img-placeholder { width: 100%; height: 100%; background: var(--bg-soft, #eee); }
.img-placeholder.large { aspect-ratio: 1; border-radius: 12px; }
.img-placeholder.small { width: 44px; height: 44px; border-radius: 8px; display: inline-block; }
.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-title {
  font-weight: 700; color: var(--fg);
  padding-bottom: 8px; border-bottom: 1px solid var(--border, #e5e5e5);
}
.card-brand { font-size: 13px; color: color-mix(in srgb, var(--fg) 78%, var(--bg)); }
.card-price { display: flex; align-items: baseline; gap: 8px; margin-top: auto; }
.card-price.big { font-size: 24px; margin: 10px 0; }
.price { font-weight: 800; }
.price-was { text-decoration: line-through; color: color-mix(in srgb, var(--fg) 75%, var(--bg)); font-size: 0.85em; }
.btn-add {
  margin-top: 4px; justify-content: center;
  background: var(--fg, #1a1a1a); color: var(--bg, #fff); border-color: var(--fg, #1a1a1a);
}
.btn-add:disabled { background: var(--bg-soft, #eee); color: var(--fg, #1a1a1a); border-color: var(--border, #ddd); opacity: 1; }

/* Product page */
.product-page { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; margin-top: 24px; }
@media (max-width: 720px) { .product-page { grid-template-columns: 1fr; } }
.gallery-main { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px; background: var(--bg-soft, #f0f0f0); }
.gallery-thumbs { display: flex; gap: 8px; margin-top: 8px; }
.gallery-thumbs img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; cursor: pointer; border: 1px solid var(--border, #ddd); }
.product-meta { display: flex; gap: 12px; font-size: 14px; opacity: 0.75; }
.product-description { line-height: 1.6; margin-top: 20px; }
.product-description p { margin: 0 0 10px; }
.product-description ul, .product-description ol { margin: 0 0 12px; padding-left: 22px; }
.product-description li { margin: 4px 0; }
.product-description h3, .product-description h4, .product-description h5, .product-description h6 { margin: 16px 0 6px; }
.product-description code {
  background: var(--bg-soft, #eee); border-radius: 5px; padding: 1px 6px; font-size: 0.9em;
}
.back-link { display: inline-block; margin-top: 18px; }

/* Cart & checkout */
.cart-items { margin: 18px 0; }
.cart-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 0;
  border-bottom: 1px solid var(--border, #eee);
}
.cart-row img { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; }
.cart-name { flex: 1; font-weight: 600; }
.cart-qty { display: flex; align-items: center; gap: 8px; }
.cart-line-total { min-width: 90px; text-align: right; font-weight: 700; }
.cart-sub { text-align: right; font-size: 14.5px; padding: 3px 0; opacity: 0.8; }
.cart-discount { color: var(--accent); opacity: 1; }
.cart-total { text-align: right; font-size: 20px; padding: 10px 0 14px; }
.coupon-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 6px 0 18px; }
.coupon-row input { max-width: 200px; margin: 0; text-transform: uppercase; }
.checkout-form { max-width: 480px; }
.turnstile-slot { margin: 14px 0 4px; }
.turnstile-slot .muted-note { display: block; margin-bottom: 6px; }
/* The order action must visually dominate the Turnstile "Success" box. */
.btn-place-order {
  width: 100%; justify-content: center; padding: 15px 20px; font-size: 19px;
  font-weight: 800; margin-top: 12px; border-radius: 12px;
}
.checkout-error { color: #dc2626; font-weight: 600; }
.order-confirmation { background: var(--card, #fff); border: 1px solid var(--border, #e5e5e5); border-radius: 12px; padding: 22px; margin: 18px 0; }
.pay-methods label.radio { margin: 8px 0; }

.empty-state { text-align: center; padding: 60px 0; opacity: 0.85; }
.muted-note { font-size: 13px; opacity: 0.7; font-weight: 400; }

/* v3: buyer-facing language switcher (Business multi-language storefronts) */
.lang-switch {
  font-size: 13px; padding: 4px 8px; border-radius: 8px;
  border: 1px solid var(--border, #ddd); background: var(--card, #fff); color: var(--fg, #1a1a1a);
}
