/* ─── SOL chat widget ──────────────────────────────────────────────
 *
 * Floating "Confused? Ask SOL" pill in the bottom-right of every page.
 * Click → opens a chat panel. Posts to /api/ask. One-shot responses.
 *
 * Used on: app.html, docs.html, index.html
 * No external dependencies. Imports nothing else.
 * ───────────────────────────────────────────────────────────────── */

/* Floating action button — sits over content, draws attention */
.sol-fab {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 70;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px 12px 14px;
  background: linear-gradient(135deg, #8b5cf6, #7c3aed);
  color: #fff;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.86rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  border: 0;
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(139, 92, 246, 0.42), 0 2px 6px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}
.sol-fab:hover { transform: translateY(-2px); box-shadow: 0 14px 40px rgba(139, 92, 246, 0.55), 0 4px 10px rgba(0, 0, 0, 0.4); }
.sol-fab:focus-visible { outline: 2px solid #a78bfa; outline-offset: 3px; }
.sol-fab[aria-expanded="true"] { opacity: 0; pointer-events: none; }

.sol-fab-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #f5f5f7 0%, #c4b5fd 35%, #8b5cf6 100%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'Syne', 'Inter', sans-serif;
  font-weight: 800;
  font-size: 0.7rem;
  color: #1a0f2e;
  letter-spacing: 0.04em;
  box-shadow: inset 0 0 6px rgba(255, 255, 255, 0.4);
}

.sol-fab-label {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.15;
}
.sol-fab-label small {
  font-size: 0.66rem;
  font-weight: 500;
  opacity: 0.78;
  letter-spacing: 0.04em;
}

/* Chat panel — full popover */
.sol-panel {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 71;
  width: min(420px, calc(100vw - 32px));
  height: min(620px, calc(100vh - 48px));
  background: #0d0d1a;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7), 0 4px 16px rgba(0, 0, 0, 0.4);
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: sol-pop 0.18s ease;
}
.sol-panel.open { display: flex; }

@keyframes sol-pop {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

.sol-head {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, rgba(139, 92, 246, 0.06), transparent);
}
.sol-head-l { display: flex; align-items: center; gap: 10px; }
.sol-head-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #f5f5f7 0%, #c4b5fd 35%, #8b5cf6 100%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 0.78rem;
  color: #1a0f2e;
  letter-spacing: 0.04em;
}
.sol-head-title { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 0.95rem; color: #f5f5f7; letter-spacing: 0.02em; }
.sol-head-sub {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  color: #6b6b74;
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.sol-head-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.6);
  animation: sol-pulse 2s ease-in-out infinite;
}
@keyframes sol-pulse { 50% { opacity: 0.4; } }

