/**
 * TouchPass — Tody Voice Sales Assistant Styles (voice-agent.css)
 * Adheres strictly to the 6 UX Invariants of /voice-landing-agent:
 * 1. 85vw Expanded Bottom HUD (w-[85vw] max-w-4xl, fixed bottom-4)
 * 2. No Mascot during speech (launcher only; clean status dot + 5-bar waveform)
 * 3. 2-Line Rolling Captions (line-clamp-2 min-h-[2.6em] max-h-[2.75em])
 * 4. Max 2 Buttons Per Step (1 Primary #1D1D1F + 1 Secondary #F3F4F1)
 * 5. Zero Mic Permission Friction (Listen & Choose model)
 * 6. Two-Way DOM Sync & Compact Demo Companion (388px in bottom-right corner)
 * Light-First Daylight aesthetic: 85/10/5 color rationing, 1px hairline borders.
 */

:root {
  --tody-bg: #FFFFFF;
  --tody-bg-subtle: #F7F8FA;
  --tody-border: #E4E4E7;
  --tody-border-subtle: rgba(0, 0, 0, 0.08);
  --tody-text: #1D1D1F;
  --tody-text-muted: #6E6E73;
  --tody-primary: #1D1D1F;
  --tody-primary-hover: #000000;
  --tody-secondary: #F3F4F1;
  --tody-secondary-hover: #E7E8E4;
  --tody-accent: #1F6E5A;
  --tody-accent-light: rgba(31, 110, 90, 0.12);
  --tody-radius-hud: 16px;
  --tody-radius-btn: 8px;
  --tody-shadow: 0 8px 32px -4px rgba(15, 23, 42, 0.12), 0 2px 8px -2px rgba(15, 23, 42, 0.04);
}

/* ==========================================================================
   1. Floating Idle Launcher (Only place avatar/mascot is visible)
   ========================================================================== */
.tody-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9990;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  background: var(--tody-bg);
  border: 1px solid var(--tody-border);
  padding: 8px 16px 8px 10px;
  border-radius: 9999px;
  box-shadow: var(--tody-shadow);
  transition: all 180ms cubic-bezier(0.2, 0, 0, 1);
  user-select: none;
}

.tody-launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 36px -4px rgba(15, 23, 42, 0.16);
  border-color: rgba(31, 110, 90, 0.35);
}

.tody-launcher.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px) scale(0.95);
}

.tody-launcher-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #EAECEF;
  border: 1px solid var(--tody-border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.tody-launcher-avatar svg {
  width: 20px;
  height: 20px;
  color: var(--tody-accent);
}

.tody-launcher-text {
  display: flex;
  flex-direction: column;
}

.tody-launcher-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--tody-text);
  line-height: 1.2;
}

.tody-launcher-sub {
  font-size: 11px;
  color: var(--tody-text-muted);
  line-height: 1.2;
  margin-top: 2px;
}

/* ==========================================================================
   2. Main HUD Container (Invariant 1: 85vw Expanded Bottom HUD)
   ========================================================================== */
.tody-hud-overlay {
  position: fixed;
  inset-inline: 0;
  bottom: 16px;
  z-index: 9995;
  display: flex;
  justify-content: center;
  pointer-events: none;
  padding-inline: 16px;
  transition: all 240ms cubic-bezier(0.2, 0, 0, 1);
}

.tody-hud-card {
  pointer-events: auto;
  width: 85vw;
  max-width: 56rem; /* 896px = max-w-4xl */
  background: var(--tody-bg);
  border: 1px solid var(--tody-border);
  border-radius: var(--tody-radius-hud);
  box-shadow: var(--tody-shadow);
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all 260ms cubic-bezier(0.2, 0, 0, 1);
  transform: translateY(0);
  opacity: 1;
}

.tody-hud-overlay.is-closed .tody-hud-card {
  opacity: 0;
  transform: translateY(24px) scale(0.98);
  pointer-events: none;
}

/* Invariant 6: Compact mode during demo (collapseToCorner) */
.tody-hud-overlay.is-compact {
  justify-content: flex-end;
  padding-right: 20px;
}

.tody-hud-overlay.is-compact .tody-hud-card {
  width: 388px;
  max-width: calc(100vw - 32px);
  padding: 12px 14px;
  gap: 8px;
}

/* ==========================================================================
   3. Header Bar (Status Dot, Waveform, Close) — NO MASCOT DURING SPEECH
   ========================================================================== */
.tody-hud-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.tody-status-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--tody-text);
  letter-spacing: -0.01em;
}

.tody-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--tody-accent);
  position: relative;
}

.tody-status-dot::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: var(--tody-accent-light);
  animation: todyPulseDot 2s ease-out infinite;
}

@keyframes todyPulseDot {
  0% { transform: scale(0.8); opacity: 1; }
  100% { transform: scale(2.2); opacity: 0; }
}

.tody-role-tag {
  font-size: 11px;
  font-weight: 500;
  color: var(--tody-text-muted);
  background: var(--tody-bg-subtle);
  padding: 2px 7px;
  border-radius: 4px;
  margin-left: 4px;
}

/* 5-Bar AudioWaveform Visualizer */
.tody-waveform {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 18px;
  padding-inline: 4px;
}

.tody-wave-bar {
  width: 3px;
  height: 4px;
  border-radius: 2px;
  background: var(--tody-accent);
  transition: height 120ms ease;
}

