/* ============================================================
   Welcome Mascot - Animations
   Mascot idle, entrance, head swap, emotion transitions
   ============================================================ */

/* ─── Mascot Entrance ─── */
.mascot-center {
    animation: mascot-entrance 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes mascot-entrance {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.3) translateY(30px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1) translateY(0);
    }
}

/* ─── Idle Breathing ─── */
.mascot-body-svg.idle {
    animation: mascot-breathe 3s ease-in-out infinite;
}

@keyframes mascot-breathe {
    0%, 100% { transform: scaleY(1); }
    50% { transform: scaleY(1.02); }
}

/* ─── Idle Blink ─── */
/* Blinking is handled via JS SVG src swap (head-forward-blink.svg)
   because head SVGs are loaded as <img>, not inline SVG.
   See HeadTracker.js startBlinking() / doBlink() */

/* ─── Head Position Swap ─── */
.mascot-head-svg {
    transition: opacity 0.15s ease;
}

.mascot-head-svg.swapping {
    opacity: 0;
}

/* ─── Emotion Fade In/Out ─── */
.mascot-emotion-svg {
    transition: opacity 0.4s ease;
}

.mascot-emotion-svg.active {
    opacity: 1;
}

/* ─── Wave Animation (greeting) ─── */
.mascot-body-svg.waving .arm-wave {
    animation: mascot-wave 0.8s ease-in-out 3;
    transform-origin: 50% 50%;
}

@keyframes mascot-wave {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(15deg); }
    75% { transform: rotate(-10deg); }
}

/* ─── Bounce (excited reaction) ─── */
.mascot-center.bounce {
    animation: mascot-bounce 0.5s ease;
}

@keyframes mascot-bounce {
    0%, 100% { transform: translate(-50%, -50%) translateY(0); }
    30% { transform: translate(-50%, -50%) translateY(-15px); }
    60% { transform: translate(-50%, -50%) translateY(-5px); }
}

/* ─── Nod (acknowledgment) ─── */
.mascot-head-svg.nodding {
    animation: mascot-nod 0.4s ease 2;
}

@keyframes mascot-nod {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(5px); }
}

/* ─── Subtle Float (idle on homepage) ─── */
.mascot-center.floating {
    animation: mascot-float 4s ease-in-out infinite;
}

@keyframes mascot-float {
    0%, 100% { transform: translate(-50%, -50%) translateY(0); }
    50% { transform: translate(-50%, -50%) translateY(-8px); }
}

/* ─── Attention Grab (after idle timeout) ─── */
.mascot-center.attention {
    animation: mascot-attention 0.6s ease;
}

@keyframes mascot-attention {
    0%, 100% { transform: translate(-50%, -50%) rotate(0deg); }
    20% { transform: translate(-50%, -50%) rotate(-5deg); }
    40% { transform: translate(-50%, -50%) rotate(5deg); }
    60% { transform: translate(-50%, -50%) rotate(-3deg); }
    80% { transform: translate(-50%, -50%) rotate(3deg); }
}

/* ─── Speech Bubble Entrance ─── */
.speech-bubble.animate-in {
    animation: mascot-speech-enter 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes mascot-speech-enter {
    from {
        opacity: 0;
        transform: translateX(-50%) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) scale(1);
    }
}

/* ─── Speech Bubble Exit ─── */
.speech-bubble.animate-out {
    animation: mascot-speech-exit 0.3s ease forwards;
}

@keyframes mascot-speech-exit {
    from {
        opacity: 1;
        transform: translateX(-50%) scale(1);
    }
    to {
        opacity: 0;
        transform: translateX(-50%) scale(0.8);
    }
}

/* ─── Sparkle Effect ─── */
.mascot-sparkle {
    position: absolute;
    width: 8px;
    height: 8px;
    background: #FFD700;
    border-radius: 50%;
    pointer-events: none;
    animation: mascot-sparkle 1s ease forwards;
}

@keyframes mascot-sparkle {
    0% { opacity: 1; transform: scale(0) translateY(0); }
    50% { opacity: 1; transform: scale(1) translateY(-20px); }
    100% { opacity: 0; transform: scale(0.5) translateY(-40px); }
}

/* ─── Reduced Motion ─── */
@media (prefers-reduced-motion: reduce) {
    .mascot-center,
    .mascot-body-svg,
    .mascot-head-svg,
    .mascot-emotion-svg,
    .speech-bubble,
    .octagon-button,
    .mascot-sparkle {
        animation: none !important;
        transition-duration: 0.001ms !important;
    }
    
    /* Still allow opacity transitions for state changes */
    .mascot-emotion-svg {
        transition: opacity 0.1s ease;
    }
    
    /* Remove entrance delays */
    .octagon-button {
        opacity: 1 !important;
        animation-delay: 0s !important;
    }
}
