/* Drinkstore — mobile-first styles. No frameworks, ~10KB. */

:root {
  --brand: #0f766e;
  --brand-dark: #0b5e57;
  --brand-soft: #ccfbf1;
  --accent: #f59e0b;
  --bg: #fafaf7;
  --surface: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --danger: #dc2626;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 6px 18px rgba(0,0,0,.08);
  --tap: 44px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
img { max-width: 100%; display: block; }
button { font: inherit; }
a { color: var(--brand-dark); }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding-top: calc(12px + env(safe-area-inset-top));
}
.brand {
  display: inline-flex; align-items: center; gap: 8px;
  text-decoration: none; color: var(--text); font-weight: 700; font-size: 18px;
}
.brand-mark { font-size: 22px; }
.cart-toggle {
  position: relative;
  background: var(--brand-soft); color: var(--brand-dark); border: none;
  width: var(--tap); height: var(--tap); border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.cart-toggle:hover { background: #99f6e4; }
.cart-badge {
  position: absolute; top: -2px; right: -2px;
  background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 700;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
}

/* ---------- Page ---------- */
.page { padding: 16px 16px 32px; max-width: 1200px; margin: 0 auto; }

.hero { padding: 8px 0 16px; }
.hero h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: -0.01em; }
.hero p { margin: 0; color: var(--muted); }

/* ---------- Category chips ---------- */
.category-bar {
  display: flex; gap: 8px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  padding: 8px 0 12px; margin: 4px -16px 12px; padding-left: 16px; padding-right: 16px;
  scrollbar-width: none;
}
.category-bar::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  padding: 8px 14px; min-height: var(--tap);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 999px;
  font-weight: 600; cursor: pointer; white-space: nowrap;
}
.chip.is-active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---------- Catalog grid ---------- */
.catalog { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 640px) { .catalog { grid-template-columns: repeat(3, 1fr); gap: 16px; } }
@media (min-width: 1024px){ .catalog { grid-template-columns: repeat(4, 1fr); } }

.loading, .empty { padding: 32px 0; text-align: center; color: var(--muted); grid-column: 1 / -1; }

