/* OrderLink shared styles. Each client only changes --accent (set from config.js). */

:root {
  --paper: #f6f6f3;
  --surface: #ffffff;
  --ink: #1c1e22;
  --ink-soft: #5b6068;
  --line: #e2e2dc;
  --accent: #0f6e64;
  --accent-ink: #ffffff;
  --danger: #b3261e;
  --ok: #1e7a3c;
  --radius-sm: 8px;
  --radius-lg: 18px;
  --font-display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --font-body: "Atkinson Hyperlegible", "Segoe UI", Roboto, system-ui, sans-serif;
  --bar-h: 76px;
  color-scheme: light;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #141518;
    --surface: #1d1f23;
    --ink: #f1f1ee;
    --ink-soft: #a6abb3;
    --line: #2e3137;
    --danger: #ff8a80;
    --ok: #7bd88f;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #141518; --surface: #1d1f23; --ink: #f1f1ee; --ink-soft: #a6abb3;
  --line: #2e3137; --danger: #ff8a80; --ok: #7bd88f; color-scheme: dark;
}

*, *::before, *::after { box-sizing: inherit; }
html { scroll-padding-top: env(safe-area-inset-top, 0px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.5 var(--font-body);
}
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.wrap { max-width: 560px; margin: 0 auto; padding: 0 18px; }

/* ---------- Mockup ribbon ---------- */
.mockup-note {
  background: var(--ink); color: var(--paper);
  font-size: 14px; line-height: 1.4; padding: 10px 18px; text-align: center;
}

/* ---------- Header ---------- */
.shop-head { padding: 28px 0 18px; }
.shop-head .logo {
  width: 64px; height: 64px; border-radius: 50%; object-fit: cover;
  margin-bottom: 14px; border: 1px solid var(--line); background: var(--surface);
}
.shop-name {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(30px, 8vw, 40px); line-height: 1.05; letter-spacing: -0.02em; margin: 0;
}
.shop-tagline { margin: 8px 0 0; color: var(--ink-soft); max-width: 40ch; }
.shop-facts { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 6px; font-size: 15px; }
.shop-facts li { display: flex; gap: 8px; align-items: baseline; }
.shop-facts b { font-weight: 700; min-width: 74px; }
.notice {
  margin: 18px 0 0; padding: 12px 14px; border-left: 4px solid var(--accent);
  background: var(--surface); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-size: 15px;
}

/* ---------- Product list ---------- */
.menu { list-style: none; margin: 8px 0 0; padding: 0; border-top: 1px solid var(--line); }
.item {
  display: grid; grid-template-columns: 92px 1fr; gap: 14px;
  padding: 16px 0; border-bottom: 1px solid var(--line);
}
.item .photo {
  width: 92px; height: 92px; border-radius: var(--radius-sm); object-fit: cover; background: var(--line);
}
.item .tile {
  width: 92px; height: 92px; border-radius: var(--radius-sm);
  display: grid; place-items: center; background: var(--accent); color: var(--accent-ink);
  font-family: var(--font-display); font-weight: 700; font-size: 26px;
}
.item > div { min-width: 0; }
.item h3 { font-family: var(--font-display); font-size: 19px; line-height: 1.2; margin: 0; font-weight: 600; }
.item .desc { margin: 4px 0 0; font-size: 15px; color: var(--ink-soft); }
.item .stock { margin: 4px 0 0; font-size: 14px; color: var(--ink-soft); }
.item .price { font-weight: 700; margin-top: 6px; font-size: 17px; }
.item.sold-out .photo, .item.sold-out .tile { filter: grayscale(1); opacity: .55; }
.item .controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.item select {
  min-height: 42px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); max-width: 100%;
}

.btn {
  min-height: 44px; padding: 0 18px; border-radius: 999px; border: 0; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line); }
.btn.block { width: 100%; min-height: 52px; font-size: 18px; }

.stepper {
  display: inline-flex; align-items: center; border: 1.5px solid var(--accent);
  border-radius: 999px; overflow: hidden; min-height: 44px;
}
.stepper button {
  width: 44px; height: 44px; border: 0; background: transparent; color: var(--accent);
  font-size: 22px; font-weight: 700; cursor: pointer;
}
.stepper output { min-width: 28px; text-align: center; font-weight: 700; }

/* ---------- Order slip: the sticky bar with a torn receipt edge ---------- */
.slip {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  transform: translateY(110%); transition: transform .25s ease;
}
.slip.show { transform: none; }
.slip-inner {
  max-width: 560px; margin: 0 auto; background: var(--ink); color: var(--paper);
  padding: 14px 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  position: relative; min-height: var(--bar-h);
  /* perforated tear line: small notches cut into the top edge, like a torn order slip */
  background:
    radial-gradient(circle at 8px 0, var(--paper) 4.5px, transparent 5px) 0 0 / 16px 6px repeat-x,
    var(--ink);
  padding-top: 18px;
}
.slip .count { font-size: 14px; opacity: .8; }
.slip .sum { font-family: var(--font-display); font-size: 22px; font-weight: 700; }
.slip .btn { background: var(--accent); color: var(--accent-ink); }
@media (prefers-reduced-motion: reduce) { .slip { transition: none; } }

