/* Design tokens: tamm.in (system sans, zinc neutrals, brand orange #f48031,
   bold tight headings, rounded-lg cards) blended with the markdown-viewer
   theme (tight negative letter-spacing on headings, thin borders, quiet
   code/mono accents). No custom webfonts — system stack, like both
   sources. */
:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --surface: #ffffff;
  --fg: #18181b;
  --muted: #71717a;
  --accent: #f48031;
  --accent-fg: #1a1005;
  --border: #e4e4e7;
  --sheet-shadow: 0 -8px 30px rgba(24, 24, 27, 0.12);
  --card-shadow: 0 1px 2px rgba(24, 24, 27, 0.05);
  --radius: 14px;
  --status-new: #b45309;
  --status-claimed: #c2680f;
  --status-ready: #15803d;
  --status-error: #c0392b;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #18181b;
    --surface: #27272a;
    --fg: #f4f4f5;
    --muted: #a1a1aa;
    --accent: #ff9f5a;
    --accent-fg: #1a1005;
    --border: #3f3f46;
    --sheet-shadow: 0 -8px 30px rgba(0, 0, 0, 0.5);
    --card-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    --status-error: #ff6b5c;
  }
}
* { box-sizing: border-box; }
/* LA-40: html needs its own background, not just body's — iOS Safari
   paints the elastic overscroll (rubber-band) area at the top and bottom
   with html's background, not body's. Without this it was transparent,
   so a pull-past-the-edge bounce (and the notch/home-indicator strip on
   some devices) flashed the browser's own white canvas through instead
   of the theme colour. */
html, body { height: 100%; min-height: 100dvh; background: var(--bg); }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color: var(--fg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, .display {
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
a { color: inherit; }
button { font-family: inherit; }
::selection { background: var(--accent); color: var(--accent-fg); }

.page { max-width: 560px; margin: 0 auto; padding: 0 0 100px; }
.page-pad { padding-left: 16px; padding-right: 16px; }

/* ---- Hero ---- */
.hero {
  background: var(--surface);
  color: var(--fg);
  padding: calc(20px + env(safe-area-inset-top)) 20px 16px;
  border-bottom: 1px solid var(--border);
}
.hero .brand { display: flex; align-items: center; gap: 10px; }
.hero .brand-mark { height: 48px; width: auto; }
/* Thai Baan's wordmark is white on transparent: black in light mode. */
.hero .brand-word { height: 36px; width: auto; filter: brightness(0); }
@media (prefers-color-scheme: dark) { .hero .brand-word { filter: none; } }
.hero h1 { font-size: 1.5rem; margin: 0; color: var(--fg); }
/* Order-type chip: used on the cart page, above the fulfilment fieldset.
   On the menu page it's now the floating .order-type-pill (LA-22), below. */
.order-type-chip {
  display: inline-flex; align-items: center; gap: 8px;
  margin: 12px 16px; background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent); padding: 6px 6px 6px 12px; border-radius: 999px; font-size: 0.83rem; font-weight: 700;
}
.hero .order-type-chip { margin: 12px 0 0; }
.order-type-chip button {
  background: var(--accent); color: var(--accent-fg); border: none; border-radius: 999px;
  padding: 4px 10px; font-size: 0.76rem; font-weight: 700; cursor: pointer; min-height: unset;
}

/* ---- Category tabs ---- */
.tabs {
  position: sticky; top: 0; z-index: 5;
  display: flex; gap: 8px; overflow-x: auto;
  padding: 12px 16px; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto; padding: 8px 16px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--fg); font-size: 0.87rem; font-weight: 600;
  white-space: nowrap; cursor: pointer; min-height: 36px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.tab.active { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }

/* ---- Menu list ---- */
.category-heading {
  font-size: 1.1rem; margin: 24px 16px 10px; scroll-margin-top: 64px;
}
.food-card {
  display: flex; gap: 12px; align-items: stretch;
  margin: 0 16px 12px; padding: 12px; border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--card-shadow);
  border: 1px solid var(--border); cursor: pointer; text-align: left;
  width: calc(100% - 32px); color: inherit;
}
.food-card img {
  width: 84px; height: 84px; border-radius: 10px; object-fit: cover;
  flex: 0 0 auto; background: var(--border);
}
.food-card .info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.food-card .name { font-weight: 700; font-size: 1rem; letter-spacing: -0.01em; }
.food-card .desc {
  color: var(--muted); font-size: 0.85rem; margin: 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.food-card .row { display: flex; align-items: center; justify-content: space-between; margin-top: auto; }
.food-card .price { font-weight: 700; }
.food-card .qty-pill {
  background: var(--accent); color: var(--accent-fg); border-radius: 999px;
  font-size: 0.78rem; font-weight: 700; padding: 2px 9px;
}
.food-card.sold-out { opacity: 0.55; cursor: not-allowed; }
.food-card .sold-out-badge { color: var(--accent); font-size: 0.78rem; font-weight: 700; }

/* ---- Bottom sheet ---- */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(24, 24, 27, 0.45);
  z-index: 20; opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21;
  background: var(--surface); border-radius: 20px 20px 0 0;
  box-shadow: var(--sheet-shadow); max-width: 560px; margin: 0 auto;
  transform: translateY(100%); transition: transform 0.25s cubic-bezier(.32,.72,0,1);
  /* LA-21: sheet grows to fit its content and scrolls inside past this cap.
     vh first as a fallback for browsers without dvh support. */
  max-height: 88vh; max-height: 85dvh; overflow-y: auto;
}
.sheet.open { transform: translateY(0); }
.sheet .grabber { width: 36px; height: 4px; background: var(--border); border-radius: 999px; margin: 10px auto; }
/* LA-42: the cart page itself, in an iframe, filling a tall sheet. It's a
   full page with its own scrolling and its own `min-height: 100dvh` (for
   when it's opened standalone), which fights measuring its real content
   height from outside — so this is a fixed height, not shrink-to-fit like
   the other sheets, capped low enough that a short cart doesn't read as
   mostly dead space. */