.product {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column;
}
.product__img {
  aspect-ratio: 1 / 1; background: var(--brand-soft);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.product__img img { width: 100%; height: 100%; object-fit: cover; }
.product__img-fallback { font-size: 38px; opacity: .8; }
.product__price--quote {
  font-weight: 600; font-size: 12px;
  color: var(--brand-dark); background: var(--brand-soft);
  padding: 2px 8px; border-radius: 999px;
}
.product--custom .product__img { background: linear-gradient(135deg, var(--brand-soft), #fef3c7); }
.product__body { padding: 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.product__name { font-weight: 600; font-size: 15px; margin: 0; }
.product__desc { color: var(--muted); font-size: 13px; margin: 0; flex: 1;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.product__row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; }
.product__price { font-weight: 700; font-size: 15px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--tap); padding: 10px 16px;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn--primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn--block { width: 100%; }
.btn--sm { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.icon-btn {
  width: var(--tap); height: var(--tap); border-radius: 999px;
  border: none; background: transparent; cursor: pointer; font-size: 18px;
}

/* ---------- Cart drawer ---------- */
.cart-drawer { position: fixed; inset: 0; z-index: 50; display: flex; justify-content: flex-end; }
.cart-drawer[hidden] { display: none; }
.cart-drawer__scrim {
  position: absolute; inset: 0; background: rgba(0,0,0,.4); border: none; cursor: pointer;
}
.cart-drawer__panel {
  position: relative; z-index: 1; background: var(--surface);
  width: 100%; max-width: 420px; height: 100%;
  display: flex; flex-direction: column; box-shadow: var(--shadow-md);
  animation: slidein .2s ease-out;
}
@keyframes slidein { from { transform: translateX(8%); opacity: 0; } to { transform: none; opacity: 1; } }
.cart-drawer__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.cart-drawer__header h2 { margin: 0; font-size: 18px; }
.cart-items { padding: 8px 8px 0; overflow-y: auto; flex: 1; }
.cart-line {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px;
  padding: 12px 8px; border-bottom: 1px solid var(--border);
}
.cart-line__name { font-weight: 600; }
.cart-line__price { color: var(--muted); font-size: 14px; }
.cart-line__qty { display: inline-flex; align-items: center; gap: 4px; }
.cart-line__qty button {
  width: 32px; height: 32px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 700;
}
.cart-line__qty .qty-val { min-width: 24px; text-align: center; font-weight: 600; }
.cart-line__remove {
  background: none; border: none; color: var(--danger);
  font-size: 13px; cursor: pointer; padding: 0; margin-top: 2px; justify-self: end;
}
.cart-drawer__footer { padding: 12px 16px 16px; border-top: 1px solid var(--border);
  padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
.cart-totals { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.cart-empty { text-align: center; color: var(--muted); padding: 32px 16px; }

/* ---------- Forms ---------- */
.form { display: grid; gap: 14px; max-width: 560px; }
.field { display: grid; gap: 6px; }
.field label { font-weight: 600; font-size: 14px; }
.field input, .field textarea {
  font: inherit; padding: 10px 12px; min-height: var(--tap);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
}
.field textarea { min-height: 80px; resize: vertical; }
.field input:focus, .field textarea:focus {
  outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand);
}
.field input[readonly] {
  background: var(--bg); color: var(--muted); cursor: not-allowed;
}
.field .hint { color: var(--muted); font-size: 12px; }
.field.has-error input, .field.has-error textarea { border-color: var(--danger); }
.field .error { color: var(--danger); font-size: 13px; min-height: 1em; }

.summary-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; margin-bottom: 16px;
}
.summary-line { display: flex; justify-content: space-between; padding: 6px 0; font-size: 14px; }
.summary-total { font-weight: 700; font-size: 16px; border-top: 1px solid var(--border); margin-top: 8px; padding-top: 10px; }

.checkout-grid { display: grid; gap: 16px; }
@media (min-width: 900px) { .checkout-grid { grid-template-columns: 1.4fr 1fr; align-items: start; } }

.page-title { margin: 8px 0 4px; font-size: 22px; }
.muted { color: var(--muted); }

/* ---------- Confirmation ---------- */
.confirm {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; text-align: center; box-shadow: var(--shadow-sm);
}
.confirm__mark {
  width: 56px; height: 56px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand-dark);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 28px; margin-bottom: 12px;
}
.confirm h1 { margin: 0 0 6px; font-size: 22px; }
.confirm .order-id { display: inline-block; padding: 4px 10px; border-radius: 6px;
  background: var(--bg); border: 1px solid var(--border); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ---------- Generic modal (used by Custom Drink) ---------- */
.modal {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal[hidden] { display: none; }
.modal__scrim {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.5); border: 0; cursor: pointer; padding: 0;
}
.modal__panel {
  position: relative; z-index: 1;
  background: var(--surface); border-radius: var(--radius);
  padding: 16px 20px 20px; max-width: 460px; width: 100%;
  box-shadow: var(--shadow-md);
  max-height: calc(100dvh - 32px); overflow-y: auto;
  animation: pop-in .15s ease-out;
}
@keyframes pop-in { from { transform: scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
.modal__header {
  display: flex; align-items: center; justify-content: space-between;
  margin: -4px 0 12px;
}
.modal__header h2 { margin: 0; font-size: 18px; }

.field--inline {
  display: flex; align-items: center; gap: 12px;
}
.field--inline label { margin: 0; flex: 0 0 auto; }
.field--inline input { width: 96px; }

/* ---------- Email gate (landing-page only) ---------- */
.email-gate {
  position: fixed; inset: 0; z-index: 100;
  background: linear-gradient(135deg, rgba(15,118,110,.94), rgba(11,94,87,.94));
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  padding-top: calc(24px + env(safe-area-inset-top));
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}
html.has-email .email-gate { display: none; }
.email-gate[hidden] { display: none; }

/* On the landing page only (the one containing #email-gate), hide the catalog
   until an email is provided. Other pages (checkout, confirmation) don't have
   the gate, so the rule must NOT match there. */
html:has(#email-gate):not(.has-email) .topbar,
html:has(#email-gate):not(.has-email) .page,
html:has(#email-gate):not(.has-email) .cart-drawer { display: none !important; }
.email-gate__card {
  background: var(--surface); border-radius: var(--radius);
  padding: 28px 24px; max-width: 420px; width: 100%;
  box-shadow: var(--shadow-md); text-align: center;
}
.email-gate__icon {
  width: 64px; height: 64px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand-dark);
  font-size: 32px; line-height: 64px;
  margin: 0 auto 12px;
}
.email-gate__card h2 { margin: 0 0 6px; font-size: 22px; }
.email-gate__lede { margin: 0 0 18px; font-size: 14px; }
.email-gate .form { text-align: left; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ---------- Product quantity stepper ---------- */
.qty-stepper { display: inline-flex; align-items: center; gap: 4px; }
.qty-stepper__btn {
  width: 34px; height: 34px; border-radius: 999px;
  border: 1px solid var(--brand); background: var(--surface); color: var(--brand-dark);
  font-weight: 700; font-size: 18px; line-height: 1; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.qty-stepper__btn:active { background: var(--brand-soft); }
.qty-stepper__val {
  min-width: 24px; text-align: center; font-weight: 700; font-size: 15px;
}
