/* ============================================================
   Blanco Castelar — Casa Domit, Polanco
   Voice-first ordering · design system
   Ivory "blanco" surfaces, brass hairlines, Fraunces serif.
   One living surface (the concierge dock) — everything else calm.
   ============================================================ */

:root {
  /* Surfaces — warm ivory, the "Blanco" */
  --paper: #faf7f1;
  --paper-2: #f1ebdf;
  --card: #fffdf8;
  --ink: #211d18;
  --ink-soft: #4c453c;
  --muted: #8b8174;

  /* Hairlines */
  --line: rgba(33, 29, 24, 0.13);
  --line-strong: rgba(33, 29, 24, 0.3);

  /* Brass — iron chandeliers, aged fittings */
  --brass: #a07c45;
  --brass-deep: #82632f;
  --brass-soft: rgba(160, 124, 69, 0.32);
  --brass-tint: rgba(160, 124, 69, 0.1);

  /* Verde — the payment / concierge accent */
  --verde: #44604f;
  --verde-deep: #34503f;
  --verde-tint: rgba(68, 96, 79, 0.12);

  --error: #9c3b2e;

  /* Light — the chandelier glow */
  --glow-warm: rgba(216, 184, 128, 0.22);

  --shadow-soft: 0 28px 70px rgba(74, 58, 32, 0.16);
  --shadow-tight: 0 14px 36px rgba(74, 58, 32, 0.12);
  --shadow-hairline: 0 1px 0 rgba(255, 255, 255, 0.7) inset;

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 26px;

  --font-ui: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: "Fraunces", "Cormorant Garamond", "Times New Roman", Georgia, serif;

  /* Voice presence — agent accent (overridden by body[data-agent]) */
  --voice: var(--brass);

  /* Motion language — slow, assured, one set everywhere */
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --dur-1: 160ms;
  --dur-2: 300ms;
  --dur-3: 560ms;
  --dur-4: 840ms;

  /* Z-index scale */
  --z-stage: 1;
  --z-nav: 8;
  --z-topbar: 20;
  --z-cart: 900;
  --z-overlay: 1100;
  --z-veil: 1250;
  --z-mic: 1300;

  /* Mic + floating-surface geometry — a single source of truth so the dock
     and cart clearances are DERIVED from the real control sizes and the
     safe-area insets, never hand-tuned pixels that rot when one of them moves.
     --mic-size mirrors the .mic-button clamp; --mic-inset mirrors its right
     inset; --mic-gap is the breathing room every floating surface keeps. */
  --mic-size: clamp(72px, 9vw, 88px);
  --mic-inset: max(22px, env(safe-area-inset-right, 0px));
  --mic-gap: 16px;
  --cart-width: 360px;
  --cart-rail-inset: clamp(20px, 3vw, 44px);

  /* "only light": opts out of Chrome's Auto Dark Theme, which otherwise
     inverts the ivory surfaces into muddy browns. The brand IS blanco. */
  color-scheme: light;
  color-scheme: only light;
}

body[data-agent="sales"] { --voice: var(--brass); }
body[data-agent="payment"] { --voice: var(--verde); }

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  /* The Casa Domit hall ghosts through ~5% under the ivory washes */
  background:
    radial-gradient(58% 44% at 50% -8%, var(--glow-warm) 0%, transparent 62%),
    radial-gradient(90% 56% at 50% 112%, var(--verde-tint) 0%, transparent 58%),
    linear-gradient(180deg, rgba(252, 250, 245, 0.94) 0%, rgba(250, 247, 241, 0.95) 46%, rgba(243, 238, 227, 0.97) 100%),
    url("/static/casa-domit.jpg") center top / cover no-repeat;
  background-attachment: scroll, scroll, scroll, fixed;
  background-color: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  background: var(--brass-soft);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

img,
svg {
  display: block;
}

.hidden {
  display: none !important;
}

/* The shell is a viewport-fitting column: topbar, then the stage, which
   flexes. The carte compresses on short screens instead of sliding under
   the fixed concierge dock. */
.app-shell {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(22px, env(safe-area-inset-top)) clamp(18px, 3vw, 44px) max(24px, env(safe-area-inset-bottom));
}

/* Chandelier breath — one ambient light, opacity only, GPU-cheap */
.app-shell::before {
  content: "";
  position: fixed;
  top: -22vh;
  left: 50%;
  width: min(900px, 120vw);
  height: 58vh;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at center, var(--glow-warm) 0%, transparent 68%);
  pointer-events: none;
  animation: chandelier 9s var(--ease) infinite alternate;
  z-index: 0;
}

@keyframes chandelier {
  from { opacity: 0.55; }
  to { opacity: 1; }
}