.cart-sheet { height: 70dvh; max-height: 70dvh; padding: 0; }
.cart-sheet iframe { width: 100%; height: 100%; border: 0; display: block; }
.sheet-close {
  /* LA-19: 44px tap target (WCAG minimum). Fixed dark chip + white glyph,
     not theme colors — this sits on a food photo, so it must read against
     any image or any venue theme, not just against --surface. */
  position: absolute; top: 6px; right: 6px; z-index: 1;
  width: 44px; height: 44px; border-radius: 50%; border: none;
  background: rgba(0, 0, 0, 0.5); color: #fff; font-size: 1.3rem; line-height: 1;
  cursor: pointer; min-height: unset; min-width: unset;
  display: flex; align-items: center; justify-content: center;
}
.order-type-options { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }
.order-type-btn {
  padding: 16px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg);
  color: var(--fg); font-size: 1rem; font-weight: 600; text-align: left; cursor: pointer;
}
.table-picker { margin-top: 14px; }
.table-picker label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 6px; }
.table-picker select {
  width: 100%; padding: 11px 12px; font-size: 1rem; min-height: 44px; margin-bottom: 12px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--fg);
}
.sheet img { width: 100%; height: 200px; object-fit: cover; }
.sheet .sheet-body { padding: 16px 20px 20px; }
.sheet h2 { font-size: 1.25rem; margin: 0 0 6px; }
.sheet .desc { color: var(--muted); font-size: 0.92rem; white-space: pre-line; }
.sheet .price { font-weight: 700; font-size: 1.1rem; margin: 12px 0; }
.option-group { border: none; padding: 0; margin: 0 0 16px; }
.option-group legend { padding: 0; font-weight: 700; font-size: 0.88rem; margin-bottom: 6px; }
.option-group .req { color: var(--accent); font-weight: 600; text-transform: none; }
.option-row {
  /* LA-20: full-width tappable row, 44px minimum hit area. */
  display: flex; align-items: center; gap: 10px; padding: 12px 0;
  min-height: 44px; border-bottom: 1px solid var(--border); font-size: 0.92rem; cursor: pointer;
}
.option-row:last-of-type { border-bottom: none; }
.option-row input { flex: 0 0 auto; }
.option-row span:first-of-type { flex: 1; }

/* ---- Checkboxes & radios (LA-20): hand-styled, no browser defaults. A
   native unchecked control is drawn by the OS, not the page, so it can't
   pick up a venue's theme colors — this makes it a themed ring/dot instead,
   filled with --accent when checked. Works for every venue via variables. */
