/* EDT Luma — AI Product Specialist
   ---------------------------------------------------------------------------
   Warm, light, editorial. No glassmorphism: the product is the only glass.

   Structure: a left rail holding the presenter and the ways in, and the
   stage as a raised surface with the product committed to real scale.
   The previous version left everything floating in flat colour, which read
   as unstyled rather than restrained.
--------------------------------------------------------------------------- */

:root {
  /* Surfaces, warm and layered rather than one flat field */
  --bone:     #EFEAE3;
  --bone-lo:  #E7E1D8;
  --surface:  #FBF9F6;
  --paper:    #FFFFFF;

  --ink:      #211C18;
  --ink-soft: #4A433C;
  --muted:    #8A8078;
  --faint:    #B3A9A0;

  --line:     #E0D8CD;
  --hairline: rgba(33, 28, 24, 0.07);
  --accent:   #D9541A;

  --r-lg: 26px;
  --r-md: 16px;

  --stage-fade: 560ms;
  --stage-fade-slow: 900ms;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);

  --rail: 320px;
  --portrait: 100%;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

/* The hidden attribute is only display:none in the browser's default
   stylesheet, so any class rule with display beats it. Several elements
   here (.devpanel, .chips, .ask) set display, which silently un-hid them. */
[hidden] { display: none !important; }

body {
  margin: 0;
  /* A gentle vertical wash, so the page has a light source */
  background: linear-gradient(175deg, var(--surface) 0%, var(--bone) 58%, var(--bone-lo) 100%);
  color: var(--ink);
  font-family: "Instrument Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

/* ═══════════════════════════════════════════════════════════════ topbar */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 30px;
  border-bottom: 1px solid var(--hairline);
}

.brand { display: flex; align-items: center; gap: 13px; }
.brand-mark {
  font-size: 13px; font-weight: 600;
  letter-spacing: 0.22em; text-transform: uppercase;
}
.brand-rule { width: 1px; height: 15px; background: var(--line); }
.brand-name {
  font-family: "Instrument Serif", Georgia, serif;
  font-size: 19px;
  letter-spacing: 0.01em;
  color: var(--ink-soft);
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* No reason to offer "End session" before there is one. */
body:not([data-phase="live"]) #leave { opacity: 0; pointer-events: none; }

.topbar-right { display: flex; align-items: center; gap: 10px; }

.pill {
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.6);
  box-shadow: inset 0 0 0 1px var(--hairline);
}

.btn {
  font: inherit;
  font-size: 13.5px;
  padding: 9px 20px;
  border-radius: 999px;
  border: none;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  box-shadow: inset 0 0 0 1px var(--hairline), 0 1px 2px rgba(33,28,24,0.04);
  transition: box-shadow 200ms var(--ease), opacity 200ms var(--ease),
              transform 200ms var(--ease);
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:disabled { opacity: 0.32; cursor: default; }
.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(217,84,26,0.25), 0 6px 18px -8px rgba(217,84,26,0.5);
}
.btn-primary:disabled { opacity: 0.28; }

/* ═══════════════════════════════════════════════════════════════ layout */

.layout {
  position: relative;
  display: grid;
  grid-template-columns: var(--rail) 1fr;
  gap: 26px;
  padding: 26px 30px 30px;
  min-height: 0;
  transition: grid-template-columns 700ms var(--ease);
}

/* Before the session the cover gets the full width — an empty rail with a
   grey box in it was the emptiest part of the page. */
.rail { overflow: hidden; }

/* ═════════════════════════════════════════════════════════════════ rail */

.rail {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  transition: opacity 500ms var(--ease);
}
/* The portrait yields height so the question box is never clipped. */
.portrait { flex: 0 1 auto; min-height: 0; }
.rail-foot { flex: 0 0 auto; }
body[data-session="off"] .rail .portrait-state,
body[data-session="off"] .rail .portrait-media { opacity: 0.55; }

.portrait { margin: 0; }

