/* Nimbus kiosk. Palette and type follow ANVKA's Project Nimbus deck:
   warm cream ground, violet accent, slate ink, Poppins, lilac-tinted cards. */
:root {
  --bg: #efebe4;
  --surface: #fbf9f6;
  --card: #f7f3fd;
  --card-line: #e3d8f6;
  --line: #ddd6cc;
  --ink: #1e2533;
  --muted: #5b6170;
  --brand: #6d28d9;
  --brand-deep: #5b21b6;
  --brand-soft: #ede5fb;
  --on-brand: #ffffff;
  --ok: #17663f;
  --ok-soft: #e3f3ea;
  --alert: #b42318;
  --alert-soft: #fdecea;
  --paper: #fbfaf6;
  --paper-ink: #24221f;
  --radius: 18px;
  --gap: clamp(12px, 2vw, 24px);
  --font: 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.5 var(--font);
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100dvh;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }

/* ── bar ──────────────────────────────────────────────────── */
.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px var(--gap);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand__mark { width: 40px; height: 40px; flex: none; }
.brand__mark rect { fill: var(--brand); }
.brand__mark path { fill: var(--on-brand); }
.brand b { display: block; font-weight: 600; font-size: 17px; line-height: 1.2; }
.brand span { font-size: 13px; color: var(--muted); }
.bar__right { display: flex; align-items: center; gap: 10px; }
.clock { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; }

