/* ==========================================================================
   Talk Page — Premium Futuristic Dark Theme
   A voice-first interface with 3D ethereal wave visualization & animations
   ========================================================================== */

/* ---------- Custom Properties ---------- */
.ti-spin {
    animation: ti-spin 1s linear infinite;
}

@keyframes ti-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
:root {
    --talk-bg: #050510;
    --talk-bg-secondary: #080818;
    --talk-accent: #00e5a0;
    --talk-accent-active: #ff6b6b;
    --talk-glass-bg: rgba(255, 255, 255, 0.06);
    --talk-glass-border: rgba(255, 255, 255, 0.12);
    --talk-text: rgba(255, 255, 255, 0.7);
    --talk-text-bright: rgba(255, 255, 255, 0.92);
    --talk-transition: 0.3s ease;
    --talk-mic-size: 80px;
}

/* ---------- Scene Container ---------- */
.talk-scene {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background:
        /* Subtle dot-grid pattern for depth */
        radial-gradient(circle, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        /* Primary radial gradient — centered teal glow */
        radial-gradient(ellipse at 50% 50%, #0a1a1a 0%, #070e14 30%, var(--talk-bg) 100%);
    background-size:
        24px 24px,
        100% 100%;
    color: var(--talk-text);
    font-family: 'Inter', 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ---------- Three.js / WebGL Canvas ---------- */
.talk-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    display: block;
}

/* ---------- Vignette Overlay ---------- */
.talk-vignette {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
    background: radial-gradient(
        ellipse at center,
        transparent 55%,
        rgba(6, 6, 20, 0.45) 80%,
        rgba(4, 4, 16, 0.85) 100%
    );
}

/* ---------- Controls Overlay ---------- */
.talk-controls {
    position: absolute;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

/* ---------- Mic Button ---------- */
.talk-mic-btn {
    position: relative;
    width: var(--talk-mic-size);
    height: var(--talk-mic-size);
    border-radius: 50%;
    border: 1px solid var(--talk-glass-border);
    background: var(--talk-glass-bg);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    color: var(--talk-text-bright);
    font-size: 1.6rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition:
        transform var(--talk-transition),
        box-shadow var(--talk-transition),
        border-color var(--talk-transition),
        background var(--talk-transition),
        color var(--talk-transition);
    box-shadow:
        0 0 20px rgba(0, 229, 160, 0.08),
        0 4px 30px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
    outline: none;
    -webkit-tap-highlight-color: transparent;
    animation: idle-glow 3s ease-in-out infinite;
}

.talk-mic-btn:hover {
    transform: scale(1.08);
    border-color: rgba(0, 229, 160, 0.35);
    box-shadow:
        0 0 32px rgba(0, 229, 160, 0.2),
        0 0 60px rgba(0, 229, 160, 0.08),
        0 4px 30px rgba(0, 0, 0, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.09);
}

.talk-mic-btn:active {
    transform: scale(0.96);
}

/* Active (Recording) State — override idle glow */
.talk-mic-btn.active {
    border-color: rgba(255, 107, 107, 0.45);
    color: var(--talk-accent-active);
    animation: glow-pulse-active 2s ease-in-out infinite;
    background: rgba(255, 107, 107, 0.1);
}

/* Connecting State — override idle glow */
.talk-mic-btn.connecting {
    border-color: rgba(0, 229, 160, 0.4);
    color: var(--talk-accent);
    animation: glow-pulse-connecting 1.5s ease-in-out infinite;
    background: rgba(0, 229, 160, 0.08);
    pointer-events: none;
}

/* ---------- Pulse Ring ---------- */
.talk-pulse-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    width: var(--talk-mic-size);
    height: var(--talk-mic-size);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(1);
    pointer-events: none;
    opacity: 0;
    z-index: -1;
}

.talk-mic-btn.active ~ .talk-pulse-ring,
.talk-mic-btn.active .talk-pulse-ring {
    border: 2px solid var(--talk-accent-active);
    animation: pulse-ring 2s ease-out infinite;
}

.talk-mic-btn.connecting ~ .talk-pulse-ring,
.talk-mic-btn.connecting .talk-pulse-ring {
    border: 2px solid var(--talk-accent);
    animation: pulse-ring 1.8s ease-out infinite;
}

/* Second ring (delayed) for richer effect */
.talk-pulse-ring::after {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 50%;
    border: inherit;
    animation: inherit;
    animation-delay: 0.6s;
}

/* ---------- Status Text ---------- */
.talk-status {
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--talk-text);
    transition: opacity var(--talk-transition), color var(--talk-transition);
    opacity: 0.75;
    user-select: none;
    text-align: center;
    min-height: 1.2em;
}

.talk-status.hidden {
    opacity: 0;
}

.talk-mic-btn.active ~ .talk-status,
.talk-controls.active .talk-status {
    color: var(--talk-accent-active);
    opacity: 1;
}

.talk-mic-btn.connecting ~ .talk-status,
.talk-controls.connecting .talk-status {
    color: var(--talk-accent);
    opacity: 1;
}

/* ---------- Hide Chat Widget & Footer on Talk Page ---------- */
.talk-scene ~ siestaai-chat-widget,
body:has(.talk-scene) siestaai-chat-widget {
    display: none !important;
}

body:has(.talk-scene) footer.footer {
    display: none !important;
}

/* ---------- Topic Suggestion Chips ---------- */
.talk-topic-chips {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    opacity: 1;
    transition: opacity 0.5s ease, transform 0.5s ease;
}

/* Hide chips when session is active (user is talking) */
.talk-scene.session-active .talk-topic-chips {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(10px);
}

.talk-chips-label {
    font-size: 0.58rem;
    font-weight: 500;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.2);
    user-select: none;
}