.portrait-media {
  position: relative;
  width: var(--portrait);
  aspect-ratio: 4 / 5;
  /* Caps the portrait on shorter viewports; the video covers, so a slightly
     squarer crop is fine and beats clipping the controls below. */
  max-height: 42vh;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: linear-gradient(160deg, #EDE7DF, #E3DCD2);
  box-shadow: inset 0 0 0 1px var(--hairline),
              0 2px 4px rgba(33,28,24,0.04),
              0 26px 50px -24px rgba(33,28,24,0.32);
  transition: opacity 500ms var(--ease), transform 700ms var(--ease),
              box-shadow 700ms var(--ease);
}
.portrait-media video { width: 100%; height: 100%; object-fit: cover; }

/* She leans in a little while speaking. */
body[data-agent="speaking"] .portrait-media {
  transform: scale(1.018);
  box-shadow: inset 0 0 0 1px var(--hairline),
              0 2px 4px rgba(33,28,24,0.04),
              0 30px 58px -24px rgba(33,28,24,0.38);
}

.portrait-fallback {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--muted);
}
body[data-avatar="on"] .portrait-fallback { display: none; }

.portrait figcaption {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
}
.portrait-id { display: grid; gap: 1px; }
.portrait-name {
  font-family: "Instrument Serif", Georgia, serif;
  font-size: 19px;
  line-height: 1.15;
  color: var(--ink);
}
.portrait-role {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}
.portrait-state {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted);
}
.dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--faint);
  transition: background 260ms var(--ease), box-shadow 260ms var(--ease);
}
body[data-agent="speaking"] .dot {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(217,84,26,0.16);
}
body[data-agent="listening"] .dot {
  background: #6E9A63;
  box-shadow: 0 0 0 3px rgba(110,154,99,0.16);
}
body[data-agent="thinking"] .dot {
  background: #C39B2E;
  box-shadow: 0 0 0 3px rgba(195,155,46,0.16);
}

/* --- the ways in, at the foot of the rail --- */

.rail-foot { margin-top: auto; display: grid; gap: 10px; padding-bottom: 2px; }

.chips {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  opacity: 0.8;
  transition: opacity 700ms var(--ease);
}
.chips:hover { opacity: 1; }
body[data-spoken="yes"] .chips { opacity: 0.4; }
body[data-spoken="yes"] .chips:hover { opacity: 1; }

.chip {
  font: inherit;
  font-size: 13px;
  padding: 7px 15px;
  border-radius: 999px;
  border: none;
  background: rgba(255,255,255,0.72);
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  box-shadow: inset 0 0 0 1px var(--hairline);
  transition: color 200ms var(--ease), background 200ms var(--ease),
              transform 200ms var(--ease);
}
.chip:hover:not(:disabled) {
  color: var(--ink);
  background: var(--paper);
  transform: translateX(2px);
}

.ask { display: flex; gap: 7px; }
.ask input {
  flex: 1; min-width: 0;
  font: inherit; font-size: 13.5px;
  padding: 10px 16px;
  border-radius: 999px;
  border: none;
  background: var(--paper);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--hairline);
  transition: box-shadow 200ms var(--ease);
}
.ask input::placeholder { color: var(--faint); }
.ask input:focus {
  outline: none;
  box-shadow: inset 0 0 0 1px rgba(217,84,26,0.4), 0 0 0 3px rgba(217,84,26,0.10);
}
.ask button {
  width: 40px; height: 40px;
  font-size: 15px;
  border: none; border-radius: 50%;
  background: var(--accent); color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 14px -6px rgba(217,84,26,0.6);
}

.hint {
  margin: 0;
  font-size: 12px;
  color: var(--faint);
  transition: opacity 1200ms var(--ease);
}
.hint strong { color: var(--muted); font-weight: 500; }

/* ════════════════════════════════════════════════════════════════ stage */

.stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 0;
  padding: 26px 30px 22px;
  border-radius: var(--r-lg);
  /* A raised surface with its own light, rather than a hole in the page */
  background:
    radial-gradient(74% 62% at 50% 40%, #FFFFFF 0%, rgba(255,255,255,0) 68%),
    linear-gradient(168deg, #FCFBF9 0%, #F5F1EB 100%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.7),
              inset 0 0 0 1.5px var(--hairline),
              0 2px 5px rgba(33,28,24,0.04),
              0 40px 70px -36px rgba(33,28,24,0.28);
  /* Anything that reaches the edge crops on the radius instead of
     spilling past the corner. */
  overflow: hidden;
}

/* The label: what this is. Top centre, quiet, always there. */
.stage-caption {
  margin: 0 0 14px;
  min-height: 1.4em;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 500ms var(--ease), transform 500ms var(--ease);
}
.stage-caption.is-visible { opacity: 1; transform: none; }

.stage-frame {
  position: relative;
  width: 100%;
  flex: 1;
  min-height: 0;
}

.stage-layer {
  position: absolute; inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--stage-fade) var(--ease);
}
.stage[data-layout="single"] #stage-single,
.stage[data-layout="grid"]   #stage-grid,
.stage[data-layout="views"]  #stage-views { opacity: 1; pointer-events: auto; }

.stage-img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  opacity: 0;
  transform: scale(0.992);
  transition: opacity var(--stage-fade) var(--ease),
              transform var(--stage-fade) var(--ease);
}
.stage-img.is-visible { opacity: 1; transform: scale(1); }

.stage.is-slow .stage-img {
  transition: opacity var(--stage-fade-slow) var(--ease), transform 7s linear;
}
.stage.is-slow .stage-img.is-visible { transform: scale(1.025); }

/* --- the six cooking modes --- */
.stage-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 16px;
  padding: 2px;
}
.tile {
  margin: 0;
  overflow: hidden;
  border-radius: var(--r-md);
  background: var(--paper);
  box-shadow: inset 0 0 0 1px var(--hairline), 0 6px 18px -12px rgba(33,28,24,0.3);
  opacity: 0;
  transform: translateY(14px) scale(0.985);
  transition: opacity 520ms var(--ease), transform 520ms var(--ease);
}
.stage[data-layout="grid"] .tile { opacity: 1; transform: none; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* --- every angle at once --- */
.stage-views {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-content: center;
  gap: 18px;
}
.vtile {
  margin: 0;
  display: flex; flex-direction: column;
  min-width: 0;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 520ms var(--ease), transform 520ms var(--ease);
}
.stage[data-layout="views"] .vtile { opacity: 1; transform: none; }
.vtile img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  display: block;
}
.vtile figcaption {
  margin-top: 10px;
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--faint);
}

/* --- subtitle: inside the stage, under the product --- */
.subtitle {
  margin: 16px 0 0;
  width: min(620px, 100%);
  text-align: center;
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink-soft);
  min-height: 2.6em;

  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;

  opacity: 0;
  transform: translateY(5px);
  transition: opacity 320ms var(--ease), transform 320ms var(--ease);
}
.subtitle.is-visible { opacity: 1; transform: none; }
.subtitle[data-who="user"] {
  color: var(--faint);
  font-family: "Instrument Serif", Georgia, serif;
  font-style: italic;
  font-size: 16px;
}

/* ════════════════════════════════════════════════════════════════ cover */
/* The idle state. A landing composition rather than an empty frame. */

.cover {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(380px, 1fr) 1.05fr;
  align-items: center;
  column-gap: 56px;
  padding: 10px 14px 0 24px;
  opacity: 1;
  transition: opacity 700ms var(--ease), visibility 700ms;
}

/* ── The transition, in four phases ───────────────────────────────────────
   idle        cover hero, product right
   committing  copy clears, the same product glides to centre and grows
   connecting  product holds centre, a thin line reports progress
   live        the stage builds around the product, then the rail arrives

   The product element is never replaced — it is the constant the eye holds
   on to, which is what stops this feeling like a page change.
------------------------------------------------------------------------- */