/* ---------- Topbar: static brand, nothing pulses here ---------- */
.topbar {
  position: relative;
  z-index: var(--z-topbar);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

/* The official wordmark (black AVIF on transparent) */
.wordmark {
  line-height: 0;
}

.wordmark img {
  display: block;
  width: auto;
  height: clamp(40px, 5vw, 52px);
}

/* The receipt carries the house mark */
.bill-logo {
  width: clamp(112px, 12vw, 148px);
  height: auto;
  margin-bottom: 2px;
  opacity: 0.92;
}

#agent-label {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.84rem;
  letter-spacing: 0.02em;
  line-height: 1.25;
}

.brand-place {
  flex: 0 0 auto;
  color: var(--brass-deep);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-align: right;
  text-transform: uppercase;
}

.brand-place small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.18em;
}

/* ---------- Stage ---------- */
.ordering-stage {
  position: relative;
  z-index: var(--z-stage);
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  /* the row can shrink to the leftover viewport, never below its content;
     when content can't fit, the page scrolls instead of clipping */
  grid-template-rows: minmax(min-content, 1fr);
  justify-items: center;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  /* reserve the dock's strip: the carte and its caption pill always clear it */
  padding-bottom: clamp(96px, 12vh, 140px);
}

.menu-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  gap: clamp(8px, 2vh, 22px);
}

.stage-copy {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: clamp(12px, 3vh, 30px) 0 clamp(6px, 1.5vh, 14px);
  text-align: center;
}

.eyebrow,
.panel-kicker {
  color: var(--brass-deep);
  font-size: 0.7rem;
  font-weight: 640;
  letter-spacing: 0.26em;
  line-height: 1.2;
  text-transform: uppercase;
}

#menu-heading {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 2.6vw, 2.2rem);
  font-style: italic;
  font-weight: 460;
  letter-spacing: 0.005em;
  line-height: 1.08;
  text-wrap: balance;
}

/* ---------- Carousel: la carte ---------- */
/* Flexes to the space the viewport actually has; the cards are sized
   from this box (cqh) so they can never outgrow it. */
.carousel-container {
  position: relative;
  flex: 1 1 auto;
  min-height: 250px;
  max-height: 680px;
  width: 100%;
  perspective: 1500px;
  overflow: visible;
}

/* Casa Domit arch — a single hairline behind the carte */
.carousel-container::before {
  content: "";
  position: absolute;
  top: 4%;
  left: 50%;
  width: min(620px, 78vw);
  height: 96%;
  transform: translateX(-50%);
  border: 1px solid var(--brass-soft);
  border-bottom: 0;
  border-radius: 999px 999px 0 0;
  opacity: 0.5;
  pointer-events: none;
}

.carousel {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
}

.carousel-item {
  position: absolute;
  top: 50%;
  left: 50%;
  /* --card-h is overridden with cqh units when container queries are
     supported, so the plates track the real space, not the viewport */
  --card-w: min(64vw, 460px);
  --card-h: min(48vh, 420px);
  width: var(--card-w);
  height: var(--card-h);
  margin: calc(-0.5 * var(--card-h)) 0 0 calc(-0.5 * var(--card-w));
  display: flex;
  align-items: stretch;
  justify-content: center;
  text-align: center;
  opacity: 0.18;
  pointer-events: none;
  transition: transform var(--dur-3) var(--ease-out), opacity var(--dur-3) var(--ease);
  will-change: transform, opacity;
}

.carousel-item.active {
  opacity: 1;
  pointer-events: auto;
}

/* The plate — an ivory card with a double hairline frame */
.dish-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 1.8vh, 18px);
  width: 100%;
  padding: clamp(26px, 4.5vh, 46px) clamp(22px, 3vw, 44px);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: var(--shadow-hairline);
  transition: border-color var(--dur-3) var(--ease), box-shadow var(--dur-3) var(--ease);
}

/* Inner hairline — the menu-card frame */
.dish-card::before {
  content: "";
  position: absolute;
  inset: 9px;
  border: 1px solid var(--brass-tint);
  border-radius: calc(var(--radius-lg) - 8px);
  pointer-events: none;
  transition: border-color var(--dur-3) var(--ease);
}

.carousel-item.active .dish-card {
  border-color: var(--brass-soft);
  box-shadow: var(--shadow-soft), var(--shadow-hairline);
}

/* First paint: the carte settles in, front plate first, neighbors after */
.dish-card {
  animation: card-in 700ms var(--ease-out) backwards;
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.carousel-item:nth-child(1) .dish-card { animation-delay: 60ms; }
.carousel-item:nth-child(2) .dish-card,
.carousel-item:nth-child(10) .dish-card { animation-delay: 150ms; }
.carousel-item:nth-child(3) .dish-card,
.carousel-item:nth-child(9) .dish-card { animation-delay: 240ms; }
.carousel-item:nth-child(n+4):nth-child(-n+8) .dish-card { animation-delay: 320ms; }

.carousel-item.active .dish-card::before {
  border-color: var(--brass-soft);
}

.dish-course {
  color: var(--brass-deep);
  font-size: 0.68rem;
  font-weight: 640;
  letter-spacing: 0.3em;
  text-transform: uppercase;
}

.dish-rule {
  width: 44px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--brass), transparent);
}

