/* Lena demo landing page — minimal, brand-conscious, mobile-first.
 * Three viewports verified at 360px (phone) and 1280px (laptop):
 * primary CTA visible above the fold at both. */

:root {
  --bg: #0b1220;
  --surface: #131c30;
  --ink: #f3f7ff;
  --ink-mute: #98a3b6;
  --accent: #7cd9d6;
  --accent-deep: #0e8a86;
  --danger: #ff7676;
  --radius: 18px;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
  --font-sans:
    "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100dvh;
  background: radial-gradient(
      ellipse at 30% -10%,
      rgba(124, 217, 214, 0.18),
      transparent 55%
    ),
    radial-gradient(ellipse at 80% 110%, rgba(14, 138, 134, 0.18), transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.stage {
  max-width: 720px;
  margin: 0 auto;
  padding: clamp(20px, 6vw, 48px);
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: clamp(20px, 4vw, 36px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #04221f;
  font-weight: 800;
  font-size: 15px;
}

/* State-driven copy panels: only the panel matching body[data-state] is shown. */
.copy {
  display: none;
  align-self: center;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0));
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius);
  padding: clamp(20px, 4vw, 36px);
  box-shadow: var(--shadow);
}
body[data-state="idle"] .copy[data-show-when="idle"],
body[data-state="ringing"] .copy[data-show-when="ringing"],
body[data-state="connected"] .copy[data-show-when="connected"],
body[data-state="ended"] .copy[data-show-when="ended"] {
  display: block;
}

.copy h1 {
  margin: 0 0 14px 0;
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.copy p {
  margin: 0;
  color: var(--ink-mute);
  font-size: clamp(16px, 1.8vw, 18px);
  line-height: 1.55;
}
.copy strong {
  color: var(--ink);
}
.hint {
  font-size: clamp(14px, 1.6vw, 16px);
}

/* "ringing" pulse animates Lena's name until the user answers. */
body[data-state="ringing"] .copy[data-show-when="ringing"] h1 {
  animation: pulse 1.1s ease-in-out infinite;
}
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.55;
  }
}

/* Status indicator color shift per Lena's state — wired by ENG-2330. */
.lena-status[data-status="listening"]::before {
  background: var(--accent);
}
.lena-status[data-status="thinking"]::before {
  background: #ffd166;
  animation: pulse 0.8s ease-in-out infinite;
}
.lena-status[data-status="speaking"]::before {
  background: #b4ff5a;
}
.lena-status::before {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 12px;
  background: var(--ink-mute);
  vertical-align: middle;
  transition: background 120ms ease;
}

#transcript-region {
  margin-top: 18px;
  font-size: 15px;
  color: var(--ink-mute);
  min-height: 60px;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 6px;
}
.transcript-row {
  margin: 0 0 10px 0;
  line-height: 1.45;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  word-wrap: break-word;
}
.transcript-row[data-speaker="input"] {
  border-color: rgba(124, 217, 214, 0.22);
}
.transcript-row[data-speaker="output"] {
  border-color: rgba(180, 255, 90, 0.22);
}
.transcript-label {
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--ink);
}
.transcript-row[data-speaker="input"] .transcript-label {
  color: var(--accent);
}
.transcript-row[data-speaker="output"] .transcript-label {
  color: #b4ff5a;
}
.transcript-body {
  color: var(--ink);
}

/* ── Debug overlay (ENG-2384, ?debug=1 only) ─────────────────────────── */
#debug-overlay {
  position: fixed;
  bottom: 16px;
  right: 16px;
  width: min(360px, 90vw);
  max-height: 70vh;
  overflow-y: auto;
  z-index: 9999;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.5;
  background: rgba(8, 12, 22, 0.92);
  color: var(--ink);
  border: 1px solid rgba(124, 217, 214, 0.35);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  padding: 10px 12px;
  backdrop-filter: blur(6px);
}
#debug-overlay header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-bottom: 6px;
  margin-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  letter-spacing: 0.06em;
  font-size: 10.5px;
  text-transform: uppercase;
}
#debug-overlay header .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
}
#debug-overlay header .dim {
  margin-left: auto;
  color: var(--ink-mute);
  font-size: 10px;
  letter-spacing: 0;
  text-transform: none;
}
#debug-overlay dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 12px;
  row-gap: 2px;
  margin: 0;
}
#debug-overlay dt {
  color: var(--ink-mute);
}
#debug-overlay dd {
  margin: 0;
  word-break: break-all;
}
#debug-overlay .transcripts {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
#debug-overlay .transcripts .row {
  margin-bottom: 4px;
}
#debug-overlay .transcripts strong {
  color: var(--accent);
  font-weight: 600;
  margin-right: 4px;
}

/* CTA button: same element morphs label across states. */
.cta-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.cta {
  appearance: none;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  font-size: clamp(17px, 2vw, 19px);
  letter-spacing: 0.01em;
  color: #04221f;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  padding: 18px 40px;
  border-radius: 999px;
  box-shadow:
    0 12px 28px rgba(14, 138, 134, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transition:
    transform 80ms ease,
    box-shadow 200ms ease,
    opacity 200ms ease;
}
.cta:hover,
.cta:focus-visible {
  transform: translateY(-1px);
  outline: none;
}
.cta:active {
  transform: translateY(1px);
}
.cta:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

/* Secondary CTA (end demo) — subdued, danger-tinted. */
.cta-secondary {
  background: linear-gradient(135deg, #2a3450, #1a2238);
  color: var(--ink);
  box-shadow:
    0 8px 20px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  padding: 14px 28px;
  font-size: clamp(15px, 1.6vw, 17px);
}
.cta-secondary:hover,
.cta-secondary:focus-visible {
  background: linear-gradient(135deg, #3a2434, #2a1822);
  color: var(--danger);
}

/* Primary CTA visibility: hidden when call is live (only end button shows). */
body[data-state="connected"] #cta {
  display: none;
}
body[data-state="ringing"] .cta {
  background: linear-gradient(135deg, #b4ff5a, #4caf50);
}

.copy.error {
  border-color: rgba(255, 118, 118, 0.25);
}

.footnote {
  text-align: center;
  color: var(--ink-mute);
  font-size: 13px;
  opacity: 0.85;
}
.footnote p {
  margin: 0;
}

/* Reduce-motion respect. */
@media (prefers-reduced-motion: reduce) {
  body[data-state="ringing"] .copy[data-show-when="ringing"] h1,
  .lena-status[data-status="thinking"]::before {
    animation: none;
  }
}