.sol-close {
  background: transparent;
  border: 0;
  color: #6b6b74;
  cursor: pointer;
  padding: 6px 10px;
  font-size: 1.4rem;
  line-height: 1;
  border-radius: 6px;
  transition: color 0.15s ease, background 0.15s ease;
}
.sol-close:hover { color: #f5f5f7; background: rgba(255, 255, 255, 0.05); }

.sol-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.sol-msg {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 14px;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.88rem;
  line-height: 1.55;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.sol-msg.user {
  align-self: flex-end;
  background: rgba(139, 92, 246, 0.16);
  border: 1px solid rgba(139, 92, 246, 0.3);
  color: #f5f5f7;
  border-bottom-right-radius: 4px;
}
.sol-msg.bot {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: #c4c4cf;
  border-bottom-left-radius: 4px;
}
.sol-msg.bot strong { color: #f5f5f7; font-weight: 600; }
.sol-msg.bot em { color: #f5f5f7; font-style: italic; }
.sol-msg.bot code {
  background: rgba(167, 139, 250, 0.12);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.84em;
  padding: 2px 6px;
  border-radius: 4px;
  color: #c4b5fd;
}
.sol-msg.bot a { color: #a78bfa; border-bottom: 1px solid rgba(167, 139, 250, 0.3); text-decoration: none; }
.sol-msg.bot a:hover { border-bottom-color: #a78bfa; }
.sol-msg.error {
  align-self: stretch;
  max-width: 100%;
  background: rgba(239, 68, 68, 0.06);
  border: 1px solid rgba(239, 68, 68, 0.22);
  color: #f5f5f7;
}

/* Typing indicator (3 bouncing dots) */
.sol-msg.thinking {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-bottom-left-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 14px 14px;
}
.sol-msg.thinking span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #a78bfa;
  animation: sol-blink 1.2s ease-in-out infinite both;
}
.sol-msg.thinking span:nth-child(2) { animation-delay: 0.15s; }
.sol-msg.thinking span:nth-child(3) { animation-delay: 0.3s; }
@keyframes sol-blink {
  0%, 80%, 100% { opacity: 0.25; transform: scale(0.85); }
  40% { opacity: 1; transform: scale(1); }
}

/* Suggested-question chips, shown on first open */
.sol-suggestions {
  padding: 0 16px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.sol-suggestion {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #c4c4cf;
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.sol-suggestion:hover {
  background: rgba(139, 92, 246, 0.1);
  border-color: rgba(139, 92, 246, 0.4);
  color: #f5f5f7;
}

.sol-input-row {
  padding: 10px 12px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.sol-input {
  flex: 1;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #f5f5f7;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.9rem;
  line-height: 1.4;
  padding: 9px 12px;
  border-radius: 10px;
  resize: none;
  max-height: 120px;
  min-height: 40px;
  transition: border-color 0.15s ease;
}
.sol-input::placeholder { color: #6b6b74; }
.sol-input:focus {
  outline: none;
  border-color: rgba(139, 92, 246, 0.55);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.sol-send {
  padding: 9px 14px;
  background: #8b5cf6;
  color: #fff;
  border: 0;
  border-radius: 10px;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 0.84rem;
  cursor: pointer;
  transition: background 0.15s ease;
  height: 40px;
}
.sol-send:hover:not(:disabled) { background: #7c3aed; }
.sol-send:disabled { opacity: 0.4; cursor: not-allowed; }

.sol-foot {
  padding: 8px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  color: #6b6b74;
  text-align: center;
}
.sol-foot strong { color: #c4c4cf; font-weight: 500; }

/* Mobile: full-screen panel */
@media (max-width: 600px) {
  .sol-fab {
    bottom: 16px;
    right: 16px;
    padding: 8px 12px 8px 10px;
    font-size: 0.76rem;
    gap: 6px;
  }
  .sol-fab-avatar { width: 22px; height: 22px; font-size: 0.6rem; }
  .sol-fab-label small { display: none; }
  .sol-panel {
    inset: 0;
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    bottom: 0; right: 0;
  }
  .sol-msg { max-width: 92%; font-size: 0.92rem; }
}

/* ════════════════════════════════════════════════════════════════
 *  VOICE MODE — JARVIS-style hands-free overlay
 * ════════════════════════════════════════════════════════════════ */

/* Header buttons — group close + voice */
.sol-head-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.sol-voice-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #c4c4cf;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.sol-voice-btn:hover {
  color: #f5f5f7;
  background: rgba(139, 92, 246, 0.1);
  border-color: rgba(139, 92, 246, 0.4);
}
.sol-voice-btn svg { width: 16px; height: 16px; }

/* Voice overlay — covers the chat panel when active */
.sol-voice {
  position: absolute;
  inset: 0;
  z-index: 5;
  background:
    radial-gradient(ellipse at top, rgba(167, 139, 250, 0.10), transparent 55%),
    rgba(8, 8, 14, 0.96);
  backdrop-filter: blur(16px);
  display: none;
  flex-direction: column;
  border-radius: inherit;
  overflow: hidden;
  opacity: 0;
  transition: opacity 320ms cubic-bezier(0.16, 1, 0.3, 1);
}
.sol-voice.open {
  display: flex;
  opacity: 1;
}

.sol-voice-x {
  position: absolute;
  top: 14px;
  right: 14px;
  background: transparent;
  border: 0;
  color: rgba(255, 255, 255, 0.55);
  font-size: 1.6rem;
  line-height: 1;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  z-index: 2;
  transition: color 0.15s ease, background 0.15s ease;
}
.sol-voice-x:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }

.sol-voice-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 32px 24px;
  text-align: center;
}

/* The orb — central interactive element */
.sol-orb {
  position: relative;
  width: 200px;
  height: 200px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sol-orb-core {
  position: relative;
  z-index: 3;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 28%, #ddd6fe 0%, #a78bfa 35%, #7c3aed 75%, #4c1d95 100%);
  box-shadow:
    0 0 32px rgba(167, 139, 250, 0.55),
    0 0 80px rgba(167, 139, 250, 0.30),
    inset 0 0 24px rgba(255, 255, 255, 0.18);
  transition: transform 280ms cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 280ms ease;
}
.sol-orb-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(167, 139, 250, 0.35);
  pointer-events: none;
  opacity: 0;
}
.sol-orb-ring-1 { inset: 28px; }
.sol-orb-ring-2 { inset: 12px; }
.sol-orb-ring-3 { inset: -4px; }
.sol-orb-wave {
  position: absolute;
  inset: -20px;
  z-index: 1;
  width: calc(100% + 40px);
  height: calc(100% + 40px);
  pointer-events: none;
  opacity: 0;
  transition: opacity 320ms ease;
}

/* IDLE — gentle slow pulse */
.sol-orb.idle .sol-orb-core {
  animation: sol-orb-idle 3.6s ease-in-out infinite;
}
@keyframes sol-orb-idle {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.04); box-shadow: 0 0 40px rgba(167, 139, 250, 0.65), 0 0 96px rgba(167, 139, 250, 0.35), inset 0 0 28px rgba(255, 255, 255, 0.22); }
}
.sol-orb.idle:hover .sol-orb-core {
  transform: scale(1.07);
  box-shadow: 0 0 48px rgba(167, 139, 250, 0.7), 0 0 110px rgba(167, 139, 250, 0.4), inset 0 0 28px rgba(255, 255, 255, 0.25);
}

/* LISTENING — rapid concentric ripples, brighter core, breathing */
.sol-orb.listening .sol-orb-core {
  background: radial-gradient(circle at 30% 28%, #f5f3ff 0%, #c4b5fd 30%, #8b5cf6 70%, #5b21b6 100%);
  box-shadow:
    0 0 56px rgba(167, 139, 250, 0.85),
    0 0 140px rgba(167, 139, 250, 0.5),
    inset 0 0 32px rgba(255, 255, 255, 0.3);
  animation: sol-orb-listen-pulse 1s ease-in-out infinite;
}
@keyframes sol-orb-listen-pulse {
  0%, 100% { transform: scale(1.05); }
  50%      { transform: scale(1.18); }
}
.sol-orb.listening .sol-orb-ring {
  opacity: 1;
  animation: sol-orb-ripple 1.6s ease-out infinite;
}
.sol-orb.listening .sol-orb-ring-1 { animation-delay: 0s; }
.sol-orb.listening .sol-orb-ring-2 { animation-delay: 0.5s; }
.sol-orb.listening .sol-orb-ring-3 { animation-delay: 1s; }
@keyframes sol-orb-ripple {
  0%   { transform: scale(0.65); opacity: 0.7; }
  100% { transform: scale(1.4);  opacity: 0; }
}

/* THINKING — orb shrinks slightly, cool teal-ish tone, gentle wobble */
.sol-orb.thinking .sol-orb-core {
  background: radial-gradient(circle at 30% 28%, #e0e7ff 0%, #93c5fd 35%, #6366f1 80%, #312e81 100%);
  animation: sol-orb-think 1.4s ease-in-out infinite;
}
@keyframes sol-orb-think {
  0%   { transform: scale(0.92) rotate(0deg); }
  50%  { transform: scale(0.96) rotate(180deg); }
  100% { transform: scale(0.92) rotate(360deg); }
}

/* SPEAKING — energetic, audio-reactive */
.sol-orb.speaking .sol-orb-core {
  background: radial-gradient(circle at 30% 28%, #fef3c7 0%, #c4b5fd 25%, #a78bfa 60%, #7c3aed 100%);
  box-shadow:
    0 0 64px rgba(167, 139, 250, 0.9),
    0 0 160px rgba(167, 139, 250, 0.55),
    inset 0 0 36px rgba(255, 255, 255, 0.32);
  animation: sol-orb-speak 0.6s ease-in-out infinite;
}
@keyframes sol-orb-speak {
  0%, 100% { transform: scale(1.02); }
  50%      { transform: scale(1.12); }
}
.sol-orb.speaking .sol-orb-wave {
  opacity: 0.9;
}

/* Status text below orb */
.sol-voice-status {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  color: rgba(255, 255, 255, 0.5);
  text-transform: uppercase;
  min-height: 1.2em;
}

/* Live transcript / answer text */
.sol-voice-transcript {
  font-family: 'Syne', 'Inter', sans-serif;
  font-weight: 500;
  font-size: 1.08rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.92);
  max-width: 32ch;
  text-wrap: balance;
  text-align: center;
  letter-spacing: -0.005em;
  min-height: 2.4em;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.7);
}
.sol-voice-transcript:empty::before {
  content: '';
  display: inline-block;
}

/* Quick prompts — tappable suggestions */
.sol-voice-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  max-width: 380px;
}
.sol-voice-prompt {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.78);
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 7px 13px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.sol-voice-prompt:hover {
  background: rgba(167, 139, 250, 0.14);
  border-color: rgba(167, 139, 250, 0.5);
  color: #fff;
}

.sol-voice-foot {
  padding: 12px 16px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  color: rgba(255, 255, 255, 0.32);
  text-transform: uppercase;
}
.sol-voice-foot-tag {
  padding: 3px 8px;
  background: rgba(167, 139, 250, 0.14);
  border: 1px solid rgba(167, 139, 250, 0.32);
  border-radius: 999px;
  color: rgba(167, 139, 250, 0.85);
  letter-spacing: 0.18em;
}

@media (max-width: 600px) {
  .sol-orb { width: 220px; height: 220px; }
  .sol-orb-core { width: 100px; height: 100px; }
  .sol-voice-transcript { font-size: 1.15rem; }
}
