/* ============================================================ */
/* GESTITO - Mascota Animada Interactiva                        */
/* ============================================================ */

/* 1. Base Integration */
.gw-mascot {
    position: fixed;
    z-index: 9999;
    cursor: pointer;
    width: 60px;
    height: auto;

    /* Master Transition: Handle all animatable properties smoothy */
    /* specialized timing function for "alive" feel */
    transition:
        transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1),
        opacity 0.5s ease-out,
        top 0.8s cubic-bezier(0.34, 1.56, 0.64, 1),
        left 0.8s cubic-bezier(0.34, 1.56, 0.64, 1),
        right 0.8s cubic-bezier(0.34, 1.56, 0.64, 1),
        bottom 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);

    /* Default Float Animation (can be overridden by states) */
    animation: mascot-float 6s ease-in-out infinite;
}

/* 2. Visual Parts */
.mascot-body {
    position: relative;
    width: 100%;
    /* Ensure body doesn't flip independently unless specified */
}

.mascot-body img {
    width: 100%;
    display: block;
    filter: drop-shadow(0 10px 10px rgba(0, 0, 0, 0.2));
}

.mascot-eyes {
    position: absolute;
    top: 2px;
    left: 55%;
    transform: translateX(-50%);
    width: 30%;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
    /* Let clicks pass through */
}

.eye {
    width: 6px;
    height: 8px;
    background: white;
    border-radius: 50%;
    overflow: hidden;
    position: relative;
    animation: mascot-blink 4s infinite;
}

.pupil {
    width: 4px;
    height: 4px;
    background: #333;
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 1px;
    transition: transform 0.1s ease-out;
    /* Fast tracking */
}

/* 3. Message Bubble */
.mascot-message {
    position: absolute;
    bottom: 110%;
    /* Slightly higher */
    right: 0;
    width: max-content;
    max-width: 220px;
    background: white;
    padding: 12px 18px;
    border-radius: 18px 18px 2px 18px;
    /* Chat bubble style */
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    font-size: 0.95rem;
    color: #333;
    opacity: 0;
    transform: translateY(15px) scale(0.8) rotate(-5deg);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
    font-weight: 600;
    line-height: 1.4;
    z-index: 10001;
}

/* Show message on hover or when class added */
.gw-mascot:hover .mascot-message,
.gw-mascot.showing-message .mascot-message {
    opacity: 1;
    transform: translateY(0) scale(1) rotate(0deg);
}

/* 4. Positions & Transforms */

/* --- Bottom Left --- */
.gw-mascot.pos-bottom-left {
    bottom: 30px;
    left: 30px;
    right: auto;
    top: auto;
}

/* Fix message text for standard orientation */
.gw-mascot.pos-bottom-left .mascot-message {
    right: auto;
    left: 80%;
    /* Push it slightly right of the mascot body */
    bottom: 100%;
    /* Above */
    border-radius: 18px 18px 18px 2px;
    transform: translateY(15px) scale(0.8) rotate(5deg);
    min-width: 150px;
    /* Ensure it has width to grow right */
}

.gw-mascot.pos-bottom-left:hover .mascot-message,
.gw-mascot.pos-bottom-left.showing-message .mascot-message,
.gw-mascot.pos-bottom-left.attention .mascot-message {
    transform: translateY(0) scale(1) rotate(0deg);
}


/* --- Side Right Mid --- */
/* Peeking from the right side, rotated 90deg */
.gw-mascot.pos-side-right-mid {
    top: 50%;
    right: -15px;
    /* Slight peek */
    bottom: auto;
    left: auto;
    transform: translateY(-50%) rotate(-90deg);
}

.gw-mascot.pos-side-right-mid:hover,
.gw-mascot.pos-side-right-mid.attention {
    right: 10px;
    /* Slide out */
    transform: translateY(-50%) rotate(0deg);
    /* Rotate up */
}

/* --- Corner Peek Right --- */
/* Peeking from bottom right corner, rotated 45deg */
.gw-mascot.pos-corner-peek-right {
    bottom: -25px;
    right: -25px;
    transform: rotate(-45deg);
}

.gw-mascot.pos-corner-peek-right:hover,
.gw-mascot.pos-corner-peek-right.attention {
    bottom: 20px;
    right: 20px;
    transform: rotate(0deg);
}

/* --- Corner Peek Left --- */
/* Peeking from bottom left corner, NO FLIP */
.gw-mascot.pos-corner-peek-left {
    bottom: -25px;
    left: -25px;
    /* If not flipped, rotating 45deg makes head point right-down */
    /* We want head pointing right-up (standard peek) */
    transform: rotate(45deg);
}

.gw-mascot.pos-corner-peek-left .mascot-message {
    right: auto;
    left: 100%;
    /* Anchor to right of mascot */
    bottom: 100%;
    transform-origin: bottom left;
}

.gw-mascot.pos-corner-peek-left:hover,
.gw-mascot.pos-corner-peek-left.attention {
    bottom: 20px;
    left: 20px;
    transform: rotate(0deg);
}


/* 5. States & Animations */