/* Background-removed dishes float on the card — the card is the plate.
   drop-shadow follows the cutout silhouette, grounding it like a real
   contact shadow. */
.dish-photo {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: min(80%, 300px);
  height: clamp(140px, 21vh, 200px);
  margin: 0;
}

.dish-photo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 20px 16px rgba(74, 58, 32, 0.26));
  transform-origin: center bottom;
  transition: transform var(--dur-3) var(--ease-out), filter var(--dur-3) var(--ease);
}

.carousel-item.active .dish-photo img {
  transform: translateY(-4px);
  filter: drop-shadow(0 26px 22px rgba(74, 58, 32, 0.3));
}

/* Photo cards: tighter rhythm and a calmer name size so the dish,
   a two-line name, and the price all stay inside the card frame */
.dish-card:has(.dish-photo) {
  gap: clamp(8px, 1.4vh, 14px);
  padding: clamp(20px, 3.5vh, 34px) clamp(22px, 3vw, 44px);
}

.dish-photo ~ .dish-name {
  font-size: clamp(1.4rem, 3vw, 2rem);
}

.dish-name {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 4vw, 2.7rem);
  font-weight: 500;
  letter-spacing: 0.005em;
  line-height: 1.04;
  text-wrap: balance;
}

.dish-desc {
  max-width: 30ch;
  color: var(--ink-soft);
  font-size: clamp(0.9rem, 1.4vw, 1.02rem);
  font-weight: 420;
  line-height: 1.5;
  text-wrap: pretty;
}

.dish-price,
.smaller-heading {
  color: var(--brass-deep);
  font-size: clamp(0.95rem, 1.6vw, 1.1rem);
  font-weight: 620;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.12em;
}

.carousel-nav {
  position: absolute;
  top: 50%;
  z-index: var(--z-nav);
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 253, 248, 0.86);
  color: var(--ink);
  box-shadow: var(--shadow-tight);
  transform: translateY(-50%);
  transition: transform var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.carousel-nav:hover {
  border-color: var(--brass);
  color: var(--brass-deep);
  transform: translateY(-50%) scale(1.05);
}

.carousel-nav:focus-visible,
.mic-button:focus-visible,
.checkout-btn:focus-visible,
.add-active-btn:focus-visible,
.btn:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 3px;
}

.carousel-nav svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.carousel-nav--prev {
  left: 18px;
}

.carousel-nav--next {
  right: 18px;
}

/* ---------- Active item bar ---------- */
.active-item-bar {
  position: relative;
  z-index: var(--z-nav);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  width: max-content;
  max-width: min(680px, 92vw);
  margin: clamp(8px, 2vh, 22px) auto 0;
  padding: 10px 10px 10px 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.82);
  box-shadow: var(--shadow-tight);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  transition: transform var(--dur-2) var(--ease);
}

.active-item-label {
  display: flex;
  align-items: baseline;
  gap: 14px;
  min-width: 0;
}

#active-item-name {
  /* min-width:0 lets the flex item shrink below its content width so the
     ellipsis below can actually fire when the bar hits its 92vw cap. */
  min-width: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 2.1vw, 1.45rem);
  font-weight: 520;
  letter-spacing: 0.005em;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#active-item-price {
  flex: 0 0 auto;
  color: var(--brass-deep);
  font-size: clamp(0.88rem, 1.5vw, 1.02rem);
  font-weight: 620;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.1em;
}

.add-active-btn,
.checkout-btn,
.btn {
  border: 0;
  border-radius: 999px;
  font-weight: 560;
  letter-spacing: 0.04em;
}

.add-active-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 20px;
  background: var(--ink);
  color: var(--paper);
  white-space: nowrap;
  box-shadow: var(--shadow-tight);
  transition: transform var(--dur-1) var(--ease), background-color var(--dur-1) var(--ease);
}

/* Scope the brass disc to the decorative "+" icon ONLY. The label is the
   button's other <span>; an unscoped `.add-active-btn span` was forcing the
   text into a 20px circle too, so "Add to order" overflowed a stray disc. */
.add-active-btn span[aria-hidden] {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--brass);
  color: var(--card);
  font-size: 1rem;
  line-height: 1;
}

.add-active-btn:hover,
.checkout-btn:hover,
.btn:hover {
  transform: translateY(-1px);
}

.add-active-btn:hover {
  background: #38322a;
}

/* ---------- Live cart ---------- */
.cart-panel {
  align-self: center;
  width: 100%;
  max-height: min(620px, calc(100vh - 150px));
  max-height: min(620px, calc(100dvh - 150px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow-soft);
  transition: transform var(--dur-2) var(--ease), opacity var(--dur-2) var(--ease);
}

.cart-panel.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(28px);
}

