/* =====================================================================
   Thai Spice — customer menu (Phase 2)
   Mobile-first, flat, hairline borders, two font weights (400/500).
   ===================================================================== */

:root {
    --brand: #A32D2D;          /* the one place to retune the accent */
    --ink: #1b1b1b;
    --muted: #6c6c6c;
    --line: rgba(0, 0, 0, 0.14);
    --surface: #ffffff;
    --surface-2: #f5f4f2;
    --radius: 12px;
    --maxw: 720px;
    --pad: 16px;
    --sticky-h: 0px;           /* set by JS to the sticky header height */
}

* { box-sizing: border-box; }

body.page-menu {
    margin: 0;
    background: var(--surface);
    color: var(--ink);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-weight: 400;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.page-menu .icon { width: 1.25em; height: 1.25em; display: inline-block; vertical-align: middle; }

/* Centre everything in a comfortable column on desktop. */
.menu-top,
.menu-main,
.empty-menu,
.menu-footer {
    width: 100%;
    max-width: var(--maxw);
    margin-inline: auto;
}

/* ---- Sticky top region: one container holding header + status + chips ---- */
.menu-top {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--surface);
}

.menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px var(--pad);
    border-bottom: 0.5px solid var(--line);
}

.brand {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}
.wordmark {
    color: var(--brand);
    font-weight: 500;
    font-size: 20px;
    letter-spacing: 0.01em;
    text-decoration: none;
}
.tagline {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.2;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.phone-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--ink);
    text-decoration: none;
    font-size: 13px;
    white-space: nowrap;
}
.phone-link .icon { width: 18px; height: 18px; color: var(--brand); }
.phone-link:hover { text-decoration: underline; }

.basket-button {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: 0;
    padding: 6px;
    color: var(--ink);
    cursor: pointer;
    font: inherit;
}
.basket-button .icon { width: 24px; height: 24px; }
.basket-count {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--brand);
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    line-height: 18px;
    text-align: center;
}

.status-strip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px var(--pad);
    font-size: 13px;
    color: var(--muted);
    border-bottom: 0.5px solid var(--line);
}
.status-dot {
    width: 8px; height: 8px; border-radius: 999px;
    background: #2e7d32;        /* open: green */
    display: inline-block;
}
.status-dot.is-closed { background: #c0392b; }   /* closed: red */

/* Closed: dot + text bold and in the closed colour. */
.status-strip.is-closed {
    color: #c0392b;
    font-weight: 700;
}
.status-strip.is-closed .status-dot.is-closed {
    width: 10px; height: 10px;
    box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.18);
}

/* Closed banner under the status strip on the menu. */
.closed-banner {
    margin: 10px var(--pad) 0;
    padding: 10px 14px;
    border-radius: 10px;
    background: #fdecea;
    border: 1px solid #f3c3bd;
    color: #8a1c11;
    font-size: 14px;
    line-height: 1.4;
}
.closed-banner strong { font-weight: 700; }

/* Closed message inside the item detail sheet (replaces the add controls). */
.sheet-closed {
    margin-top: 16px;
    padding: 12px 14px;
    border-radius: 10px;
    background: #fdecea;
    border: 1px solid #f3c3bd;
    color: #8a1c11;
    font-size: 14px;
    line-height: 1.45;
}
.sheet-closed strong { font-weight: 700; }

.chips {
    display: flex;
    flex-wrap: nowrap;          /* single line */
    gap: 6px;
    padding: 6px var(--pad);    /* minimal vertical space */
    border-bottom: 0.5px solid var(--line);
    width: 100%;                /* never wider than its column */
    max-width: 100%;
    overflow-x: auto;           /* the bar scrolls INSIDE its own box */
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;      /* Firefox */
    scroll-snap-type: x proximity;
}
.chips::-webkit-scrollbar { display: none; } /* WebKit */

.chip {
    flex: 0 0 auto;             /* don't shrink; keep on one line */
    scroll-snap-align: start;
    border: 0.5px solid var(--line);
    border-radius: 999px;
    padding: 5px 11px;
    font-size: 13px;
    line-height: 1.2;
    color: var(--ink);
    background: var(--surface);
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}
.chip.is-active {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}

