/* App layout: full-height map with list panel (desktop) / bottom sheet (mobile) */
.app-body {
  height: 100vh;          /* fallback: iOS < 16.4, older Android */
  height: 100dvh;         /* modern: shrinks/grows with browser chrome */
  display: flex;
  flex-direction: column;
  overflow: hidden;
  overscroll-behavior: none;  /* no rubber-band bounce behind the map */
}

.app-header {
  display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap;
  flex: 0 0 auto;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
  padding-left: calc(16px + env(safe-area-inset-left));
  padding-right: calc(16px + env(safe-area-inset-right));
  background: var(--surface);
  border-bottom: 4px solid var(--asphalt);
  border-image: repeating-linear-gradient(90deg, var(--asphalt) 0 40px, transparent 40px 64px) 4;
  z-index: 1001;
}
.app-header .brand { display: flex; align-items: center; gap: 8px; font-family: var(--font-display); font-weight: 700; font-size: 17px; text-decoration: none; }
.app-header .brand img { width: 26px; height: 26px; border-radius: 6px; }
@media (max-width: 560px) { .app-header .brand span { display: none; } }

.filters {
  display: flex; gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  min-width: 0;
}
.filters::-webkit-scrollbar { display: none; }
.chip {
  font-family: var(--font-body); font-size: 13px; font-weight: 600;
  padding: 9px 14px; border-radius: 999px;   /* 38px tall — thumb-sized */
  border: 2px solid var(--hairline); background: transparent; color: var(--ink);
  cursor: pointer; white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.chip.active { background: var(--lime); color: #10140F; }
.chip:focus-visible { outline: 3px solid var(--marigold-deep); outline-offset: 2px; }

.app-main { flex: 1 1 auto; display: flex; position: relative; min-height: 0; }
#map { flex: 1; min-height: 0; height: 100%; z-index: 1; }

/* Desktop: fixed right column. Mobile: swipe-up bottom sheet. */
.list-handle { display: none; }
.truck-list {
  width: 340px; overflow-y: auto; background: var(--surface);
  border-left: 1px solid var(--hairline); padding: 14px; display: flex; flex-direction: column; gap: 10px;
}

@media (max-width: 820px) {
  .list-panel {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    z-index: 900;
    background: var(--surface);
    border-top: 2px solid var(--lime);
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.5);
    display: flex; flex-direction: column;
    /* Collapsed: only the handle peeks above the fold. */
    height: min(66%, 520px);
    transform: translateY(calc(100% - var(--handle-h, 58px)));
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
    touch-action: none;
  }
  .list-panel.open { transform: translateY(0); }
  .list-panel.dragging { transition: none; }

  .list-handle {
    display: flex; flex-direction: column; align-items: center; gap: 5px;
    width: 100%;
    padding: 9px 16px calc(10px + env(safe-area-inset-bottom) * 0.2);
    border: none; background: none; cursor: pointer;
    font-family: var(--font-body); font-size: 14px; font-weight: 700; color: var(--ink);
    -webkit-tap-highlight-color: transparent;
  }
  .list-handle .grip {
    width: 42px; height: 5px; border-radius: 3px; background: var(--hairline);
  }
  .list-panel.open .list-handle .grip { background: var(--lime); }

  .truck-list {
    width: auto; border-left: none;
    padding: 4px 16px calc(18px + env(safe-area-inset-bottom));
    flex: 1; min-height: 0;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  /* The detail sheet sits above the list sheet. */
  .sheet { z-index: 1000; }
}

.truck-card {
  background: var(--surface); border: 1px solid var(--hairline); border-radius: 12px;
  padding: 14px; cursor: pointer; text-align: left; font-family: var(--font-body);
  transition: border-color 0.12s ease;
}
.truck-card:hover, .truck-card.selected { border-color: var(--ink); }
.truck-card:focus-visible { outline: 3px solid var(--marigold-deep); outline-offset: 2px; }
.truck-card .row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.truck-card h3 { font-size: 16px; font-family: var(--font-display); }
.truck-card .meta { font-size: 13px; color: var(--muted); margin: 4px 0 0; }

/* Detail sheet: bottom sheet on mobile, right overlay on desktop */
.sheet {
  position: absolute; z-index: 1000; background: var(--surface);
  border: 1px solid var(--hairline); box-shadow: 0 -6px 24px rgba(0,0,0,0.5);
  left: 0; right: 0; bottom: 0;
  border-radius: 18px 18px 0 0;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  max-height: 62%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
@media (min-width: 821px) {
  .sheet { left: auto; top: 14px; right: 354px; bottom: 14px; width: 360px; max-height: none; border-radius: 16px; box-shadow: 0 6px 24px rgba(0,0,0,0.45); }
}
.sheet-close {
  position: absolute; top: 10px; right: 12px;
  width: 34px; height: 34px; border-radius: 50%;
  border: 2px solid var(--asphalt); background: var(--surface);
  font-size: 18px; cursor: pointer; line-height: 1;
}
.sheet h2 { font-size: 22px; padding-right: 40px; }
.sheet .sub { font-size: 13px; color: var(--muted); margin: 4px 0 10px; }
.sheet .loc { font-size: 14px; margin: 0 0 14px; }

.menu-item {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 12px 0; border-top: 1px solid var(--hairline);
}
.menu-item .name { font-weight: 600; font-size: 15px; }
.menu-item .desc { font-size: 13px; color: var(--muted); margin: 2px 0 0; }
.menu-item .price { font-weight: 600; white-space: nowrap; }
.menu-item.soldout { opacity: 0.45; }
.menu-item.soldout .name::after { content: " · 86'd"; color: #A32D2D; font-size: 12px; }
.add-btn {
  border: 2px solid var(--asphalt); background: var(--surface); border-radius: 8px;
  width: 34px; height: 34px; font-size: 18px; cursor: pointer; flex-shrink: 0;
}
.add-btn:hover { background: var(--marigold); }

.sheet-cta {
  position: sticky; bottom: 0; background: var(--surface);
  padding-top: 12px; margin-top: 6px;
  display: flex; justify-content: center;
}
.sheet-cta .btn { width: 100%; justify-content: center; }

.fav-btn { background: none; border: none; font-size: 20px; cursor: pointer; padding: 4px; }

/* Leaflet pin markers */
.ftf-pin { background: none; border: none; }
.ftf-pin .pinbody {
  width: 34px; height: 34px; border-radius: 50% 50% 50% 6px;
  transform: rotate(-45deg);
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--asphalt);
  background: #B4B2A9;
  box-shadow: 0 2px 6px rgba(30,27,22,0.3);
}
.ftf-pin.live .pinbody { background: var(--live); }
.ftf-pin .pinbody span { transform: rotate(45deg); font-size: 15px; }

/* --toast-lift is set from JS to the height of whatever is docked to the
   bottom of the screen (the detail sheet and its sticky CTA), so a toast
   never lands on top of the button you just tapped. */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--toast-lift, 0px)); transform: translateX(-50%);
  background: var(--asphalt); color: var(--paper);
  padding: 12px 20px; border-radius: 10px; font-size: 14px; font-weight: 500;
  z-index: 2000;
}

