/*
 * voice-assistant.css — JARVIS-style full-screen overlay for Lexxie voice mode.
 * Three layers:
 *   .lx-launcher  → small floating mic in the bottom-right (always visible)
 *   .lx-overlay   → full-screen JARVIS UI with rings, core orb, status text
 *   .minimized    → modifier on the wrapper that hides the overlay so the
 *                   launcher stays as the only visible UI while voice keeps
 *                   listening (used during navigation).
 */

:root {
    --lx-cyan: #38d8ff;
    --lx-cyan-soft: rgba(56, 216, 255, 0.55);
    --lx-cyan-faint: rgba(56, 216, 255, 0.18);
    --lx-amber: #ffd166;
    --lx-green: #00ffa3;
}

.lx-voice {
    font-family: 'Roboto', sans-serif;
    color: #e8f4ff;
}

/* ------------------------------------------------------------------ */
/* Floating-button stack (bottom-right corner)                         */
/* ------------------------------------------------------------------ */
/* The page already has two floating buttons (chatbot toggle + back-to-top).
 * We use !important here to keep the ordering predictable regardless of
 * load order: chatbot at the bottom, back-to-top in the middle, voice
 * launcher on top. Heights/gaps are sized so the three never overlap.
 *
 *   Desktop:                Tablet (<=768):           Mobile (<=480):
 *   chatbot toggle: 100-160 chatbot toggle: 90-145    chatbot toggle: 80-130
 *   back-to-top:    175-225 back-to-top:    160-205   back-to-top:    145-185
 *   voice launcher: 240-300 voice launcher: 220-275   voice launcher: 200-250
 */
.back-to-top-btn.visible { bottom: 175px !important; right: 25px !important; }

.lx-launcher {
    position: fixed !important;
    right: 20px;
    bottom: 240px;          /* above back-to-top, no overlap */
    margin-bottom: 0 !important;
    z-index: 9998;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 2px solid var(--lx-cyan);
    background: radial-gradient(circle at 30% 30%, #1B4965 0%, #051018 78%);
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 10px 28px rgba(56, 216, 255, 0.35),
        0 0 18px rgba(56, 216, 255, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
    overflow: visible;
}
.lx-launcher:hover { transform: scale(1.07); }
.lx-launcher:focus-visible { outline: 2px solid var(--lx-cyan); outline-offset: 4px; }

.lx-launcher-icon { position: relative; z-index: 2; font-size: 22px; }

.lx-launcher-glow {
    position: absolute; inset: -6px;
    border-radius: 50%;
    background: conic-gradient(from 0deg, transparent, var(--lx-cyan), transparent 65%);
    opacity: 0.6;
    animation: lxSpin 5s linear infinite;
    pointer-events: none;
}
.lx-launcher-pulse {
    position: absolute; inset: 0;
    border-radius: 50%;
    border: 2px solid var(--lx-cyan-soft);
    pointer-events: none;
    opacity: 0;
}

/* Tiny green "I'm awake" dot in the corner of the orb, visible whenever
 * the assistant is actively listening (wake-word, recording, thinking,
 * or speaking). Pulses gently so the user can tell at a glance that
 * Lexxie is on. Hidden in idle state. */
.lx-launcher-status-dot {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--lx-green);
    box-shadow: 0 0 8px var(--lx-green), 0 0 14px rgba(0, 255, 163, 0.5);
    border: 2px solid #051018;
    z-index: 3;
    opacity: 0;
    transform: scale(0.6);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}
.lx-voice[data-state='listening_wake'] .lx-launcher-status-dot,
.lx-voice[data-state='recording']      .lx-launcher-status-dot,
.lx-voice[data-state='thinking']       .lx-launcher-status-dot,
.lx-voice[data-state='speaking']       .lx-launcher-status-dot {
    opacity: 1;
    transform: scale(1);
    animation: lxStatusPulse 1.6s ease-in-out infinite;
}
@keyframes lxStatusPulse {
    0%, 100% { box-shadow: 0 0 8px var(--lx-green), 0 0 14px rgba(0, 255, 163, 0.5);  transform: scale(1);   }
    50%      { box-shadow: 0 0 12px var(--lx-green), 0 0 22px rgba(0, 255, 163, 0.8); transform: scale(1.18); }
}
@keyframes lxSpin { to { transform: rotate(360deg); } }
@keyframes lxPulse {
    0%   { transform: scale(1);   opacity: 0.7; }
    80%  { transform: scale(1.7); opacity: 0;   }
    100% { transform: scale(1.7); opacity: 0;   }
}

/* Launcher state-driven look (set on the .lx-voice wrapper) */
.lx-voice[data-state='listening_wake'] .lx-launcher-pulse { animation: lxPulse 2.4s ease-out infinite; opacity: 1; }
.lx-voice[data-state='recording']      .lx-launcher-pulse { animation: lxPulse 1.0s ease-out infinite; opacity: 1; border-color: var(--lx-green); }
.lx-voice[data-state='speaking']       .lx-launcher-pulse { animation: lxPulse 1.4s ease-out infinite; opacity: 1; border-color: var(--lx-amber); }

.lx-voice[data-state='recording'] .lx-launcher { border-color: var(--lx-green); box-shadow: 0 10px 28px rgba(0, 255, 163, 0.4), 0 0 22px rgba(0, 255, 163, 0.4); }
.lx-voice[data-state='speaking']  .lx-launcher { border-color: var(--lx-amber); box-shadow: 0 10px 28px rgba(255, 209, 102, 0.4), 0 0 22px rgba(255, 209, 102, 0.4); }
.lx-voice[data-state='thinking']  .lx-launcher-glow { animation-duration: 1.5s; }

/* ------------------------------------------------------------------ */
/* Overlay                                                             */
/* ------------------------------------------------------------------ */
.lx-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s ease, visibility 0.35s ease;
}
.lx-overlay.open { opacity: 1; visibility: visible; pointer-events: auto; }

