/* SmartSeats demo — implements the Nocturne design canvas (SmartSeats Demo.dc.html).
   Tokens below are the subset of the design system the page actually uses. */

:root {
  --color-text: #e9e9ed;
  --color-surface: #232532;
  --color-accent: #9184d9;
  --color-accent-400: #b5abfc;
  --color-divider: color-mix(in srgb, #e9e9ed 16%, transparent);

  --color-neutral-300: #cfd3e5;
  --color-neutral-400: #b2b6ca;
  --color-neutral-500: #9397ab;
  --color-neutral-600: #75798c;
  --color-neutral-700: #595d6c;
  --color-neutral-900: #292b31;

  /* Warmth and warning are the only colours besides the seat's own yellow. */
  --color-warm: #ff8a3d;
  --color-fault: #d24a3e;
  --color-fault-text: #e07a70;

  --font-heading: "Inter", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;

  --space-1: 2.8px; --space-2: 5.6px; --space-3: 8.4px;
  --space-4: 11.2px; --space-6: 16.8px; --space-8: 22.4px;

  --radius-md: 8px;
  --radius-lg: 14px;

  --topbar-h: 52px;

  /* The part of the 1000x600 design canvas that actually carries the tribune.
     app.js fits the window against this band; the panel aligns to it. */
  --content-top: 176px;
  --content-h: 424px;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }
body {
  margin: 0;
  font: 400 15px/1.55 var(--font-body);
  color: var(--color-text);
  background: radial-gradient(ellipse 90% 70% at 50% 40%, #171a2a 0%, #0c0d14 100%) fixed;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 1;
  background: radial-gradient(ellipse 80% 80% at 50% 50%, transparent 55%, rgba(0,0,0,.55) 100%);
}
h2 { font-family: var(--font-heading); font-weight: 500; letter-spacing: -.02em; margin: 0; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }

.sc-defs { position: absolute; width: 0; height: 0; }

/* — buttons (Nocturne) ---------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  cursor: pointer; text-decoration: none;
  font-family: var(--font-heading); font-weight: 500; font-size: 14px; line-height: 1.2;
  color: var(--color-text); background: transparent;
  border: 1px solid transparent; border-radius: var(--radius-md);
  padding: var(--space-2) calc(var(--space-3) * 1.2);
  transition: background .2s, border-color .3s, color .3s;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { color: var(--color-accent); border-color: var(--color-accent); }
.btn-primary:not(:disabled):hover { background: color-mix(in srgb, var(--color-accent) 12%, transparent); }
.btn-primary:not(:disabled):active { background: color-mix(in srgb, var(--color-accent) 22%, transparent); }
.btn-ghost { color: var(--color-accent); padding-inline: var(--space-1); }
.btn-ghost:not(:disabled):hover { background: color-mix(in srgb, var(--color-accent) 10%, transparent); }
.btn-block { width: 100%; }
.btn-lg { min-height: 64px; font-size: 18px; padding: 18px 28px; border-width: 1.5px; }
/* The button borrows the seat's own state colour. */
.btn-primary.is-warm { color: var(--color-warm); border-color: var(--color-warm); }
.btn-primary.is-warm:not(:disabled):hover { background: color-mix(in srgb, var(--color-warm) 12%, transparent); }
.btn-primary.is-muted { color: var(--color-neutral-500); border-color: var(--color-neutral-500); }

.hr {
  height: 1px; border: 0; margin: var(--space-3) 0;
  background: linear-gradient(to right, var(--color-divider) 0, var(--color-divider) calc(100% - 48px), transparent);
}
.kicker {
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--color-accent);
}
.status { display: flex; align-items: center; gap: 10px; font-size: 15px; color: var(--color-neutral-500); }
.status .dot {
  width: 9px; height: 9px; border-radius: 50%; background: #75798c; flex: none;
  box-shadow: 0 0 10px currentColor; transition: background .4s, color .4s;
}
.status.is-warm { color: var(--color-warm); } .status.is-warm .dot { background: var(--color-warm); color: var(--color-warm); }
.status.is-fault { color: var(--color-fault-text); } .status.is-fault .dot { background: var(--color-fault); color: var(--color-fault); }
.status.is-bright { color: var(--color-text); } .status.is-bright .dot { background: #e9e9ed; color: #e9e9ed; }
.note {
  margin-top: var(--space-2); padding: var(--space-3) var(--space-4);
  border: 1px solid #5a2a27; border-radius: var(--radius-md);
  background: rgba(210,74,62,.08); font-size: 14px; color: #f0a59d; line-height: 1.45;
}

/* — top bar --------------------------------------------------------------- */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--topbar-h); z-index: 3;
  display: flex; align-items: center; gap: var(--space-6);
  padding: 0 var(--space-8); padding-top: env(safe-area-inset-top);
  font-size: 13px; color: var(--color-neutral-400);
  background: linear-gradient(rgba(12,13,20,.92), rgba(12,13,20,0));
  pointer-events: none;
}
.brand {
  font-family: var(--font-heading); font-weight: 500; font-size: 15px;
  color: var(--color-text); margin-right: auto; letter-spacing: .01em;
}
.brand-sep { color: var(--color-neutral-600); }
.link-status { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.link-status .dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--color-neutral-700);
  box-shadow: 0 0 8px currentColor; color: var(--color-neutral-700); transition: background .4s, color .4s;
}
.link-status.is-online .dot { background: var(--color-accent); color: var(--color-accent); }
.link-status.is-offline .dot { background: var(--color-fault); color: var(--color-fault); }
.topbar-sep { color: var(--color-neutral-600); }
.active-count b { font-weight: 500; color: var(--color-text); }

