/* ── COMMANDER (takeaway order page) ──
   Reuses style.css design tokens (--gold, --crimson, --cream, --dark, --text, --muted).
   Two-column desktop (menu + sticky cart); single column on mobile. */

.commander {
  max-width: 1100px;
  margin: 0 auto;
  /* Fixed site header: ~78px desktop, ~120px mobile (style.css placeholders) */
  padding: 100px 5% 90px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 32px;
}
@media (max-width: 768px) {
  /* header-placeholder (style.css:21) already reserves the fixed header's own height
     (120px) in normal flow — this padding is pure breathing room below it, not header
     clearance, so it can be cut hard without hiding content under the header. */
  .commander { padding-top: 16px; }
}

/* HERO / HEADER */
.commander-hero {
  /* style.css:63 styles the bare `header` tag (site fixed header: crimson,
     fixed, z-index 1000). This in-page <header> must opt back out of all of it,
     or it becomes an invisible fixed band that swallows taps on the first menu items. */
  position: static;
  width: auto;
  z-index: auto;
  background: transparent;
  grid-column: 1 / -1;
  text-align: center;
  padding: 32px 0 8px;
  border-bottom: 1px solid rgba(201, 168, 76, 0.25);
}
.commander-hero h1 {
  font-family: 'Cormorant Garamond', serif;
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  font-weight: 600;
  color: var(--dark);
  line-height: 1.05;
}
.commander-hero h1::after {
  content: '';
  display: block;
  width: 52px;
  height: 2px;
  background: var(--gold);
  margin: 14px auto 0;
}
.commander-note {
  margin-top: 14px;
  font-size: 0.9rem;
  color: var(--muted);
  font-style: italic;
}
.commander-pickup-window {
  margin-top: 6px;
  font-size: 0.85rem;
  color: var(--dark);
  font-weight: 600;
}
.commander-pickup-window span[data-i18n] {
  font-weight: 600;
  color: var(--muted);
  font-style: normal;
}
.commander-closed {
  margin: 18px auto 0;
  max-width: 620px;
  padding: 14px 20px;
  background: rgba(139, 16, 32, 0.06);
  border: 1px solid var(--crimson);
  border-radius: 3px;
  color: var(--crimson);
  font-weight: 600;
  font-size: 0.9rem;
}
/* First-screen density budget (audit measurement 390x844: first item was at y=591,
   test 17 pins it under 450px). Placed AFTER the base hero rules above so these actually
   win the cascade at equal specificity (source order, not just media-match, decides ties).
   Spacing only — no DOM reorder, takeaway.spec.js selects
   .menu-item button:not([disabled]).first(). */
@media (max-width: 768px) {
  .commander-hero { padding: 10px 0 6px; }
  .commander-hero h1::after { margin: 6px auto 0; }
  .commander-note { margin-top: 6px; }
  .commander-pickup-window { margin-top: 4px; }
}

/* TWO-COLUMN LAYOUT (desktop) */
@media (min-width: 900px) {
  .commander {
    grid-template-columns: minmax(0, 1fr) 340px;
    align-items: start;
  }
  .commander-hero { grid-column: 1 / -1; }
  .cart-panel {
    position: sticky;
    top: 96px;
    padding-bottom: 24px;
  }
}

/* CATEGORY NAV */
.category-nav {
  position: sticky;
  top: 78px;
  background: var(--cream);
  z-index: 80;
  display: flex;
  /* style.css @768px turns bare `nav` into a full-width column (burger menu);
     this in-page <nav> must stay a horizontal scroll strip. */
  flex-direction: row;
  overflow-x: auto;
  gap: 8px;
  padding: 12px 5%;
  border-bottom: 1px solid rgba(201, 168, 76, 0.3);
  scrollbar-width: none;
  grid-column: 1 / -1;
  margin: 0 -5%;
}
.category-nav::-webkit-scrollbar { display: none; }
@media (max-width: 899px) {
  .category-nav { top: 120px; padding: 8px 5%; }
  /* .commander's 32px grid gap (base rule) sits between EVERY top-level child —
     hero->nav->menu-root on the single-column mobile layout — so it is crossed twice
     before the first dish. Two-column desktop (>=900px) keeps the base 32px. */
  .commander { gap: 10px; }
}
.cat-chip {
  flex-shrink: 0;
  height: 44px;
  padding: 0 20px;
  border-radius: 22px;
  border: 1px solid var(--gold);
  background: transparent;
  color: var(--crimson);
  font-family: 'Jost', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  text-decoration: none;
}
.cat-chip.active {
  background: var(--crimson);
  color: white;
}

