/*
 * PreVU Labs · v1.4.3 · voice-widget.css
 * Floating bottom-right Voice AI widget · powered by ElevenLabs Conversational AI.
 *
 * Two visual states ·
 *   1. Launcher (collapsed) — 56x56 circle fixed to bottom-right corner, always visible.
 *   2. Panel (expanded)     — 340x500 rounded card, appears above the launcher.
 *
 * Colour tokens (--brand-indigo · --brand-orange etc.) come from site.css.
 * Trade-off · we lean on the existing indigo accent rather than inventing a new purple —
 *   keeps the brand consistent and means one CSS change ripples across the whole site.
 *
 * Motion respects prefers-reduced-motion (mirrors site.js discipline).
 */

/* ============================================================================
 * 1 · Launcher (collapsed button in bottom-right corner)
 * ============================================================================ */

.pv-voice-launcher {
  /* Fixed-position so it stays visible on scroll — matches Intercom/Vapi convention. */
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;

  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 0;
  cursor: pointer;

  /* Brand indigo → indigo-hi gradient. Indigo is the closest thing in our palette
     to "voice AI purple" — signals interactivity without clashing with brand orange. */
  background: linear-gradient(135deg, var(--brand-indigo) 0%, var(--brand-indigo-hi) 100%);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.08) inset;

  display: flex;
  align-items: center;
  justify-content: center;

  transition: transform var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}

/* Hover lift · gentle scale-up + shadow bloom for tactile feedback. */
.pv-voice-launcher:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.14) inset;
}

.pv-voice-launcher:focus-visible {
  outline: 2px solid var(--brand-indigo-hi);
  outline-offset: 3px;
}

/* Launcher icon (SVG waveform bars). */
.pv-voice-launcher svg {
  width: 26px;
  height: 26px;
  color: #fff;
}

/* When panel is open we swap the icon to a chevron/close-hint · handled by JS class. */
.pv-voice-launcher.is-open {
  background: linear-gradient(135deg, var(--brand-indigo-lo) 0%, var(--brand-indigo) 100%);
}

/* ---- Waveform bars inside the launcher ---- */
.pv-voice-launcher .pv-bar {
  fill: currentColor;
  transform-origin: center;
  animation: pv-bar-idle 1.6s ease-in-out infinite;
}
.pv-voice-launcher .pv-bar:nth-child(1) { animation-delay: 0.0s; }
.pv-voice-launcher .pv-bar:nth-child(2) { animation-delay: 0.15s; }
.pv-voice-launcher .pv-bar:nth-child(3) { animation-delay: 0.30s; }
.pv-voice-launcher .pv-bar:nth-child(4) { animation-delay: 0.45s; }

@keyframes pv-bar-idle {
  0%, 100% { transform: scaleY(0.5); }
  50%      { transform: scaleY(1);   }
}

/* ============================================================================
 * 2 · "Try our Voice AI" chip — small nudge that fades in on first visit
 * ============================================================================ */

.pv-voice-chip {
  /* Sits above the launcher · pointer-events off so it doesn't block clicks. */
  position: fixed;
  bottom: 30px;
  right: 92px;
  z-index: 9998;

  padding: 8px 14px 8px 12px;
  border-radius: 999px;
  background: var(--bg-3);
  color: var(--fg-0);
  border: 1px solid var(--line-2);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);

  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;

  display: flex;
  align-items: center;
  gap: 8px;

  opacity: 0;
  transform: translateX(8px);
  transition: opacity 400ms var(--ease-out), transform 400ms var(--ease-out);
  pointer-events: none;
}

.pv-voice-chip.is-visible {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

.pv-voice-chip button {
  /* Dismiss X — tiny, subtle. */
  background: transparent;
  border: 0;
  color: var(--fg-2);
  cursor: pointer;
  padding: 0 2px;
  font-size: 15px;
  line-height: 1;
}

.pv-voice-chip button:hover { color: var(--fg-0); }

/* ============================================================================
 * 3 · Panel (expanded voice-chat surface)
 * ============================================================================ */

.pv-voice-panel {
  position: fixed;
  bottom: 96px;
  right: 24px;
  z-index: 9999;

  width: 340px;
  height: 500px;
  border-radius: 16px;
  overflow: hidden;

  background: var(--bg-2);
  border: 1px solid var(--line-2);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);

  display: none;
  flex-direction: column;

  /* Enter animation applied via JS class-toggle · avoids "flash on load". */
  transform-origin: bottom right;
  opacity: 0;
  transform: translateY(12px) scale(0.96);
  transition: opacity 220ms var(--ease-out), transform 220ms var(--ease-out);
}