/* ---------- Chat button ---------- */
.chat-fab {
  position: fixed; right: 16px; z-index: 19;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  background: var(--surface); color: var(--ink); border: 1.5px solid var(--line);
  box-shadow: 0 6px 18px rgba(20, 22, 26, .14);
}
body.has-slip .chat-fab { bottom: calc(var(--bar-h) + 22px + env(safe-area-inset-bottom, 0px)); }

/* ---------- Checkout ---------- */
.view-head { display: flex; align-items: center; gap: 10px; padding: 18px 0 6px; }
.back {
  width: 44px; height: 44px; border-radius: 50%; border: 1.5px solid var(--line);
  background: var(--surface); cursor: pointer; font-size: 20px;
}
.view-title { font-family: var(--font-display); font-size: 28px; margin: 0; letter-spacing: -0.01em; }
.section-title { font-family: var(--font-display); font-size: 20px; margin: 28px 0 10px; }

.lines { list-style: none; margin: 0; padding: 0; }
.line {
  display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center;
  padding: 12px 0; border-bottom: 1px dashed var(--line);
}
.line .name { font-weight: 700; }
.line .variant { color: var(--ink-soft); font-size: 15px; }
.line .amt { font-weight: 700; text-align: right; }
.totals { margin: 12px 0 0; display: grid; gap: 6px; }
.totals div { display: flex; justify-content: space-between; gap: 12px; }
.totals .grand { font-family: var(--font-display); font-size: 22px; font-weight: 700; padding-top: 8px; border-top: 2px solid var(--ink); }
.muted { color: var(--ink-soft); font-size: 15px; }

.field { margin: 0 0 14px; }
.field label, .field legend { display: block; font-weight: 700; margin-bottom: 6px; }
.field input[type="text"], .field input[type="tel"], .field textarea {
  width: 100%; min-height: 48px; padding: 10px 12px; border: 1.5px solid var(--line);
  border-radius: var(--radius-sm); background: var(--surface);
}
.field textarea { min-height: 88px; resize: vertical; }
.field .hint { font-size: 14px; color: var(--ink-soft); margin-top: 4px; }
.field .err { color: var(--danger); font-size: 14px; margin-top: 4px; }
.field.invalid input, .field.invalid textarea { border-color: var(--danger); }
fieldset.field { border: 0; padding: 0; min-width: 0; }

.choices { display: grid; gap: 8px; }
.choices > .choice {
  margin: 0; font-weight: 400;
  display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; align-items: start;
  padding: 12px 14px; border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer;
}
.choice input { margin: 3px 0 0; width: 18px; height: 18px; accent-color: var(--accent); }
.choice .c-label { font-weight: 700; }
.choice .c-note { display: block; font-size: 14px; color: var(--ink-soft); font-weight: 400; }
.choice .c-fee { font-weight: 700; white-space: nowrap; }
.choices > .choice:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

.privacy { font-size: 13px; color: var(--ink-soft); margin: 4px 0 16px; }
.form-error { color: var(--danger); font-weight: 700; margin: 0 0 12px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Done: the paper slip ---------- */
.receipt {
  background: var(--surface); margin: 22px 0 0; padding: 24px 20px 22px; position: relative;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.receipt::after { /* zigzag torn bottom */
  content: ""; position: absolute; left: 0; right: 0; bottom: -10px; height: 10px;
  background:
    linear-gradient(-45deg, transparent 7px, var(--surface) 0) 0 0 / 14px 10px repeat-x,
    linear-gradient(45deg, transparent 7px, var(--surface) 0) 0 0 / 14px 10px repeat-x;
}
.receipt .ok { color: var(--ok); font-weight: 700; margin: 0; }
.receipt .ref { font-family: var(--font-display); font-size: 34px; font-weight: 700; letter-spacing: .02em; margin: 4px 0 2px; }
.receipt .total { font-size: 18px; margin: 0; }
.pay-block { margin-top: 20px; padding-top: 18px; border-top: 1px dashed var(--line); }
.pay-block .section-title { margin-top: 0; }
.pay-steps { margin: 10px 0 0; padding-left: 22px; }
.pay-steps li { margin-bottom: 8px; }
.kv { display: grid; grid-template-columns: auto 1fr auto; gap: 8px 12px; align-items: center; margin: 12px 0; }
.kv dt { color: var(--ink-soft); font-size: 15px; }
.kv dd { margin: 0; font-weight: 700; word-break: break-word; }
.copy { min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1.5px solid var(--line); background: transparent; cursor: pointer; font-size: 14px; font-weight: 700; }
.qr { width: min(240px, 70vw); margin: 14px auto 4px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: #fff; padding: 8px; }
.after { margin: 28px 0 0; display: grid; gap: 10px; }

/* ---------- Footer ---------- */
.foot { margin: 40px 0 0; padding: 22px 0 120px; border-top: 1px solid var(--line); font-size: 14px; color: var(--ink-soft); }
.foot strong { color: var(--ink); }
.foot p { margin: 4px 0; }
.foot a { color: inherit; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(110px + env(safe-area-inset-bottom, 0px)); z-index: 40;
  transform: translateX(-50%); background: var(--ink); color: var(--paper);
  padding: 10px 16px; border-radius: 999px; font-size: 15px; max-width: 90vw; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.toast.show { opacity: 1; }

.empty { padding: 40px 0; text-align: center; color: var(--ink-soft); }
[hidden] { display: none !important; }
