/* ===========================================
   CHRONOS THE TIME-TRAVELING HAMSTER
   History Quest Mascot System
   =========================================== */

/* Mascot Container - Fixed Position Bottom Right */
.mascot-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 90;
    pointer-events: auto;
    transition: all 0.3s ease;
}

.mascot-container.collapsed {
    bottom: 10px;
    right: 10px;
}

/* Hidden where the mascot would sit on top of the content: the minigame, and
   every teacher/admin screen. Chronos is fixed to the bottom-right, so on an
   analytics page at 1280px he lands ON the data (measured: his box starts at
   x=1165 while the tracker's content runs to x=1223). */
body.mascot-hidden .mascot-container {
    display: none !important;
}

/* ===========================================
   THE HAMSTER CHARACTER (Pure CSS)
   =========================================== */

.mascot {
    position: relative;
    width: 80px;
    height: 90px;
    cursor: pointer;
    transition: transform 0.3s ease;
    filter: drop-shadow(2px 4px 6px rgba(0,0,0,0.3));
}

.mascot:hover {
    transform: scale(1.1);
}

.mascot:active {
    transform: scale(0.95);
}

/* Hamster Body */
.hamster-body {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 50px;
    background: linear-gradient(135deg, #F4A460 0%, #DEB887 50%, #D2691E 100%);
    border-radius: 50% 50% 45% 45%;
    border: 2px solid #8B4513;
    animation: mascot-breathe 3s ease-in-out infinite;
}

/* Belly */
.hamster-belly {
    position: absolute;
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 30px;
    background: linear-gradient(to bottom, #FFE4C4, #FFDAB9);
    border-radius: 50%;
}

/* Head */
.hamster-head {
    position: absolute;
    bottom: 35px;
    left: 50%;
    transform: translateX(-50%);
    width: 55px;
    height: 45px;
    background: linear-gradient(135deg, #F4A460 0%, #DEB887 100%);
    border-radius: 50% 50% 40% 40%;
    border: 2px solid #8B4513;
    z-index: 2;
}

/* Cheeks (hamster cheek pouches!) */
.hamster-cheek {
    position: absolute;
    bottom: 8px;
    width: 18px;
    height: 15px;
    background: linear-gradient(to bottom, #FFB6C1, #FFA07A);
    border-radius: 50%;
    z-index: 3;
}

.hamster-cheek.left {
    left: 2px;
}

.hamster-cheek.right {
    right: 2px;
}

/* Ears */
.hamster-ear {
    position: absolute;
    top: -8px;
    width: 16px;
    height: 14px;
    background: linear-gradient(to bottom, #DEB887, #D2691E);
    border-radius: 50% 50% 30% 30%;
    border: 2px solid #8B4513;
}

.hamster-ear.left {
    left: 5px;
    transform: rotate(-15deg);
}

.hamster-ear.right {
    right: 5px;
    transform: rotate(15deg);
}

/* Eyes - THE EXPRESSIVE PART */
.hamster-eyes {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 12px;
    z-index: 4;
}

.hamster-eye {
    width: 14px;
    height: 14px;
    background: #1a1a1a;
    border-radius: 50%;
    position: relative;
    animation: mascot-blink 4s ease-in-out infinite;
}

.hamster-eye::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 3px;
    width: 5px;
    height: 5px;
    background: white;
    border-radius: 50%;
}

/* Nose */
.hamster-nose {
    position: absolute;
    top: 22px;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 6px;
    background: #FF69B4;
    border-radius: 50%;
    z-index: 4;
}

/* Mouth - changes based on state */
.hamster-mouth {
    position: absolute;
    top: 28px;
    left: 50%;
    transform: translateX(-50%);
    width: 10px;
    height: 5px;
    border-bottom: 2px solid #8B4513;
    border-radius: 0 0 50% 50%;
    z-index: 4;
}

/* Goggles (Time Traveler!) */
.hamster-goggles {
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    width: 48px;
    height: 18px;
    z-index: 5;
}

.goggle-lens {
    position: absolute;
    top: 0;
    width: 18px;
    height: 16px;
    background: linear-gradient(135deg, #87CEEB 0%, #4169E1 50%, #1E90FF 100%);
    border: 2px solid #4a4a4a;
    border-radius: 40%;
    box-shadow: inset 0 0 5px rgba(255,255,255,0.5);
}

.goggle-lens.left {
    left: 0;
}

.goggle-lens.right {
    right: 0;
}

.goggle-strap {
    position: absolute;
    top: 6px;
    left: 16px;
    width: 16px;
    height: 4px;
    background: #4a4a4a;
}

/* Tiny Arms */
.hamster-arm {
    position: absolute;
    bottom: 20px;
    width: 12px;
    height: 20px;
    background: linear-gradient(to bottom, #F4A460, #DEB887);
    border-radius: 30% 30% 50% 50%;
    border: 1px solid #8B4513;
    transform-origin: top center;
}

.hamster-arm.left {
    left: -5px;
    transform: rotate(20deg);
}

.hamster-arm.right {
    right: -5px;
    transform: rotate(-20deg);
}

/* Tiny Tail */
.hamster-tail {
    position: absolute;
    bottom: 8px;
    right: -6px;
    width: 10px;
    height: 7px;
    background: #DEB887;
    border-radius: 50%;
    border: 1px solid #8B4513;
    transform: rotate(-15deg);
}

/* Whiskers */
.hamster-whiskers {
    position: absolute;
    bottom: 14px;
    width: 14px;
    height: 1px;
    background: rgba(139, 69, 19, 0.5);
    z-index: 3;
}

.hamster-whiskers.left {
    left: -10px;
    transform: rotate(5deg);
}

.hamster-whiskers.right {
    right: -10px;
    transform: rotate(-5deg);
}

.hamster-whiskers::before,
.hamster-whiskers::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 1px;
    background: rgba(139, 69, 19, 0.5);
}

.hamster-whiskers::before {
    top: -4px;
}

.hamster-whiskers::after {
    top: 4px;
}

.hamster-whiskers.left::before {
    transform: rotate(-8deg);
}

.hamster-whiskers.left::after {
    transform: rotate(8deg);
}

.hamster-whiskers.right::before {
    transform: rotate(8deg);
}

.hamster-whiskers.right::after {
    transform: rotate(-8deg);
}

/* Tiny Feet */
.hamster-foot {
    position: absolute;
    bottom: -2px;
    width: 14px;
    height: 8px;
    background: #DEB887;
    border-radius: 50%;
    border: 1px solid #8B4513;
}

.hamster-foot.left {
    left: 10px;
}

.hamster-foot.right {
    right: 10px;
}

/* ===========================================
   ANIMATIONS
   =========================================== */

/* Idle breathing */
@keyframes mascot-breathe {
    0%, 100% { transform: translateX(-50%) scaleY(1); }
    50% { transform: translateX(-50%) scaleY(1.03); }
}

/* Blinking */
@keyframes mascot-blink {
    0%, 45%, 55%, 100% { transform: scaleY(1); }
    50% { transform: scaleY(0.1); }
}

/* Bounce (celebration) */
@keyframes mascot-bounce {
    0%, 100% { transform: translateY(0); }
    25% { transform: translateY(-15px) rotate(-5deg); }
    50% { transform: translateY(-5px); }
    75% { transform: translateY(-10px) rotate(5deg); }
}

/* Wiggle (excited) */
@keyframes mascot-wiggle {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-10deg); }
    75% { transform: rotate(10deg); }
}

/* Sad droop */
@keyframes mascot-droop {
    0%, 100% { transform: translateY(0) rotate(0); }
    50% { transform: translateY(3px) rotate(-3deg); }
}

/* Thinking */
@keyframes mascot-think {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(3px); }
}

/* Poked reaction */
@keyframes mascot-poked {
    0% { transform: scale(1); }
    20% { transform: scale(0.8) rotate(-10deg); }
    40% { transform: scale(1.2) rotate(10deg); }
    60% { transform: scale(0.9) rotate(-5deg); }
    80% { transform: scale(1.1) rotate(5deg); }
    100% { transform: scale(1) rotate(0); }
}

/* Wave arms */
@keyframes mascot-wave {
    0%, 100% { transform: rotate(20deg); }
    50% { transform: rotate(-30deg); }
}

/* State Classes - animations on .mascot so body, arms, legs all move together */
.mascot.celebrating {
    animation: mascot-bounce 0.5s ease-in-out 3;
}

.mascot.celebrating .hamster-arm.left {
    animation: mascot-wave 0.3s ease-in-out 6;
}

.mascot.excited {
    animation: mascot-wiggle 0.3s ease-in-out 4;
}

.mascot.encouraging {
    animation: mascot-droop 2s ease-in-out infinite;
}

.mascot.thinking {
    animation: mascot-think 1s ease-in-out infinite;
}

.mascot.poked {
    animation: mascot-poked 0.6s ease-out;
}

/* Big smile when celebrating */
.mascot.celebrating .hamster-mouth,
.mascot.excited .hamster-mouth {
    width: 14px;
    height: 8px;
    border-bottom: none;
    background: #1a1a1a;
    border-radius: 0 0 50% 50%;
}

/* Happy squint eyes when celebrating */
.mascot.celebrating .hamster-eye,
.mascot.excited .hamster-eye {
    animation: none;
    transform: scaleY(0.3);
}

.mascot.celebrating .hamster-eye::after,
.mascot.excited .hamster-eye::after {
    display: none;
}

/* Sympathetic wide eyes when encouraging */
.mascot.encouraging .hamster-eye {
    animation: none;
    transform: scaleY(1.15) scaleX(1.1);
}

/* Frown mouth when encouraging */
.mascot.encouraging .hamster-mouth {
    border-bottom: none;
    border-top: 2px solid #8B4513;
    border-radius: 50% 50% 0 0;
}

/* Ears droop when encouraging */
.mascot.encouraging .hamster-ear.left {
    transform: rotate(-30deg);
    transition: transform 0.3s ease;
}

.mascot.encouraging .hamster-ear.right {
    transform: rotate(30deg);
    transition: transform 0.3s ease;
}

/* Surprised O-mouth when poked */
.mascot.poked .hamster-mouth {
    width: 8px;
    height: 8px;
    border: none;
    background: #1a1a1a;
    border-radius: 50%;
}

/* Wide eyes when poked */
.mascot.poked .hamster-eye {
    animation: none;
    transform: scale(1.3);
}

/* Thinking: one eye squinted */
.mascot.thinking .hamster-eye:first-child {
    animation: none;
    transform: scaleY(0.6);
}

/* ===========================================
   SPEECH BUBBLE
   =========================================== */

.mascot-speech {
    position: absolute;
    bottom: 100%;
    right: 0;
    margin-bottom: 10px;
    background: var(--card-bg, white);
    border: 2px solid var(--border-color, #64B5F6);
    border-radius: 15px;
    padding: 10px 14px;
    max-width: 200px;
    min-width: 120px;
    font-size: 13px;
    line-height: 1.4;
    color: var(--text-primary, #333);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    opacity: 0;
    transform: translateY(10px) scale(0.9);
    transition: all 0.3s ease;
    pointer-events: none;
    z-index: 91;
}

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

/* Speech bubble tail */
.mascot-speech::after {
    content: '';
    position: absolute;
    bottom: -10px;
    right: 25px;
    border-width: 10px 8px 0 8px;
    border-style: solid;
    border-color: var(--card-bg, white) transparent transparent transparent;
}

.mascot-speech::before {
    content: '';
    position: absolute;
    bottom: -13px;
    right: 24px;
    border-width: 11px 9px 0 9px;
    border-style: solid;
    border-color: var(--border-color, #64B5F6) transparent transparent transparent;
}

/* ===========================================
   COLLAPSE/EXPAND CONTROLS
   =========================================== */

.mascot-close {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 22px;
    height: 22px;
    background: #ff6b6b;
    border: 2px solid white;
    border-radius: 50%;
    color: white;
    font-size: 14px;
    font-weight: bold;
    line-height: 18px;
    text-align: center;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 92;
}

.mascot:hover .mascot-close {
    opacity: 1;
}

.mascot-close:hover {
    background: #ff4757;
    transform: scale(1.1);
}

/* Collapsed State - Just a small icon */
.mascot-collapsed {
    display: none;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #F4A460, #DEB887);
    border: 3px solid #8B4513;
    border-radius: 50%;
    cursor: pointer;
    position: relative;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
    overflow: hidden;
}

.mascot-collapsed:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0,0,0,0.3);
}

.mascot-collapsed::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 12px;
    width: 8px;
    height: 8px;
    background: #1a1a1a;
    border-radius: 50%;
}

.mascot-collapsed::after {
    content: '';
    position: absolute;
    top: 8px;
    right: 12px;
    width: 8px;
    height: 8px;
    background: #1a1a1a;
    border-radius: 50%;
}

/* Goggle hint on collapsed icon */
.mascot-collapsed .goggle-hint {
    position: absolute;
    top: 5px;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 10px;
    background: linear-gradient(135deg, #87CEEB, #4169E1);
    border: 1px solid #4a4a4a;
    border-radius: 30%;
    opacity: 0.8;
}

.mascot-container.collapsed .mascot {
    display: none;
}

.mascot-container.collapsed .mascot-collapsed {
    display: block;
}

.mascot-container.collapsed .mascot-speech {
    display: none;
}

/* ===========================================
   DARK MODE
   =========================================== */

[data-theme="dark"] .mascot-speech {
    background: var(--card-bg, #1f4068);
    border-color: var(--border-color, #4a90d9);
    color: var(--text-primary, #e8e8e8);
}

[data-theme="dark"] .mascot-speech::after {
    border-color: var(--card-bg, #1f4068) transparent transparent transparent;
}

[data-theme="dark"] .mascot-speech::before {
    border-color: var(--border-color, #4a90d9) transparent transparent transparent;
}

[data-theme="dark"] .mascot {
    filter: drop-shadow(2px 4px 8px rgba(0,0,0,0.5));
}

/* ===========================================
   MOBILE RESPONSIVE
   =========================================== */

@media (max-width: 768px) {
    .mascot-container {
        bottom: 15px;
        right: 15px;
    }

    .mascot {
        width: 60px;
        height: 70px;
        transform: scale(0.8);
    }

    .mascot-speech {
        max-width: 160px;
        font-size: 12px;
        right: 0;
    }

    .mascot-collapsed {
        width: 40px;
        height: 40px;
    }
}

@media (max-width: 480px) {
    .mascot-container {
        bottom: 10px;
        right: 10px;
    }

    .mascot {
        transform: scale(0.65);
    }

    .mascot-speech {
        max-width: 140px;
        font-size: 12px;
        padding: 8px 10px;
    }
}

/* ===========================================
   GOAL 71: WARDROBE ACCESSORIES
   Pure-CSS overlays anchored to the hamster head.
   =========================================== */

.mascot-accessory {
    position: absolute;
    z-index: 6;
    pointer-events: none;
}

/* Golden Laurel — Ancient Civilizations */
.mascot-accessory.acc-laurel {
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 56px;
    height: 14px;
    border: 3px solid #DAA520;
    border-bottom: none;
    border-radius: 28px 28px 0 0;
    background: transparent;
}
.mascot-accessory.acc-laurel::before,
.mascot-accessory.acc-laurel::after {
    content: '';
    position: absolute;
    bottom: -2px;
    width: 10px;
    height: 6px;
    background: #DAA520;
    border-radius: 50% 0 50% 0;
}
.mascot-accessory.acc-laurel::before { left: -6px; transform: rotate(-30deg); }
.mascot-accessory.acc-laurel::after { right: -6px; transform: rotate(30deg) scaleX(-1); }

/* Knight's Helm — Medieval Period */
.mascot-accessory.acc-knight_helm {
    top: -14px;
    left: 50%;
    transform: translateX(-50%);
    width: 48px;
    height: 22px;
    background: linear-gradient(135deg, #B0BEC5, #78909C);
    border: 2px solid #546E7A;
    border-radius: 24px 24px 4px 4px;
}
.mascot-accessory.acc-knight_helm::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 6px;
    height: 10px;
    background: #C62828;
    border-radius: 3px 3px 0 0;
}

/* Navigator's Tricorn — Age of Exploration */
.mascot-accessory.acc-tricorn {
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    width: 58px;
    height: 14px;
    background: linear-gradient(135deg, #4E342E, #3E2723);
    border-radius: 50% 50% 30% 30%;
    border: 2px solid #260e04;
}
.mascot-accessory.acc-tricorn::before {
    content: '';
    position: absolute;
    top: -7px;
    left: 50%;
    transform: translateX(-50%);
    width: 26px;
    height: 12px;
    background: #4E342E;
    border-radius: 13px 13px 0 0;
    border: 2px solid #260e04;
    border-bottom: none;
}
.mascot-accessory.acc-tricorn::after {
    content: '';
    position: absolute;
    top: 1px;
    left: 8px;
    width: 10px;
    height: 4px;
    background: #FFD54F;
    border-radius: 2px;
}

/* Time Lord Top Hat — 20th Century */
.mascot-accessory.acc-top_hat {
    top: -24px;
    left: 50%;
    transform: translateX(-50%) rotate(-4deg);
    width: 30px;
    height: 24px;
    background: linear-gradient(135deg, #37474F, #212121);
    border-radius: 4px 4px 0 0;
}
.mascot-accessory.acc-top_hat::before {
    content: '';
    position: absolute;
    bottom: -4px;
    left: -8px;
    right: -8px;
    height: 5px;
    background: #212121;
    border-radius: 3px;
}
.mascot-accessory.acc-top_hat::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 0;
    right: 0;
    height: 5px;
    background: #B8860B;
}

/* Goal 86: close/collapse controls are real <button>s now — neutralize UA styles */
button.mascot-close,
button.mascot-collapsed {
    font-family: inherit;
    padding: 0;
    line-height: 1;
}

/* ===========================================
   REDUCED MOTION (Accessibility)
   =========================================== */

@media (prefers-reduced-motion: reduce) {
    .mascot,
    .mascot *,
    .mascot-speech,
    .mascot-collapsed {
        animation: none !important;
        transition: opacity 0.2s ease !important;
    }
}