/* --- Hiding (The Exit Animation) --- */
.gw-mascot.hiding {
    opacity: 0;
    pointer-events: none;
    /* We assume specific positions define their own hiding transform below */
}

/* Specific Hiding Transforms (Crucial for the "Rotation" request) */
.gw-mascot.pos-bottom-left.hiding {
    /* Dive down and rotate out (standard, no flip) */
    transform: translateY(150px) rotate(-45deg);
}

.gw-mascot.pos-side-right-mid.hiding {
    /* Retreat back right and rotate more */
    transform: translate(100px, -50%) rotate(-135deg);
}

.gw-mascot.pos-corner-peek-right.hiding {
    /* Retreat deeply into corner */
    transform: translate(80px, 80px) rotate(-90deg);
}

.gw-mascot.pos-corner-peek-left.hiding {
    /* Retreat deeply into corner (standard, no flip) */
    transform: translate(-80px, 80px) rotate(90deg);
}

/* --- Interactive States --- */

/* Dancing */
.gw-mascot.dancing {
    animation: mascot-dance-crazy 0.4s infinite alternate;
}

@keyframes mascot-dance-crazy {
    0% {
        transform: rotate(-15deg) scale(1.1) translateY(0);
    }

    100% {
        transform: rotate(15deg) scale(1.1) translateY(-10px);
    }
}

/* Dizzy */
.gw-mascot.dizzy {
    animation: mascot-dizzy-spin 0.5s linear infinite;
}

@keyframes mascot-dizzy-spin {
    0% {
        transform: rotate(0deg) scale(1.2);
    }

    25% {
        transform: rotate(-10deg) scale(1.2) translateX(-5px);
    }

    75% {
        transform: rotate(10deg) scale(1.2) translateX(5px);
    }

    100% {
        transform: rotate(0deg) scale(1.2);
    }
}

/* Lightning Move (Link Click) */
/* Loading/Processing State (Replaces Lightning) */
.gw-mascot.loading {
    transition: top 0.5s ease-in-out, left 0.5s ease-in-out !important;
    animation: mascot-pulse 1s infinite alternate;
    z-index: 10000;
}

@keyframes mascot-pulse {
    0% {
        transform: scale(1);
        filter: brightness(1);
    }

    100% {
        transform: scale(1.1);
        filter: brightness(1.2);
    }
}

.gw-mascot.loading .mascot-message {
    opacity: 1;
    transform: translateY(0) scale(1);
    background: #2196F3;
    /* Blue for info/loading */
    color: white;
}

/* Angry/Saturated phase */
.gw-mascot.loading.angry .mascot-message {
    background: #F44336;
    /* Red for angry */
    transform: translateY(0) scale(1.1) rotate(-2deg);
    animation: mascot-shake-angry 0.3s infinite;
}

@keyframes mascot-shake-angry {
    0% {
        transform: translateX(0) rotate(-2deg);
    }

    25% {
        transform: translateX(-2px) rotate(2deg);
    }

    50% {
        transform: translateX(0) rotate(-2deg);
    }

    75% {
        transform: translateX(2px) rotate(2deg);
    }

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

/* Tickled State */
.gw-mascot.tickled {
    animation: mascot-laugh 0.3s infinite;
}

@keyframes mascot-laugh {
    0% {
        transform: scale(1.1) rotate(0deg);
    }

    25% {
        transform: scale(1.1) rotate(5deg);
    }

    50% {
        transform: scale(1.1) rotate(0deg);
    }

    75% {
        transform: scale(1.1) rotate(-5deg);
    }

    100% {
        transform: scale(1.1) rotate(0deg);
    }
}

/* Jumping */
.gw-mascot.jumping {
    animation: mascot-jump-high 0.6s ease-out;
}

@keyframes mascot-jump-high {
    0% {
        transform: scale(1, 0.9);
    }

    30% {
        transform: scale(0.9, 1.1) translateY(-50px);
    }

    50% {
        transform: scale(1, 1) translateY(-50px) rotate(180deg);
    }

    /* Flip! */
    100% {
        transform: scale(1, 1) translateY(0) rotate(360deg);
    }
}

/* 6. Standard Keyframes */
@keyframes mascot-float {

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

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

@keyframes mascot-blink {

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

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

/* Adjust for scaleX(-1) positions */
/* If position applies a transform, animation needs to account for it, 
   OR we wrap animation on inner element. 
   Currently base "float" might conflict with position transform.
   FIX: Apply float to body instead of wrapper to separate concerns. */
.gw-mascot {
    animation: none;
    /* Move float to body */
}

.mascot-body {
    animation: mascot-float 6s ease-in-out infinite;
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    .gw-mascot {
        width: 50px;
    }

    .mascot-message {
        font-size: 0.8rem;
        padding: 8px 12px;
    }
}

/* Crying State - for abandoned visitors */
.gw-mascot.crying {
    animation: mascot-cry 0.5s ease-in-out infinite;
}

@keyframes mascot-cry {

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

    25% {
        transform: translateY(3px) rotate(-2deg);
    }

    75% {
        transform: translateY(3px) rotate(2deg);
    }
}