/* ---- Account / customer profile ---- */
.acct-overlay {
  position: fixed; inset: 0; z-index: 3000; display: flex;
  align-items: center; justify-content: center; padding: 18px;
  background: rgba(30, 27, 22, 0.55);
}
.acct-overlay[hidden] { display: none; }
.acct-card {
  position: relative; width: min(400px, 100%); max-height: 92vh; overflow-y: auto;
  background: var(--surface); border: 2px solid var(--asphalt); border-radius: 16px; padding: 24px;
}
.acct-card h2 { font-size: 21px; margin: 0 0 6px; }
.acct-sub { font-size: 14px; color: var(--muted); margin: 0 0 16px; }
.acct-card label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 5px; }
.acct-card input[type="tel"], .acct-card input[type="text"], .acct-card input[type="email"] {
  width: 100%; box-sizing: border-box; font-family: var(--font-body); font-size: 16px;
  padding: 12px 13px; border: 2px solid var(--hairline); border-radius: 9px;
  background: var(--surface-2);
  color: var(--lime);
  caret-color: var(--lime);
  font-weight: 600;
}
.acct-card input::placeholder { color: var(--ink-dim); font-weight: 400; }
.acct-check { display: flex; gap: 9px; align-items: flex-start; margin-top: 14px; font-weight: 400; }
.acct-check input { width: auto; margin-top: 3px; }
.acct-check span { font-size: 13px; color: var(--ink-dim); }
.acct-btn { width: 100%; margin-top: 14px; }
.acct-close {
  position: absolute; top: 12px; right: 12px; width: 32px; height: 32px;
  border: none; border-radius: 50%; background: #ECEAE3; cursor: pointer;
}
.acct-msg { min-height: 20px; font-size: 13px; font-weight: 600; margin: 12px 0 0; }
.acct-msg.err { color: #B3261E; }
.acct-msg.ok { color: var(--live-ink); }

/* Directions link inside the detail sheet */
#sheet-content a.btn { justify-content: center; }

/* Header: the two doors — customers and truck operators */
.header-auth { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.header-auth .chip { text-decoration: none; white-space: nowrap; }
.chip-truck {
  background: var(--lime);
  color: #10140F;
  border-color: var(--lime);
  font-weight: 700;
}
.chip-truck:hover { background: var(--lime-bright); }
@media (max-width: 560px) {
  .header-auth .chip { font-size: 12px; padding: 6px 10px; }
}

/* ---------- Phone layout ----------
   Header becomes two rows: brand + logins, then the scrolling filters.
   Everything else already flexes; the map takes whatever is left. */
@media (max-width: 700px) {
  .app-header {
    gap: 8px 10px;
    padding: 8px 12px;
    padding-top: calc(8px + env(safe-area-inset-top));
    justify-content: center;
  }
  .app-header .brand { order: 1; font-size: 15px; margin-right: auto; }
  .header-auth { order: 2; margin-left: auto; }
  /* Filters get their own centered row so they read as one group. */
  .filters {
    order: 3;
    flex: 1 0 100%;
    padding-bottom: 2px;
    justify-content: center;
  }
  .header-auth .chip { font-size: 12px; padding: 8px 11px; }
  .chip-truck { padding-left: 10px; padding-right: 10px; }
}
@media (max-width: 380px) {
  /* Tiny phones: keep the words, drop the emoji weight */
  .header-auth .chip { font-size: 11.5px; padding: 8px 9px; }
  .app-header .brand img { width: 22px; height: 22px; }
}

/* The account modal must fit a phone screen with the keyboard open */
.acct-card {
  max-height: 90vh;
  max-height: 90dvh;
}
@media (max-width: 560px) {
  .acct-overlay { align-items: flex-end; padding: 0; }
  .acct-card {
    width: 100%;
    border-radius: 18px 18px 0 0;
    border-bottom: none;
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
    max-height: 88dvh;
  }
  /* 16px inputs stop iOS from zooming the page on focus */
  .acct-card input { font-size: 16px; }
}

/* Landscape phones: the bottom sheet can't eat the whole screen */
@media (max-height: 480px) and (orientation: landscape) {
  .sheet { max-height: 80%; }
  .app-header { padding-top: calc(6px + env(safe-area-inset-top)); padding-bottom: 6px; }
}

/* ---- Referral share card ---- */
.referral {
  margin-top: 20px;
  padding: 16px;
  border: 2px dashed var(--lime);
  border-radius: 14px;
  background: rgba(140, 198, 63, 0.08);
}
.referral h3 { font-family: var(--font-display); font-size: 16px; margin: 0 0 4px; }
.ref-sub { font-size: 13px; color: var(--muted); margin: 0 0 12px; }
.ref-code {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 30px;
  letter-spacing: 0.14em;
  text-align: center;
  padding: 10px 0 12px;
  color: var(--lime);
}
#ref-link {
  width: 100%; box-sizing: border-box;
  font-size: 13px; padding: 10px 11px;
  border: 2px solid var(--hairline); border-radius: 9px;
  background: var(--surface-2); color: var(--lime); font-weight: 600;
}
.ref-actions { display: flex; gap: 8px; margin-top: 10px; }
.ref-actions .btn { flex: 1; padding: 11px; font-size: 14px; }
.ref-count { font-size: 13px; font-weight: 600; margin: 12px 0 0; text-align: center; }

/* ================= Ordering =================
   Cart bar, item choices, checkout and order status. All of it reuses the
   account modal's shell (.acct-overlay/.acct-card) so phones get the same
   bottom-sheet treatment for free. */

/* Toasts have to clear the modals, which sit at 3000. */
.toast { z-index: 4000; }

.acct-card textarea {
  width: 100%; box-sizing: border-box; font-family: var(--font-body); font-size: 16px;
  padding: 12px 13px; border: 2px solid var(--hairline); border-radius: 9px;
  background: var(--surface-2); color: var(--lime); caret-color: var(--lime);
  font-weight: 600; resize: vertical;
}
.acct-card textarea::placeholder { color: var(--ink-dim); font-weight: 400; }

/* ---- Menu rows ---- */
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.menu-cat {
  font-family: var(--font-display); font-size: 13px; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--ink-dim); margin: 18px 0 0;
}
.menu-empty { font-size: 14px; color: var(--muted); margin: 16px 0; }
.menu-item-right { display: flex; align-items: center; gap: 8px; }
.opt-hint {
  font-size: 11px; font-weight: 600; color: var(--lime);
  border: 1px solid var(--lime); border-radius: 999px; padding: 1px 7px; margin-left: 7px;
}
.qty-btn {
  border: 2px solid var(--hairline); background: var(--surface-2); color: var(--ink);
  border-radius: 8px; width: 34px; height: 34px; font-size: 18px; cursor: pointer; flex-shrink: 0;
}
.qty-count { font-weight: 700; min-width: 16px; text-align: center; }
.cta-note { font-size: 13px; color: var(--ink-dim); text-align: center; margin: 6px 0 0; }