.pv-voice-panel.is-open {
  display: flex;
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* Mobile · full-width with a small inset so it doesn't touch screen edges. */
@media (max-width: 480px) {
  .pv-voice-panel {
    right: 12px;
    left: 12px;
    width: auto;
    height: 70vh;
    bottom: 88px;
  }
  .pv-voice-launcher { bottom: 16px; right: 16px; }
  .pv-voice-chip { right: 80px; bottom: 22px; }
}

/* ---- Header (partner mark + minimise + close) ---- */
.pv-voice-panel__header {
  height: 60px;
  padding: 0 12px 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,0.02) 0%, transparent 100%);
}

.pv-voice-panel__brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--fg-0);
  letter-spacing: -0.01em;
}

.pv-voice-panel__brand small {
  display: block;
  font-family: 'Inter', sans-serif;
  font-weight: 400;
  font-size: 11px;
  color: var(--fg-2);
  margin-top: 2px;
}

.pv-voice-panel__brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--brand-indigo) 0%, var(--brand-indigo-hi) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.pv-voice-panel__actions {
  display: flex;
  gap: 4px;
}

.pv-voice-panel__actions button {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: transparent;
  border: 0;
  color: var(--fg-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}

.pv-voice-panel__actions button:hover {
  background: var(--bg-3);
  color: var(--fg-0);
}

/* ---- Body (waveform + transcript) ---- */
.pv-voice-panel__body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 20px 16px 12px;
  gap: 12px;
}

.pv-voice-waveform {
  /* Large idle/speaking waveform circle. */
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  position: relative;
}

.pv-voice-waveform::before {
  /* Soft ring behind the bars — visual anchor. */
  content: '';
  position: absolute;
  inset: 15px 90px;
  border-radius: 999px;
  background: radial-gradient(circle at center,
    var(--brand-indigo-glow) 0%,
    transparent 70%);
  filter: blur(6px);
  z-index: 0;
}

.pv-voice-waveform .pv-wf-bar {
  position: relative;
  width: 6px;
  border-radius: 3px;
  background: var(--brand-indigo-hi);
  height: 40px;
  transform-origin: center;
  animation: pv-wf-idle 1.8s ease-in-out infinite;
  z-index: 1;
}

.pv-voice-waveform .pv-wf-bar:nth-child(1) { animation-delay: 0.00s; }
.pv-voice-waveform .pv-wf-bar:nth-child(2) { animation-delay: 0.15s; }
.pv-voice-waveform .pv-wf-bar:nth-child(3) { animation-delay: 0.30s; }
.pv-voice-waveform .pv-wf-bar:nth-child(4) { animation-delay: 0.45s; }
.pv-voice-waveform .pv-wf-bar:nth-child(5) { animation-delay: 0.60s; }
.pv-voice-waveform .pv-wf-bar:nth-child(6) { animation-delay: 0.75s; }
.pv-voice-waveform .pv-wf-bar:nth-child(7) { animation-delay: 0.90s; }

@keyframes pv-wf-idle {
  0%, 100% { transform: scaleY(0.35); opacity: 0.75; }
  50%      { transform: scaleY(1.0);  opacity: 1;    }
}

/* Speaking state — faster, taller pulses. Applied by JS. */
.pv-voice-waveform.is-speaking .pv-wf-bar {
  animation-duration: 0.9s;
  background: var(--brand-orange-hi);
}
.pv-voice-waveform.is-listening .pv-wf-bar {
  animation-duration: 1.2s;
  background: var(--brand-emerald);
}

/* ---- Transcript (rolling turn history) ---- */
.pv-voice-transcript {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 4px 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.pv-voice-turn {
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
  max-width: 88%;
  animation: pv-turn-in 260ms var(--ease-out);
}

@keyframes pv-turn-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0);   }
}

.pv-voice-turn--assistant {
  align-self: flex-start;
  background: var(--bg-3);
  color: var(--fg-0);
  border: 1px solid var(--line);
}

.pv-voice-turn--user {
  align-self: flex-end;
  background: var(--brand-indigo);
  color: #fff;
  border: 1px solid var(--brand-indigo-hi);
}