input[type="radio"], input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; margin: 0;
  width: 22px; height: 22px; flex: 0 0 auto;
  border: 2px solid var(--border); background: var(--bg); cursor: pointer;
}
input[type="radio"] { border-radius: 50%; }
input[type="checkbox"] { border-radius: 6px; }
input[type="radio"]:checked, input[type="checkbox"]:checked {
  border-color: var(--accent);
  background: radial-gradient(var(--accent) 0 42%, transparent 46%) center/100% 100% no-repeat, var(--bg);
}
input[type="checkbox"]:checked {
  background: linear-gradient(var(--accent), var(--accent)) center/60% 60% no-repeat, var(--bg);
}
.opt-price { color: var(--muted); font-size: 0.82rem; }
.stepper { display: flex; align-items: center; gap: 14px; justify-content: center; margin: 16px 0; }
.stepper button {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface); font-size: 1.3rem; cursor: pointer;
}
.stepper output { min-width: 2ch; text-align: center; font-weight: 700; font-size: 1.1rem; }

/* ---- Buttons ---- */
button.primary {
  background: var(--accent); color: var(--accent-fg); border: none;
  width: 100%; padding: 15px; border-radius: 10px;
  font-weight: 700; font-size: 1.02rem; min-height: 48px; cursor: pointer;
  transition: transform 0.1s, opacity 0.15s;
}
button.primary:active { transform: scale(0.98); }
button.primary:disabled { opacity: 0.45; cursor: not-allowed; }
button.secondary {
  background: transparent; color: var(--accent); border: 1px solid var(--accent);
  width: 100%; padding: 13px; border-radius: 10px; font-weight: 600; min-height: 44px; cursor: pointer;
}

/* ---- Floating bottom bar (LA-22): order-type pill always shown, cart
   summary slides in once there's something in it. Two independent
   buttons side by side, not one shared tap target. ---- */