.cart-panel.expanded {
  max-height: min(720px, calc(100vh - 132px));
}

.cart-header,
.cart-footer {
  padding: 18px 20px;
}

.cart-header {
  border-bottom: 1px solid var(--line);
}

.cart-header h3 {
  margin-top: 5px;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 520;
  line-height: 1;
}

.cart-items {
  min-height: 80px;
  overflow-y: auto;
  padding: 4px 20px;
}

.cart-empty {
  padding: 24px 0;
  color: var(--muted);
}

.cart-item {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.cart-item:last-child {
  border-bottom: 0;
}

/* Typographic medallion in place of product photos */
.cart-medallion {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid var(--brass-soft);
  border-radius: 50%;
  background: var(--paper-2);
  color: var(--brass-deep);
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 560;
  letter-spacing: 0.05em;
}

img.cart-medallion {
  object-fit: contain;
  padding: 4px;
}

.cart-item-details {
  min-width: 0;
}

.cart-item-details h4 {
  overflow: hidden;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 540;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cart-item-details p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.2;
}

.cart-footer {
  border-top: 1px solid var(--line);
  background: var(--paper-2);
}

.cart-total,
.total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 640;
  font-variant-numeric: tabular-nums;
}

.checkout-btn,
.place-order-btn {
  width: 100%;
  min-height: 48px;
  margin-top: 14px;
  background: var(--ink);
  color: var(--paper);
  box-shadow: 0 14px 30px rgba(33, 29, 24, 0.22);
  transition: transform var(--dur-1) var(--ease), background-color var(--dur-1) var(--ease);
}

.checkout-btn:hover,
.place-order-btn:hover {
  background: var(--brass-deep);
}

/* ---------- Mic button ---------- */
.mic-button {
  position: fixed;
  right: var(--mic-inset);
  bottom: max(22px, env(safe-area-inset-bottom));
  z-index: var(--z-mic);
  display: grid;
  place-items: center;
  width: var(--mic-size);
  height: var(--mic-size);
  padding: 0;
  border: 1px solid var(--brass-soft);
  border-radius: 50%;
  background: linear-gradient(150deg, #2c2620, #17130f);
  color: var(--paper);
  box-shadow: 0 22px 50px rgba(46, 36, 20, 0.36);
  transition: transform var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
  -webkit-tap-highlight-color: transparent;
}

.mic-button::after {
  content: "";
  position: absolute;
  inset: -9px;
  border: 1px solid var(--voice);
  border-radius: inherit;
  opacity: 0;
  transform: scale(0.88);
}

.mic-button:hover {
  transform: translateY(-2px) scale(1.02);
}

.mic-button.active {
  box-shadow: 0 22px 58px rgba(46, 36, 20, 0.44), 0 0 0 1px var(--voice);
}

.mic-button.active::after {
  animation: voice-ring 2200ms var(--ease) infinite;
}

.mic-icon,
.pause-icon {
  width: 30px;
  height: 30px;
  fill: currentColor;
}

@keyframes voice-ring {
  0% {
    opacity: 0.7;
    transform: scale(0.86);
  }
  100% {
    opacity: 0;
    transform: scale(1.4);
  }
}

/* ---------- Concierge dock — the ONE living surface ---------- */
.voice-dock {
  position: fixed;
  left: 50%;
  bottom: max(28px, env(safe-area-inset-bottom));
  z-index: var(--z-mic);
  display: flex;
  align-items: center;
  gap: 13px;
  /* centered pill must always leave the bottom-right mic zone free:
     (100vw - width) / 2 >= mic inset + mic size + gap, on each side.
     Derived from the mic tokens so it self-corrects with safe-area insets. */
  max-width: min(calc(100vw - 2 * (var(--mic-inset) + var(--mic-size) + var(--mic-gap))), 560px);
  padding: 11px 20px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.86);
  box-shadow: var(--shadow-tight);
  transform: translateX(-50%);
  backdrop-filter: blur(20px) saturate(1.15);
  -webkit-backdrop-filter: blur(20px) saturate(1.15);
  transition: border-color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
}

body.session-live .voice-dock {
  border-color: var(--brass-soft);
}

/* Presence dot — quiet until the line is open */
#activity {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--line-strong);
  transition: background-color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
}

#activity.active {
  background: var(--voice);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--voice) 16%, transparent);
}

.voice-agent {
  flex: 0 0 auto;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 560;
  letter-spacing: 0.01em;
}

.voice-wave {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 3px;
  height: 18px;
}

.voice-wave span {
  width: 2px;
  height: 26%;
  border-radius: 2px;
  background: var(--line-strong);
  transition: background-color var(--dur-1) var(--ease);
}

body[data-voice="listen"] .voice-wave span { background: var(--verde); animation: voice-wave 1300ms var(--ease) infinite; }
body[data-voice="speak"] .voice-wave span { background: var(--voice); animation: voice-wave 700ms var(--ease) infinite; }
body[data-voice="think"] .voice-wave span { background: var(--muted); animation: voice-wave 1800ms var(--ease) infinite; }

