/* ── AI waiter section ──
 * Copy on one side, an HTML/CSS phone showing the app's chat sheet on the other.
 * The phone's markup lives in index.html (so each language page can carry its
 * own conversation); js/ai-waiter.js plays the conversation once on scroll. */

.waiter-section {
  border-top: 1px solid var(--border);
}

.waiter-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  gap: 4rem;
}

/* Copy comes first in the source (and on mobile); the phone sits left on desktop. */
.waiter-copy {
  order: 2;
}

.waiter-copy .section-header {
  margin-bottom: 0;
}

.waiter-points {
  display: grid;
  gap: 0.7rem;
  margin: 1.75rem 0;
  padding: 0;
  list-style: none;
}

.waiter-points li {
  position: relative;
  padding-left: 1.6rem;
  font-weight: 500;
}

.waiter-points li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: 800;
}

.waiter-note {
  max-width: 560px;
  padding: 1rem 1.2rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.waiter-note strong {
  color: var(--text);
  font-weight: 600;
}

@media (max-width: 860px) {
  .waiter-layout {
    grid-template-columns: 1fr;
    gap: 3rem;
  }

  .waiter-copy {
    order: 0;
  }
}

/* ── Phone ──
 * Mirrors the app's chat sheet (src/components/chat/* and
 * src/styles/waiter-chat.css). Lengths are the app's px values times --px, so
 * the phone behaves like a 390px-wide screen scaled to fit: it shrinks with the
 * page and the text wraps the same at every size. */

.waiter-demo {
  /* Theme tokens — dark (default). For light, set data-theme="light" on
     .waiter-demo in index.html. */
  --wd-ink: #f4f0e8;
  --wd-sub: #938e83;
  --wd-line: #262320;
  --wd-accent: #e0ae4e;
  --wd-accent-ink: #e2b45c;
  --wd-sheet-bg: #141310;
  --wd-bubble: #201e1a;
  --wd-bubble-line: #2a2722;
  --wd-dish-bg: #1b1a16;
  --wd-dish-line: #2a2722;
  --wd-chip: #221f1b;
  --wd-frame: rgba(40, 40, 40, 0.4);

  /* Theme-independent */
  --wd-on-accent: #2a2008;
  --wd-badge-bg: #2a2008;
  --wd-badge-ink: #f4d89a;

  --px: calc(100cqw / 390);

  container-type: inline-size;
  position: relative;
  width: min(340px, 100%);
  aspect-ratio: 390 / 790;
  margin: 0 auto;
  overflow: hidden;
  border: 3px solid var(--wd-frame);
  border-radius: 36px;
  background: #0e0d0b url('../images/dark-demo.webp') center top / 100% auto no-repeat;
  box-shadow:
    0 24px 60px rgba(28, 25, 23, 0.16),
    0 8px 24px rgba(28, 25, 23, 0.1);
}

.waiter-demo[data-theme='light'] {
  --wd-ink: #1b1a17;
  --wd-sub: #8c877d;
  --wd-line: #ece6db;
  --wd-accent: #d2a03c;
  --wd-accent-ink: #a8761f;
  --wd-sheet-bg: #f4f1ea;
  --wd-bubble: #ffffff;
  --wd-bubble-line: #ece6db;
  --wd-dish-bg: #fbf8f2;
  --wd-dish-line: #ebe4d7;
  --wd-chip: #efeae0;
  --wd-frame: rgba(120, 90, 50, 0.12);

  background-color: #ede8df;
  background-image: url('../images/light-demo.webp');
}

/* The menu peeks above the sheet behind a backdrop, as in the app. */
.waiter-demo::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.42);
}

/* ── Sheet shell ── */
.wd-sheet {
  position: absolute;
  inset: calc(55 * var(--px)) 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: calc(28 * var(--px)) calc(28 * var(--px)) 0 0;
  background: var(--wd-sheet-bg);
  color: var(--wd-ink);
  font-size: calc(14.5 * var(--px));
  line-height: 1.5;
  text-align: left;
}

