/* ==========================================
   Animated Explainer Character
========================================== */
#explainer-character {
    position: fixed;
    bottom: 0;
    left: 30px;
    width: 130px;
    height: 220px;
    z-index: 9999;
    transition: bottom 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: auto;
    cursor: pointer;
}

#explainer-character.active {
    bottom: 0;
}

.character-body {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: float 3s ease-in-out infinite;
}

.character-head {
    width: 80px;
    height: 80px;
    background: #D6EAEB;
    /* Light Green Tint */
    border-radius: 40% 40% 35% 35%;
    position: relative;
    box-shadow:
        inset -6px -6px 12px rgba(0, 0, 0, 0.05),
        0 6px 15px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

/* Antenna / Top Detail */
.character-head::before {
    content: '';
    position: absolute;
    top: -10px;
    width: 6px;
    height: 18px;
    background: #333;
    border-radius: 3px;
    z-index: -1;
}

.character-head::after {
    content: '';
    position: absolute;
    top: -15px;
    width: 12px;
    height: 12px;
    background: #82C7CC;
    border-radius: 50%;
    box-shadow: 0 0 10px #83FFEE;
    animation: glow-pulse-green 2s infinite alternate;
}

.character-eyes {
    display: flex;
    gap: 20px;
    margin-top: 14px;
}

.eye {
    width: 14px;
    height: 20px;
    background: #333;
    border-radius: 50%;
    position: relative;
    animation: blink 4s infinite;
}

.eye::after {
    content: '';
    position: absolute;
    top: 4px;
    right: 4px;
    width: 4px;
    height: 4px;
    background: #fff;
    border-radius: 50%;
}

.character-mouth {
    width: 20px;
    height: 4px;
    background: #333;
    border-radius: 6px;
    margin-top: 16px;
    transition: all 0.1s;
}

/* Talking Animation State */
#explainer-character.talking .character-mouth {
    animation: talk 0.2s infinite alternate;
    height: 10px;
    border-radius: 10px;
}

#explainer-character.talking .character-head {
    animation: head-bob 1s infinite alternate;
}

.character-torso {
    width: 60px;
    height: 55px;
    background: linear-gradient(135deg, #5CA4A9, #3A7074, #8FD3D8, #5CA4A9);
    background-size: 300% 300%;
    animation: gradientFlow 10s ease infinite;
    border-radius: 20px 20px 0 0;
    margin-top: -10px;
    z-index: 1;
    position: relative;
}

.character-torso::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 26px;
    height: 26px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
}

.character-torso::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 52%;
    /* Slightly offset to visually center the triangle */
    transform: translate(-50%, -50%);
    width: 0;
    height: 0;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    border-left: 7px solid rgba(255, 255, 255, 0.8);
    transition: all 0.2s ease;
}

#explainer-character.playing .character-torso::after {
    /* Pause Icon Style: two bars */
    width: 8px;
    height: 8px;
    border: none;
    border-left: 2px solid rgba(255, 255, 255, 0.8);
    border-right: 2px solid rgba(255, 255, 255, 0.8);
    background: transparent;
    left: 50%;
    /* Center exactly */
}

/* Character Arms */
.character-arm {
    position: absolute;
    top: 90px;
    width: 14px;
    height: 38px;
    background: linear-gradient(135deg, #5CA4A9, #3A7074, #8FD3D8, #5CA4A9);
    background-size: 300% 300%;
    animation: gradientFlow 10s ease infinite;
    border-radius: 10px;
    z-index: 0;
    transition: all 0.3s ease;
}

.arm-left {
    left: 28px;
    transform: rotate(15deg);
    transform-origin: top center;
}

.arm-right {
    right: 28px;
    transform: rotate(-15deg);
    transform-origin: top center;
}

/* Talking Animation State - Wave Arms */
#explainer-character.talking .arm-left {
    animation: arm-wave-left 2s infinite ease-in-out;
}

#explainer-character.talking .arm-right {
    animation: arm-wave-right 2s infinite ease-in-out;
}

/* Legs */
.character-legs {
    display: flex;
    gap: 10px;
    margin-top: -2px;
    z-index: 0;
}

.character-leg {
    width: 18px;
    height: 40px;
    background: linear-gradient(135deg, #5CA4A9, #3A7074, #8FD3D8, #5CA4A9);
    background-size: 300% 300%;
    animation: gradientFlow 10s ease infinite;
    border-radius: 0 0 10px 10px;
}

/* Animations */
@keyframes glow-pulse-green {
    0% {
        opacity: 1;
        box-shadow: 0 0 5px #83FFEE, 0 0 10px #83FFEE;
    }

    50% {
        opacity: 0.4;
        /* Dim it to simulate blinking */
    }

    100% {
        opacity: 1;
        box-shadow: 0 0 10px #5CA4A9, 0 0 20px #5CA4A9;
    }
}

@keyframes gradientFlow {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-6px);
    }
}

@keyframes blink {

    0%,
    48%,
    52%,
    100% {
        transform: scaleY(1);
    }

    50% {
        transform: scaleY(0.1);
    }
}

@keyframes talk {
    0% {
        width: 20px;
        height: 4px;
        border-radius: 6px;
    }

    100% {
        width: 16px;
        height: 12px;
        border-radius: 50%;
        background: #222;
    }
}

@keyframes head-bob {
    0% {
        transform: rotate(-2deg);
    }

    100% {
        transform: rotate(2deg);
    }
}

@keyframes glow-pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    #explainer-character {
        left: 10px;
        /* Move to left, smaller margin */
        width: 90px;
        /* Half size */
        height: 130px;
        /* Half size */
        bottom: 0;
        /* Keep visible on mobile */
    }

    .character-head {
        width: 50px;
        /* Half size */
        height: 50px;
    }

    .character-head::before {
        width: 4px;
        height: 12px;
        top: -8px;
    }

    .character-head::after {
        width: 8px;
        height: 8px;
        top: -12px;
    }

    .character-eyes {
        gap: 10px;
        margin-top: 8px;
    }

    .eye {
        width: 8px;
        height: 12px;
    }

    .eye::after {
        width: 2px;
        height: 2px;
        top: 2px;
        right: 2px;
    }

    .character-mouth {
        width: 12px;
        height: 3px;
        margin-top: 10px;
    }

    .character-torso {
        width: 40px;
        height: 35px;
        margin-top: -8px;
        border-radius: 15px 15px 0 0;
    }

    .character-torso::before {
        width: 15px;
        height: 15px;
    }

    .character-torso::after {
        border-top: 3px solid transparent;
        border-bottom: 3px solid transparent;
        border-left: 5px solid rgba(255, 255, 255, 0.8);
    }

    #explainer-character.playing .character-torso::after {
        width: 6px;
        height: 7px;
        border: none;
        border-left: 2px solid rgba(255, 255, 255, 0.8);
        border-right: 2px solid rgba(255, 255, 255, 0.8);
    }

    .character-arm {
        width: 10px;
        height: 25px;
        top: 65px;
        border-radius: 6px;
    }

    .arm-left {
        left: 15px;
    }

    .arm-right {
        right: 15px;
    }

    .character-legs {
        gap: 6px;
    }

    .character-leg {
        width: 12px;
        height: 25px;
        border-radius: 0 0 6px 6px;
    }
}

@keyframes arm-wave-left {

    0%,
    100% {
        transform: rotate(15deg);
    }

    50% {
        transform: rotate(35deg);
    }
}

@keyframes arm-wave-right {

    0%,
    100% {
        transform: rotate(-15deg);
    }

    50% {
        transform: rotate(-35deg);
    }
}