.voice-wave span:nth-child(1) { animation-delay: 100ms; }
.voice-wave span:nth-child(2) { animation-delay: 200ms; }
.voice-wave span:nth-child(3) { animation-delay: 300ms; }
.voice-wave span:nth-child(4) { animation-delay: 400ms; }
.voice-wave span:nth-child(5) { animation-delay: 500ms; }

@keyframes voice-wave {
  0%, 100% { height: 22%; }
  50% { height: 88%; }
}

.voice-state {
  /* 0 1 auto: hold natural width but allow shrinking so the ellipsis below
     is real — `0 0 auto` made it inert and the caption overflowed the pill. */
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 0.84rem;
  font-weight: 480;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Connection caption — only visible when it has something to say.
   Shrinks before the voice-state label: transient captions give way,
   "Listening"/"Speaking" stays whole. */
#status {
  flex: 0 4 auto;
  max-width: 200px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 520;
  letter-spacing: 0.04em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#status:empty {
  display: none;
}

#status::before {
  content: "·" / "";
  margin-right: 9px;
  color: var(--line-strong);
}

/* ---------- Cart → checkout transition ---------- */
.cart-panel.transitioning-to-checkout {
  animation: cart-to-checkout var(--dur-2) var(--ease) forwards;
}

@keyframes cart-to-checkout {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(18px) scale(0.97);
  }
}

/* ---------- Checkout & success overlays ---------- */
/* No backdrop-filter on full-screen overlays: the app-shell is hidden
   behind them anyway, and fixed-position backdrop-filter layers have
   previously swallowed the mic button on iOS Safari.
   Flex + margin:auto centers the panel on tall viewports and still
   scrolls cleanly when content is taller than the screen. */
#checkout,
#order-complete {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  display: flex;
  overflow-y: auto;
  padding: clamp(14px, 2.5vw, 34px);
  /* the concierge dock follows onto these screens — keep its strip clear
     so it never sits on "Confirm & send" / "Begin a new order" */
  padding-bottom: max(104px, env(safe-area-inset-bottom));
  background:
    radial-gradient(60% 38% at 50% 0%, var(--glow-warm), transparent 60%),
    rgba(243, 238, 227, 0.97);
  color: var(--ink);
  animation: overlay-in var(--dur-3) var(--ease-out);
}

#checkout.hidden,
#order-complete.hidden {
  display: none;
}

#checkout:focus,
#order-complete:focus {
  outline: none;
}

@keyframes overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.checkout-container {
  display: grid;
  grid-template-columns: minmax(280px, 390px) minmax(0, 1fr);
  width: min(1180px, 100%);
  min-height: min(720px, calc(100vh - 150px));
  min-height: min(720px, calc(100dvh - 150px));
  margin: auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: var(--shadow-soft);
  animation: panel-rise var(--dur-3) var(--ease-out);
}

@keyframes panel-rise {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.cart-summary {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  padding: clamp(20px, 3vw, 30px);
  border-right: 1px solid var(--line);
  background: var(--paper-2);
}

.cart-summary h2 {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 3vw, 2.45rem);
  font-weight: 500;
  line-height: 1.02;
  text-wrap: balance;
}

#cart-count {
  color: var(--muted);
  font-size: 0.9rem;
}

#cart-items {
  min-height: 120px;
}

.cart-summary .total {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--line-strong);
}

.order-details {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  padding: clamp(18px, 2.4vw, 26px);
  background: var(--card);
  max-height: calc(100vh - 150px);
  max-height: calc(100dvh - 150px);
  overflow-y: auto;
}

.checkout-heading-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.order-details h3 {
  margin-top: 6px;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(1.45rem, 2.6vw, 2.1rem);
  font-weight: 500;
  line-height: 1.02;
}


.details-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.map,
.form-section--full,
.delivery-info {
  grid-column: 1 / -1;
}

.map {
  position: relative;
  min-height: 112px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--paper-2);
}

.map iframe {
  display: block;
  width: 100%;
  height: 112px;
  border: 0;
  filter: saturate(0.82) sepia(0.06);
}

.map-empty {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 520;
}

.map.map-offline iframe {
  display: none;
}

.map.map-offline .map-empty {
  display: grid;
}

.form-section {
  min-width: 0;
}

.section-label {
  margin-bottom: 8px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--line);
  color: var(--brass-deep);
  font-size: 0.68rem;
  font-weight: 640;
  letter-spacing: 0.22em;
  line-height: 1.2;
  text-transform: uppercase;
}

.order-details label {
  display: block;
  margin: 8px 0 4px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 520;
  letter-spacing: 0.02em;
}

.order-details input {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}

.order-details input:focus {
  border-color: var(--brass);
  box-shadow: 0 0 0 4px var(--brass-tint);
}