/* MENU */
.commander-menu section {
  margin-bottom: 40px;
  scroll-margin-top: 140px;
}
@media (max-width: 899px) {
  .commander-menu section {
    scroll-margin-top: 190px;
  }
}
.commander-menu h2 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--dark);
  padding-bottom: 8px;
  margin-bottom: 12px;
  border-bottom: 2px solid var(--gold);
}
/* Density budget (see the hero block above) — after the base rule so it wins the tie. */
@media (max-width: 899px) {
  .commander-menu h2 {
    padding-bottom: 6px;
    margin-bottom: 8px;
  }
}
.commander-menu ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.menu-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 14px;
  padding: 14px 4px;
  border-bottom: 1px solid rgba(201, 168, 76, 0.18);
}
.menu-item:last-child { border-bottom: none; }
.mi-name {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--dark);
}
.mi-desc {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  font-family: 'Jost', sans-serif;
  margin-top: 4px;
}
.mi-price {
  /* was var(--gold): 1.91:1 on cream — the prices on the page whose only job is
     selling. --crimson is 8.69:1 and is already the price colour on the carte. */
  color: var(--crimson);
  font-weight: 600;
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.05rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.menu-item button {
  font-family: 'Jost', sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  background: var(--gold);
  color: var(--dark);
  border: none;
  padding: 8px 16px;
  min-height: 44px;
  min-width: 80px;
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.25s, transform 0.15s;
}
.menu-item button:hover:not(:disabled) {
  background: var(--gold-lt);
  transform: translateY(-1px);
}
.menu-item button:disabled {
  background: rgba(122, 80, 64, 0.18);
  color: var(--muted);
  cursor: not-allowed;
}

/* CART PANEL */
.mobile-cart-toggle { display: none; }
.mobile-cart-backdrop { display: none; }

@media (max-width: 899px) {
  .mobile-cart-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 60px;
    background: var(--crimson);
    color: white;
    border: none;
    border-top: 2px solid var(--gold);
    padding: 0 20px;
    font-family: 'Jost', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    z-index: 100;
    cursor: pointer;
  }
  .mobile-cart-toggle[hidden] {
    display: none !important;
  }
  .mct-badge {
    background: white;
    color: var(--crimson);
    border-radius: 50%;
    padding: 2px 8px;
    font-size: 0.9rem;
    margin-right: 8px;
    display: inline-block;
    transition: transform 0.2s;
  }
  .mct-chevron {
    margin-left: 8px;
    font-size: 0.8rem;
    display: inline-block;
    transition: transform 0.3s;
  }
  .mobile-cart-toggle[aria-expanded="true"] .mct-chevron {
    transform: rotate(180deg);
  }
  /* When the sheet is open, the peek bar is redundant (the panel shows the full
     cart + total) and its z:100 would paint over the Commander button. Hide it —
     the sheet closes via backdrop tap or Escape. [aria-expanded="true"] (0,2,0)
     outranks the base .mobile-cart-toggle{display:flex} (0,1,0). */
  .mobile-cart-toggle[aria-expanded="true"] {
    display: none;
  }
  .mobile-cart-backdrop {
    display: block;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(26, 8, 8, 0.5);
    /* Above the site cookie banner (z:10000) so the OPEN cart is a true modal and
       its Commander button is usable even before cookie consent is dismissed; the
       banner reappears (top-most again) when the cart closes. */
    z-index: 10001;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
  }
  .mobile-cart-backdrop.open {
    opacity: 1;
    pointer-events: auto;
  }
  .cart-panel {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    margin: 0;
    max-height: 70vh;
    overflow-y: auto;
    z-index: 10002; /* above the cookie banner (10000) + its own backdrop (10001) */
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 12px 12px 0 0;
  }
  .cart-panel.open {
    transform: translateY(0);
    /* .open (0,2,0) outranks the base .cart-panel rule (0,1,0) so this can't be
       clobbered again. The toggle bar is hidden while open, so this is just
       breathing room + home-indicator clearance, not bar-clearance. */
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  }
  /* Bottom-sheet grab handle — signals the sheet is dismissable (tap the backdrop
     above it, or Escape) now that the peek bar's chevron is hidden while open. */
  .cart-panel::before {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    margin: -8px auto 14px;
    border-radius: 2px;
    background: rgba(26, 8, 8, 0.18);
  }
  @media (prefers-reduced-motion: reduce) {
    .cart-panel, .mobile-cart-backdrop { transition: none; }
  }
}

.cart-panel {
  background: white;
  border: 1px solid rgba(201, 168, 76, 0.3);
  border-radius: 4px;
  box-shadow: 0 6px 24px rgba(26, 8, 8, 0.08);
  /* bottom padding is set per-context (desktop rule + mobile .open rule) so this
     shorthand no longer clobbers the mobile bottom-sheet clearance. */
  padding: 24px 22px 0;
}
.cart-panel h2 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--dark);
  margin-bottom: 14px;
}
#cart-lines {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  min-height: 40px;
}
#cart-lines li {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(122, 80, 64, 0.12);
  font-size: 0.92rem;
}
#cart-lines li span:first-child {
  color: var(--text);
}
#cart-lines button {
  font-family: 'Jost', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1;
  width: 44px;
  height: 44px;
  border: 1px solid var(--gold);
  background: var(--cream);
  color: var(--dark);
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
#cart-lines button:hover {
  background: var(--gold);
}
.cart-total {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--dark);
  margin: 8px 0 18px;
  text-align: right;
}
.cart-total span { color: var(--crimson); }
.cart-discount-note {
  font-size: 0.8rem;
  color: var(--muted);
  text-align: right;
  margin: -12px 0 16px;
}
#checkout-btn {
  width: 100%;
  font-family: 'Jost', sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  background: var(--crimson);
  color: white;
  border: none;
  padding: 15px;
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.25s, transform 0.15s;
}
#checkout-btn:hover:not(:disabled) {
  background: #a3172b;
  transform: translateY(-1px);
}
#checkout-btn:disabled {
  background: rgba(122, 80, 64, 0.2);
  color: var(--muted);
  cursor: not-allowed;
}