/* ---- Sections & cards ---- */
.menu-main { padding-bottom: 96px; }       /* room above any future bar */

.menu-section {
    padding: 8px var(--pad) 0;
    /* offset for the sticky header when chip-scrolling / anchor jumps */
    scroll-margin-top: calc(var(--sticky-h) + 8px);
}
.menu-section h2 {
    font-size: 18px;
    font-weight: 500;
    margin: 16px 0 4px;
}

.item-list { list-style: none; margin: 0; padding: 0; }

.item-card {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    width: 100%;
    text-align: left;
    background: var(--surface);
    border: 0;
    border-bottom: 0.5px solid var(--line);
    padding: 14px 0;
    cursor: pointer;
    color: inherit;
    font: inherit;
}
.item-card:hover { background: var(--surface-2); }
.item-card:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }

/* Sold out (item-level, or every protein out): not orderable. */
.item-card.is-soldout { cursor: not-allowed; }
.item-card.is-soldout:hover { background: var(--surface); }
.item-card.is-soldout .thumb,
.item-card.is-soldout .card-body { opacity: 0.5; }
.item-card.is-soldout .soldout-label {
    opacity: 1; font-weight: 600; color: #8a1c11;
    text-transform: uppercase; letter-spacing: 0.02em; font-size: 13px;
}

.thumb {
    width: 64px; height: 64px;
    border-radius: 10px;
    object-fit: cover;
    background: var(--surface-2);
    border: 0.5px solid var(--line);
    flex: 0 0 auto;
}

.card-body { flex: 1 1 auto; min-width: 0; display: block; }
.meta-row { display: block; }
.code { color: var(--muted); font-size: 12px; margin-right: 6px; }
.name { font-weight: 500; }
.name-thai { color: var(--muted); font-size: 13px; margin-left: 6px; }

.flags { display: inline-flex; align-items: center; gap: 8px; margin-top: 2px; }
.badge-v {
    display: inline-flex; align-items: center; justify-content: center;
    width: 18px; height: 18px; border-radius: 4px;
    background: #2e7d32; color: #fff;
    font-size: 11px; font-weight: 500;
}
.flames { display: inline-flex; align-items: center; gap: 1px; color: var(--brand); }
.flames .icon-flame { width: 13px; height: 13px; }

.desc {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--muted);
    font-size: 13px;
    margin-top: 4px;
}
.price { display: block; font-weight: 500; margin-top: 6px; }

.chev { color: var(--muted); align-self: center; flex: 0 0 auto; }
.chev .icon { width: 20px; height: 20px; }

.empty-menu { padding: 32px var(--pad); color: var(--muted); }

.menu-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
    padding: 24px var(--pad) 40px;
    border-top: 0.5px solid var(--line);
    font-size: 13px;
}
.footer-address { font-style: normal; color: var(--muted); }
.footer-links { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; }
.menu-footer a { color: var(--muted); }

/* =====================================================================
   Sticky basket bar — appears once the basket has items, giving a clear
   route to review + checkout. Toggled (hidden attr) by menu.js.
   ===================================================================== */