.order-details input[readonly] {
  background: var(--paper-2);
  color: var(--muted);
}

/* Voice-filled fields flash a brass ring so the guest sees Karol writing */
.order-details input.field-updated {
  animation: field-flash 1100ms var(--ease-out);
}

@keyframes field-flash {
  0% {
    border-color: var(--brass);
    box-shadow: 0 0 0 5px var(--brass-tint), 0 0 16px rgba(160, 124, 69, 0.3);
    background: #fdf7ec;
  }
  100% {
    border-color: var(--line);
    box-shadow: none;
    background: #fff;
  }
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.delivery-info {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.delivery-info-label {
  color: var(--brass-deep);
  font-size: 0.7rem;
  font-weight: 640;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

/* ---------- Success — the arch of Casa Domit ---------- */
.success-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: min(480px, 100%);
  margin: auto;
  padding: clamp(40px, 8vw, 64px) clamp(28px, 6vw, 52px) clamp(28px, 6vw, 48px);
  border: 1px solid var(--brass-soft);
  border-radius: 240px 240px var(--radius-lg) var(--radius-lg);
  background: var(--card);
  color: var(--ink);
  text-align: center;
  box-shadow: var(--shadow-soft);
  animation: panel-rise var(--dur-3) var(--ease-out);
}

.success-card::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid var(--brass-tint);
  border-radius: 232px 232px calc(var(--radius-lg) - 8px) calc(var(--radius-lg) - 8px);
  pointer-events: none;
}

/* The house itself, framed in its own arch */
.success-venue {
  width: min(80%, 300px);
  height: 150px;
  margin: 0 0 4px;
  overflow: hidden;
  border: 1px solid var(--brass-soft);
  border-radius: 999px 999px 16px 16px;
  box-shadow: var(--shadow-tight);
}

.success-venue img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.check-icon {
  width: 66px;
  height: 66px;
  padding: 14px;
  border: 1px solid var(--brass-soft);
  border-radius: 50%;
  background: var(--brass-tint);
  fill: var(--brass-deep);
}

.success-card h2 {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(2.1rem, 6vw, 3.4rem);
  font-style: italic;
  font-weight: 480;
  line-height: 0.98;
}

.success-card p {
  color: var(--muted);
  font-size: 0.96rem;
  line-height: 1.5;
}

.order-number {
  color: var(--ink) !important;
  font-weight: 640;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
}

.new-order-btn {
  min-height: 46px;
  padding: 0 26px;
  background: var(--ink);
  color: var(--paper);
  transition: transform var(--dur-1) var(--ease), background-color var(--dur-1) var(--ease);
}

.new-order-btn:hover {
  background: var(--brass-deep);
}

body.checkout-active .app-shell,
body.order-complete-active .app-shell {
  display: none;
}

/* Mic stays in its home (bottom-right) across every screen — it never jumps */
body.checkout-active > .mic-button,
body.order-complete-active > .mic-button {
  display: grid !important;
}

/* The dock follows into checkout — same single surface, never a second one */
body.checkout-active .voice-dock,
body.order-complete-active .voice-dock {
  z-index: var(--z-mic);
}

/* ---------- Agent handoff veil ---------- */
body.agent-switching {
  overflow: hidden;
}

body.agent-switching .mic-button {
  pointer-events: none;
}

body.agent-switching::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: var(--z-veil);
  background: rgba(250, 247, 241, 0.72);
  animation: overlay-in var(--dur-2) var(--ease-out);
}

/* One universal caption: data-agent flips mid-switch, so directional
   wording ("Karol joins you") would flash the wrong way first. */
body.agent-switching::after {
  content: "Un momento";
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: var(--z-veil);
  padding: 14px 28px;
  border: 1px solid var(--brass-soft);
  border-radius: 999px;
  background: var(--card);
  box-shadow: var(--shadow-tight);
  color: var(--brass-deep);
  font-size: 0.74rem;
  font-weight: 640;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  transform: translate(-50%, -50%);
  animation: panel-rise var(--dur-2) var(--ease-out);
}

/* ---------- Desktop layout ---------- */
@media (min-width: 981px) {
  /* One fixed screen; if a viewport is shorter than the carte's minimums,
     the shell scrolls instead of hiding content behind the dock. */
  .app-shell {
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    transition: padding-right var(--dur-3) var(--ease);
  }

  /* Cart is a floating right rail — it never compresses the carte */
  .cart-panel {
    position: fixed;
    top: 50%;
    right: var(--cart-rail-inset);
    left: auto;
    width: var(--cart-width);
    max-height: min(640px, calc(100vh - 140px));
    max-height: min(640px, calc(100dvh - 140px));
    transform: translateY(-50%);
    z-index: var(--z-cart);
  }

  .cart-panel.hidden {
    transform: translateY(-50%) translateX(40px);
  }

  .cart-panel.expanded {
    max-height: min(720px, calc(100vh - 132px));
    max-height: min(720px, calc(100dvh - 132px));
  }

  /* When the rail opens, the stage re-centers in the remaining width (a fixed
     translateX used to throw the prev-arrow off-screen ≤1100px). Reserve the
     rail's footprint — inset + width + a gap — derived so it self-corrects if
     the rail width or inset changes. */
  body.cart-visible .app-shell {
    padding-right: calc(var(--cart-rail-inset) + var(--cart-width) + 20px);
  }
}

