/* ============================================================
   MANTA Design System v1 — "Machined"
   Single shared stylesheet for every customer-facing page.
   Black/white base, hairline greys, Space Grotesk + Inter.
   Mobile-first: 90% of traffic is phones.
   ============================================================ */

/* ---------- Fonts (self-hosted variable fonts) ---------- */
@font-face {
  font-family: 'Inter';
  src: url('/assets/fonts/inter-var-latin.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Space Grotesk';
  src: url('/assets/fonts/space-grotesk-var-latin.woff2') format('woff2');
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  --ink: #0A0A0B;
  --paper: #FFFFFF;
  --surface: #F5F5F6;
  --surface-2: #EDEDEF;
  --hairline: #E4E4E7;
  --muted: #6E6E73;
  --faint: #A1A1A6;
  --volt: #C8FF00;
  --ok: #1DB954;
  --warn: #A66A00; --warn-fill: #E8A13C;
  --err: #D93025;

  --font-display: 'Space Grotesk', -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-body: 'Inter', -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

  --text-hero: clamp(2.5rem, 9vw, 4.5rem);
  --text-h1: clamp(2rem, 7vw, 3.25rem);
  --text-h2: clamp(1.5rem, 5vw, 2.25rem);
  --text-h3: 1.25rem;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px;
  --s6: 32px; --s7: 48px; --s8: 64px; --s9: 96px;
  --gutter: 20px;
  --max: 1200px;
  --max-prose: 720px;

  --r-card: 16px;
  --r-btn: 12px;
  --r-chip: 999px;
  --r-img: 12px;

  --ease: cubic-bezier(.22, .61, .36, 1);
  --shadow-float: 0 -1px 0 var(--hairline), 0 -8px 24px rgba(10, 10, 11, .06);
  --shadow-sheet: 0 -12px 40px rgba(10, 10, 11, .18);

  --header-h: 56px;
  --tabbar-h: 62px;
}

/* ---------- Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
}
body.no-tabbar { padding-bottom: 0; }
img, svg, video { display: block; max-width: 100%; }
img { height: auto; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
ul, ol { list-style: none; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; line-height: 1.08; letter-spacing: -0.02em; }
h1 { font-size: var(--text-h1); }
h2 { font-size: var(--text-h2); }
h3 { font-size: var(--text-h3); font-weight: 500; letter-spacing: -0.01em; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--ink); color: var(--paper); }
::placeholder { color: var(--faint); }

/* ---------- Layout helpers ---------- */
.container { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter); }
.container-prose { max-width: var(--max-prose); margin: 0 auto; padding: 0 var(--gutter); }
.section { padding: var(--s8) 0; }
.section-tight { padding: var(--s6) 0; }
.eyebrow {
  font-family: var(--font-body); font-size: .75rem; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
  margin-bottom: var(--s3);
}
.section-title { margin-bottom: var(--s5); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s4); margin-bottom: var(--s5); }
.section-head .section-title { margin-bottom: 0; }
.section-link { font-size: .875rem; font-weight: 600; color: var(--muted); white-space: nowrap; transition: color .18s var(--ease); }
.section-link:hover { color: var(--ink); }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.micro { font-size: .75rem; }
.price, .tabular { font-weight: 600; font-variant-numeric: tabular-nums; }