.talk-chips-row {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    gap: 6px;
}

.talk-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 100px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: rgba(255, 255, 255, 0.55);
    font-family: inherit;
    font-size: 0.62rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    cursor: default;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    white-space: nowrap;
    pointer-events: none;
}

.talk-chip i {
    font-size: 0.7rem;
    opacity: 0.7;
}

/* Staggered fade-in animation for chips */
.talk-chip {
    animation: chip-fade-in 0.4s ease backwards;
}

.talk-chip:nth-child(1) { animation-delay: 0.05s; }
.talk-chip:nth-child(2) { animation-delay: 0.1s; }
.talk-chip:nth-child(3) { animation-delay: 0.15s; }
.talk-chip:nth-child(4) { animation-delay: 0.2s; }
.talk-chip:nth-child(5) { animation-delay: 0.25s; }
.talk-chip:nth-child(6) { animation-delay: 0.3s; }
.talk-chip:nth-child(7) { animation-delay: 0.35s; }
.talk-chip:nth-child(8) { animation-delay: 0.4s; }

@keyframes chip-fade-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---------- Transcript Panel ---------- */
.talk-transcript {
    position: absolute;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    width: min(560px, 88vw);
    max-height: 180px;
    overflow-y: auto;
    z-index: 20;
    padding: 0;
    border-radius: 16px;
    border: 1px solid var(--talk-glass-border);
    background: var(--talk-glass-bg);
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
    color: var(--talk-text-bright);
    font-size: 0.92rem;
    line-height: 1.65;
    transition:
        opacity 0.4s ease,
        transform 0.4s ease,
        padding 0.3s ease;
    box-shadow:
        0 8px 40px rgba(0, 0, 0, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
    /* Hidden when empty */
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(8px);
}

.talk-transcript:not(:empty) {
    opacity: 1;
    pointer-events: auto;
    padding: 18px 22px;
    transform: translateX(-50%) translateY(0);
}

.talk-transcript::-webkit-scrollbar {
    width: 4px;
}

.talk-transcript::-webkit-scrollbar-track {
    background: transparent;
}

.talk-transcript::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

/* Transcript lines */
.talk-transcript-line {
    margin: 0 0 8px 0;
    padding: 0;
    animation: transcript-fade-in 0.3s ease;
}

.talk-transcript-line:last-child {
    margin-bottom: 0;
}

.talk-transcript-line.ai {
    color: var(--talk-text-bright);
}

@keyframes transcript-fade-in {
    from {
        opacity: 0;
        transform: translateY(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---------- Keyframe Animations ---------- */
@keyframes pulse-ring {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.6;
    }
    100% {
        transform: translate(-50%, -50%) scale(2.5);
        opacity: 0;
    }
}

@keyframes glow-pulse-active {
    0%, 100% {
        box-shadow:
            0 0 20px rgba(255, 107, 107, 0.15),
            0 0 40px rgba(255, 107, 107, 0.06),
            0 4px 30px rgba(0, 0, 0, 0.3),
            inset 0 1px 0 rgba(255, 255, 255, 0.06);
    }
    50% {
        box-shadow:
            0 0 30px rgba(255, 107, 107, 0.3),
            0 0 70px rgba(255, 107, 107, 0.12),
            0 4px 30px rgba(0, 0, 0, 0.3),
            inset 0 1px 0 rgba(255, 255, 255, 0.08);
    }
}

@keyframes glow-pulse-connecting {
    0%, 100% {
        box-shadow:
            0 0 20px rgba(0, 229, 160, 0.15),
            0 0 40px rgba(0, 229, 160, 0.06),
            0 4px 30px rgba(0, 0, 0, 0.3),
            inset 0 1px 0 rgba(255, 255, 255, 0.06);
    }
    50% {
        box-shadow:
            0 0 30px rgba(0, 229, 160, 0.3),
            0 0 70px rgba(0, 229, 160, 0.12),
            0 4px 30px rgba(0, 0, 0, 0.3),
            inset 0 1px 0 rgba(255, 255, 255, 0.08);
    }
}

@keyframes idle-glow {
    0%, 100% {
        box-shadow:
            0 0 0 0 rgba(255, 255, 255, 0),
            0 4px 30px rgba(0, 0, 0, 0.3),
            inset 0 1px 0 rgba(255, 255, 255, 0.06);
    }
    50% {
        box-shadow:
            0 0 14px 4px rgba(255, 255, 255, 0.12),
            0 4px 30px rgba(0, 0, 0, 0.3),
            inset 0 1px 0 rgba(255, 255, 255, 0.06);
    }
}

/* ---------- Responsive — Mobile ---------- */
@media (max-width: 640px) {
    :root {
        --talk-mic-size: 64px;
    }

    .talk-scene {
        align-items: flex-start;
        padding-top: 35vh;
    }

    .talk-canvas,
    .talk-vignette {
        top: -15vh;
    }

    .talk-mic-btn {
        font-size: 1.3rem;
    }

    .talk-transcript {
        width: 92vw;
        bottom: 20px;
        padding: 14px 16px;
        font-size: 0.85rem;
        max-height: 150px;
        border-radius: 12px;
    }

    .talk-status {
        font-size: 0.62rem;
    }

    .talk-topic-chips {
        bottom: 170px;
    }

    .talk-chips-row {
        flex-wrap: wrap;
        max-width: 92vw;
        gap: 5px;
    }

    .talk-chip {
        padding: 4px 8px;
        font-size: 0.58rem;
        gap: 3px;
    }

    .talk-chip i {
        font-size: 0.62rem;
    }
}

/* ---------- Legal Disclaimer (bottom-right) ---------- */
.talk-legal {
    position: absolute;
    bottom: 16px;
    right: 20px;
    z-index: 15;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    max-width: 340px;
    text-align: right;
}

.talk-legal span {
    font-size: 0.56rem;
    color: rgba(255, 255, 255, 0.25);
    line-height: 1.4;
}

.talk-legal a {
    color: rgba(255, 255, 255, 0.4);
    text-decoration: underline;
    text-decoration-color: rgba(255, 255, 255, 0.15);
    transition: color 0.2s ease;
}

.talk-legal a:hover {
    color: rgba(255, 255, 255, 0.6);
}

/* Light mode */
.talk-scene.light-mode .talk-legal span {
    color: rgba(0, 0, 0, 0.25);
}

.talk-scene.light-mode .talk-legal a {
    color: rgba(0, 0, 0, 0.4);
    text-decoration-color: rgba(0, 0, 0, 0.15);
}

.talk-scene.light-mode .talk-legal a:hover {
    color: rgba(0, 0, 0, 0.6);
}

@media (max-width: 640px) {
    .talk-legal {
        bottom: 10px;
        right: 12px;
        max-width: 200px;
    }

    .talk-legal span {
        font-size: 0.48rem;
    }
}

/* ---------- Theme Toggle Button ---------- */
.talk-theme-toggle {
    position: absolute;
    bottom: 24px;
    left: 24px;
    z-index: 15;
}

.talk-theme-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: rgba(255, 255, 255, 0.5);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.talk-theme-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.8);
    border-color: rgba(255, 255, 255, 0.2);
}

/* ---------- Light Mode Overrides ---------- */
.talk-scene.light-mode {
    background:
        radial-gradient(circle, rgba(0, 0, 0, 0.02) 1px, transparent 1px),
        #ffffff;
    background-size:
        24px 24px,
        100% 100%;
    color: rgba(0, 0, 0, 0.6);
}

.talk-scene.light-mode .talk-vignette {
    background: radial-gradient(
        ellipse at center,
        transparent 55%,
        rgba(255, 255, 255, 0.3) 80%,
        rgba(255, 255, 255, 0.7) 100%
    );
}

.talk-scene.light-mode .talk-mic-btn {
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: rgba(0, 0, 0, 0.04);
    color: rgba(0, 0, 0, 0.7);
    box-shadow:
        0 0 20px rgba(0, 0, 0, 0.04),
        0 4px 30px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.5);
    animation: idle-glow-light 3s ease-in-out infinite;
}