/* ---- Footer (mic button + fallback + demo-mode label) ---- */
.pv-voice-panel__footer {
  padding: 12px 16px 14px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.pv-voice-mic {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 0;
  cursor: pointer;
  background: linear-gradient(135deg, var(--brand-indigo) 0%, var(--brand-indigo-hi) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px var(--brand-indigo-glow);
  transition: transform var(--dur-fast) var(--ease-out);
}

.pv-voice-mic:hover { transform: scale(1.06); }
.pv-voice-mic:active { transform: scale(0.98); }

.pv-voice-mic.is-active {
  background: linear-gradient(135deg, var(--brand-orange) 0%, var(--brand-orange-hi) 100%);
  box-shadow: 0 4px 14px var(--brand-orange-glow);
}

.pv-voice-fallback-link {
  background: none;
  border: 0;
  color: var(--fg-2);
  cursor: pointer;
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 0;
}
.pv-voice-fallback-link:hover { color: var(--fg-0); }

.pv-voice-footer-note {
  font-size: 10.5px;
  color: var(--fg-3);
  text-align: center;
  letter-spacing: 0.02em;
}

/* ============================================================================
 * 4 · Above-fold agent greeter · v1.7.1 · split-fold + shrunk mount
 * ============================================================================
 * v1.7   · Pav decision 15-08-26 PM · widget was the primary demo surface
 *          placed immediately below the hero with a tall min-height (640px).
 * v1.7.1 · Pav flag 15-08-26 PM (late) · giant empty rectangle mid-page when
 *          the ElevenLabs widget hadn't rendered · fix ·
 *          (a) split the single hero card into TWO sections · a slim intro
 *              card (heading + copy · #voice-demo) and a separate widget
 *              fold (#voice-demo-widget) so the widget has its own real
 *              estate without a giant empty container hiding empty when the
 *              vendor script hasn't drawn.
 *          (b) card min-height goes from 640px to auto (heading card sits
 *              at natural height); mount container gets a 320px placeholder
 *              floor (still visible but not painful).
 *          (c) inline placeholder text renders inside the mount immediately,
 *              swapped by voice-widget.js after 5s if the vendor hasn't drawn.
 * ============================================================================ */

.pv-agent-greeter {
  padding: 40px 0 24px;
  position: relative;
}

/* v1.7.1 · second fold, widget-only surface. Sits below the intro card so the
 * widget claims its own visual real estate. Slightly tighter top padding
 * because the intro card immediately above already leads the eye down. */
.pv-agent-widget-fold {
  padding: 8px 0 56px;
  position: relative;
}

.pv-agent-card {
  display: block;
  padding: 32px 32px 24px;
  border-radius: 24px;
  background: linear-gradient(180deg, var(--bg-3) 0%, var(--bg-2) 100%);
  border: 1px solid var(--line-2);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5),
              0 0 0 1px rgba(91, 109, 255, 0.14) inset;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 480ms var(--ease-out), transform 480ms var(--ease-out);
  /* v1.7.1 · min-height auto · card sits at natural height when it holds
   * only the heading strip, and grows to fit the widget when it holds the
   * live mount. Kills the mid-page empty rectangle. */
  min-height: auto;
}
.pv-agent-card.is-in-view {
  opacity: 1;
  transform: translateY(0);
}

/* v1.7.1 · slim intro-only card · sits in #voice-demo section above the
 * widget fold. Same visual language as the widget card but tighter padding
 * and no fade-in-on-scroll (renders visible immediately). */
.pv-agent-intro-card {
  display: block;
  padding: 22px 28px;
  border-radius: 24px;
  background: linear-gradient(180deg, var(--bg-3) 0%, var(--bg-2) 100%);
  border: 1px solid var(--line-2);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5),
              0 0 0 1px rgba(91, 109, 255, 0.14) inset;
}
.pv-agent-intro-card .pv-agent-heading {
  margin-bottom: 0;
}

/* Heading strip · avatar + eyebrow + headline + sub as a compact top row.
   Everything below (the widget + consent banner) claims the full card width. */
.pv-agent-heading {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 20px;
  align-items: start;
  margin-bottom: 20px;
}

.pv-agent-avatar {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--brand-indigo) 0%, var(--brand-indigo-hi) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 18px var(--brand-indigo-glow);
  flex-shrink: 0;
}

.pv-agent-eyebrow {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--brand-indigo-hi);
  margin-bottom: 6px;
}

.pv-agent-headline {
  margin: 0 0 8px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: clamp(22px, 3.2vw, 32px);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--fg-0);
}