.lx-overlay-bg {
    position: absolute; inset: 0;
    background:
        radial-gradient(ellipse at center, rgba(56, 216, 255, 0.12) 0%, rgba(2, 6, 12, 0.85) 55%, rgba(0, 0, 0, 0.95) 100%),
        repeating-linear-gradient(0deg, rgba(56, 216, 255, 0.04) 0 1px, transparent 1px 4px);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.lx-controls {
    position: absolute;
    top: 22px;
    right: 22px;
    display: flex;
    gap: 10px;
    z-index: 2;
}
.lx-ctrl {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid var(--lx-cyan-faint);
    background: rgba(8, 18, 28, 0.7);
    color: var(--lx-cyan);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.25s ease;
    font-size: 14px;
}
.lx-ctrl:hover { color: #ffffff; border-color: var(--lx-cyan); box-shadow: 0 0 14px var(--lx-cyan-soft); }

/* ------------------------------------------------------------------ */
/* Stage — the JARVIS orb assembly                                    */
/* ------------------------------------------------------------------ */
.lx-stage {
    position: relative;
    width: 360px;
    height: 360px;
    max-width: 75vw;
    max-height: 75vw;
    z-index: 1;
}

/* Concentric rings — purely decorative, rotate at different speeds */
.lx-rings, .lx-ring, .lx-arc, .lx-reactive, .lx-core, .lx-particles {
    position: absolute; inset: 0;
    pointer-events: none;
    border-radius: 50%;
}
.lx-ring {
    border: 1px solid var(--lx-cyan-faint);
    box-shadow: inset 0 0 30px rgba(56, 216, 255, 0.05);
}
.lx-ring-1 { inset: 0;     border-style: dashed; animation: lxSpin 24s linear infinite; }
.lx-ring-2 { inset: 22px;  border-color: rgba(56, 216, 255, 0.28); animation: lxSpin 16s linear infinite reverse; }
.lx-ring-3 { inset: 50px;  border-color: rgba(56, 216, 255, 0.45); border-style: dotted; animation: lxSpin 9s linear infinite; }

.lx-arc {
    border: 2px solid transparent;
    border-top-color: var(--lx-cyan);
    border-right-color: var(--lx-cyan-soft);
    filter: drop-shadow(0 0 8px var(--lx-cyan));
}
.lx-arc-1 { inset: -10px; animation: lxSpin 6s linear infinite; }
.lx-arc-2 { inset: -30px; border-top-color: transparent; border-bottom-color: var(--lx-cyan); animation: lxSpin 11s linear infinite reverse; opacity: 0.7; }

/* Audio-reactive ring — JS sets --lx-amp from 0 to 1 */
.lx-reactive {
    inset: 75px;
    border: 2px solid var(--lx-cyan);
    box-shadow:
        0 0 24px var(--lx-cyan-soft),
        inset 0 0 24px rgba(56, 216, 255, 0.4);
    transform: scale(calc(1 + var(--lx-amp, 0) * 0.18));
    transition: transform 80ms linear;
    --lx-amp: 0;
}

/* Central core orb */
.lx-core {
    inset: 110px;
    background:
        radial-gradient(circle at 30% 28%, rgba(255, 255, 255, 0.9) 0%, rgba(56, 216, 255, 0.65) 18%, rgba(15, 60, 95, 0.85) 60%, rgba(2, 14, 24, 1) 100%);
    box-shadow:
        0 0 60px rgba(56, 216, 255, 0.55),
        0 0 120px rgba(56, 216, 255, 0.25),
        inset 0 0 30px rgba(0, 0, 0, 0.6);
    animation: lxBreathe 3.8s ease-in-out infinite;
}
.lx-core-shimmer {
    position: absolute; inset: 0;
    border-radius: 50%;
    background: conic-gradient(from 0deg, transparent 0deg, rgba(255, 255, 255, 0.18) 90deg, transparent 180deg, rgba(56, 216, 255, 0.15) 270deg, transparent 360deg);
    animation: lxSpin 7s linear infinite;
    mix-blend-mode: screen;
}
@keyframes lxBreathe {
    0%, 100% { transform: scale(1);    filter: brightness(1); }
    50%      { transform: scale(1.04); filter: brightness(1.15); }
}

/* Floating particle dots, anchored to the orb */
.lx-particles { inset: 0; }
.lx-particle {
    position: absolute;
    top: 50%; left: 50%;
    width: 4px; height: 4px;
    border-radius: 50%;
    background: var(--lx-cyan);
    box-shadow: 0 0 8px var(--lx-cyan);
    transform-origin: center;
    transform: rotate(var(--lx-angle)) translateY(calc(var(--lx-radius) * -1));
    animation: lxParticleFloat 5s ease-in-out infinite;
    animation-delay: var(--lx-delay);
    opacity: 0.7;
}
@keyframes lxParticleFloat {
    0%, 100% { transform: rotate(var(--lx-angle)) translateY(calc(var(--lx-radius) * -1)) scale(1);   opacity: 0.4; }
    50%      { transform: rotate(calc(var(--lx-angle) + 6deg)) translateY(calc(var(--lx-radius) * -1.06)) scale(1.4); opacity: 1; }
}

/* State-driven color tints on the orb */
.lx-voice[data-state='recording'] .lx-reactive { border-color: var(--lx-green); box-shadow: 0 0 28px rgba(0, 255, 163, 0.6), inset 0 0 24px rgba(0, 255, 163, 0.4); }
.lx-voice[data-state='recording'] .lx-core    { box-shadow: 0 0 60px rgba(0, 255, 163, 0.55), 0 0 120px rgba(0, 255, 163, 0.25), inset 0 0 30px rgba(0, 0, 0, 0.6); }

.lx-voice[data-state='speaking']  .lx-reactive { border-color: var(--lx-amber); box-shadow: 0 0 28px rgba(255, 209, 102, 0.55), inset 0 0 24px rgba(255, 209, 102, 0.4); }
.lx-voice[data-state='speaking']  .lx-core    { box-shadow: 0 0 60px rgba(255, 209, 102, 0.55), 0 0 120px rgba(255, 209, 102, 0.25), inset 0 0 30px rgba(0, 0, 0, 0.6); }

.lx-voice[data-state='thinking']  .lx-arc-1   { animation-duration: 1.5s; }
.lx-voice[data-state='thinking']  .lx-arc-2   { animation-duration: 2.5s; }

/* ------------------------------------------------------------------ */
/* Status / subtitle / hint                                           */
/* ------------------------------------------------------------------ */
.lx-status {
    margin-top: 32px;
    font-size: 14px;
    letter-spacing: 4px;
    text-transform: uppercase;
    color: var(--lx-cyan);
    text-shadow: 0 0 14px var(--lx-cyan-soft);
    z-index: 1;
    font-weight: 500;
}

.lx-subtitle {
    margin-top: 16px;
    max-width: min(720px, 80vw);
    min-height: 24px;
    font-size: 18px;
    line-height: 1.45;
    color: #cfeaff;
    text-shadow: 0 0 10px rgba(56, 216, 255, 0.3);
    z-index: 1;
}

.lx-hint {
    position: absolute;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12.5px;
    color: rgba(207, 234, 255, 0.65);
    letter-spacing: 0.4px;
    z-index: 1;
}
.lx-hint strong { color: var(--lx-cyan); font-weight: 600; }

/* ------------------------------------------------------------------ */
/* Minimized state — overlay hidden, launcher remains active          */
/* ------------------------------------------------------------------ */
.lx-voice.minimized .lx-overlay { opacity: 0; visibility: hidden; pointer-events: none; }

/* ------------------------------------------------------------------ */
/* Periodic floating wake-word hint above the launcher                */
/* ------------------------------------------------------------------ */
.lx-tooltip {
    position: fixed;
    right: 18px;          /* aligns roughly with the orb */
    bottom: 310px;        /* sits ~10px above the desktop orb (orb top ≈ 300px) */
    z-index: 9997;
    max-width: 240px;
    background: linear-gradient(135deg, rgba(13, 27, 42, 0.96) 0%, rgba(27, 38, 59, 0.96) 100%);
    border: 1px solid var(--lx-cyan);
    color: #e8f4ff;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.4;
    box-shadow:
        0 8px 22px rgba(0, 0, 0, 0.45),
        0 0 16px rgba(56, 216, 255, 0.25);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.4s ease, transform 0.4s ease;
    pointer-events: none;
    white-space: nowrap;
}
.lx-tooltip.show {
    opacity: 1;
    transform: translateY(0);
    animation: lxTooltipBob 3.2s ease-in-out 0.4s infinite;
}
.lx-tooltip-arrow {
    position: absolute;
    bottom: -6px;
    right: 28px;
    width: 12px;
    height: 12px;
    background: linear-gradient(135deg, rgba(13, 27, 42, 0.96), rgba(27, 38, 59, 0.96));
    border-right: 1px solid var(--lx-cyan);
    border-bottom: 1px solid var(--lx-cyan);
    transform: rotate(45deg);
}
@keyframes lxTooltipBob {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-4px); }
}