.talk-scene.light-mode .talk-mic-btn:hover {
    border-color: rgba(0, 0, 0, 0.18);
    background: rgba(0, 0, 0, 0.07);
    box-shadow:
        0 0 32px rgba(0, 0, 0, 0.06),
        0 4px 30px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.talk-scene.light-mode .talk-mic-btn.active {
    border-color: rgba(255, 107, 107, 0.4);
    background: rgba(255, 107, 107, 0.08);
}

.talk-scene.light-mode .talk-mic-btn.connecting {
    border-color: rgba(0, 150, 100, 0.3);
    background: rgba(0, 150, 100, 0.06);
}

.talk-scene.light-mode .talk-status {
    color: rgba(0, 0, 0, 0.45);
}

.talk-scene.light-mode .talk-chips-label {
    color: rgba(0, 0, 0, 0.25);
}

.talk-scene.light-mode .talk-chip {
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: rgba(0, 0, 0, 0.03);
    color: rgba(0, 0, 0, 0.45);
}

.talk-scene.light-mode .talk-chip i {
    opacity: 0.5;
}

.talk-scene.light-mode .talk-transcript {
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(22px);
    color: rgba(0, 0, 0, 0.8);
    box-shadow:
        0 8px 40px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    scrollbar-color: rgba(0, 0, 0, 0.1) transparent;
}

.talk-scene.light-mode .talk-transcript::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
}

.talk-scene.light-mode .talk-transcript-line.ai {
    color: rgba(0, 0, 0, 0.8);
}

.talk-scene.light-mode .talk-theme-btn {
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: rgba(0, 0, 0, 0.04);
    color: rgba(0, 0, 0, 0.45);
}

.talk-scene.light-mode .talk-theme-btn:hover {
    background: rgba(0, 0, 0, 0.08);
    color: rgba(0, 0, 0, 0.7);
    border-color: rgba(0, 0, 0, 0.15);
}

@keyframes idle-glow-light {
    0%, 100% {
        box-shadow:
            0 0 0 0 rgba(0, 0, 0, 0),
            0 4px 30px rgba(0, 0, 0, 0.08),
            inset 0 1px 0 rgba(255, 255, 255, 0.5);
    }
    50% {
        box-shadow:
            0 0 14px 4px rgba(0, 0, 0, 0.06),
            0 4px 30px rgba(0, 0, 0, 0.08),
            inset 0 1px 0 rgba(255, 255, 255, 0.5);
    }
}