.wd-glow {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: calc(130 * var(--px));
  background: radial-gradient(120% 100% at 50% 0, rgba(216, 160, 60, 0.16), transparent 72%);
  pointer-events: none;
}

.wd-grip {
  position: relative;
  flex: 0 0 auto;
  align-self: center;
  width: calc(40 * var(--px));
  height: calc(5 * var(--px));
  margin: calc(8 * var(--px)) 0 calc(2 * var(--px));
  border-radius: 999px;
  background: var(--wd-sub);
  opacity: 0.5;
}

/* ── Header ── */
.wd-header {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: calc(11 * var(--px));
  padding: calc(14 * var(--px)) calc(14 * var(--px)) calc(13 * var(--px));
  border-bottom: 1px solid var(--wd-line);
}

.wd-id {
  flex: 1 1 auto;
  min-width: 0;
  line-height: 1.1;
}

.wd-name {
  display: block;
  font-size: calc(16 * var(--px));
  font-weight: 800;
  letter-spacing: -0.2px;
}

.wd-subline {
  display: block;
  margin-top: calc(3 * var(--px));
  font-size: calc(12 * var(--px));
  color: var(--wd-sub);
}

.wd-close {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: calc(34 * var(--px));
  height: calc(34 * var(--px));
  border-radius: 999px;
  background: var(--wd-chip);
  color: var(--wd-sub);
}

.wd-close svg {
  width: calc(18 * var(--px));
  height: calc(18 * var(--px));
}