/* — the stage ------------------------------------------------------------- */
.view { position: fixed; inset: 0; z-index: 2; }
.view[hidden] { display: none; }

.stage-fit { position: absolute; inset: var(--topbar-h) 0 var(--lockbar-h, 0px) 0; overflow: hidden; }
.stage {
  position: absolute; left: 0; top: 0; width: 1000px; height: 600px;
  transform-origin: 0 0; /* app.js places and scales this explicitly */
}
.stage-inner {
  position: absolute; inset: 0; transform-origin: 0 0;
  transition: transform .4s cubic-bezier(.2,.7,.2,1), filter .4s ease;
}
.stage.is-zoomed .stage-inner { filter: brightness(.42) blur(3px) saturate(.7); }
.tiers { position: absolute; inset: 0; display: block; }
.seats { position: absolute; inset: 0; }

.seat {
  position: absolute; cursor: pointer; transition: transform .25s ease, opacity .25s ease;
  border: 0; padding: 0; background: none;
}
.seat:hover { transform: translateY(-3px); }
/* Seat code on the step band right below its own seat. */
.seat-code {
  position: absolute; left: 0; right: 0;
  text-align: center; font-size: 10.5px; letter-spacing: .08em;
  color: var(--color-neutral-400); pointer-events: none;
}
.seat.is-focused { opacity: 0; pointer-events: none; }
.focus-seat {
  position: absolute; transform-origin: 0 0; pointer-events: none;
  transition: transform .4s cubic-bezier(.2,.7,.2,1);
  filter: drop-shadow(0 30px 40px rgba(0,0,0,.6));
}
.focus-seat[hidden] { display: none; }

.panel {
  position: absolute; left: 560px; top: var(--content-top); width: 380px; height: var(--content-h);
  display: flex; flex-direction: column; justify-content: center; gap: var(--space-4);
  opacity: 0; transform: translateX(40px);
  transition: opacity .35s ease .1s, transform .4s cubic-bezier(.2,.7,.2,1);
}
.panel[hidden] { display: none; }
.stage.is-zoomed .panel { opacity: 1; transform: translateX(0); }
.panel h2 { font-size: 38px; }
.panel .btn-lg { justify-content: space-between; }
.panel .arrow { font-size: 22px; line-height: 1; }
.panel-foot { display: flex; gap: var(--space-4); align-items: center; }
.panel-foot .btn-ghost { white-space: nowrap; min-height: 44px; }
.panel-foot .hint {
  font-size: 12px; line-height: 1.35; color: var(--color-neutral-600);
  margin-left: auto; text-align: right; max-width: 150px;
}

/* — seat screen (what a seat's QR code opens) ----------------------------- */
.view-seat { display: flex; flex-direction: column; padding-top: var(--topbar-h); }
.seat-screen {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--space-4); padding: 0 22px; text-align: center; min-height: 0;
}
.seat-hero { width: min(280px, 62vw); flex: 0 1 auto; filter: drop-shadow(0 30px 40px rgba(0,0,0,.6)); }
.seat-hero .seat-svg { max-height: 42vh; }
.view-seat .kicker { margin-top: var(--space-3); }
.view-seat h2 { font-size: 32px; }
.view-seat .note { max-width: 360px; }
.seat-actions {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 0 22px 34px;
  padding-bottom: calc(34px + env(safe-area-inset-bottom) + var(--lockbar-h, 0px));
  width: min(420px, 100%); margin: 0 auto;
}
.seat-actions .btn-lg { font-size: 19px; min-height: 68px; }
.seat-back {
  font-size: 13px; color: var(--color-neutral-500); text-decoration: none;
  min-height: 44px; display: inline-flex; align-items: center;
}
.seat-back:hover { color: var(--color-accent); }

