/* ========================================
   TALKING AVATAR ANIMATIONS
   CSS for mouth, body, and gesture animations
   ======================================== */

/* ========================================
   MOUTH SHAPE TRANSITIONS
   ======================================== */

.mouth-shape {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.08s ease-in-out;
}

.mouth-shape.active {
    opacity: 1;
}

/* ========================================
   SPEAK BUTTON STYLES
   ======================================== */

.speak-button {
    
    /* Position relative to avatar container */
    position: absolute;
    top: 16.07%;  /* Y: 241px on 1500px canvas */
    left: 34.27%; /* X: 514px on 1500px canvas */
    transform: translate(-50%, -50%); /* Center the button on those coordinates */
    
    width: 40px;
    height: 40px;
    border-radius: 50%;
    padding: 0;
    margin: 0; /* Remove all margins */
    
    background: linear-gradient(135deg, #0069c1, #082247);
    color: white;
    border: 2px solid #69eafc;
    box-shadow: 0 4px 4px rgba(105, 234, 252, 0.3);
    transition: all 0.3s ease;
    cursor: pointer;
    z-index: 100; /* Make sure it's on top of avatar */
    
    font-size: 18px;
    font-weight: bold;
}

.speak-button:hover {
    transform: translate(-50%, -50%) translateY(-2px);
    box-shadow: 0 6px 20px rgba(105, 234, 252, 0.5);
    border-color: #15e3ff;
}

.speak-button:active {
    transform: translateY(0px);
}

.speak-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.speak-button.playing {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 4px 15px rgba(105, 234, 252, 0.3);
    }
    50% {
        box-shadow: 0 4px 25px rgba(105, 234, 252, 0.6);
    }
}

.speak-button .button-icon {
    font-size: 24px;
    display: inline-block;
    animation: none;
}

.speak-button.playing .button-icon {
    animation: iconBounce 0.6s ease-in-out infinite;
}

@keyframes iconBounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* Hide button text - icon only */
.speak-button .button-text {
    display: none;
}



/* Muted state - diagonal orange line */
.speak-button.muted {
    border-color: #fa9200;
}

.speak-button.muted::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        to bottom right,
        transparent 0%,
        transparent calc(50% - 2px),
        #fa9200 calc(50% - 2px),
        #fa9200 calc(50% + 2px),
        transparent calc(50% + 2px),
        transparent 100%
    );
    pointer-events: none;
    border-radius: 50%;
}

/* Stop icon bounce when muted */
.speak-button.muted .button-icon {
    animation: none;
}

/* ========================================
   BODY ANIMATIONS DURING SPEECH
   ======================================== */

/* Head bobbing */
@keyframes headBob {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-4px);
    }
}

.avatar-container.talking-bob {
    animation: headBob 0.8s ease-in-out infinite;
}

/* Right arm waving */
@keyframes armWave {
    0%, 100% {
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(-12deg);
    }
    75% {
        transform: rotate(8deg);
    }
}

.right-forearm-container.talking-wave {
    animation: armWave 2s ease-in-out infinite;
    transform-origin: 39.7% 36.7%; /* Elbow pivot: x:595.5, y:550.5 */
}

/* Left arm gesturing */
@keyframes armGesture {
    0%, 100% {
        transform: rotate(0deg);
    }
    33% {
        transform: rotate(8deg);
    }
    66% {
        transform: rotate(-5deg);
    }
}

.left-forearm-container.talking-gesture {
    animation: armGesture 2.5s ease-in-out infinite;
    transform-origin: 58.13% 37.33%; /* Elbow pivot: x:872, y:560 */
}

/* Eyebrow expression */
@keyframes expressiveBrow {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-2px);
    }
}

.eyebrow.talking-expressive {
    animation: expressiveBrow 1.5s ease-in-out infinite;
}

/* ========================================
   ENHANCED BLINK ANIMATION
   ======================================== */