/* ------------------------------------------------------------------ */
/* Responsive                                                         */
/* ------------------------------------------------------------------ */
/* Tablet — match the chatbot's responsive size + position */
@media (max-width: 768px) {
    .back-to-top-btn.visible { bottom: 160px !important; right: 22px !important; }
    .lx-launcher { right: 18px; bottom: 220px; width: 55px; height: 55px; }
    .lx-launcher-icon { font-size: 20px; }
    .lx-tooltip { bottom: 285px; right: 16px; max-width: 220px; }
}

@media (max-width: 480px) {
    .back-to-top-btn.visible { bottom: 145px !important; right: 17px !important; }
    .lx-launcher { right: 14px; bottom: 200px; width: 50px; height: 50px; }
    .lx-launcher-icon { font-size: 19px; }
    .lx-tooltip { bottom: 260px; right: 12px; max-width: 200px; font-size: 12px; padding: 8px 12px; white-space: normal; }
    .lx-tooltip-arrow { right: 24px; }
    .lx-stage { width: 84vw; height: 84vw; }
    .lx-reactive { inset: 22%; }
    .lx-core { inset: 32%; }
    .lx-status { font-size: 12px; letter-spacing: 3px; margin-top: 22px; }
    .lx-subtitle { font-size: 15px; padding: 0 16px; }
    .lx-hint { font-size: 11px; padding: 0 16px; bottom: 22px; }
    .lx-controls { top: 14px; right: 14px; }
    .lx-ctrl { width: 38px; height: 38px; }
}

@media (prefers-reduced-motion: reduce) {
    .lx-ring, .lx-arc, .lx-core-shimmer, .lx-particle, .lx-launcher-glow { animation: none !important; }
    .lx-core { animation: none !important; }
}