.switch {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px;
  padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-size: 14px;
}
.switch__track { width: 34px; height: 20px; border-radius: 999px; background: #c9c3ba; position: relative; transition: background .2s; }
.switch__dot { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch[aria-pressed="true"] .switch__track { background: var(--brand); }
.switch[aria-pressed="true"] .switch__dot { transform: translateX(14px); }

.ghost, .primary, .secondary {
  min-height: 52px; padding: 0 22px; border-radius: 14px; font-weight: 500; font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
}
.ghost { min-height: 44px; border: 1px solid var(--line); background: var(--surface); }
.primary { border: 0; background: var(--brand); color: var(--on-brand); }
.primary:active { background: var(--brand-deep); }
.primary:disabled { opacity: .45; cursor: default; }
.secondary { border: 1.5px solid var(--brand); background: transparent; color: var(--brand); }
.primary--xl { min-height: 72px; padding: 0 36px; font-size: 20px; border-radius: 18px; }
.primary svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 3px; }

.note { padding: 8px var(--gap); font-size: 12px; color: var(--muted); text-align: center; border-top: 1px solid var(--line); }

/* ── kiosk layout ─────────────────────────────────────────────
   Full: the agent owns the screen (attract, identify).
   Compact: the agent becomes a tile and the panel shows the options. */
.kiosk {
  position: relative; min-height: 0;
  display: grid; gap: var(--gap); padding: var(--gap);
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
}
.agent { min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 12px; view-transition-name: agent; }
.panel { min-height: 0; overflow: auto; view-transition-name: panel; }

body[data-stage="attract"] .panel,
body[data-stage="identify"]:not([data-named]) .panel { display: none; }

.face {
  position: relative; overflow: hidden; border-radius: var(--radius);
  background: radial-gradient(120% 90% at 50% 20%, #fff 0%, var(--brand-soft) 60%, #ddd0f5 100%);
  min-height: 0;
}
.face video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 20%; transition: opacity .4s; }
#video { opacity: 0; }
.face.live #video { opacity: 1; }
.face.live #idleVideo { opacity: 0; }

.orb { position: absolute; inset: 0; display: none; place-items: center; }
.orb span {
  --lvl: 0;
  width: min(42%, 260px); aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #b794f6, var(--brand) 55%, var(--brand-deep));
  box-shadow: 0 0 0 calc(var(--lvl) * 28px) rgb(109 40 217 / .14), 0 0 0 calc(var(--lvl) * 56px) rgb(109 40 217 / .07);
  transform: scale(calc(1 + var(--lvl) * .08));
  transition: transform 80ms linear, box-shadow 80ms linear;
}
body[data-avatar="off"] .orb { display: grid; }
body[data-avatar="off"] .face video { opacity: 0 !important; }

.status {
  position: absolute; left: 14px; top: 14px; padding: 6px 12px; border-radius: 999px;
  background: rgb(255 255 255 / .86); font-size: 13px; font-weight: 500; display: inline-flex; align-items: center; gap: 8px;
}
.status::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #9a948b; }
.status[data-mode="listening"]::before { background: var(--ok); animation: pulse 1.4s ease-in-out infinite; }
.status[data-mode="speaking"]::before { background: var(--brand); }
@keyframes pulse { 50% { opacity: .3; } }

.captions { display: grid; gap: 6px; min-height: 4.5em; }
.cap { font-size: clamp(17px, 2.1vw, 22px); line-height: 1.4; }
.cap--agent { font-weight: 500; }
.cap--user { color: var(--muted); font-size: clamp(15px, 1.7vw, 18px); }
.cap--user:not(:empty)::before { content: 'You: '; font-weight: 500; }

/* Compact: landscape puts the agent in a left column. */
body:not([data-stage="attract"]):not([data-stage="identify"]:not([data-named])) .kiosk {
  grid-template-columns: minmax(240px, 30%) minmax(0, 1fr);
}
body:not([data-stage="attract"]):not([data-stage="identify"]:not([data-named])) .agent { grid-template-rows: auto 1fr; align-content: start; }
body:not([data-stage="attract"]):not([data-stage="identify"]:not([data-named])) .face { aspect-ratio: 4 / 5; }
body:not([data-stage="attract"]):not([data-stage="identify"]:not([data-named])) .cap { font-size: 16px; }

/* Portrait (a real kiosk, a tablet, a phone): the agent becomes a row on top. */
@media (max-aspect-ratio: 5/6), (max-width: 720px) {
  body:not([data-stage="attract"]):not([data-stage="identify"]:not([data-named])) .kiosk {
    grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr);
  }
  body:not([data-stage="attract"]):not([data-stage="identify"]:not([data-named])) .agent {
    grid-template-columns: clamp(88px, 22vw, 180px) 1fr; grid-template-rows: auto; align-items: center;
  }
  body:not([data-stage="attract"]):not([data-stage="identify"]:not([data-named])) .face { aspect-ratio: 4 / 5; }
  body:not([data-stage="attract"]):not([data-stage="identify"]:not([data-named])) .status { font-size: 0; padding: 6px; left: 8px; top: 8px; }
  body:not([data-stage="attract"]):not([data-stage="identify"]:not([data-named])) .captions { min-height: 0; }
  .bar .clock { display: none; }
}

/* ── attract ──────────────────────────────────────────────── */
.attract {
  position: absolute; inset: var(--gap); border-radius: var(--radius);
  display: flex; flex-direction: column; justify-content: flex-end; gap: 18px;
  padding: clamp(20px, 4vw, 48px);
  background: linear-gradient(180deg, rgb(239 235 228 / 0) 25%, rgb(239 235 228 / .92) 58%, var(--bg) 80%);
}
body:not([data-stage="attract"]) .attract { display: none; }
body[data-stage="attract"] .captions { display: none; }
.eyebrow { font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--brand); }
.attract h1 { font-weight: 700; font-size: clamp(30px, 5vw, 56px); line-height: 1.08; letter-spacing: -.02em; max-width: 16ch; color: var(--brand); }
.lede { font-size: clamp(16px, 1.8vw, 20px); color: var(--ink); max-width: 46ch; }
.attract .primary--xl { align-self: flex-start; }
/* Landscape: text on the left over cream, the face clear on the right. */
@media (min-aspect-ratio: 5/4) {
  .attract { justify-content: center; background: linear-gradient(90deg, var(--bg) 0%, var(--bg) 42%, rgb(239 235 228 / 0) 60%); }
  body[data-stage="attract"] .face { background: var(--bg); }
  body[data-stage="attract"] .face video { width: 60%; left: auto; right: 0; }
}
.hints { display: grid; gap: 8px; font-size: 14px; color: var(--muted); }
.hints ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.hints li { padding: 6px 12px; border: 1px solid var(--card-line); background: var(--card); border-radius: 10px; color: var(--ink); }
.hints li b { font-weight: 500; }