/* ---------- Tablet & below ---------- */
@media (max-width: 980px) {
  .cart-panel {
    position: fixed;
    right: 12px;
    bottom: 124px;
    left: 12px;
    z-index: var(--z-cart);
    width: auto;
    max-height: 46vh;
    margin: 0;
    transform: none;
  }

  .cart-panel.hidden {
    transform: translateY(22px);
  }

  /* On a bottom-sheet cart, the sheet owns the bottom; drop the redundant pill */
  body.cart-visible .active-item-bar {
    display: none;
  }

  .checkout-container {
    grid-template-columns: 1fr;
  }

  .cart-summary {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  /* Single-column checkout: reserve a bottom safe-area so the primary CTA
     clears the fixed bottom-right mic. */
  .order-details {
    padding-bottom: 112px;
  }
}

@media (max-width: 720px) {
  /* the dock strip is already reserved by .ordering-stage padding-bottom */
  .app-shell {
    padding: max(16px, env(safe-area-inset-top)) 14px max(20px, env(safe-area-inset-bottom));
  }

  .topbar {
    align-items: flex-start;
  }

  .wordmark img {
    height: 36px;
  }

  .brand-place {
    display: none;
  }

  #agent-label {
    font-size: 0.78rem;
  }

  .stage-copy {
    margin-top: 18px;
  }

  #menu-heading {
    font-size: clamp(1.3rem, 5vw, 1.6rem);
  }

  .carousel-container::before {
    width: min(360px, 88vw);
  }

  .carousel-item {
    --card-w: min(84vw, 330px);
    --card-h: min(52vh, 380px);
  }

  .dish-name {
    font-size: clamp(1.5rem, 7vw, 1.9rem);
  }

  .dish-photo ~ .dish-name {
    font-size: clamp(1.25rem, 5.5vw, 1.55rem);
  }

  .carousel-nav {
    top: auto;
    bottom: 86px;
    width: 44px;
    height: 44px;
    transform: none;
  }

  .carousel-nav:hover {
    transform: scale(1.03);
  }

  .carousel-nav--prev {
    left: 10px;
  }

  .carousel-nav--next {
    right: 10px;
  }

  .active-item-bar {
    flex-direction: column;
    gap: 10px;
    width: min(340px, 92vw);
    max-width: 92vw;
    padding: 14px 18px;
  }

  .active-item-label {
    justify-content: center;
    flex-wrap: wrap;
  }

  #active-item-name {
    overflow: visible;
    white-space: normal;
    text-overflow: clip;
  }

  .add-active-btn {
    width: 100%;
    white-space: nowrap;
  }

  .cart-panel {
    position: fixed;
    right: 12px;
    bottom: 108px;
    left: 12px;
    z-index: var(--z-cart);
    width: auto;
    max-height: 42vh;
  }

  .cart-panel.hidden {
    transform: translateY(22px);
  }

  .mic-button {
    width: 72px;
    height: 72px;
  }

  /* Anchor the dock bottom-left so it can never slide under the
     bottom-right mic, whatever the state text length. */
  .voice-dock {
    left: max(14px, env(safe-area-inset-left, 0px));
    transform: none;
    gap: 10px;
    bottom: max(26px, env(safe-area-inset-bottom));
    padding: 9px 16px;
    /* anchored bottom-left; right edge stops short of the bottom-right mic:
       left inset + mic inset + mic size + gap. Derived, safe-area aware. */
    max-width: calc(100vw - max(14px, env(safe-area-inset-left, 0px)) - var(--mic-inset) - var(--mic-size) - var(--mic-gap));
  }

  .voice-agent {
    display: none;
  }

  .voice-state {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #status {
    max-width: 110px;
  }

  .details-grid {
    grid-template-columns: 1fr;
  }

  .field-row {
    grid-template-columns: 1fr;
  }

  #checkout,
  #order-complete {
    /* keep the dock/mic strip clear below the panel */
    padding: 10px 10px max(96px, env(safe-area-inset-bottom));
  }

  .checkout-container {
    border-radius: var(--radius-md);
  }

  .cart-summary,
  .order-details {
    padding: 18px;
    max-height: none;
    overflow-y: visible;
  }

  .order-details {
    padding-bottom: 112px;
  }

  body.checkout-active > .mic-button {
    right: max(22px, env(safe-area-inset-right));
    bottom: max(22px, env(safe-area-inset-bottom));
    top: auto;
    left: auto;
    width: 72px;
    height: 72px;
  }
}

