/* Intro de voz post split — landing avatar (no depender de CSS de tests) */

.landing-avatar-page .avatar-intro-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Clips de boca encima de persona/robot; visibles solo con .is-visible (JS) */
.landing-avatar-page .avatar-hero-video-stack .avatar-hero-video--talk {
    position: absolute;
    inset: 0;
    z-index: 3;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.1s ease;
}

.landing-avatar-page .avatar-hero-video-stack .avatar-hero-video--talk.is-visible {
    opacity: 1;
}

/* Evita selección de texto y zoom doble toque al usar el mic en móvil */
.landing-avatar-page .avatar-intro-voice,
.landing-avatar-page .avatar-intro-voice__inner,
.landing-avatar-page .avatar-intro-actions {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

.landing-avatar-page .avatar-intro-voice {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    /* Por encima de barra de carga (15), split (12), etc.; el vídeo hero queda debajo */
    z-index: 50;
    isolation: isolate;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    padding: 0 16px max(28px, calc(env(safe-area-inset-bottom, 0px) + 16px));
    pointer-events: none;
    box-sizing: border-box;
}

.landing-avatar-page .avatar-intro-voice.is-visible {
    pointer-events: auto;
}

.landing-avatar-page .avatar-intro-voice__inner {
    width: min(420px, 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

/* Micrófono y “saltar”: solo tras la bienvenida por voz (clase la pone el JS) */
.landing-avatar-page .avatar-intro-voice:not(.avatar-intro-voice--show-actions) .avatar-intro-actions {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
    pointer-events: none;
    visibility: hidden;
}

.landing-avatar-page .avatar-intro-stt-input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
    user-select: none;
}

.landing-avatar-page .avatar-intro-tts-stage {
    width: 100%;
    max-width: min(400px, 100%);
    padding: 0 8px;
    background: none;
    border: none;
    box-shadow: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

.landing-avatar-page .avatar-intro-tts-stage__row {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    text-align: center;
}

.landing-avatar-page .avatar-intro-tts-wave {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 3px;
    height: 28px;
    flex-shrink: 0;
}

.landing-avatar-page .avatar-intro-tts-wave span {
    width: 4px;
    border-radius: 2px;
    background: linear-gradient(180deg, rgba(120, 220, 255, 0.95), rgba(80, 140, 255, 0.75));
    animation: avatar-intro-tts-bar 0.85s ease-in-out infinite;
}

.landing-avatar-page .avatar-intro-tts-wave span:nth-child(1) { animation-delay: 0s; height: 8px; }
.landing-avatar-page .avatar-intro-tts-wave span:nth-child(2) { animation-delay: 0.08s; height: 14px; }
.landing-avatar-page .avatar-intro-tts-wave span:nth-child(3) { animation-delay: 0.16s; height: 18px; }
.landing-avatar-page .avatar-intro-tts-wave span:nth-child(4) { animation-delay: 0.24s; height: 12px; }
.landing-avatar-page .avatar-intro-tts-wave span:nth-child(5) { animation-delay: 0.32s; height: 20px; }
.landing-avatar-page .avatar-intro-tts-wave span:nth-child(6) { animation-delay: 0.4s; height: 10px; }
.landing-avatar-page .avatar-intro-tts-wave span:nth-child(7) { animation-delay: 0.48s; height: 16px; }

@keyframes avatar-intro-tts-bar {
    0%, 100% { transform: scaleY(0.45); opacity: 0.55; }
    50% { transform: scaleY(1); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .landing-avatar-page .avatar-intro-tts-wave span {
        animation: none;
        opacity: 0.75;
        height: 10px !important;
    }

    .landing-avatar-page .avatar-intro-tts-sub.is-chunked {
        transition: none;
        transform: none;
    }

    .landing-avatar-page .avatar-intro-tts-sub.is-chunked.avatar-intro-tts-sub--visible,
    .landing-avatar-page .avatar-intro-tts-sub.is-chunked.avatar-intro-tts-sub--hide {
        transform: none;
    }
}

.landing-avatar-page .avatar-intro-tts-sub {
    margin: 0;
    width: 100%;
    max-width: 100%;
    font-size: clamp(0.92rem, 3.2vw, 1.05rem);
    font-weight: 500;
    line-height: 1.45;
    text-align: center;
    color: rgba(255, 255, 255, 0.94);
    text-shadow: 0 1px 12px rgba(0, 0, 0, 0.65);
}

/* Subtítulos por frases (TTS largo), alineado con test_avatar_castellano */
.landing-avatar-page .avatar-intro-tts-sub.is-chunked {
    opacity: 0;
    transform: translateY(5px);
    transition:
        opacity 0.38s ease,
        transform 0.38s ease;
}

.landing-avatar-page .avatar-intro-tts-sub.is-chunked.avatar-intro-tts-sub--visible {
    opacity: 1;
    transform: translateY(0);
}

.landing-avatar-page .avatar-intro-tts-sub.is-chunked.avatar-intro-tts-sub--hide {
    opacity: 0;
    transform: translateY(3px);
}

.landing-avatar-page .avatar-intro-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
    position: relative;
    z-index: 1;
    pointer-events: auto;
}

/*
 * En móvil, <button disabled> no recibe toques (atraviesan al vídeo).
 * El JS usa aria-disabled + .avatar-intro-mic-hold--locked sin disabled nativo.
 */
.landing-avatar-page .avatar-intro-mic-hold[aria-disabled='true'] {
    pointer-events: auto;
    cursor: not-allowed;
    opacity: 0.5;
}

.landing-avatar-page .avatar-intro-mic-hold.avatar-intro-mic-hold--gate-wait {
    opacity: 0.55;
}

.landing-avatar-page .avatar-intro-mic-wrap {
    display: flex;
    justify-content: center;
}

.landing-avatar-page .avatar-intro-mic-hold {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-width: 52px;
    min-height: 52px;
    padding: 10px 14px;
    border: none;
    border-radius: 0;
    cursor: pointer;
    background: transparent;
    color: rgba(255, 255, 255, 0.95);
    transition: opacity 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    box-shadow: none;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}

.landing-avatar-page .avatar-intro-mic-hold:hover:not(:disabled):not([aria-disabled='true']) {
    background: transparent;
}

.landing-avatar-page
    .avatar-intro-mic-hold:hover:not(:disabled):not([aria-disabled='true'])
    .avatar-intro-mic-hint {
    color: rgba(255, 255, 255, 0.88);
}

.landing-avatar-page .avatar-intro-mic-hold.is-active {
    background: transparent;
    box-shadow: none;
}

.landing-avatar-page .avatar-intro-mic-hold:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.landing-avatar-page .avatar-intro-mic-glow {
    --intro-voice: 0.18;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: radial-gradient(
        circle at 50% 45%,
        rgba(255, 255, 255, 0.2) 0%,
        rgba(120, 160, 220, 0.18) 50%,
        transparent 70%
    );
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.12),
        0 0 calc(10px + var(--intro-voice) * 22px) rgba(140, 180, 255, 0.35);
    transition: background 0.22s ease, box-shadow 0.22s ease;
}

/* Verde solo en el círculo al mantener pulsado */
.landing-avatar-page .avatar-intro-mic-hold.is-active .avatar-intro-mic-glow {
    background: radial-gradient(
        circle at 50% 42%,
        rgba(134, 239, 172, 0.95) 0%,
        rgba(34, 197, 94, 0.55) 48%,
        rgba(22, 163, 74, 0.25) 72%,
        transparent 88%
    );
    box-shadow:
        0 0 0 2px rgba(34, 197, 94, 0.55),
        0 0 28px rgba(34, 197, 94, 0.55),
        0 0 52px rgba(34, 197, 94, 0.28);
}

/* Pulso animado en móvil (en vez de voice meter con getUserMedia) */
.landing-avatar-page .avatar-intro-mic-glow.avatar-intro-mic-glow--pulse {
    animation: introMicPulse 1.4s ease-in-out infinite;
}
@keyframes introMicPulse {
    0%, 100% {
        box-shadow:
            0 0 0 2px rgba(34, 197, 94, 0.55),
            0 0 18px rgba(34, 197, 94, 0.4),
            0 0 36px rgba(34, 197, 94, 0.15);
    }
    50% {
        box-shadow:
            0 0 0 4px rgba(34, 197, 94, 0.7),
            0 0 36px rgba(34, 197, 94, 0.6),
            0 0 60px rgba(34, 197, 94, 0.3);
    }
}

.landing-avatar-page .avatar-intro-mic-icon {
    width: 26px;
    height: 26px;
    color: rgba(255, 255, 255, 0.95);
}

.landing-avatar-page .avatar-intro-mic-hint {
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.72);
    text-shadow: 0 1px 10px rgba(0, 0, 0, 0.6);
}

.landing-avatar-page .avatar-intro-skip-mic {
    padding: 10px 14px;
    font-size: 0.82rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.65);
    background: transparent;
    border: none;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
    border-radius: 8px;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.landing-avatar-page .avatar-intro-skip-mic:hover:not(:disabled) {
    color: rgba(255, 255, 255, 0.9);
}

.landing-avatar-page .avatar-intro-skip-mic:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Feedback “escuchando”: el estado principal es el círculo verde del micrófono */
.landing-avatar-page .avatar-intro-listening {
    display: none !important;
}

.landing-avatar-page .avatar-intro-listening-bars {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 3px;
    height: 20px;
    margin-bottom: 8px;
}

.landing-avatar-page .avatar-intro-listening-bars span {
    width: 3px;
    border-radius: 1px;
    background: rgba(180, 230, 255, 0.85);
    animation: avatar-intro-listen-bar 0.7s ease-in-out infinite;
}

.landing-avatar-page .avatar-intro-listening-bars span:nth-child(odd) { animation-delay: 0.1s; height: 10px; }
.landing-avatar-page .avatar-intro-listening-bars span:nth-child(even) { animation-delay: 0.2s; height: 16px; }

@keyframes avatar-intro-listen-bar {
    0%, 100% { transform: scaleY(0.5); opacity: 0.5; }
    50% { transform: scaleY(1); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .landing-avatar-page .avatar-intro-listening-bars span {
        animation: none;
        height: 10px !important;
    }
}

.landing-avatar-page .avatar-intro-listening-label {
    margin: 0;
    text-align: center;
    font-size: 0.88rem;
    color: rgba(255, 255, 255, 0.8);
}