/* The stage assembles only at the end. */
body:not([data-phase="live"]) .stage { opacity: 0; visibility: hidden; }
body[data-phase="live"] .stage {
  opacity: 1;
  animation: stageIn 900ms var(--ease) both;
}
@keyframes stageIn {
  from { opacity: 0; transform: scale(0.985); }
  to   { opacity: 1; transform: none; }
}

body[data-phase="live"] .cover { opacity: 0; visibility: hidden; }

/* The rail slides in last, after the stage has settled. */
body:not([data-phase="live"]) .rail { opacity: 0; pointer-events: none; }
body[data-phase="live"] .rail {
  animation: railIn 800ms var(--ease) 260ms both;
}
@keyframes railIn {
  from { opacity: 0; transform: translateX(-16px); }
  to   { opacity: 1; transform: none; }
}

body:not([data-phase="live"]) .layout { grid-template-columns: 0 1fr; gap: 0; }
body[data-session="on"] .cover { opacity: 0; visibility: hidden; }

/* The live stage sits underneath the cover and was rendering its own hero
   image through it — two air fryers, slightly offset. Hide it until the
   session starts. */
body[data-session="off"] .stage-frame,
body[data-session="off"] .stage-caption { opacity: 0; }

.cover-copy {
  max-width: 540px;
  align-self: center;
  justify-self: end;
  padding-bottom: 20px;
  transition: opacity 520ms var(--ease), transform 640ms var(--ease);
}
/* Clears out of the way as the product takes over. */
body:not([data-phase="idle"]) .cover-copy {
  opacity: 0;
  transform: translateY(-14px);
  pointer-events: none;
}

/* Content arrives in sequence on load. One-time only. */
.cover-copy > * { animation: riseIn 900ms var(--ease) both; }
.cover-eyebrow { animation-delay: 120ms; }
.cover-title   { animation-delay: 200ms; }
.cover-lede    { animation-delay: 300ms; }
.cover-stats   { animation-delay: 400ms; }
#join-cover    { animation-delay: 500ms; }
.cover-note    { animation-delay: 600ms; }
@keyframes riseIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}

.cover-eyebrow {
  margin: 0 0 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
}

.cover-title {
  margin: 0 0 22px;
  font-family: "Instrument Serif", Georgia, serif;
  font-weight: 400;
  font-size: clamp(46px, 5vw, 72px);
  line-height: 1.04;
  letter-spacing: -0.018em;
  color: var(--ink);
}
.cover-title em { font-style: italic; }

.cover-lede {
  margin: 0 0 34px;
  font-size: clamp(17px, 1.35vw, 20px);
  line-height: 1.58;
  color: var(--ink-soft);
  max-width: 42ch;
}

.cover-stats {
  display: flex;
  gap: clamp(28px, 3vw, 44px);
  margin: 0 0 38px;
  padding: 26px 0 0;
  border-top: 1px solid var(--hairline);
}
.cover-stats div { display: grid; gap: 4px; }
.cover-stats dt {
  font-family: "Instrument Serif", Georgia, serif;
  font-size: clamp(26px, 2.1vw, 30px);
  line-height: 1.05;
  color: var(--ink);
}
.cover-stats dd {
  margin: 0;
  font-size: 10.5px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--muted);
}

.btn-lg {
  font-size: 15px;
  padding: 14px 32px;
}

.cover-note {
  margin: 18px 0 0;
  font-size: 11px;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--faint);
}

/* --- connection report: visible only while connecting --- */

.cover-connect {
  display: grid;
  justify-items: center;
  gap: 14px;
  opacity: 0;
  transition: opacity 600ms var(--ease);
  pointer-events: none;
}
body[data-phase="connecting"] .cover-connect { opacity: 1; }