/* Dark sections */
.dark {
  background: var(--ink); color: var(--paper);
  --hairline: rgba(255, 255, 255, .14);
  --muted: rgba(255, 255, 255, .64);
  --faint: rgba(255, 255, 255, .4);
  --surface: rgba(255, 255, 255, .06);
  --surface-2: rgba(255, 255, 255, .1);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 52px; padding: 0 var(--s5);
  border-radius: var(--r-btn);
  font-weight: 600; font-size: .9375rem; line-height: 1.2;
  transition: transform .18s var(--ease), background .18s var(--ease), color .18s var(--ease), border-color .18s var(--ease), opacity .18s var(--ease);
  user-select: none; white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #232326; }
.btn-secondary { background: transparent; color: var(--ink); border: 1px solid var(--ink); }
.btn-secondary:hover { background: var(--surface); }
.btn-ghost { color: var(--muted); }
.btn-ghost:hover { color: var(--ink); }
.btn-block { width: 100%; }
.btn[disabled], .btn.disabled { opacity: .4; pointer-events: none; }
.dark .btn-primary { background: #fff; color: var(--ink); }
.dark .btn-primary:hover { background: #E8E8EA; }
.dark .btn-secondary { color: #fff; border-color: rgba(255, 255, 255, .4); }
.dark .btn-secondary:hover { background: rgba(255, 255, 255, .08); border-color: #fff; }
@media (min-width: 900px) { .btn { min-height: 48px; } }

/* ---------- Chips ---------- */
.chip {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 var(--s4);
  border: 1px solid var(--hairline); border-radius: var(--r-chip);
  background: var(--paper); color: var(--ink);
  font-size: .875rem; font-weight: 500; white-space: nowrap;
  transition: background .18s var(--ease), color .18s var(--ease), border-color .18s var(--ease), transform .18s var(--ease);
}
.chip:active { transform: scale(.97); }
.chip:hover { border-color: var(--ink); }
.chip.selected, .chip[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip-row { display: flex; gap: var(--s2); overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none; padding: 2px; }
.chip-row::-webkit-scrollbar { display: none; }

/* ---------- Cards / product grid ---------- */
.card { background: var(--paper); border: 1px solid var(--hairline); border-radius: var(--r-card); overflow: hidden; }

.product-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s3);
}
@media (min-width: 700px) { .product-grid { grid-template-columns: repeat(3, 1fr); gap: var(--s4); } }
@media (min-width: 1024px) { .product-grid { grid-template-columns: repeat(4, 1fr); } }

.product-card {
  display: flex; flex-direction: column;
  background: var(--paper); border: 1px solid var(--hairline); border-radius: var(--r-card);
  overflow: hidden;
  transition: transform .18s var(--ease), border-color .18s var(--ease);
}
.product-card:hover { border-color: var(--faint); }
.product-card:active { transform: scale(.985); }
.product-image-box {
  aspect-ratio: 1 / 1; background: var(--surface);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.product-image-box img { width: 100%; height: 100%; object-fit: contain; mix-blend-mode: multiply; }
.product-info { display: flex; flex-direction: column; gap: 6px; padding: var(--s3) var(--s4) var(--s4); flex: 1; }
.product-name {
  font-size: .9375rem; font-weight: 500; line-height: 1.35; color: var(--ink);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 2.5em;
}
.product-price { font-size: 1rem; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Stock + delivery badges (classes produced by products.js) */
.stock-status { display: inline-flex; align-items: center; gap: 6px; font-size: .75rem; font-weight: 500; color: var(--muted); }
.stock-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); display: inline-block; flex: none; }
.stock-status.in-stock .stock-dot, .in-stock .stock-dot { background: var(--ok); }
.stock-status.very-low-stock, .very-low-stock { color: var(--warn); }
.stock-status.very-low-stock .stock-dot, .very-low-stock .stock-dot { background: var(--warn-fill); }
.stock-status.out-of-stock, .out-of-stock { color: var(--muted); }
.stock-status.out-of-stock .stock-dot, .out-of-stock .stock-dot { background: var(--faint); }
.delivery-badge { display: inline-flex; align-items: center; gap: 6px; font-size: .75rem; color: var(--muted); }

/* Horizontal product rail (home) */
.rail { display: flex; gap: var(--s3); overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; padding: 2px 2px var(--s2); }
.rail::-webkit-scrollbar { display: none; }
.rail > * { flex: 0 0 46%; scroll-snap-align: start; }
@media (min-width: 700px) { .rail > * { flex-basis: 30%; } }
@media (min-width: 1024px) { .rail > * { flex-basis: 23%; } }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: .8125rem; font-weight: 600; color: var(--ink); }
.input, .field input, .field select, .field textarea {
  width: 100%; min-height: 52px; padding: 14px var(--s4);
  font-size: 1rem; /* 16px stops iOS zoom */
  background: var(--surface); border: 1px solid transparent; border-radius: var(--r-btn);
  transition: border-color .18s var(--ease), background .18s var(--ease);
  appearance: none;
}
.field textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--ink); background: var(--paper);
}
.field .error-text { font-size: .8125rem; color: var(--err); }
.field.invalid input, .field.invalid textarea { border-color: var(--err); background: var(--paper); }

/* Quantity stepper */
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--hairline); border-radius: var(--r-chip); overflow: hidden; }
.stepper button { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; font-size: 1.125rem; color: var(--ink); transition: background .15s var(--ease); }
.stepper button:hover { background: var(--surface); }
.stepper button:disabled { color: var(--faint); pointer-events: none; }
.stepper .qty { min-width: 40px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- Header ---------- */
.m-header, .main-header {
  position: sticky; top: 0; z-index: 90;
  height: var(--header-h);
  background: rgba(255, 255, 255, .88);
  -webkit-backdrop-filter: blur(16px) saturate(1.6); backdrop-filter: blur(16px) saturate(1.6);
  border-bottom: 1px solid var(--hairline);
  transition: transform .28s var(--ease);
}
.m-header.hidden { transform: translateY(-100%); }
.m-header-inner {
  max-width: var(--max); margin: 0 auto; height: 100%;
  padding: 0 var(--gutter);
  display: flex; align-items: center; justify-content: space-between; gap: var(--s4);
}
.m-wordmark {
  font-family: var(--font-display); font-weight: 700; font-size: 1.25rem;
  letter-spacing: .06em; color: var(--ink);
}
.m-nav { display: none; align-items: center; gap: var(--s5); }
.m-nav a { font-size: .875rem; font-weight: 500; color: var(--muted); transition: color .18s var(--ease); }
.m-nav a:hover, .m-nav a.active { color: var(--ink); }
@media (min-width: 900px) { .m-nav { display: flex; } }
.m-header-actions { display: flex; align-items: center; gap: var(--s1); }
.m-iconbtn {
  position: relative; width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; color: var(--ink);
  transition: background .15s var(--ease), transform .15s var(--ease);
}
.m-iconbtn:hover { background: var(--surface); }
.m-iconbtn:active { transform: scale(.92); }
.m-iconbtn svg { width: 22px; height: 22px; }
.cart-count {
  position: absolute; top: 4px; right: 2px;
  min-width: 17px; height: 17px; padding: 0 4px;
  background: var(--ink); color: #fff;
  font-size: .625rem; font-weight: 700; line-height: 17px; text-align: center;
  border-radius: var(--r-chip); border: 2px solid var(--paper);
  display: none; align-items: center; justify-content: center;
}

/* ---------- Bottom tab bar (mobile) ---------- */
.m-tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 95;
  display: flex; align-items: stretch;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(255, 255, 255, .94);
  -webkit-backdrop-filter: blur(16px) saturate(1.6); backdrop-filter: blur(16px) saturate(1.6);
  border-top: 1px solid var(--hairline);
}
.m-tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--faint); font-size: .625rem; font-weight: 500;
  transition: color .18s var(--ease), transform .18s var(--ease);
  position: relative;
}
.m-tab svg { width: 23px; height: 23px; }
.m-tab.active { color: var(--ink); }
.m-tab:active { transform: scale(.94); }
.m-tab .cart-count { top: 2px; right: calc(50% - 20px); }
@media (min-width: 900px) {
  .m-tabbar { display: none; }
  body { padding-bottom: 0; }
}

