/* PGH brand palette */
:root {
  --pgh-blue: #1a3f6f;
  --pgh-blue-deep: #0d2546;
  --pgh-grey: #8a9bb0;
  --pgh-gold: #c9a84c;
  --pgh-cyan: #4ec1d3;
  --bg-0: #06101f;
  --bg-1: #0d1c33;
  --fg: #eef2f8;
  --fg-dim: #a9b6c9;
  --danger: #e0524c;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: radial-gradient(ellipse at top, var(--bg-1) 0%, var(--bg-0) 70%);
  color: var(--fg);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#stage {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

#scene {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  z-index: 0;
}

/* Header brand */
.brand {
  position: absolute;
  top: clamp(16px, 3vw, 32px);
  left: clamp(16px, 3vw, 32px);
  z-index: 2;
  pointer-events: none;
  user-select: none;
}
.brand-mark {
  font-weight: 800;
  font-size: clamp(20px, 2.4vw, 32px);
  letter-spacing: 0.16em;
  color: var(--fg);
}
.brand-sub {
  margin-top: 4px;
  font-size: clamp(11px, 1.1vw, 14px);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-dim);
}

/* -------- Pipeline switcher (top-right) -------- */
.pipeline-switcher {
  position: absolute;
  top: clamp(16px, 3vw, 32px);
  right: clamp(16px, 3vw, 32px);
  z-index: 3;
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(13, 28, 51, 0.65);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.07);
}
.ps-chip {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--fg-dim);
  font-size: clamp(10px, 1vw, 12px);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 180ms ease, color 180ms ease;
}
.ps-chip:hover { color: var(--fg); }
.ps-chip[aria-selected="true"] {
  background: rgba(201, 168, 76, 0.18);
  color: var(--pgh-gold);
}

/* -------- State pill -------- */
/* Floats just above the sphere so the user always knows what's happening. */
.state-pill {
  position: absolute;
  top: clamp(70px, 11vh, 110px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(13, 28, 51, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: clamp(11px, 1.1vw, 13px);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-dim);
  transition: color 220ms ease, border-color 220ms ease, background 220ms ease;
}
.state-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--fg-dim);
  box-shadow: 0 0 0 0 transparent;
  transition: background 220ms ease, box-shadow 220ms ease;
}

.state-pill.state-idle      .state-dot { background: var(--fg-dim); }
.state-pill.state-listening { color: var(--pgh-cyan); border-color: rgba(78, 193, 211, 0.4); }
.state-pill.state-listening .state-dot {
  background: var(--pgh-cyan);
  box-shadow: 0 0 0 6px rgba(78, 193, 211, 0.18);
  animation: dotPulse 1.4s ease-in-out infinite;
}
.state-pill.state-thinking  { color: var(--pgh-grey); border-color: rgba(138, 155, 176, 0.35); }
.state-pill.state-thinking  .state-dot {
  background: var(--pgh-grey);
  animation: dotBlink 1s steps(2, end) infinite;
}
.state-pill.state-speaking  { color: var(--pgh-gold); border-color: rgba(201, 168, 76, 0.45); }
.state-pill.state-speaking  .state-dot {
  background: var(--pgh-gold);
  box-shadow: 0 0 0 6px rgba(201, 168, 76, 0.18);
}
.state-pill.state-error     { color: var(--danger); border-color: rgba(224, 82, 76, 0.45); }
.state-pill.state-error     .state-dot { background: var(--danger); }

@keyframes dotPulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(78, 193, 211, 0.20); }
  50%      { box-shadow: 0 0 0 12px rgba(78, 193, 211, 0.0); }
}
@keyframes dotBlink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.3; }
}

/* -------- Transcript chip -------- */
.transcript-chip {
  position: absolute;
  top: clamp(120px, 17vh, 160px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  max-width: min(80vw, 640px);
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  font-size: clamp(11px, 1.1vw, 13px);
  font-style: italic;
  color: var(--fg-dim);
  letter-spacing: 0.01em;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.transcript-chip[hidden] { display: none; }

/* -------- Answer card -------- */
/* Lives below the sphere, fades in after speaking ends. */
.answer-card {
  position: absolute;
  left: 50%;
  bottom: clamp(220px, 28vh, 280px);
  transform: translateX(-50%);
  width: min(92vw, 880px);
  max-height: 50vh;
  overflow-y: auto;
  padding: 18px 22px 16px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(13, 28, 51, 0.72) 0%, rgba(6, 16, 31, 0.85) 100%);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(201, 168, 76, 0.18);
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.6);
  z-index: 2;
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: opacity 320ms ease, transform 320ms ease;
}
.answer-card[hidden] { display: none; }
.answer-card.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.answer-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}
.answer-badges:empty { display: none; }