.tody-waveform.is-active .tody-wave-bar:nth-child(1) {
  animation: todyWave 0.9s ease-in-out infinite alternate;
}
.tody-waveform.is-active .tody-wave-bar:nth-child(2) {
  animation: todyWave 0.75s ease-in-out 0.15s infinite alternate;
}
.tody-waveform.is-active .tody-wave-bar:nth-child(3) {
  animation: todyWave 1.05s ease-in-out 0.3s infinite alternate;
}
.tody-waveform.is-active .tody-wave-bar:nth-child(4) {
  animation: todyWave 0.85s ease-in-out 0.2s infinite alternate;
}
.tody-waveform.is-active .tody-wave-bar:nth-child(5) {
  animation: todyWave 0.95s ease-in-out 0.4s infinite alternate;
}

@keyframes todyWave {
  0% { height: 4px; opacity: 0.5; }
  50% { height: 16px; opacity: 0.9; }
  100% { height: 8px; opacity: 1; }
}

/* Close & Minimize buttons */
.tody-hud-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tody-icon-btn {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--tody-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: all 120ms ease;
}

.tody-icon-btn:hover {
  background: var(--tody-bg-subtle);
  color: var(--tody-text);
}

.tody-icon-btn svg {
  width: 14px;
  height: 14px;
  stroke-width: 1.75;
}

/* ==========================================================================
   4. Caption Container (Invariant 3: 2-Line Rolling Captions)
   ========================================================================== */
.tody-caption-container {
  min-height: 2.6em;
  max-height: 2.75em;
  display: flex;
  align-items: center;
  overflow: hidden;
}

.tody-caption-text {
  font-size: 14px;
  line-height: 1.35;
  color: var(--tody-text);
  font-weight: 450;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 150ms ease, transform 150ms ease;
}

.tody-caption-text.is-updating {
  opacity: 0.4;
  transform: translateY(3px);
}

/* ==========================================================================
   5. Buttons Area (Invariant 4: Strictly Max 2 Buttons Per Step)
   ========================================================================== */
.tody-choices-container {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.tody-choice-btn {
  height: 36px;
  padding: 0 16px;
  border-radius: var(--tody-radius-btn);
  font-size: 13px;
  white-space: nowrap;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 140ms cubic-bezier(0.2, 0, 0, 1);
  text-decoration: none;
  user-select: none;
}

.tody-choice-btn.primary {
  background: var(--tody-primary);
  color: #FFFFFF;
  font-weight: 600;
  border: 1px solid transparent;
}

.tody-choice-btn.primary:hover {
  background: var(--tody-primary-hover);
  transform: translateY(-1px);
}

.tody-choice-btn.secondary {
  background: var(--tody-secondary);
  color: var(--tody-text);
  font-weight: 500;
  border: 1px solid var(--tody-border);
}

.tody-choice-btn.secondary:hover {
  background: var(--tody-secondary-hover);
  transform: translateY(-1px);
}

/* When in compact demo mode, stack or tighten buttons */
.tody-hud-overlay.is-compact .tody-choices-container {
  flex-wrap: wrap;
  gap: 6px;
}

.tody-hud-overlay.is-compact .tody-choice-btn {
  height: 32px;
  padding: 0 12px;
  font-size: 12px;
  flex: 1 1 calc(50% - 3px);
}

/* ==========================================================================
   6. DOM Sync & Visual Highlight Effects (Invariant 6)
   ========================================================================== */
.tody-highlight-ring {
  outline: 2px solid var(--tody-accent) !important;
  box-shadow: 0 0 0 4px var(--tody-accent-light), 0 8px 24px rgba(31, 110, 90, 0.16) !important;
  transition: all 300ms cubic-bezier(0.2, 0, 0, 1) !important;
}

.tody-pulse-ring {
  animation: todyPulseRing 1.5s cubic-bezier(0.2, 0, 0, 1) infinite !important;
}

@keyframes todyPulseRing {
  0% {
    box-shadow: 0 0 0 0 rgba(31, 110, 90, 0.5);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(31, 110, 90, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(31, 110, 90, 0);
  }
}

/* Quick trigger button styles for Header & Hero */
.tody-voice-trigger-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(31, 110, 90, 0.08);
  color: var(--tody-accent);
  border: 1px solid rgba(31, 110, 90, 0.2);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  cursor: pointer;
  transition: all 140ms ease;
  white-space: nowrap;
}

.tody-voice-trigger-btn:hover {
  background: rgba(31, 110, 90, 0.14);
  border-color: rgba(31, 110, 90, 0.35);
  transform: translateY(-1px);
}

.tody-voice-trigger-btn svg {
  width: 14px;
  height: 14px;
  stroke-width: 1.75;
}

.tody-voice-hero-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tody-voice-hero-btn svg {
  width: 16px;
  height: 16px;
  stroke-width: 1.75;
}

/* Mobile responsive adjustments */
@media (max-width: 640px) {
  .tody-hud-card {
    width: calc(100vw - 24px);
    max-width: none;
    padding: 12px 14px;
  }
  .tody-choices-container {
    flex-direction: column;
    gap: 6px;
  }
  .tody-choice-btn {
    width: 100%;
  }
  .tody-launcher {
    bottom: 16px;
    right: 16px;
    padding: 6px 12px 6px 8px;
  }
}

/* Hide header quick trigger on mobile to prevent navbar overflow */
@media (max-width: 859px) {
  #headerVoiceTriggerBtn {
    display: none !important;
  }
}