/* Sticky action bar (product ATC / cart checkout / pay) */
.m-actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 96;
  display: flex; align-items: center; gap: var(--s4);
  padding: var(--s3) var(--gutter) calc(var(--s3) + env(safe-area-inset-bottom, 0px));
  background: rgba(255, 255, 255, .94);
  -webkit-backdrop-filter: blur(16px) saturate(1.6); backdrop-filter: blur(16px) saturate(1.6);
  box-shadow: var(--shadow-float);
}
.m-actionbar .btn { flex: 1; }
body.has-actionbar { padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
@media (min-width: 900px) {
  .m-actionbar { position: static; box-shadow: none; padding: 0; background: none; }
  body.has-actionbar { padding-bottom: 0; }
}

/* ---------- Footer ---------- */
.m-footer { background: var(--ink); color: #fff; margin-top: var(--s8); }
.m-footer a { color: rgba(255, 255, 255, .64); font-size: .875rem; line-height: 2.1; transition: color .18s var(--ease); display: block; }
.m-footer a:hover { color: #fff; }
.m-footer-inner { max-width: var(--max); margin: 0 auto; padding: var(--s7) var(--gutter) var(--s5); }
.m-footer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s6) var(--s5); }
@media (min-width: 900px) { .m-footer-grid { grid-template-columns: 2fr 1fr 1fr 1fr; } }
.m-footer-brand { grid-column: 1 / -1; }
@media (min-width: 900px) { .m-footer-brand { grid-column: auto; } }
.m-footer-brand .m-wordmark { color: #fff; font-size: 1.375rem; }
.m-footer-brand p { color: rgba(255, 255, 255, .64); font-size: .875rem; margin-top: var(--s3); max-width: 320px; }
.m-footer h4 { font-family: var(--font-body); font-size: .75rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: rgba(255, 255, 255, .4); margin-bottom: var(--s3); }
.m-footer-legal {
  margin-top: var(--s7); padding-top: var(--s5);
  border-top: 1px solid rgba(255, 255, 255, .14);
  display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); align-items: center; justify-content: space-between;
  color: rgba(255, 255, 255, .4); font-size: .75rem;
}
.m-footer-legal span { line-height: 1.8; }

/* ---------- Trust row ---------- */
.trust-row {
  display: flex; gap: var(--s5); overflow-x: auto; scrollbar-width: none;
  padding: var(--s4) 0; border-top: 1px solid var(--hairline); border-bottom: 1px solid var(--hairline);
}
.trust-row::-webkit-scrollbar { display: none; }
.trust-item { display: flex; align-items: center; gap: var(--s2); flex: none; color: var(--muted); font-size: .8125rem; font-weight: 500; white-space: nowrap; }
.trust-item svg { width: 18px; height: 18px; flex: none; }
@media (min-width: 900px) { .trust-row { justify-content: space-between; } }

/* ---------- Accordions ---------- */
.acc { border-top: 1px solid var(--hairline); }
.acc-item { border-bottom: 1px solid var(--hairline); }
.acc-trigger {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: var(--s4);
  padding: var(--s4) 0; text-align: left;
  font-weight: 500; font-size: 1rem; min-height: 56px;
}
.acc-trigger svg { width: 18px; height: 18px; flex: none; color: var(--muted); transition: transform .28s var(--ease); }
.acc-item.open .acc-trigger svg { transform: rotate(180deg); }
.acc-panel { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .28s var(--ease); }
.acc-item.open .acc-panel { grid-template-rows: 1fr; }
.acc-panel-inner { overflow: hidden; }
.acc-panel-content { padding: 0 0 var(--s5); color: var(--muted); font-size: .9375rem; }
.acc-panel-content p + p { margin-top: var(--s3); }

/* ---------- Sheets (bottom drawers) ---------- */
.m-sheet-backdrop {
  position: fixed; inset: 0; z-index: 120;
  background: rgba(10, 10, 11, .4);
  opacity: 0; pointer-events: none; transition: opacity .28s var(--ease);
}
.m-sheet-backdrop.open { opacity: 1; pointer-events: auto; }
.m-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 121;
  max-height: 86vh; display: flex; flex-direction: column;
  background: var(--paper); border-radius: 20px 20px 0 0;
  box-shadow: var(--shadow-sheet);
  transform: translateY(105%); transition: transform .28s var(--ease);
}
.m-sheet.open { transform: translateY(0); }
.m-sheet-handle { width: 36px; height: 4px; border-radius: 2px; background: var(--hairline); margin: 10px auto 0; flex: none; }
.m-sheet-head { display: flex; align-items: center; justify-content: space-between; padding: var(--s4) var(--gutter); flex: none; }
.m-sheet-head h3 { font-size: 1.125rem; }
.m-sheet-body { overflow-y: auto; padding: 0 var(--gutter) var(--s4); -webkit-overflow-scrolling: touch; }
.m-sheet-foot { flex: none; padding: var(--s3) var(--gutter) calc(var(--s3) + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--hairline); display: flex; gap: var(--s3); }
.m-sheet-foot .btn { flex: 1; }
@media (min-width: 900px) {
  .m-sheet { left: auto; right: var(--s5); bottom: auto; top: 50%; transform: translate(0, -45%); opacity: 0; pointer-events: none; width: 400px; border-radius: var(--r-card); max-height: 80vh; transition: opacity .2s var(--ease), transform .2s var(--ease); }
  .m-sheet.open { opacity: 1; pointer-events: auto; transform: translate(0, -50%); }
}