.cover-connect p {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}
.connect-bar {
  width: 132px; height: 2px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
}
.connect-bar i {
  display: block; height: 100%; width: 36%;
  background: var(--accent);
  border-radius: 2px;
  animation: slide 1500ms var(--ease) infinite;
}
@keyframes slide {
  0%   { transform: translateX(-110%); }
  100% { transform: translateX(390%); }
}

/* The product at real scale, sitting on the bottom edge of the page.
   Cropping against the viewport is safe; cropping against a rounded card
   was what read as broken. */
.cover-product {
  position: relative;
  height: 100%;
  display: grid;
  place-items: end center;
  min-height: 0;
}

.cover-product img {
  width: 100%;
  max-width: 820px;          /* ~8% larger than before, per the brief */
  height: auto;
  max-height: 100%;
  object-fit: contain;
  object-position: bottom;
  filter: drop-shadow(0 46px 54px rgba(33, 28, 24, 0.18));
  animation: settle 1700ms var(--ease) both;
  transition: opacity 600ms var(--ease);
}
@keyframes settle {
  from { opacity: 0; transform: translateY(22px) scale(0.976); }
  to   { opacity: 1; transform: none; }
}

/* ── The travel ─────────────────────────────────────────────────────────
   From "committing" the product leaves the grid and becomes fixed, centred
   in the viewport. Grid properties (grid-column, place-items) do not
   transition, which is why animating them left the product anchored to the
   bottom and cropped. Fixed positioning with explicit sizing is
   deterministic and animates cleanly.
--------------------------------------------------------------------------- */
body:not([data-phase="idle"]) .cover-product {
  position: fixed;
  top: 62px; right: 0; bottom: 0; left: 0;
  height: auto;
  place-items: center;
  z-index: 30;
  pointer-events: none;
}
body:not([data-phase="idle"]) .cover-product img {
  animation: fly 1000ms var(--ease) both;
  width: min(500px, 40vw);
  max-width: none;
  max-height: 60vh;
  object-position: center;
  filter: drop-shadow(0 48px 56px rgba(33, 28, 24, 0.2));
}
@keyframes fly {
  from { transform: translateY(16%) scale(1.22); }
  to   { transform: none; }
}

/* Hands off to the stage's own copy of the same image — identical source,
   so the cross-fade is invisible. */
body[data-phase="live"] .cover-product img {
  animation: none;
  opacity: 0;
}

.cover-connect {
  position: fixed;
  left: 0; right: 0;
  bottom: clamp(48px, 10vh, 110px);
  z-index: 31;
}

@media (max-width: 1080px) {
  .cover { grid-template-columns: 1fr; padding: 30px 40px 0; }
  .cover-copy { justify-self: start; }
  body[data-phase="idle"] .cover-product { display: none; }
}

/* On short screens, drop the least-needed chips rather than clip the form. */
@media (max-height: 860px) {
  .portrait-media { max-height: 34vh; }
  .chip:nth-of-type(n+4) { display: none; }
}

/* ════════════════════════════════════════════════════════════ dev panel */

.devpanel {
  position: fixed;
  right: 16px; bottom: 16px;
  width: 400px; max-height: 52vh;
  display: flex; flex-direction: column;
  background: var(--paper);
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px var(--hairline), 0 20px 50px -20px rgba(33,28,24,0.4);
  z-index: 50;
}
.devpanel header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 13px;
  border-bottom: 1px solid var(--hairline);
  font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--muted);
}
.devpanel button {
  font: inherit; font-size: 10px;
  border: none; background: none; color: var(--muted); cursor: pointer;
}
#log {
  margin: 0; padding: 12px 14px; overflow: auto;
  font: 11px/1.75 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--muted);
  white-space: pre-wrap;
}

.btn:focus-visible,
.chip:focus-visible,
.ask button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(217,84,26,0.3);
}

@media (max-width: 1180px) {
  :root { --rail: 260px; }
  .stage-views { gap: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 1ms !important; animation: none !important; }
}