/* ── panel content ────────────────────────────────────────── */
.view { display: grid; gap: 18px; align-content: start; animation: rise .35s cubic-bezier(.2,.8,.2,1); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.view h2 { font-weight: 600; font-size: clamp(22px, 2.6vw, 30px); line-height: 1.2; letter-spacing: -.01em; }
.view .sub { color: var(--muted); }

.who { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; padding: 12px 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); font-size: 14px; }
.who b { font-weight: 600; font-size: 16px; }
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--ok-soft); color: var(--ok); }
.tag--brand { background: var(--brand-soft); color: var(--brand-deep); }

.steps { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 0; counter-reset: step; font-size: 13px; color: var(--muted); }
.steps li { counter-increment: step; display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; border-radius: 999px; border: 1px solid var(--line); }
.steps li::before { content: counter(step); display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--line); font-weight: 600; font-size: 11px; color: var(--muted); }
.steps li.done::before { content: '✓'; background: var(--ok-soft); color: var(--ok); }
.steps li.now { border-color: var(--brand); color: var(--brand-deep); font-weight: 600; }
.steps li.now::before { background: var(--brand); color: var(--on-brand); }

.keypad { display: grid; gap: 12px; max-width: 360px; }
.keypad output { font-size: 30px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: .06em; padding: 10px 16px; min-height: 64px; border-radius: 14px; background: var(--surface); border: 1.5px solid var(--line); }
.keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.keys button { min-height: 64px; border-radius: 14px; font-size: 24px; font-weight: 600; background: var(--card); border: 1.5px solid var(--card-line); }
.keys button:active { transform: scale(.97); }
.keys .primary { font-size: 18px; border: 0; background: var(--brand); color: var(--on-brand); }
.keys .primary:disabled { opacity: .4; }

.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.tile {
  text-align: left; display: grid; gap: 6px; align-content: start;
  padding: 18px; border-radius: 16px; background: var(--card); border: 1.5px solid var(--card-line);
  min-height: 64px; transition: border-color .15s, background .15s, transform .1s;
}
.tile:active { transform: scale(.985); }
.tile.is-picked, .tile[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); }
.tile h3 { font-weight: 600; font-size: 18px; line-height: 1.3; }
.tile p { font-size: 14px; color: var(--muted); }
.tile .meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 14px; color: var(--muted); }
.tile .fee { color: var(--ink); font-weight: 600; }

.service { min-height: 150px; padding: 24px; }
.service svg { width: 40px; height: 40px; fill: none; stroke: var(--brand); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.service h3 { font-size: 22px; }

.doc { grid-template-columns: 56px 1fr; column-gap: 14px; }
.doc .initials { grid-row: span 3; width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: var(--brand); color: var(--on-brand); font-weight: 600; }
.doc .next { font-size: 14px; color: var(--ink); }

.days { display: grid; gap: 16px; }
.days h3 { font-size: 15px; font-weight: 600; color: var(--muted); margin-bottom: 8px; }
.slots { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(116px, 1fr)); }
.slot { min-height: 56px; border-radius: 12px; border: 1.5px solid var(--card-line); background: var(--card); font-weight: 500; font-variant-numeric: tabular-nums; }
.slot.is-picked { border-color: var(--brand); background: var(--brand); color: var(--on-brand); }