.badge {
  flex: 0 1 auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 130px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(26, 63, 111, 0.45);
  border: 1px solid rgba(201, 168, 76, 0.22);
}
.badge-label {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-dim);
}
.badge-value {
  display: flex;
  align-items: baseline;
  gap: 4px;
  color: var(--fg);
  font-weight: 700;
  font-size: clamp(20px, 2.4vw, 28px);
  line-height: 1.1;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.badge-unit {
  font-size: 0.55em;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--fg-dim);
  font-weight: 600;
}
.badge-year {
  font-size: 11px;
  color: var(--pgh-gold);
  letter-spacing: 0.06em;
}

.answer-prose {
  margin: 0;
  font-size: clamp(13px, 1.4vw, 16px);
  line-height: 1.55;
  color: var(--fg);
  text-wrap: balance;
}

.answer-cites {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}
.cite-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(201, 168, 76, 0.10);
  border: 1px solid rgba(201, 168, 76, 0.28);
  font-size: 11px;
  color: var(--pgh-gold);
  letter-spacing: 0.02em;
  font-feature-settings: "tnum";
}

/* -------- Push-to-talk -------- */
.ptt {
  position: absolute;
  left: 50%;
  bottom: clamp(40px, 7vh, 80px);
  transform: translateX(-50%);
  width: clamp(110px, 14vw, 150px);
  height: clamp(110px, 14vw, 150px);
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  z-index: 3;
  display: grid;
  place-items: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}
.ptt-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px solid rgba(201, 168, 76, 0.5);
  transition: transform 220ms ease, border-color 220ms ease, box-shadow 220ms ease;
}
.ptt-core {
  position: absolute;
  inset: 12px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #2a5b95 0%, #1a3f6f 60%, #0e2649 100%);
  box-shadow:
    0 8px 30px rgba(26, 63, 111, 0.45),
    inset 0 0 24px rgba(201, 168, 76, 0.15);
  transition: transform 220ms ease, box-shadow 220ms ease;
}
.ptt-label {
  position: relative;
  z-index: 1;
  font-size: clamp(12px, 1.3vw, 15px);
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg);
}
.ptt:hover .ptt-ring { border-color: var(--pgh-gold); }
.ptt.is-recording .ptt-ring {
  border-color: var(--pgh-cyan);
  box-shadow: 0 0 0 8px rgba(78, 193, 211, 0.12);
  animation: pulseRing 1.2s ease-in-out infinite;
}
.ptt.is-recording .ptt-core {
  background: radial-gradient(circle at 30% 30%, #67d0e0 0%, #1f7588 70%);
  transform: scale(0.94);
}
.ptt.is-busy { pointer-events: none; opacity: 0.7; }

@keyframes pulseRing {
  0%, 100% { box-shadow: 0 0 0 6px rgba(78, 193, 211, 0.12); }
  50%      { box-shadow: 0 0 0 18px rgba(78, 193, 211, 0.0); }
}

/* -------- QR code corner (kiosk only) -------- */
.qr-panel {
  position: absolute;
  bottom: clamp(16px, 3vh, 32px);
  right: clamp(16px, 3vw, 32px);
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px 14px 14px;
  border-radius: 16px;
  background: rgba(238, 242, 248, 0.96);
  border: 1px solid rgba(201, 168, 76, 0.4);
  box-shadow: 0 18px 40px -16px rgba(0, 0, 0, 0.45);
  color: var(--pgh-blue-deep);
  pointer-events: none;
  user-select: none;
}
.qr-img {
  width: clamp(96px, 9vw, 130px);
  height: clamp(96px, 9vw, 130px);
  display: block;
  background: #fff;
  border-radius: 8px;
  padding: 4px;
}
.qr-caption {
  max-width: 140px;
  font-family: "Inter", system-ui, sans-serif;
  line-height: 1.25;
}
.qr-caption-top {
  font-size: clamp(13px, 1.2vw, 15px);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--pgh-blue);
}
.qr-caption-bottom {
  margin-top: 4px;
  font-size: clamp(10px, 0.85vw, 12px);
  letter-spacing: 0.02em;
  color: var(--pgh-blue-deep);
  opacity: 0.85;
}

/* Bottom hint */
.hint {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: rgba(169, 182, 201, 0.45);
}

/* Mobile tweaks */
@media (max-width: 640px) {
  .state-pill   { top: 64px; }
  .transcript-chip { top: 108px; max-width: 90vw; }
  .answer-card  { bottom: 200px; max-height: 42vh; }
  .badge        { min-width: 110px; padding: 8px 12px; }
  /* Already on a phone? You don't need the QR. */
  .qr-panel     { display: none; }
}