@media (max-width: 420px) {
  .wordmark img {
    height: 32px;
  }

  .carousel-item {
    --card-h: min(52vh, 350px);
  }

  .voice-dock {
    gap: 8px;
  }

  .cart-item-details h4 {
    white-space: normal;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .carousel-container {
    min-height: 210px;
  }

  .carousel-item {
    --card-h: min(64vh, 300px);
  }

  .dish-card {
    gap: 8px;
    padding: 18px 24px;
  }

  .dish-desc {
    display: none;
  }

  .voice-dock,
  body.session-live .voice-dock {
    left: auto;
    /* sit just left of the mic instead of 6px off it: mic inset + size + gap */
    right: calc(var(--mic-inset) + var(--mic-size) + var(--mic-gap));
    bottom: 14px;
    transform: none;
    /* and don't march across the whole landscape strip toward the carte */
    max-width: min(46vw, 360px);
  }
}

/* ---------- Container-sized plates ----------
   Where size containers are supported, the cards and everything on them
   are measured from the carousel's real height — so the dish photo, name
   and price always fit inside the card, and the card always fits between
   the heading and the caption pill, on any screen. */
@supports (container-type: size) {
  /* The query container is the inset:0 layer, not .carousel-container:
     Chromium resolves cqh to 0 when a size container's height comes from
     a min-height clamp; the inner layer always has a plain definite size. */
  .carousel {
    container-type: size;
  }

  .carousel-item {
    --card-h: min(88cqh, 420px);
  }

  /* Desktop: size the plate WIDTH from the carousel's real width (cqw), not
     the viewport. When the cart rail opens it narrows the stage, so a
     vw-sized plate used to overhang the prev/next arrows; a cqw plate shrinks
     with its container and the arrows stay clear. Mobile keeps its vw width. */
  @media (min-width: 981px) {
    .carousel-item {
      --card-w: min(72cqw, 460px);
    }
  }

  .dish-photo {
    height: clamp(88px, 30cqh, 200px);
  }

  .dish-card:has(.dish-photo) {
    gap: clamp(6px, 2.4cqh, 14px);
    padding: clamp(12px, 5cqh, 34px) clamp(22px, 3vw, 44px);
  }

  .dish-photo ~ .dish-name {
    font-size: clamp(1.25rem, 7cqh, 2rem);
  }

  @media (max-width: 720px) {
    .carousel-item {
      --card-h: min(88cqh, 380px);
    }

    .dish-photo ~ .dish-name {
      font-size: clamp(1.15rem, min(5.5vw, 7cqh), 1.55rem);
    }
  }

  @media (max-width: 420px) {
    .carousel-item {
      --card-h: min(88cqh, 350px);
    }
  }

  @media (max-height: 520px) and (orientation: landscape) {
    .carousel-item {
      --card-h: min(88cqh, 300px);
    }
  }
}

/* ---------- Reduced motion: stillness is also elegant ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }

  .app-shell::before {
    animation: none;
    opacity: 0.75;
  }
}

/* --- Language / currency toggle (ES/EN) — floats above every screen --- */
.lang-toggle {
  position: fixed;
  top: max(18px, env(safe-area-inset-top));
  right: max(18px, env(safe-area-inset-right));
  z-index: var(--z-mic);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.86);
  box-shadow: var(--shadow-tight);
  backdrop-filter: blur(18px) saturate(1.1);
  -webkit-backdrop-filter: blur(18px) saturate(1.1);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 640;
  letter-spacing: 0.16em;
  color: var(--ink);
  cursor: pointer;
  transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}

.lang-toggle:hover { border-color: var(--brass); }

.lang-toggle .lang-opt {
  opacity: 0.4;
  transition: opacity var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}

.lang-toggle .lang-sep {
  opacity: 0.3;
  font-weight: 400;
}

/* The active language is highlighted; driven by body[data-lang] (no JS text swap). */
body[data-lang="en"] .lang-toggle .lang-opt[data-lang-opt="en"],
body[data-lang="es"] .lang-toggle .lang-opt[data-lang-opt="es"] {
  opacity: 1;
  color: var(--brass-deep);
}

.lang-toggle:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 3px;
}

/* Stay visible on the checkout & success overlays, mirroring the mic button. */
body.checkout-active > .lang-toggle,
body.order-complete-active > .lang-toggle {
  display: inline-flex !important;
}

/* Desktop: keep the pill clear of the top-right brand text in the topbar. */
@media (min-width: 721px) {
  .topbar { padding-right: 96px; }
}

/* Phones: brand text is hidden, so the top-right corner is clear; shrink a touch. */
@media (max-width: 420px) {
  .lang-toggle {
    top: max(12px, env(safe-area-inset-top));
    right: max(12px, env(safe-area-inset-right));
    padding: 6px 11px;
    font-size: 0.68rem;
    gap: 6px;
  }
}