.summary { border-radius: 16px; background: var(--surface); border: 1px solid var(--line); overflow: hidden; }
.summary dl { margin: 0; display: grid; grid-template-columns: max-content 1fr; }
.summary dt, .summary dd { margin: 0; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.summary dt { color: var(--muted); font-size: 14px; }
.summary dd { font-weight: 500; }
.bill { padding: 14px 18px; display: grid; gap: 6px; background: var(--card); }
.bill div { display: flex; justify-content: space-between; gap: 12px; }
.bill .total { font-weight: 700; font-size: 20px; padding-top: 8px; border-top: 1px dashed var(--card-line); margin-top: 4px; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; }

.pay { display: grid; gap: 18px; grid-template-columns: auto 1fr; align-items: center; padding: 22px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); }
.pay canvas { width: 200px; height: 200px; image-rendering: pixelated; border-radius: 10px; background: #fff; padding: 10px; border: 1px solid var(--line); }
.pay .amount { font-size: 34px; font-weight: 700; letter-spacing: -.01em; }
.pay .waiting { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.pay .waiting::before { content: ''; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--brand); border-right-color: transparent; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.demo-note { font-size: 12px; color: var(--muted); }
@media (max-width: 560px) { .pay { grid-template-columns: 1fr; justify-items: center; text-align: center; } }

.alert { padding: 24px; border-radius: 16px; background: var(--alert-soft); border: 1.5px solid var(--alert); color: var(--alert); display: grid; gap: 10px; }
.alert h2 { color: var(--alert); }
.alert p { color: var(--ink); font-size: 18px; }

/* ── printer (adapted from aqkprogrammer/receipt-printer, MIT) ─ */
.print-view { display: grid; gap: 24px; grid-template-columns: minmax(0, 1fr) auto; align-items: start; }
@media (max-width: 900px) { .print-view { grid-template-columns: 1fr; justify-items: center; } .print-view > :first-child { justify-self: stretch; } }
.printer { --paper-w: 300px; --tooth: 9px; width: calc(var(--paper-w) + 40px); display: flex; flex-direction: column; align-items: center; }
.printer-slot {
  position: relative; width: 100%; height: 34px; border-radius: 14px 14px 22px 22px;
  background: linear-gradient(180deg, #2a2f3a, #171a21); display: grid; place-items: center; overflow: hidden;
}
.slot__mouth { width: calc(var(--paper-w) + 14px); height: 7px; border-radius: 4px; background: #000; box-shadow: 0 0 14px rgb(0 0 0 / .9) inset; }
.slot__head {
  position: absolute; width: var(--paper-w); height: 1.5px; border-radius: 2px; opacity: 0;
  background: linear-gradient(90deg, transparent, #b794f6, transparent); transition: opacity .2s;
}
.printer.is-printing .slot__head { opacity: 1; animation: head .42s linear infinite; }
@keyframes head { 0%, 100% { transform: translateX(-24%) scaleX(.6); } 50% { transform: translateX(24%) scaleX(.6); } }

.paper { position: relative; z-index: 1; margin-top: -16px; width: var(--paper-w); transform-origin: top center; filter: drop-shadow(0 16px 20px rgb(30 37 51 / .22)); touch-action: none; }
.paper.is-grabbable { cursor: grab; }
.paper__window { height: 0; overflow: hidden; }
.receipt {
  padding: 26px 20px calc(18px + var(--tooth)); color: var(--paper-ink); font: 12px/1.5 var(--mono);
  background:
    repeating-linear-gradient(180deg, rgb(0 0 0 / .025) 0 1px, transparent 1px 3px),
    linear-gradient(90deg, rgb(0 0 0 / .05), transparent 7%, transparent 93%, rgb(0 0 0 / .05)),
    var(--paper);
  -webkit-mask:
    linear-gradient(#000 0 0) 0 0 / 100% calc(100% - var(--tooth)) no-repeat,
    conic-gradient(from -45deg at 50% 100%, #000 0 90deg, #0000 0) 0 100% / calc(var(--tooth) * 2) var(--tooth) repeat-x;
  mask:
    linear-gradient(#000 0 0) 0 0 / 100% calc(100% - var(--tooth)) no-repeat,
    conic-gradient(from -45deg at 50% 100%, #000 0 90deg, #0000 0) 0 100% / calc(var(--tooth) * 2) var(--tooth) repeat-x;
}
.paper.is-torn .receipt {
  -webkit-mask:
    linear-gradient(#000 0 0) 0 var(--tooth) / 100% calc(100% - var(--tooth) * 2) no-repeat,
    conic-gradient(from -45deg at 50% 100%, #000 0 90deg, #0000 0) 0 100% / calc(var(--tooth) * 2) var(--tooth) repeat-x,
    conic-gradient(from 135deg at 50% 0, #000 0 90deg, #0000 0) 0 0 / calc(var(--tooth) * 2) var(--tooth) repeat-x;
  mask:
    linear-gradient(#000 0 0) 0 var(--tooth) / 100% calc(100% - var(--tooth) * 2) no-repeat,
    conic-gradient(from -45deg at 50% 100%, #000 0 90deg, #0000 0) 0 100% / calc(var(--tooth) * 2) var(--tooth) repeat-x,
    conic-gradient(from 135deg at 50% 0, #000 0 90deg, #0000 0) 0 0 / calc(var(--tooth) * 2) var(--tooth) repeat-x;
}
.receipt .hd { text-align: center; }
.receipt .hd b { display: block; font-size: 14px; letter-spacing: .12em; }
.receipt .rule { height: 0; margin: 12px 0; border: 0; border-top: 1px dashed rgb(0 0 0 / .25); }
.receipt .token { text-align: center; }
.receipt .token span { font-size: 10px; letter-spacing: .3em; }
.receipt .token b { display: block; font-size: 44px; line-height: 1.05; letter-spacing: .04em; }
.receipt .line { display: flex; justify-content: space-between; gap: 12px; }
.receipt .line + .line { margin-top: 3px; }
.receipt .line span:last-child { text-align: right; }
.receipt .grand { font-weight: 700; font-size: 14px; margin-top: 8px; }
.receipt .stamp { margin-top: 10px; text-align: center; font-weight: 700; letter-spacing: .14em; padding: 6px; border: 1.5px solid currentColor; border-radius: 4px; }
.barcode { display: flex; align-items: flex-end; gap: 2px; height: 42px; margin: 16px 0 4px; }
.barcode i { display: block; height: 100%; background: var(--paper-ink); }
.receipt .cap-mini { text-align: center; font-size: 9px; letter-spacing: .35em; color: #8a877f; }
.receipt .foot { margin-top: 10px; text-align: center; font-size: 10.5px; color: #5d5a54; }
.tear-hint { margin-top: 12px; font-size: 13px; color: var(--muted); animation: nudge 1.8s ease-in-out infinite; }
@keyframes nudge { 50% { transform: translateY(4px); } }

::view-transition-old(agent), ::view-transition-new(agent) { animation-duration: .45s; animation-timing-function: cubic-bezier(.2,.8,.2,1); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .05s !important; }
}

/* Selected test: unmistakable at arm's length. */
.tile[data-test] { position: relative; }
.tile[data-test][aria-pressed="true"] { box-shadow: inset 0 0 0 1.5px var(--brand); }
.tile[data-test][aria-pressed="true"]::after {
  content: '✓'; position: absolute; top: 12px; right: 12px; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; background: var(--brand); color: var(--on-brand); font-size: 14px; font-weight: 700;
}

/* Portrait attract: face in the top half, words below it, never on it. */
@media (max-aspect-ratio: 4/5) {
  .attract { background: linear-gradient(180deg, rgb(239 235 228 / 0) 30%, var(--bg) 48%); gap: 14px; }
  body[data-stage="attract"] .face video { height: 50%; }
}
@media (max-width: 480px) {
  .brand span, .attract .lede { display: none; }
  .brand b { white-space: nowrap; }
  .attract h1 { font-size: 28px; }
  .primary--xl { min-height: 64px; font-size: 18px; }
}