.eye-blink {
    opacity: 0;
    transition: opacity 0.1s ease-in-out;
}

/* Natural blink animation (can be triggered via JS) */
@keyframes naturalBlink {
    0%, 90%, 100% {
        opacity: 0;
    }
    95% {
        opacity: 1;
    }
}

/* ========================================
   SUBTLE IDLE ANIMATIONS
   (When not talking - optional)
   ======================================== */

/* Breathing effect */
@keyframes breathing {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.02);
    }
}

.avatar-container:not(.talking-bob) {
    animation: breathing 4s ease-in-out infinite;
}

/* Occasional idle blink */
@keyframes idleBlink {
    0%, 95%, 100% {
        opacity: 0;
    }
    97.5% {
        opacity: 1;
    }
}

/* Apply to eye-blink elements when idle */
/* (Note: This is overridden during speech) */

/* ========================================
   RESPONSIVE ADJUSTMENTS
   ======================================== */

@media (max-width: 768px) {
     .speak-button {
        font-size: 16px;
        width: 50px;  /* Slightly bigger for touch */
        height: 50px;
        
        display: block;
    }
    
    .speak-button .button-icon {
        font-size: 28px; /* Bigger icon for mobile */
    }
    
    /* Reduce animation intensity on mobile */
    .avatar-container.talking-bob {
        animation: headBob 1s ease-in-out infinite;
    }
    
    @keyframes headBob {
        0%, 100% { transform: translateY(0px); }
        50% { transform: translateY(-2px); }
    }
}
/* Tablet adjustments */
@media (max-width: 1024px) and (min-width: 769px) {
    .speak-button {
        
        width: 45px;
        height: 45px;
    }
    
    .speak-button .button-icon {
        font-size: 26px;
    }
}

/* Small phones */
@media (max-width: 480px) {
    .speak-button {
        width: 45px;
        height: 45px;
         
    }
    
    .speak-button .button-icon {
        font-size: 24px;
    }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    .speak-button,
    .avatar-container,
    .right-forearm-container,
    .left-forearm-container,
    .eyebrow,
    .mouth-shape {
        animation: none !important;
        transition: opacity 0.3s ease !important;
    }
    
    .speak-button:hover {
        transform: none;
    }
}

/* Focus styles for keyboard navigation */
.speak-button:focus {
    outline: 3px solid #69eafc;
    outline-offset: 2px;
}

/* ========================================
   LOADING STATES
   ======================================== */

.speak-button.loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* ========================================
   INTERACTION FEEDBACK
   ======================================== */

/* Ripple effect on button click */
.speak-button::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s, opacity 0.6s;
    opacity: 0;
}

.speak-button:active::after {
    width: 300px;
    height: 300px;
    opacity: 0;
}

/* ========================================
   SPECIAL EFFECTS (Optional)
   ======================================== */

/* Sound wave effect around button when playing */
.speak-button.playing::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 120%;
    height: 120%;
    border: 2px solid #69eafc;
    border-radius: 50px;
    transform: translate(-50%, -50%);
    animation: soundWave 1.5s ease-out infinite;
    opacity: 0;
}

@keyframes soundWave {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.8;
    }
    100% {
        transform: translate(-50%, -50%) scale(1.3);
        opacity: 0;
    }
}

/* Glow effect on avatar when talking */
.avatar-container.talking-bob {
    filter: drop-shadow(0 0 10px rgba(105, 234, 252, 0.3));
}

/* ========================================
   CUSTOM PROPERTIES FOR EASY TWEAKING
   ======================================== */

:root {
    --mouth-transition-speed: 0.08s;
    --arm-wave-duration: 2s;
    --head-bob-duration: 0.8s;
    --brow-duration: 1.5s;
    
    --button-bg-gradient: linear-gradient(135deg, #0069c1, #082247);
    --button-border-color: #69eafc;
    --button-shadow-color: rgba(105, 234, 252, 0.3);
}