/* ── Avatar (serving cloche on amber) ── */
.wd-avatar {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: calc(40 * var(--px));
  height: calc(40 * var(--px));
  border-radius: 999px;
  background: linear-gradient(150deg, #ebbe60, #c9952e);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.5);
}

.wd-avatar svg {
  width: 52%;
  height: 52%;
}

.wd-row .wd-avatar {
  width: calc(28 * var(--px));
  height: calc(28 * var(--px));
  margin-top: 1px;
}

/* ── Thread ── */
.wd-thread {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: calc(13 * var(--px));
  padding: calc(16 * var(--px)) calc(15 * var(--px)) calc(18 * var(--px));
  overflow: hidden;
}

.wd-row {
  display: flex;
}

.wd-row.is-waiter {
  align-self: flex-start;
  align-items: flex-start;
  gap: calc(9 * var(--px));
  max-width: 92%;
}

.wd-row.is-guest {
  align-self: flex-end;
  justify-content: flex-end;
  max-width: 82%;
}

.wd-col {
  display: flex;
  flex-direction: column;
  gap: calc(8 * var(--px));
  min-width: 0;
}

.wd-bubble {
  padding: calc(11 * var(--px)) calc(14 * var(--px));
  overflow-wrap: anywhere;
}

.wd-bubble-waiter {
  border: 1px solid var(--wd-bubble-line);
  border-radius: calc(5 * var(--px)) calc(18 * var(--px)) calc(18 * var(--px)) calc(18 * var(--px));
  background: var(--wd-bubble);
}

.wd-bubble-waiter strong {
  font-weight: 700;
}

.wd-bubble-guest {
  padding: calc(11 * var(--px)) calc(15 * var(--px));
  border-radius: calc(18 * var(--px)) calc(18 * var(--px)) calc(5 * var(--px)) calc(18 * var(--px));
  background: var(--wd-accent);
  color: var(--wd-on-accent);
  font-weight: 500;
  line-height: 1.45;
}

/* ── Typing indicator (added by js/ai-waiter.js while playing) ── */
.wd-typing {
  display: inline-flex;
  align-items: center;
  gap: calc(5 * var(--px));
  padding: calc(2 * var(--px)) 0;
}

.wd-typing span {
  width: calc(7 * var(--px));
  height: calc(7 * var(--px));
  border-radius: 50%;
  background: var(--wd-sub);
  animation: wd-bounce 1.3s infinite ease-in-out;
}

.wd-typing span:nth-child(2) {
  animation-delay: 0.18s;
}

.wd-typing span:nth-child(3) {
  animation-delay: 0.36s;
}

/* ── Dish card ── */
.wd-dish {
  display: flex;
  align-items: center;
  gap: calc(11 * var(--px));
  padding: calc(10 * var(--px)) calc(11 * var(--px));
  border: 1px solid var(--wd-dish-line);
  border-radius: calc(15 * var(--px));
  background: var(--wd-dish-bg);
}

.wd-dish-info {
  flex: 1 1 auto;
  min-width: 0;
}

.wd-dish-name {
  font-size: calc(13.5 * var(--px));
  font-weight: 700;
  line-height: 1.2;
}

.wd-dish-desc {
  margin-top: calc(3 * var(--px));
  font-size: calc(12 * var(--px));
  line-height: 1.35;
  color: var(--wd-sub);
}

.wd-dish-price {
  margin-top: calc(5 * var(--px));
  font-size: calc(13 * var(--px));
  font-weight: 700;
  color: var(--wd-accent-ink);
}

.wd-add {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  height: calc(34 * var(--px));
  padding: 0 calc(13 * var(--px));
  border: 1.4px solid var(--wd-accent);
  border-radius: 999px;
  color: var(--wd-accent-ink);
  font-size: calc(12.5 * var(--px));
  font-weight: 700;
  white-space: nowrap;
  transition: background 0.18s ease, color 0.18s ease;
}

.wd-add.is-added {
  background: var(--wd-accent);
  color: var(--wd-on-accent);
}

/* ── Order tray ── */
.wd-tray {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: calc(11 * var(--px));
  margin: 0 calc(12 * var(--px)) calc(4 * var(--px));
  padding: calc(11 * var(--px)) calc(11 * var(--px)) calc(11 * var(--px)) calc(14 * var(--px));
  border-radius: calc(15 * var(--px));
  background: var(--wd-accent);
  color: var(--wd-on-accent);
}

.wd-tray svg {
  flex: 0 0 auto;
  width: calc(19 * var(--px));
  height: calc(19 * var(--px));
}

.wd-tray-label {
  flex: 1 1 auto;
  font-size: calc(13.5 * var(--px));
  font-weight: 700;
}

.wd-tray-view {
  flex: 0 0 auto;
  padding: calc(7 * var(--px)) calc(13 * var(--px));
  border-radius: 999px;
  background: var(--wd-badge-bg);
  color: var(--wd-badge-ink);
  font-size: calc(12.5 * var(--px));
  font-weight: 700;
}

/* ── Composer ── */
.wd-composer {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  gap: calc(9 * var(--px));
  /* Bottom includes the phone's home-indicator inset, as in the app. */
  padding: calc(11 * var(--px)) calc(12 * var(--px)) calc(30 * var(--px));
  border-top: 1px solid var(--wd-line);
  background: var(--wd-sheet-bg);
}

.wd-input {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  height: calc(46 * var(--px));
  padding: 0 calc(16 * var(--px));
  border: 1px solid var(--wd-bubble-line);
  border-radius: calc(23 * var(--px));
  background: var(--wd-bubble);
  color: var(--wd-sub);
}

.wd-send {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: calc(46 * var(--px));
  height: calc(46 * var(--px));
  border: 1px solid var(--wd-bubble-line);
  border-radius: 999px;
  background: var(--wd-chip);
  color: var(--wd-sub);
}

.wd-send svg {
  width: calc(19 * var(--px));
  height: calc(19 * var(--px));
}

/* ── Playback ──
 * The markup is the finished conversation. While playing, steps stay hidden
 * until js/ai-waiter.js reveals them. */
.waiter-demo.is-playing [data-step]:not(.is-in) {
  display: none;
}

.waiter-demo.is-playing .wd-row,
.waiter-demo.is-playing [data-step] {
  animation: wd-in 0.34s ease both;
}

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

@keyframes wd-bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.45;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}
