/* Mobile-first: the base styles target phones; the media query widens the grid. */
:root {
  /* Overridden per store by the page (see Theme in theme.go). */
  --accent: #c2410c;
  --on-accent: #fff;
  --accent-text: #c2410c;
  --bg: #fafaf9;
  --text: #1c1917;
  --muted: #78716c;
  --card: #fff;
  --radius: 14px;
}
* { box-sizing: border-box; }
/* The script hides things with the hidden attribute (filtered cards, empty cart bar);
   make sure a display rule like .card's flex can't override it. */
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 80px; /* room for the cart bar */
}
img { display: block; max-width: 100%; }
button { font: inherit; cursor: pointer; }

.hero .banner { width: 100%; aspect-ratio: 3 / 1; object-fit: cover; }
.profile { text-align: center; padding: 0 16px 8px; }
.logo {
  width: 84px; height: 84px; border-radius: 50%;
  margin: -42px auto 8px; border: 4px solid var(--bg); object-fit: cover; background: #fff;
}
.profile h1 { margin: 4px 0; font-size: 1.4rem; }
.bio { margin: 4px 0 12px; color: var(--muted); }
.socials { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.socials a {
  padding: 6px 12px; border-radius: 999px; background: #fff; border: 1px solid #e7e5e4;
  color: var(--text); text-decoration: none; font-size: .9rem;
}

main { padding: 12px 16px; max-width: 960px; margin: 0 auto; }
.search {
  width: 100%; padding: 12px 14px; border-radius: var(--radius);
  border: 1px solid #e7e5e4; font-size: 1rem; background: #fff;
}
/* Search box with the sort menu beside it (below it on narrow phones). */
.toolbar { display: flex; gap: 8px; }
.toolbar .search { flex: 1; min-width: 0; }
.sort {
  flex: none; max-width: 45%; padding: 0 10px; border-radius: var(--radius);
  border: 1px solid #e7e5e4; font: inherit; font-size: .95rem; background: #fff; color: inherit;
}
@media (max-width: 380px) {
  .toolbar { flex-wrap: wrap; }
  .sort { max-width: none; width: 100%; padding: 10px; }
}
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0; scrollbar-width: none; }
.chip {
  flex: none; padding: 6px 14px; border-radius: 999px; border: 1px solid #e7e5e4; background: #fff;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.card { background: var(--card); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.card img { aspect-ratio: 1; object-fit: cover; width: 100%; }
.card h2 { font-size: .95rem; margin: 8px 10px 2px; }
.price { margin: 0 10px 8px; font-weight: 600; color: var(--accent-text); }
.add {
  margin: auto 10px 10px; padding: 8px; border: 0; border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 10%, #fff); color: var(--accent-text); font-weight: 600;
}
.empty { color: var(--muted); text-align: center; grid-column: 1 / -1; }

.cart-bar {
  position: fixed; left: 16px; right: 16px; bottom: 16px; max-width: 928px; margin: 0 auto;
  display: flex; justify-content: space-between; padding: 14px 18px; border: 0;
  border-radius: var(--radius); background: var(--accent); color: var(--on-accent); font-size: 1rem;
  box-shadow: 0 6px 20px rgb(0 0 0 / .15);
  z-index: 10; /* above the cards' Add buttons */
}
dialog { border: 0; border-radius: var(--radius); width: min(92vw, 480px); padding: 20px; }
dialog::backdrop { background: rgb(0 0 0 / .4); }
#cart-items { list-style: none; padding: 0; margin: 0; }
#cart-items li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid #f5f5f4; }
#cart-items li span { flex: 1; }
#cart-items button { width: 32px; height: 32px; border-radius: 8px; border: 1px solid #e7e5e4; background: #fff; }
.actions { display: flex; gap: 8px; justify-content: flex-end; }
.actions button { padding: 10px 16px; border-radius: 10px; border: 1px solid #e7e5e4; background: #fff; }
.actions .primary { background: #16a34a; border-color: #16a34a; color: #fff; }

@media (min-width: 640px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 900px) {
  .grid { grid-template-columns: repeat(4, 1fr); }
}
.lang-switch { display: inline-block; margin-top: 8px; font-size: .85rem; color: var(--accent-text); }

/* --- Product card: the name button covers the card, so tapping anywhere opens the popup --- */
.card { position: relative; }
.card .open {
  all: unset; cursor: pointer; display: block; font: inherit; font-weight: 700;
}
.card .open::after { content: ""; position: absolute; inset: 0; }
.card .open:focus-visible::after { outline: 3px solid var(--accent); outline-offset: -3px; border-radius: var(--radius); }
.card .add { position: relative; z-index: 1; } /* stays clickable above the cover */
.extras { margin: 0 10px 4px; display: flex; gap: 6px; flex-wrap: wrap; font-size: .75rem; color: var(--muted); }

/* --- Product popup: bottom sheet on phones, centered window on wider screens --- */
dialog.sheet {
  padding: 0; width: 100%; max-width: 560px; max-height: 92dvh;
  margin: auto auto 0; border-radius: 18px 18px 0 0;
  display: none; flex-direction: column; overflow: hidden;
}
dialog.sheet[open] { display: flex; }
.sheet-close {
  position: absolute; top: 10px; right: 10px; z-index: 2; width: 36px; height: 36px;
  border-radius: 50%; border: 0; background: rgb(255 255 255 / .9); box-shadow: 0 1px 4px rgb(0 0 0 / .2);
}
.sheet-body { overflow-y: auto; overscroll-behavior: contain; }
.gallery-wrap { position: relative; background: #f5f5f4; }
.gallery {
  display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none;
}
.gallery::-webkit-scrollbar { display: none; }
/* Square, but never taller than about half the screen, so the details stay in view. */
.gallery img { flex: none; width: 100%; aspect-ratio: 1; max-height: 55dvh; object-fit: cover; scroll-snap-align: start; }
.dots { position: absolute; bottom: 10px; left: 0; right: 0; display: flex; justify-content: center; gap: 6px; }
.dot {
  width: 8px; height: 8px; padding: 0; border-radius: 50%; border: 0;
  background: rgb(255 255 255 / .6); box-shadow: 0 0 2px rgb(0 0 0 / .4);
}
.dot.active { background: #fff; width: 18px; border-radius: 4px; }
.carousel-btn {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 1;
  width: 40px; height: 40px; border-radius: 50%; border: 0; padding: 0 0 3px;
  background: rgb(255 255 255 / .9); color: var(--text); font-size: 1.6rem; line-height: 1;
  box-shadow: 0 1px 4px rgb(0 0 0 / .25);
}
.carousel-btn.prev { left: 10px; }
.carousel-btn.next { right: 10px; }
.counter {
  position: absolute; top: 12px; left: 12px; padding: 2px 8px; border-radius: 999px;
  background: rgb(0 0 0 / .55); color: #fff; font-size: .8rem;
}
.pd-info { padding: 16px 20px 8px; }
.pd-info h2 { margin: 0 0 4px; font-size: 1.25rem; }
.pd-info .price { margin: 0 0 12px; font-size: 1.1rem; }
.desc { color: #44403c; line-height: 1.55; }
/* A long word with no spaces (a pasted link, a key-mash) wraps instead of running out of its box. */
.desc, .card h2, .pd-info h2, .addon-text { overflow-wrap: anywhere; }
.desc p { margin: 0 0 10px; }
.desc ul, .desc ol { margin: 0 0 10px; padding-left: 22px; }
/* "> " box: tinted with the store's theme colour; "· " style bullets like a spec sheet. */
.desc .box {
  margin: 0 0 12px; padding: 12px 16px; border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 9%, #fff);
}
.desc .box ul { list-style: none; padding-left: 0; }
.desc .box ul li { position: relative; padding: 3px 0 3px 16px; }
.desc .box ul li::before { content: "·"; position: absolute; left: 2px; font-weight: 700; color: var(--accent-text); }
/* "! " warning: yellow with an icon. */
.desc .warn {
  display: flex; gap: 8px; align-items: flex-start; margin: 0 0 12px; padding: 10px 14px;
  border: 1px solid #fcd34d; border-radius: 10px; background: #fffbeb; color: #78350f; font-size: .95em;
}
.desc .warn strong { color: #78350f; }
.desc .warn-icon { flex: none; line-height: 1.55; }
.desc .box-body { min-width: 0; }
.desc .box-body > :last-child { margin-bottom: 0; }
.addons h3 { margin: 16px 0 0; font-size: 1rem; }
.addons .hint { margin: 2px 0 8px; font-size: .85rem; color: var(--muted); }
#pd-addon-list { list-style: none; margin: 0; padding: 0; }
#pd-addon-list li {
  display: flex; align-items: center; gap: 12px; padding: 8px; margin-bottom: 8px;
  border: 1px solid #e7e5e4; border-radius: 12px;
}
#pd-addon-list li.picked { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, #fff); }
#pd-addon-list img, .addon-ph { width: 56px; height: 56px; flex: none; border-radius: 8px; object-fit: cover; background: #f5f5f4; }
.addon-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.addon-text small { color: var(--accent-text); font-weight: 600; }
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button {
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid #e7e5e4; background: #fff; font-size: 1.1rem;
}
.stepper button:disabled { opacity: .4; cursor: default; }
.stepper output { min-width: 28px; text-align: center; font-weight: 600; }
.stepper.small button { width: 32px; height: 32px; }
.sheet-footer {
  display: flex; gap: 12px; align-items: center; padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid #f5f5f4; background: #fff;
}
.sheet-footer .primary {
  flex: 1; padding: 12px; border: 0; border-radius: 12px;
  background: var(--accent); color: var(--on-accent); font-weight: 600;
}
#cart-items .line { display: flex; flex-direction: column; }
#cart-items .line small { color: var(--muted); }

@media (min-width: 640px) {
  dialog.sheet { margin: auto; border-radius: var(--radius); }
}