.basket-bar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 40;
    width: 100%;
    max-width: var(--maxw);
    margin-inline: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px var(--pad);
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    border: 0;
    background: var(--brand);
    color: #fff;
    font: inherit;
    font-size: 15px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.18);
}
.basket-bar[hidden] { display: none; }
.basket-bar:hover { background: #8f2727; }
.basket-bar .icon { width: 20px; height: 20px; }
.basket-bar-left { display: inline-flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.basket-bar-cta { flex: 1 1 auto; text-align: center; font-weight: 600; }
.basket-bar-total { flex: 0 0 auto; font-variant-numeric: tabular-nums; }

/* Reserve space so the fixed bar never hides the footer / last items. */
body.page-menu.has-basket-bar { padding-bottom: 76px; }

/* =====================================================================
   Dialog: detail sheet & basket (bottom sheet on mobile, modal on desktop)
   The dialog fills the viewport in the top layer; a flex wrapper positions
   the white panel. This avoids fighting the UA's own dialog positioning.
   ===================================================================== */
dialog.sheet {
    position: fixed;
    inset: 0;                    /* fills the viewport; width/height follow */
    width: 100%;
    height: 100dvh;
    max-width: 100%;
    max-height: 100dvh;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    overflow: hidden;
}
dialog.sheet::backdrop { background: rgba(0, 0, 0, 0.45); }

.sheet-wrap {
    height: 100%;
    display: flex;
    align-items: flex-end;       /* bottom sheet on mobile */
    justify-content: center;
}
.sheet-panel {
    width: 100%;
    max-width: var(--maxw);
    max-height: 90dvh;
    overflow-y: auto;
    background: var(--surface);
    border-radius: 16px 16px 0 0;
    padding: 16px var(--pad) calc(16px + env(safe-area-inset-bottom));
    -webkit-overflow-scrolling: touch;
}

@media (min-width: 721px) {
    .sheet-wrap { align-items: center; }
    .sheet-panel { border-radius: 16px; max-height: 85vh; }
}

/* Sheet contents */
.sheet-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}
.sheet-title { font-size: 18px; font-weight: 500; margin: 0; }
.sheet-sub { color: var(--muted); font-size: 13px; margin: 2px 0 0; }
.sheet-desc { color: var(--muted); font-size: 14px; margin: 8px 0 12px; }
.sheet-close {
    background: none; border: 0; cursor: pointer; color: var(--muted);
    padding: 4px; margin: -4px -4px 0 0;
}
.sheet-close .icon { width: 22px; height: 22px; }

.sheet-section-label {
    font-size: 13px; font-weight: 500; margin: 12px 0 6px;
}
.qty-help {
    color: var(--muted);
    font-size: 13px;
    margin: 0 0 12px;
}

/* Option list (single select, native radios visually replaced) */
.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;
}

.option {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    border: 0.5px solid var(--line);
    border-radius: 10px;
    margin-bottom: 8px;
    cursor: pointer;
}
.option input {
    position: absolute;
    width: 1px; height: 1px;
    opacity: 0;            /* hidden but focusable for keyboard users */
}
.option .opt-label { display: inline-flex; align-items: center; gap: 8px; }
.option .check { width: 18px; height: 18px; color: var(--brand); visibility: hidden; }
.option .opt-price { font-weight: 500; }
.option:has(input:checked) {
    border-color: var(--brand);
    box-shadow: inset 0 0 0 1.5px var(--brand);
}
.option:has(input:checked) .check { visibility: visible; }
.option:has(input:focus-visible) { outline: 2px solid var(--brand); outline-offset: 2px; }

/* Notes textarea */
.notes-field { display: block; margin-top: 12px; }
.notes-field textarea {
    width: 100%;
    min-height: 64px;
    resize: vertical;
    padding: 10px 12px;
    border: 0.5px solid var(--line);
    border-radius: 10px;
    font: inherit;
    color: var(--ink);
    background: var(--surface);
}
.notes-field textarea:focus-visible { outline: 2px solid var(--brand); outline-offset: 0; }

/* Quantity stepper */
.qty-row {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 16px 0;
}
.qty-row .qty-label { font-weight: 500; }
.stepper {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: 0.5px solid var(--line);
    border-radius: 999px;
    padding: 2px;
    margin-left: auto;
}
.stepper button {
    width: 36px; height: 36px;
    border: 0; border-radius: 999px;
    background: var(--surface-2);
    color: var(--ink);
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
}
.stepper button:disabled { opacity: 0.4; cursor: not-allowed; }
.stepper button:focus-visible { outline: 2px solid var(--brand); }
.stepper .qty-value { min-width: 28px; text-align: center; font-weight: 500; }