/* ---------- Toast ---------- */
.m-toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + var(--s4)); z-index: 130;
  transform: translate(-50%, 16px);
  display: flex; align-items: center; gap: var(--s3);
  background: var(--ink); color: #fff;
  padding: 12px 18px; border-radius: var(--r-chip);
  font-size: .875rem; font-weight: 500; white-space: nowrap;
  opacity: 0; pointer-events: none;
  transition: opacity .28s var(--ease), transform .28s var(--ease);
}
.m-toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.m-toast a { color: var(--volt); font-weight: 600; }
body.no-tabbar .m-toast { bottom: calc(env(safe-area-inset-bottom, 0px) + var(--s5)); }

/* ---------- Skeletons ---------- */
.skel { background: var(--surface); border-radius: var(--r-img); animation: skel-pulse 1.4s ease-in-out infinite; }
@keyframes skel-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }

/* ---------- Reveal on scroll ---------- */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity .5s var(--ease), transform .5s var(--ease); }
.reveal.in { opacity: 1; transform: none; }

/* ---------- Search overlay hook (visuals in search.js) ---------- */
.search-btn { /* ensure visible — legacy home.css hid it */ display: flex !important; }

/* ---------- Utilities ---------- */
.hidden { display: none !important; }
.divider { border: 0; border-top: 1px solid var(--hairline); }
.badge-sale { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 4px; background: var(--volt); color: var(--ink); font-size: .6875rem; font-weight: 700; letter-spacing: .02em; }
.icon-row { display: flex; align-items: flex-start; gap: var(--s3); }
.icon-row svg { width: 20px; height: 20px; flex: none; margin-top: 2px; color: var(--ink); }
.icon-row .icon-row-text { font-size: .9375rem; color: var(--muted); }
.icon-row .icon-row-text strong { color: var(--ink); font-weight: 600; display: block; font-size: .9375rem; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .reveal { opacity: 1; transform: none; }
}

/* ---------- Post-review refinements ---------- */
/* Larger touch targets on touch devices */
@media (pointer: coarse) {
  .chip { min-height: 44px; }
}
/* Keep closed accordion content out of the tab order */
.acc-panel-inner { visibility: hidden; transition: visibility .28s; }
.acc-item.open .acc-panel-inner { visibility: visible; }

/* ---------- Brand logo ---------- */
.m-logo-link { display: flex; align-items: center; }
.m-logo { height: 20px; width: auto; }
.m-footer .m-logo { height: 24px; }
.m-logo-invert { filter: invert(1) brightness(1.1); }