/* CHECKOUT DIALOG */
#checkout-dialog {
  border: none;
  border-radius: 6px;
  padding: 0;
  max-width: 440px;
  width: 92%;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.4);
  color: var(--text);
  /* Restore native modal centering: style.css `* { margin:0 }` overrides the UA margin:auto */
  inset: 0;
  margin: auto;
}
#checkout-dialog::backdrop {
  background: rgba(26, 8, 8, 0.55);
}

/* iOS/Safari < 15.4 has no HTMLDialogElement: the UA neither hides a closed <dialog> — the
   checkout form would sit inline in the page — nor gives an open one a top layer or a
   ::backdrop. openModalDialog() (script.js) adds .dialog-fallback; the dialog then becomes
   the full-viewport scrim and the form becomes the panel, the .booking-modal-overlay idiom,
   so the existing `e.target === dialog` handler still reads a scrim click as "outside".
   Offsets are longhand: `inset` postdates those browsers. */
#checkout-dialog:not([open]) {
  display: none;
}
#checkout-dialog.dialog-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  /* The UA `width/height: fit-content` on <dialog> outranks bottom/right otherwise (TD-011) */
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border-radius: 0;
  box-shadow: none;
  background: rgba(26, 8, 8, 0.55);
  z-index: 10000;
}
#checkout-dialog.dialog-fallback #checkout-form {
  width: 92%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.4);
}
#checkout-form {
  padding: 28px 26px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
#checkout-form h2 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.7rem;
  font-weight: 600;
  color: var(--dark);
  margin-bottom: 4px;
}
#checkout-form label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-family: 'Jost', sans-serif;
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--muted);
}
#checkout-form input,
#checkout-form select,
#checkout-form textarea {
  font-family: 'Jost', sans-serif;
  font-size: 0.95rem;
  color: var(--text);
  padding: 10px 12px;
  border: 1px solid rgba(122, 80, 64, 0.3);
  border-radius: 3px;
  background: var(--cream);
  outline: none;
  transition: border-color 0.2s;
}
#checkout-form input:focus,
#checkout-form select:focus,
#checkout-form textarea:focus {
  border-color: var(--gold);
}
#checkout-form textarea {
  min-height: 70px;
  resize: vertical;
}
.checkout-actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}
.checkout-actions button {
  flex: 1;
  font-family: 'Jost', sans-serif;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 13px;
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.25s, border-color 0.25s;
}
#checkout-cancel {
  background: transparent;
  border: 1px solid rgba(122, 80, 64, 0.35);
  color: var(--muted);
}
#checkout-cancel:hover {
  border-color: var(--crimson);
  color: var(--crimson);
}
#checkout-submit {
  background: var(--crimson);
  border: none;
  color: white;
}
#checkout-submit:hover:not(:disabled) {
  background: #a3172b;
}
#checkout-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.checkout-error {
  color: var(--crimson);
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 4px;
}

/* CONFIRMATION */
.confirmation {
  grid-column: 1 / -1;
  text-align: center;
  max-width: 560px;
  margin: 40px auto;
  padding: 44px 32px;
  background: white;
  border: 1px solid rgba(201, 168, 76, 0.35);
  border-radius: 6px;
  box-shadow: 0 10px 40px rgba(26, 8, 8, 0.1);
}
.confirmation h2 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 2rem;
  font-weight: 600;
  color: var(--dark);
  margin-bottom: 16px;
}
.confirmation p {
  color: var(--text);
  margin-bottom: 10px;
  font-size: 1.1rem;
}
.confirmation #conf-number {
  font-family: 'Cormorant Garamond', serif;
  font-size: 3rem;
  color: var(--crimson);
  display: block;
  margin: 10px 0 20px;
}

/* FOCUS STATES (accessibility) */
.menu-item button:focus-visible,
#cart-lines button:focus-visible,
#checkout-btn:focus-visible,
.checkout-actions button:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

/* CTA button used on index/carte nav areas */
.btn-order {
  background: var(--crimson);
  color: white !important;
}
.btn-order:hover {
  background: #a3172b;
}

/* PULSE ANIMATION */
@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}
.pulse-anim {
  animation: pulse 0.3s ease-in-out;
}
@media (prefers-reduced-motion: reduce) {
  .pulse-anim { animation: none; }
}