/* Primary full-width button */
.btn-primary {
    display: block;
    width: 100%;
    padding: 14px 16px;
    border: 0;
    border-radius: 12px;
    background: var(--brand);
    color: #fff;
    font: inherit;
    font-weight: 500;
    cursor: pointer;
    text-align: center;
}
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* Basket */
.basket-empty { color: var(--muted); padding: 16px 0; }
.basket-line {
    display: flex;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 0.5px solid var(--line);
}
.basket-line .thumb { width: 56px; height: 56px; }
.basket-line .line-body { flex: 1 1 auto; min-width: 0; }
.basket-line .line-top { display: flex; justify-content: space-between; gap: 12px; }
.basket-line .line-name { font-weight: 500; }
.basket-line .line-opt { color: var(--muted); font-size: 13px; }
.basket-line .line-total { font-weight: 500; white-space: nowrap; }
.basket-line .line-note {
    width: 100%;
    margin-top: 8px;
    padding: 8px 10px;
    border: 0.5px solid var(--line);
    border-radius: 8px;
    font: inherit;
    font-size: 13px;
}
.basket-line .line-controls {
    display: flex; align-items: center; gap: 12px; margin-top: 8px;
}
.basket-line .qty-unit { color: var(--muted); font-size: 13px; margin-left: -6px; }
.line-remove {
    background: none; border: 0; color: var(--brand);
    cursor: pointer; font: inherit; font-size: 13px; padding: 0;
    text-decoration: underline;
}
.basket-subtotal {
    display: flex; justify-content: space-between;
    font-weight: 500; margin: 16px 0;
}

@media (prefers-reduced-motion: no-preference) {
    html { scroll-behavior: smooth; }
}

/* =====================================================================
   Checkout & confirmation (Phase 3)
   ===================================================================== */
.checkout {
    width: 100%;
    max-width: var(--maxw);
    margin-inline: auto;
    padding: 8px var(--pad) 40px;
}
.checkout h1 { font-size: 22px; font-weight: 500; margin: 16px 0 8px; }
.co-h { font-size: 16px; font-weight: 500; margin: 22px 0 8px; }

.field { display: block; margin-bottom: 12px; }
.field-label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field input,
.field select,
#order-note {
    width: 100%;
    max-width: 100%;            /* never exceed the wrapper */
    padding: 10px 12px;
    border: 0.5px solid var(--line);
    border-radius: 10px;
    font: inherit;
    color: var(--ink);
    background: var(--surface);
}
#order-note { resize: vertical; }
.field input:focus-visible,
.field select:focus-visible,
#order-note:focus-visible { outline: 2px solid var(--brand); outline-offset: 0; }

/* Honeypot — visually removed but present in the DOM. Uses the clip pattern
   (NOT left:-9999px, which widened the page and caused horizontal overflow). */
.hp {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.slots-message { font-size: 13px; color: var(--muted); margin: 4px 0 0; min-height: 1.1em; }
.slots-message.is-closed { color: var(--brand); }

/* Order summary lines (checkout + confirmation) */
.summary { margin-bottom: 8px; }
.sum-line {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2px 12px;
    padding: 10px 0;
    border-bottom: 0.5px solid var(--line);
}
.sum-qty { color: var(--muted); }
.sum-right { font-weight: 500; text-align: right; white-space: nowrap; }
.sum-note { grid-column: 1 / -1; color: var(--muted); font-size: 13px; }
.line-opt { color: var(--muted); font-size: 13px; }

.price-summary { margin: 16px 0; border-top: 0.5px solid var(--line); padding-top: 12px; }
.price-row { display: flex; justify-content: space-between; padding: 4px 0; }
.price-row.discount { color: var(--muted); }
.price-row.total {
    font-weight: 500;
    font-size: 16px;
    border-top: 0.5px solid var(--line);
    margin-top: 6px;
    padding-top: 10px;
}

.alert {
    padding: 10px 12px;
    border-radius: 10px;
    margin: 12px 0;
    font-size: 14px;
}
.alert-error { background: #fdecea; color: #8a1c11; border: 0.5px solid #f3c2bd; }

/* Confirmation */
.conf-headline { font-size: 16px; }
.notices {
    margin: 20px 0;
    padding-top: 12px;
    border-top: 0.5px solid var(--line);
}
.notices p { font-size: 13px; color: var(--muted); margin: 0 0 10px; line-height: 1.5; }
.pay-icons {
    display: inline-flex;
    gap: 6px;
    vertical-align: -5px;
    margin-right: 6px;
    color: var(--brand);
}
.pay-icons .icon { width: 20px; height: 20px; }
.conf-actions { margin: 12px 0; }
.conf-actions .phone-link { color: var(--brand); }