.cart-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  max-width: 560px; margin: 0 auto; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 10px;
}
.order-type-pill {
  flex: 1 1 auto; min-width: 0;
  background: var(--surface); color: var(--fg); border: 1px solid var(--border);
  border-radius: 999px; padding: 0 16px; min-height: 48px;
  font-size: 0.85rem; font-weight: 700; cursor: pointer;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cart-bar-inner {
  position: relative; flex: 0 0 auto;
  display: flex; align-items: center; gap: 8px;
  background: var(--fg); color: var(--bg); border-radius: 999px; padding: 12px 18px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  transform: translateY(120%) scale(0.9); opacity: 0; transition: transform 0.25s cubic-bezier(.32,.72,0,1), opacity 0.2s;
}
.cart-bar-inner.visible { transform: translateY(0) scale(1); opacity: 1; }
/* Small round badge on the bar's corner, not a full-size inline number. */
.cart-bar-inner .count-badge {
  position: absolute; top: -8px; right: -8px;
  background: var(--accent); color: var(--accent-fg); border-radius: 50%;
  width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.68rem; font-weight: 700; box-shadow: 0 0 0 2px var(--fg);
}
.cart-bar-inner .go { font-weight: 700; display: flex; align-items: center; gap: 4px; white-space: nowrap; }

/* ---- Cart page ---- */
.cart-header { padding: calc(20px + env(safe-area-inset-top)) 16px 8px; }
.cart-header h1 { font-size: 1.4rem; margin: 0; }
.cart-line {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.cart-line .info { min-width: 0; }
.cart-line .name { font-weight: 600; font-size: 0.95rem; }
.cart-line .unit { color: var(--muted); font-size: 0.82rem; }
.qty { display: flex; align-items: center; gap: 10px; }
.qty button {
  width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface); font-size: 1.05rem; cursor: pointer; min-height: unset; min-width: unset;
}
.qty output { min-width: 1.5em; text-align: center; font-weight: 600; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }

fieldset { border: 1px solid var(--border); border-radius: var(--radius); margin: 16px; padding: 4px 14px 14px; background: var(--surface); }
legend { padding: 0 6px; font-weight: 700; font-size: 0.92rem; }
.fulfil-option {
  display: flex; align-items: center; gap: 10px; padding: 12px 0;
  min-height: 44px; border-bottom: 1px solid var(--border); cursor: pointer;
}
.fulfil-option:last-of-type { border-bottom: none; }
input[type="text"] {
  width: 100%; padding: 11px 12px; font-size: 1rem; min-height: 44px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--fg);
  margin-top: 8px;
}
.total-row { display: flex; justify-content: space-between; align-items: baseline; padding: 4px 16px 14px; }
.total-row .label { color: var(--muted); font-size: 0.9rem; }
.total-row .amount { font-size: 1.35rem; font-weight: 800; letter-spacing: -0.02em; }
.error { color: var(--status-error); margin: 8px 16px; font-size: 0.9rem; }
.pay-buttons { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.gateway-line { text-align: center; color: var(--muted); font-size: 0.8rem; margin: 4px 0 10px; }
.gateway-line button {
  background: none; border: none; color: inherit; text-decoration: underline;
  text-decoration-color: var(--border); cursor: pointer; font: inherit; padding: 0;
}

/* ---- Order status page ---- */
.status-page { text-align: center; padding: calc(48px + env(safe-area-inset-top)) 20px 60px; }
.top-back-link { text-align: left; margin: -20px 0 16px; }
.top-back-link a { color: var(--muted); font-weight: 600; font-size: 0.88rem; text-decoration: none; }
.order-number { font-size: 2.6rem; margin: 0 0 6px; }
.status-page .venue { color: var(--muted); margin: 0 0 32px; }
.progress { display: flex; justify-content: center; gap: 0; margin: 0 auto 28px; max-width: 420px; }
.progress .step { flex: 1; text-align: center; position: relative; }
.progress .dot {
  width: 32px; height: 32px; border-radius: 50%; background: var(--border); color: var(--muted);
  display: flex; align-items: center; justify-content: center; margin: 0 auto 8px; font-weight: 700;
  transition: background 0.3s, color 0.3s;
}
.progress .step.done .dot, .progress .step.active .dot { background: var(--accent); color: var(--accent-fg); }
.progress .step::before {
  content: ''; position: absolute; top: 16px; left: -50%; width: 100%; height: 2px;
  background: var(--border); z-index: -1;
}
.progress .step:first-child::before { display: none; }
.progress .step.done::before { background: var(--accent); }
.progress .label { font-size: 0.78rem; color: var(--muted); }
.progress .step.active .label { color: var(--fg); font-weight: 600; }
.status-headline { font-size: 1.25rem; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.status-sub { color: var(--muted); margin-top: 6px; }
.status-ready-banner { color: var(--status-ready); }
.suggestions { text-align: left; margin-top: 28px; }
.suggestions h2 { font-size: 1rem; margin: 0 0 10px; }
.suggestion-list { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 2px; }
.suggestion-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 0 0 84px;
  padding: 10px 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg);
  color: inherit; text-decoration: none; font-size: 0.8rem; text-align: center;
}
.suggestion-card img { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; }
.order-back-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  max-width: 560px; margin: 0 auto; text-align: center;
  padding: 40px 16px calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 55%, transparent);
  pointer-events: none;
}
.order-back-bar a {
  pointer-events: auto; display: inline-block; min-height: 44px; line-height: 44px;
  padding: 0 20px; border-radius: 999px; background: var(--fg); color: var(--bg);
  font-weight: 700; text-decoration: none;
}

/* ---- Footer ---- */
.page-footer { text-align: center; padding: 20px 16px 100px; }
.page-footer a { color: var(--muted); font-size: 0.82rem; text-decoration: underline; text-decoration-color: var(--border); }

/* ---- Demo payment step ---- */
.pay-sheet .sheet-body { padding: 18px 20px 22px; }
.demo-badge {
  display: inline-flex; align-items: center; gap: 6px; background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent); font-size: 0.74rem; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 999px; margin-bottom: 12px;
}
.pay-total-row { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); margin: 14px 0 18px; }
.pay-total-row .label { color: var(--muted); font-size: 0.9rem; }
.pay-total-row .amount { font-size: 1.3rem; font-weight: 800; letter-spacing: -0.02em; }
.order-summary { border: 1px solid var(--border); border-radius: 10px; padding: 4px 12px; margin-bottom: 14px; background: var(--bg); }
.summary-line { display: flex; justify-content: space-between; padding: 7px 0; font-size: 0.86rem; color: var(--muted); border-bottom: 1px solid var(--border); }
.summary-line:last-child { border-bottom: none; }
.gateway-note { text-align: center; color: var(--muted); font-size: 0.8rem; margin: 10px 0 4px; }
.pay-processing { text-align: center; padding: 40px 20px 30px; }
.spinner {
  width: 36px; height: 36px; margin: 0 auto 16px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.001ms !important; animation-duration: 0.001ms !important; }
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
