/* Palette carried over from larry_display.html so the two feel like one project */
:root {
  --warm-white: #d4c8b8;
  --muted-gold: #887a6a;
  --dark-brown: #2a2520;
  --deep-black: #0a0908;
  --soft-green: #7a9a7e;
  --ember-red: #a85d5d;
  --ghost-text: #4a4238;

  --dock-h: 220px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--deep-black);
  color: var(--warm-white);
  font-family: 'Cormorant Garamond', Georgia, serif;
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
  background:
    radial-gradient(120% 80% at 50% 0%, #14110d 0%, var(--deep-black) 60%);
}

/* ---------------- masthead ---------------- */
#masthead {
  padding: 18px 24px 10px;
  text-align: center;
  border-bottom: 1px solid var(--dark-brown);
  flex: 0 0 auto;
}
#masthead h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--warm-white);
}
#masthead p {
  margin: 4px 0 0;
  font-family: 'Courier Prime', monospace;
  font-size: 9px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--ghost-text);
}

/* ---------------- transcript ---------------- */
#transcript {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px 22px 30px;
}

.line { margin-bottom: 22px; animation: rise 0.35s ease both; }
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.line .who {
  display: block;
  font-family: 'Courier Prime', monospace;
  font-size: 9px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--muted-gold);
  margin-bottom: 6px;
}
.line p {
  margin: 0;
  font-size: 19px;
  line-height: 1.5;
}
.line-larry p { color: var(--warm-white); }
.line-you {
  padding-left: 14px;
  border-left: 1px solid var(--dark-brown);
}
.line-you .who { color: var(--ghost-text); }
.line-you p { color: var(--muted-gold); font-style: italic; font-size: 17px; }

/* ---------------- dock ---------------- */
#dock {
  flex: 0 0 auto;
  padding: 14px 22px calc(18px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--dark-brown);
  background: rgba(10, 9, 8, 0.9);
  backdrop-filter: blur(8px);
  text-align: center;
}

#status {
  font-family: 'Courier Prime', monospace;
  font-size: 9px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--ghost-text);
  margin-bottom: 12px;
  min-height: 12px;
  transition: color 0.3s;
}
body[data-state="listening"] #status { color: var(--soft-green); }
body[data-state="thinking"]  #status { color: var(--muted-gold); }
body[data-state="speaking"]  #status { color: var(--warm-white); }

.talk {
  position: relative;
  width: 100%;
  padding: 20px 0;
  background: transparent;
  border: 1px solid var(--muted-gold);
  border-radius: 3px;
  color: var(--warm-white);
  font-family: 'Courier Prime', monospace;
  font-size: 12px;
  letter-spacing: 3px;
  cursor: pointer;
  user-select: none;
  touch-action: none;
  transition: border-color 0.25s, color 0.25s, background 0.25s;
}
.talk:disabled { opacity: 0.45; }

body[data-state="listening"] .talk {
  border-color: var(--soft-green);
  color: var(--soft-green);
  background: rgba(122, 154, 126, 0.06);
}
body[data-state="speaking"] .talk {
  border-color: var(--warm-white);
}

/* level-reactive halo while listening */
.orb {
  --level: 0;
  position: absolute;
  inset: -1px;
  border-radius: 3px;
  pointer-events: none;
  box-shadow: 0 0 calc(6px + var(--level) * 34px)
              rgba(122, 154, 126, calc(var(--level) * 0.85));
  opacity: 0;
  transition: opacity 0.2s;
}
body[data-state="listening"] .orb { opacity: 1; }

.dock-row {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}
.mini {
  flex: 1;
  padding: 10px 0;
  background: transparent;
  border: 1px solid var(--dark-brown);
  border-radius: 3px;
  color: var(--ghost-text);
  font-family: 'Courier Prime', monospace;
  font-size: 9px;
  letter-spacing: 2px;
  cursor: pointer;
}
.mini:active { color: var(--muted-gold); border-color: var(--muted-gold); }

/* ---------------- error bar ---------------- */
#error-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  padding: 12px 20px;
  padding-top: calc(12px + env(safe-area-inset-top));
  background: var(--ember-red);
  color: var(--deep-black);
  font-family: 'Courier Prime', monospace;
  font-size: 11px;
  letter-spacing: 1px;
  text-align: center;
  transform: translateY(-110%);
  transition: transform 0.3s;
}
#error-bar.show { transform: none; }