/* ---- Sticky cart bar (only when the truck sheet is closed) ---- */
.cart-bar {
  position: fixed; left: 12px; right: 12px; z-index: 950;
  bottom: calc(64px + env(safe-area-inset-bottom));
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-family: var(--font-body); font-size: 15px; font-weight: 600;
  padding: 14px 18px; border-radius: 12px; cursor: pointer;
  background: var(--lime); color: #10140F; border: 2px solid var(--asphalt);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}
.cart-bar[hidden] { display: none; }
@media (min-width: 821px) {
  .cart-bar { left: auto; right: 24px; width: 320px; bottom: 24px; }
}

/* ---- Item choices ---- */
.opt-group { border-top: 1px solid var(--hairline); padding: 12px 0 4px; }
.opt-group-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.opt-group-head b { font-size: 15px; }
.opt-group-head span { font-size: 12px; color: var(--ink-dim); }
/* Scoped to .acct-card: the generic `.acct-card label` rule is more specific
   than a bare `.opt-row`, and would otherwise force these back to display:block. */
.acct-card .opt-row {
  display: flex; align-items: center; gap: 10px; margin: 0;
  padding: 9px 0; font-size: 15px; font-weight: 500; cursor: pointer;
}
.acct-card .opt-row input { width: auto; margin: 0; accent-color: var(--lime); }
.acct-card .opt-row span { flex: 1; }
.acct-card .opt-row em { font-style: normal; font-size: 13px; color: var(--ink-dim); }
.acct-card .opt-row.soldout { opacity: 0.45; text-decoration: line-through; cursor: not-allowed; }
#opt-add:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---- Checkout ---- */
.cart-line {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 0; border-top: 1px solid var(--hairline); font-size: 15px;
}
.cart-line > div:first-child { flex: 1; min-width: 0; }
.cart-opts { display: block; font-size: 12px; color: var(--ink-dim); font-weight: 400; }
.cart-price { font-weight: 700; white-space: nowrap; }
.qty-stepper { display: flex; align-items: center; gap: 8px; }
.qty-stepper button {
  border: 2px solid var(--hairline); background: var(--surface-2); color: var(--ink);
  border-radius: 8px; width: 32px; height: 32px; font-size: 17px; cursor: pointer;
}
.qty-stepper span { font-weight: 700; min-width: 14px; text-align: center; }

.tip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.tip-chip {
  font-family: var(--font-body); font-size: 14px; font-weight: 600;
  padding: 10px 14px; border-radius: 999px; cursor: pointer;
  border: 2px solid var(--hairline); background: transparent; color: var(--ink);
}
.tip-chip.on { background: var(--lime); border-color: var(--lime); color: #10140F; }
.tip-note { font-size: 12px; color: var(--ink-dim); margin: 8px 0 0; }

.co-totals { margin-top: 16px; border-top: 1px solid var(--hairline); padding-top: 12px; }
.co-totals div { display: flex; justify-content: space-between; font-size: 14px; padding: 3px 0; color: var(--ink-dim); }
.co-totals .co-grand {
  font-size: 18px; font-weight: 700; color: var(--ink);
  border-top: 1px solid var(--hairline); margin-top: 8px; padding-top: 10px;
}
#co-pay-element { min-height: 140px; margin-top: 8px; }
.working { font-size: 15px; font-weight: 600; text-align: center; padding: 26px 0; }

/* ---- Order status ---- */
.order-view {
  position: fixed; inset: 0; z-index: 1200; overflow-y: auto;
  background: var(--bg); padding: 24px 18px calc(32px + env(safe-area-inset-bottom));
  padding-top: calc(24px + env(safe-area-inset-top));
}
.order-view[hidden] { display: none; }
.order-view > div { max-width: 460px; margin: 0 auto; }
.order-hero { text-align: center; padding: 18px 0 8px; }
.order-emoji { font-size: 52px; display: block; line-height: 1.2; }
.order-hero h2 { font-size: 22px; margin: 10px 0 12px; }
.countdown, .order-eta { text-align: center; font-size: 14px; font-weight: 600; color: var(--ink-dim); margin: 6px 0; }
.order-lines { margin-top: 20px; }
.order-actions { display: grid; gap: 10px; margin-top: 22px; }
.order-actions .btn { width: 100%; justify-content: center; }

.review-box {
  margin-top: 24px; padding: 18px; border-radius: 14px;
  background: var(--surface); border: 2px solid var(--hairline);
}
.review-box h3 { font-family: var(--font-display); font-size: 17px; margin: 0 0 10px; }
.review-box textarea {
  width: 100%; box-sizing: border-box; font-family: var(--font-body); font-size: 16px;
  padding: 10px 12px; border: 2px solid var(--hairline); border-radius: 9px;
  background: var(--surface-2); color: var(--lime); font-weight: 600; margin-bottom: 10px;
}
.review-box .btn { width: 100%; justify-content: center; margin-top: 8px; }
.stars { display: flex; gap: 4px; justify-content: center; margin-bottom: 12px; }
.stars button {
  background: none; border: none; cursor: pointer;
  font-size: 30px; line-height: 1; color: var(--lime); padding: 2px;
}

/* ---- Order history in the account panel ---- */
.acct-orders { margin-top: 20px; }
.acct-orders h3 { font-family: var(--font-display); font-size: 16px; margin: 0 0 8px; }
.hist-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%;
  font-family: var(--font-body); font-size: 14px; text-align: left; cursor: pointer;
  padding: 11px 0; border: none; border-top: 1px solid var(--hairline);
  background: none; color: var(--ink);
}

/* Demo mode: ordering works end to end without Stripe, but nobody should ever
   mistake a walk-through for real food on the way. */
/* Device-level demo mode. First child of the flex column that is .app-body,
   so it pushes the header and map down instead of covering them. */
.demo-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 8px 14px;
  padding-top: calc(8px + env(safe-area-inset-top));
  background: rgba(228, 50, 43, 0.16);
  border-bottom: 2px solid var(--red-ink, #FF7A6E);
  color: var(--red-ink, #FF7A6E);
  font-size: 13px;
  font-weight: 700;
  z-index: 1002;
}
.demo-bar button {
  font: inherit;
  cursor: pointer;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid currentColor;
  background: none;
  color: inherit;
}

.demo-ribbon {
  margin: 0 0 14px; padding: 10px 13px; border-radius: 10px;
  background: rgba(228, 50, 43, 0.12); border: 2px solid var(--red-ink);
  color: var(--red-ink); font-size: 13px; font-weight: 700; text-align: center;
}

/* Directions + favorite sit under the menu, where the customer ends up. */
.sheet-actions {
  display: flex; align-items: center; gap: 10px;
  margin-top: 16px;
}
.sheet-actions .btn { flex: 1; justify-content: center; }
.fav-icon {
  /* Sits inline with the truck name, sized to stay a comfortable tap target
     without competing with the heading. */
  vertical-align: middle;
  margin-left: 8px;
  width: 38px; height: 38px; border-radius: 10px; cursor: pointer;
  border: 2px solid var(--hairline); background: var(--surface-2);
  color: var(--ink-dim); font-size: 18px; line-height: 1;
}
.fav-icon.on { color: var(--red-ink); border-color: var(--red-ink); }