.pv-agent-sub {
  margin: 0 0 16px;
  color: var(--fg-1);
  font-size: 15px;
  line-height: 1.55;
  max-width: 62ch;
}

/* -- Live mount · the ElevenLabs widget host --
 * v1.7.1 · shrink from 560px floor to 320px so an un-rendered widget doesn't
 * leave a giant empty rectangle mid-page. The vendor's <elevenlabs-convai>
 * element sizes itself to its content once the script loads, so we don't need
 * to reserve tall vertical space up-front. */
.pv-agent-live {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.pv-agent-mount {
  min-height: 320px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.02);
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.04);
  position: relative;
  /* Center the placeholder text vertically while widget hasn't rendered. */
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
}

/* v1.7.1 · placeholder shown inline before the vendor script has drawn.
 * voice-widget.js swaps this out on mount, or replaces with a fallback CTA
 * after 5s if the vendor never renders. */
.pv-agent-mount-placeholder {
  text-align: center;
  color: var(--fg-2);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  line-height: 1.55;
  padding: 24px 16px;
  margin: 0;
}
.pv-agent-mount-placeholder strong {
  color: var(--fg-0);
  font-weight: 600;
  display: block;
  margin-bottom: 6px;
  font-size: 15px;
}
.pv-agent-mount-placeholder a {
  color: var(--brand-orange-hi);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.pv-agent-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.pv-agent-status {
  margin: 0;
  color: var(--fg-3);
  font-size: 12px;
  letter-spacing: 0.02em;
}

/* -- Consent banner (below the widget · Option A pattern) --
   Slim horizontal strip · privacy note left · pause + read-privacy right.
   Distinct from the consent-first gate we shipped in v1.6 · lighter weight,
   never blocks first interaction. */
.pv-agent-consent-banner {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.pv-agent-consent-banner-text {
  color: var(--fg-2);
  font-size: 12.5px;
  line-height: 1.5;
  margin: 0;
  flex: 1 1 320px;
  min-width: 240px;
}
.pv-agent-consent-banner-text a {
  color: var(--brand-orange-hi);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.pv-agent-consent-banner-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.pv-agent-pause-btn,
.pv-agent-resume-btn {
  background: transparent;
  border: 1px solid var(--line-2);
  color: var(--fg-1);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out);
}
.pv-agent-pause-btn:hover,
.pv-agent-resume-btn:hover {
  background: var(--bg-3);
  color: var(--fg-0);
  border-color: var(--fg-3);
}

/* -- Paused placeholder · shown when visitor previously declined -- */
.pv-agent-paused {
  min-height: 220px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 40px 24px;
  text-align: center;
}
.pv-agent-paused-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 18px;
  font-weight: 600;
  color: var(--fg-0);
  margin: 0;
}
.pv-agent-paused-sub {
  color: var(--fg-2);
  font-size: 13px;
  line-height: 1.55;
  margin: 0;
  max-width: 44ch;
}

/* -- Demo bubble (shown when agent-id absent) -- */
.pv-agent-demo-bubble,
.pv-agent-decline-bubble {
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  color: var(--fg-0);
  font-size: 14px;
  line-height: 1.55;
}
.pv-agent-decline-bubble a {
  color: var(--brand-orange-hi);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* -- Mobile · stack avatar above copy · widget min-height eased -- */
@media (max-width: 640px) {
  .pv-agent-card {
    padding: 22px 20px;
    min-height: 0;
  }
  .pv-agent-heading {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .pv-agent-avatar {
    width: 52px;
    height: 52px;
    border-radius: 12px;
  }
  .pv-agent-avatar svg { width: 28px; height: 28px; }
  .pv-agent-mount {
    /* v1.7.1 · mobile matches desktop 320px floor · same rationale, kills
     * the mid-page empty rectangle on phones. */
    min-height: 320px;
  }
  .pv-agent-consent-banner {
    flex-direction: column;
    align-items: stretch;
  }
  .pv-agent-consent-banner-actions {
    justify-content: flex-start;
  }
}

/* ============================================================================
 * 5 · Reduced-motion respect · kill animations for users who ask for it
 * ============================================================================ */

@media (prefers-reduced-motion: reduce) {
  .pv-voice-launcher .pv-bar,
  .pv-voice-waveform .pv-wf-bar {
    animation: none !important;
  }
  .pv-voice-panel,
  .pv-voice-chip,
  .pv-agent-card {
    transition: none !important;
  }
  .pv-voice-turn { animation: none !important; }
  .pv-agent-card { opacity: 1; transform: none; }
}
