.fox-mascot {
    position: fixed;
    z-index: 45;
    width: 96px;
    pointer-events: none;
    opacity: 0;
    transform: translateY(-24px) scale(0.5);
    transition:
        opacity 0.4s ease,
        transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.fox-mascot--visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.fox-mascot__shadow {
    width: 55%;
    height: 9px;
    margin: 0 auto;
    border-radius: 50%;
    background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.28) 0%, rgba(0, 0, 0, 0) 72%);
    animation: fox3-shadow-breathe 2.4s ease-in-out infinite;
}

/* Faces left by default; mirrored when the fox is on the left half of the
   screen so it always looks toward screen-center / the cursor. */
.fox3-flip {
    transition: transform 0.4s ease;
}
.fox3-flip--mirrored {
    transform: scaleX(-1);
}

/* Composed from 4 hand-made assets stacked on a shared stage, positioned by
   percentage so the whole thing scales with .fox-mascot's width. */
.fox3-stage {
    position: relative;
    width: 100%;
    aspect-ratio: 260 / 220;
    filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.16));
    pointer-events: auto;
    cursor: pointer;
}

.fox3-stage img {
    width: 100%;
    height: 100%;
    display: block;
}

.fox3-tail {
    position: absolute;
    left: 53.8%;
    top: 40.9%;
    width: 35.8%;
    height: 50.9%;
    transform-origin: 20% 90%;
    animation: fox3-wag 0.8s ease-in-out infinite;
}
@keyframes fox3-wag {
    0%, 100% { rotate: -9deg; }
    50% { rotate: 11deg; }
}

.fox3-body {
    position: absolute;
    left: 25%;
    top: 63.6%;
    width: 46.2%;
    height: 30.8%;
    transform-origin: 50% 100%;
    animation: fox3-breathe 2.4s ease-in-out infinite;
}
@keyframes fox3-breathe {
    0%, 100% { scale: 1 1; }
    50% { scale: 1.025 0.97; }
}
@keyframes fox3-shadow-breathe {
    0%, 100% { transform: scaleX(1); opacity: 0.5; }
    50% { transform: scaleX(0.92); opacity: 0.38; }
}

.fox3-head {
    position: absolute;
    left: 2.5%;
    top: 4.5%;
    width: 74.2%;
    height: 67.7%;
    transform-origin: 50% 92%;
    animation:
        fox3-head-tilt 4.2s ease-in-out infinite,
        fox3-head-bob 2.4s ease-in-out infinite;
}
@keyframes fox3-head-tilt {
    0%, 12% { rotate: -5deg; }
    38%, 50% { rotate: 5deg; }
    76%, 88% { rotate: -5deg; }
    100% { rotate: -5deg; }
}
@keyframes fox3-head-bob {
    0%, 100% { translate: 0 0; }
    50% { translate: 0 -2px; }
}

.fox3-mouth {
    position: absolute;
    left: 41%;
    top: 77%;
    width: 14%;
    height: 13.8%;
}

/* Default calm eyes, laid over the blank head; crossfades with .fox3-eye below on hover. */
.fox3-eye-normal {
    position: absolute;
    left: 34.65%;
    top: 53.06%;
    width: 27.75%;
    aspect-ratio: 53.65 / 19.49;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.fox3-eye-normal img {
    width: 100%;
    height: 100%;
    display: block;
}
.fox3-eye-normal--visible {
    opacity: 1;
}

/* Happy squint-eye overlays, swapped in over the head's normal eyes on hover. */
.fox3-eye {
    position: absolute;
    opacity: 0;
    transform: scale(0.6);
    transform-origin: center;
    transition:
        opacity 0.2s ease,
        transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.fox3-eye img {
    width: 100%;
    height: 100%;
    display: block;
}
.fox3-eye--visible {
    opacity: 1;
    transform: scale(1);
}
.fox3-eye--left {
    left: 22.5%;
    top: 55.3%;
    width: 22%;
    aspect-ratio: 43.57 / 27.51;
}
.fox3-eye--right {
    left: 55.4%;
    top: 55.5%;
    width: 22%;
    aspect-ratio: 48.31 / 32.97;
}

/* Speech bubble that pops up above the fox on hover; kept out of .fox3-flip
   so mirroring never flips the text backward. Its tail sits near the bubble's
   own left edge, so "left" is tuned to land that tail on the head -- and
   since the head swaps sides when .fox3-flip mirrors (fox parked left of the
   cursor), --mirrored re-anchors to the same tail-on-head spot on that side. */
.fox-mascot__bubble {
    position: absolute;
    left: 55%;
    bottom: calc(78% + 18px);
    width: 150px;
    transform: translateX(-50%) translateY(6px) scale(0.7);
    transform-origin: 50% 100%;
    opacity: 0;
    pointer-events: none;
    transition:
        opacity 0.25s ease,
        transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
        left 0.3s ease;
}
.fox-mascot__bubble--mirrored {
    left: 110.7%;
}
.fox-mascot__bubble img {
    width: 100%;
    display: block;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.2));
}
.fox-mascot__bubble--visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
}