/* — lock bar ------------------------------------------------------------- */
.lockbar {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); z-index: 4;
  display: flex; align-items: center; gap: var(--space-6); flex-wrap: wrap; justify-content: center;
  padding: var(--space-3) var(--space-8);
  padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom));
  width: min(660px, 100%);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: color-mix(in srgb, var(--color-surface) 92%, transparent);
  box-shadow: 0 0 0 1px var(--color-neutral-800), 0 -12px 32px rgba(0,0,0,.5);
  backdrop-filter: blur(8px);
}
.lockbar[hidden] { display: none; }
.lockbar-text { font-size: 13px; color: var(--color-neutral-400); }
.lockbar-form { display: flex; gap: var(--space-3); align-items: center; }
.input {
  min-height: 40px; padding: 6px 12px; width: 9.5em;
  font: 500 15px/1.2 ui-monospace, Menlo, monospace; letter-spacing: .08em;
  text-transform: uppercase; color: var(--color-text); caret-color: var(--color-accent);
  background: rgba(0,0,0,.25);
  border: 1px solid var(--color-divider); border-radius: var(--radius-md);
}
.input:focus-visible { border-color: var(--color-accent); outline-offset: 0; }

/* — toast ----------------------------------------------------------------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 5;
  padding: var(--space-3) var(--space-6); border-radius: var(--radius-md);
  background: var(--color-surface); box-shadow: 0 0 0 1px var(--color-neutral-700), 0 16px 40px rgba(0,0,0,.65);
  font-size: 14px; color: var(--color-text); max-width: min(420px, calc(100vw - 32px));
}
.toast[hidden] { display: none; }

/* — the seat itself ------------------------------------------------------- */
.seat-svg { display: block; width: 100%; height: auto; overflow: visible; }

.sc-glow { filter: blur(7px); opacity: 0; transition: opacity .8s ease; }
.sc-shell { transition: filter .5s ease; }
.sc-heat { opacity: .92; transform: translateY(90px); transition: transform .6s ease-in; }
.sc-core { opacity: 0; transition: opacity .8s ease; }
.sc-pan-heat { opacity: 0; transition: opacity .6s ease; }
.sc-dash { opacity: 0; transition: opacity .4s; }
.sc-fault-ring { opacity: 0; filter: drop-shadow(0 0 4px rgba(210,74,62,.7)); }
.sc-fault-badge, .sc-identify { display: none; }

[data-state="on"] .sc-heat { transform: translateY(0); }
[data-state="on"] .sc-core { opacity: 1; animation: scBreath 3s ease-in-out infinite; }
[data-state="on"] .sc-pan-heat { opacity: .9; }
[data-state="on"] .sc-glow { opacity: .9; animation: scGlow 3s ease-in-out infinite; }

[data-state="heating"] .sc-heat { transform: translateY(0); animation: scRise .8s cubic-bezier(.2,.7,.2,1) forwards; }
[data-state="heating"] .sc-pan-heat { animation: scFade .5s ease-out forwards; }
[data-state="heating"] .sc-glow { opacity: .6; }

[data-state="offline"] .sc-shell { filter: saturate(0) brightness(.55); }
[data-state="offline"] .sc-dash { opacity: 1; }
[data-state="offline"].seat { cursor: default; }

[data-state="fault"] .sc-fault-ring { opacity: 1; animation: scFault 1.8s ease-in-out infinite; }
[data-state="fault"] .sc-fault-badge { display: block; }

[data-state="identify"] .sc-identify { display: block; }
.sc-ring { transform-origin: 50px 58px; animation: scRing 2.4s ease-out infinite; }
.sc-ring-2 { animation-delay: .8s; }
.sc-ring-3 { animation-delay: 1.6s; }

@keyframes scBreath { 0%, 100% { opacity: .7 } 50% { opacity: 1 } }
@keyframes scGlow   { 0%, 100% { opacity: .5 } 50% { opacity: .95 } }
@keyframes scRise   { from { transform: translateY(90px) } to { transform: translateY(0) } }
@keyframes scFade   { from { opacity: 0 } to { opacity: .9 } }
@keyframes scRing   { 0% { transform: scale(.55); opacity: .85 } 100% { transform: scale(1.35); opacity: 0 } }
@keyframes scFault  { 0%, 100% { opacity: .4 } 50% { opacity: 1 } }

/* — narrow screens: the right-hand panel gives way to the seat screen ----- */
@media (max-width: 859px) {
  .panel { display: none !important; }
  .topbar { gap: var(--space-4); padding: 0 var(--space-6); font-size: 12px; }
  .topbar-sep, .active-count { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .sc-core, .sc-glow, .sc-fault-ring, .sc-ring, .sc-heat, .sc-pan-heat { animation: none !important; }
  .stage-inner, .focus-seat, .panel, .seat { transition-duration: .01ms !important; }
}