/* ---------------- info sheet ---------------- */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(10, 9, 8, 0.97);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.sheet.hidden { display: none; }
.sheet-inner {
  max-width: 620px;
  margin: 0 auto;
  padding: calc(36px + env(safe-area-inset-top)) 26px
           calc(40px + env(safe-area-inset-bottom));
}
.sheet h2 {
  font-size: 24px;
  font-weight: 600;
  margin: 0 0 18px;
}
.sheet h3 {
  font-family: 'Courier Prime', monospace;
  font-size: 10px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--muted-gold);
  margin: 26px 0 8px;
}
.sheet p {
  font-size: 17px;
  line-height: 1.6;
  color: var(--warm-white);
  margin: 0 0 14px;
}
.sheet .fineprint {
  font-family: 'Courier Prime', monospace;
  font-size: 10px;
  line-height: 1.8;
  letter-spacing: 0.5px;
  color: var(--ghost-text);
  margin-top: 26px;
}
.sheet .mini { margin-top: 24px; }

@media (min-width: 700px) {
  #transcript { padding: 30px 15%; }
  #dock { padding-left: 15%; padding-right: 15%; }
}


/* ---------------- avatar stage ----------------

   Two very different states:
     no video — a short strip holding the "show his face" button. Must size
                itself to its content, so the placeholder stays IN FLOW.
     video    — a fixed-aspect black frame with the video filling it.

   The placeholder used to be position:absolute in both states, which collapsed
   the strip to zero height and clipped the button. Only the video is absolute. */
#stage {
  position: relative;
  flex: 0 0 auto;
  width: 100%;
  border-bottom: 1px solid var(--dark-brown);
  display: none;
}
#stage.on { display: block; }

/* --- video state --- */
#stage.has-video {
  aspect-ratio: 3 / 4;
  max-height: 42vh;
  background: #000;
  overflow: hidden;
}

.avatar-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* --- placeholder state: in normal flow so it gives the stage its height --- */
#stage-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 20px;
  text-align: center;
}
#stage.has-video #stage-placeholder { display: none; }

.face-toggle {
  padding: 12px 22px;
  background: transparent;
  border: 1px solid var(--muted-gold);
  border-radius: 3px;
  color: var(--warm-white);
  font-family: 'Courier Prime', monospace;
  font-size: 11px;
  letter-spacing: 2.5px;
  cursor: pointer;
}
.face-toggle:active { background: rgba(136,122,106,0.15); }

.face-note {
  margin: 0;
  font-family: 'Courier Prime', monospace;
  font-size: 9px;
  letter-spacing: 1px;
  color: var(--ghost-text);
  max-width: 240px;
  line-height: 1.6;
}

#stage-status {
  text-align: center;
  padding: 0 0 10px;
  min-height: 12px;
  font-family: 'Courier Prime', monospace;
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--muted-gold);
  text-shadow: 0 1px 4px #000;
  pointer-events: none;
}
#stage.has-video #stage-status {
  position: absolute;
  bottom: 10px; left: 0; right: 0;
  padding: 0;
}

/* A running avatar session costs money every second, so say so plainly and
   keep the stop control large and always visible. */
#live-bar {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: linear-gradient(rgba(10,9,8,0.85), rgba(10,9,8,0));
  z-index: 5;
}
#live-bar.hidden { display: none; }

.live-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--ember-red);
  box-shadow: 0 0 8px var(--ember-red);
  animation: pulse 1.6s ease-in-out infinite;
  flex: 0 0 auto;
}
@keyframes pulse { 50% { opacity: 0.25; } }

#live-timer {
  flex: 1 1 auto;
  font-family: 'Courier Prime', monospace;
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--warm-white);
  text-shadow: 0 1px 4px #000;
  text-align: left;
}

.face-off {
  flex: 0 0 auto;
  padding: 8px 18px;
  border-radius: 3px;
  background: var(--ember-red);
  border: none;
  color: var(--deep-black);
  font-family: 'Courier Prime', monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  cursor: pointer;
}
.face-off:active { opacity: 0.8; }

/* Show the toggle strip even before the face is on */
body.face-available #stage { display: block; }