.fox3-leg {
    position: absolute;
    transform-origin: 50% 0%;
}
.fox3-leg--1 {
    left: 34.6%;
    top: 87%;
    width: 6.2%;
    height: 10.3%;
}
.fox3-leg--2 {
    left: 41.5%;
    top: 82.5%;
    width: 9%;
    height: 14.1%;
}
.fox3-leg--3 {
    left: 50.8%;
    top: 92.5%;
    width: 6.1%;
    height: 3.6%;
}
.fox3-leg--4 {
    left: 55.8%;
    top: 72%;
    width: 16.9%;
    height: 24%;
}
/* Legs only wiggle while the fox is actually chasing the cursor. */
.fox-mascot__body--walking .fox3-leg--1 {
    animation: fox3-leg-wiggle 1.3s ease-in-out infinite;
    animation-delay: 0s;
}
.fox-mascot__body--walking .fox3-leg--2 {
    animation: fox3-leg-wiggle 1.5s ease-in-out infinite;
    animation-delay: 0.25s;
}
.fox-mascot__body--walking .fox3-leg--3 {
    animation: fox3-leg-wiggle 1.1s ease-in-out infinite;
    animation-delay: 0.5s;
}
.fox-mascot__body--walking .fox3-leg--4 {
    animation: fox3-leg-wiggle 1.6s ease-in-out infinite;
    animation-delay: 0.15s;
}
@keyframes fox3-leg-wiggle {
    0%, 100% { rotate: -4deg; }
    50% { rotate: 4deg; }
}

/* Occasional whole-body accent tricks, layered on .fox-mascot__body (not the
   outer .fox-mascot) so the speech bubble sibling never gets dragged along
   for the ride -- it should stay put while the character hops/spins. */
.fox-mascot__body--bounce {
    animation: fox-wrapper-bounce 0.9s ease-in-out;
}
@keyframes fox-wrapper-bounce {
    0%, 100% { transform: translateY(0) scale(1); }
    30% { transform: translateY(-26px) scale(1.05, 0.93); }
    50% { transform: translateY(2px) scale(0.95, 1.08); }
    70% { transform: translateY(-8px) scale(1.02, 0.97); }
}

.fox-mascot__body--shake {
    animation: fox-wrapper-shake 0.6s ease-in-out;
}
@keyframes fox-wrapper-shake {
    0%, 100% { transform: translateX(0) rotate(0deg); }
    20% { transform: translateX(-5px) rotate(-6deg); }
    40% { transform: translateX(5px) rotate(6deg); }
    60% { transform: translateX(-4px) rotate(-4deg); }
    80% { transform: translateX(3px) rotate(2deg); }
}

/* Happy little hop while the cursor is right on the fox. */
.fox-mascot__body--hovered {
    animation: fox-wrapper-happy-jump 0.45s ease-in-out infinite;
}
@keyframes fox-wrapper-happy-jump {
    0%, 100% { transform: translateY(0) scale(1, 1); }
    40% { transform: translateY(-5px) scale(1.04, 0.95); }
    70% { transform: translateY(0) scale(0.97, 1.04); }
}

/* Occasional excited somersault, randomly rolled in while hovered. */
.fox-mascot__body--somersault {
    animation: fox-wrapper-somersault 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes fox-wrapper-somersault {
    0% { transform: translateY(0) rotate(0deg) scale(1, 1); }
    30% { transform: translateY(-22px) rotate(160deg) scale(0.9, 1.1); }
    60% { transform: translateY(-8px) rotate(360deg) scale(1.05, 0.95); }
    100% { transform: translateY(0) rotate(360deg) scale(1, 1); }
}

@media (prefers-reduced-motion: reduce) {
    .fox3-tail,
    .fox3-body,
    .fox3-head,
    .fox3-leg,
    .fox-mascot__shadow {
        animation: none !important;
    }
    .fox-mascot__body--bounce,
    .fox-mascot__body--shake,
    .fox-mascot__body--hovered,
    .fox-mascot__body--somersault {
        animation: none !important;
    }
    .fox-mascot {
        transition: opacity 0.3s ease;
    }
}

@media (max-width: 575.98px) {
    .fox-mascot { display: none; }
}
