/* ===== Avatar (bold reactions) ===== */
.avatar {
    position: relative;
    width: 280px;
    height: 320px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 12px 30px rgba(0, 0, 0, 0.12));
    transition: transform 0.18s ease;
    /* Responsive scale knob (used by pose transforms) */
    --avatar-scale: 1;
    /* Hint that we animate transforms and sometimes filter */
    will-change: transform, filter;
}
@keyframes reading-glow {
    0%, 100% { opacity: 0.25; filter: blur(0); }
    50% { opacity: 0.55; filter: blur(2px); }
}
.avatar .floaty-stars {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(8px 8px at 20% 10%, #ffe380 40%, transparent 41%),
        radial-gradient(6px 6px at 80% 25%, #ffd2f4 45%, transparent 46%),
        radial-gradient(5px 5px at 70% 70%, #b5fbdc 45%, transparent 46%);
    opacity: 0.6;
    animation: twinkle 3s infinite ease-in-out alternate;
    will-change: opacity, transform;
}

@keyframes twinkle {
    from {
        opacity: 0.35;
        transform: translateY(0);
    }
    to {
        opacity: 0.8;
        transform: translateY(-4px);
    }
}

/* Reaction Burst */
.burst {
    position: absolute;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    background: radial-gradient(
        closest-side,
        rgba(255, 255, 255, 0.85),
        rgba(255, 255, 255, 0)
    );
    filter: blur(6px);
    opacity: 0;
    transform: scale(0.6);
    pointer-events: none;
}
.avatar.burst-on .burst {
    animation: burst-pop 0.6s ease forwards;
}
@keyframes burst-pop {
    0% {
        opacity: 0;
        transform: scale(0.6);
    }
    30% {
        opacity: 1;
        transform: scale(1.1);
    }
    100% {
        opacity: 0;
        transform: scale(1.6);
    }
}

/* Emoji fireworks container; children are absolutely positioned */
.emoji-fireworks {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: visible;
}

/* Core shapes - More realistic proportions - removed animal-specific styling */

/* Avatar faces and body elements removed - only human 3D avatars supported now */

/* ===== Poses (2D avatars removed - poses now only apply to 3D human avatars) ===== */

/* ===== Enhanced Reactions ===== */
.avatar.shake {
    animation: shake 0.35s ease both;
}
@keyframes shake {
    0%,
    100% {
        transform: translateX(0) scale(1.08);
    }
    25% {
        transform: translateX(-6px) scale(1.08);
    }
    75% {
        transform: translateX(6px) scale(1.08);
    }
}

.avatar.dizzy {
    animation: dizzy 0.8s ease both;
}
@keyframes dizzy {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-5deg); }
    75% { transform: rotate(5deg); }
}

.avatar.lean-in {
    animation: leanIn 1s ease both;
}
@keyframes leanIn {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1) translateY(-5px); }
}

/* Removed .avatar.cover-ears - animal-specific reaction */

.avatar.bounce {
    animation: happyBounce 0.6s ease both;
}
@keyframes happyBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

.avatar.peaceful {
    animation: peaceful 1s ease both;
}
@keyframes peaceful {
    0%, 100% { filter: hue-rotate(0deg); }
    50% { filter: hue-rotate(30deg) brightness(1.1); }
}

.avatar.encouraging {
    animation: encouraging 1s ease both;
}
@keyframes encouraging {
    0%, 100% { transform: scale(1); }
    25% { transform: scale(1.05); }
    75% { transform: scale(1.02); }
}

/* Removed .avatar.clap arm animations - animal-specific */

/* ===== Keyframes ===== */
/* Removed animal-specific animations (idle, wag, cat-swish, bunny-wiggle, bunny-nose-twitch, read-bob, breathing, celebrate-bounce) */
/* Removed animal-specific arm/ear animations (clap-left, clap-right, ear-pop, dog-ear-flop, cat-ear-twitch, bunny-ear-twitch) */

/* ===== Outfits and Accessories ===== */
/* Removed animal avatar outfit/accessory styling - these were specific to 2D avatars */

/* ===== Special Celebration Animations ===== */
.avatar.speed-celebration {
    animation: speedCelebration 1.5s ease both;
}
@keyframes speedCelebration {
    0%, 100% { transform: scale(1); }
    25% { transform: scale(1.1) rotate(-5deg); }
    50% { transform: scale(1.2) rotate(5deg); }
    75% { transform: scale(1.1) rotate(-2deg); }
}

.avatar.volume-celebration {
    animation: volumeCelebration 1.5s ease both;
}
@keyframes volumeCelebration {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.3) saturate(1.5); }
}

.avatar.emotion-celebration {
    animation: emotionCelebration 1.5s ease both;
}
@keyframes emotionCelebration {
    0%, 100% { transform: scale(1); filter: hue-rotate(0deg); }
    25% { transform: scale(1.05); filter: hue-rotate(90deg); }
    50% { transform: scale(1.1); filter: hue-rotate(180deg); }
    75% { transform: scale(1.05); filter: hue-rotate(270deg); }
}

/* ===== Emoji star flight ===== */
.star-fx {
    position: absolute;
    font-size: 22px;
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.6);
    animation: star-fly 0.8s ease forwards;
    filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.15));
}
@keyframes star-fly {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.6);
    }
    25% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -120%) scale(1.2);
    }
}

/* ===== 3D Human Avatar Container ===== */
.human-avatar-container {
    position: relative;
    width: 100%;
    /* Keep a pleasant portrait ratio; matches previous 280x320 (7:8) */
    aspect-ratio: 7 / 8;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 12px 30px rgba(0, 0, 0, 0.12));
    transition: transform 0.18s ease;
    will-change: transform, filter;
}

#humanAvatarCanvas {
    width: 100%;
    height: 100%;
    border-radius: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* Human avatar poses - minimal container effects, let 3D model handle animations */
.human-avatar-container.pose-waiting {
    transform: scale(1);
}

.human-avatar-container.pose-reading {
    transform: scale(1.02);
    filter: drop-shadow(0 8px 20px rgba(160, 120, 255, 0.12));
}

.human-avatar-container.pose-celebrate {
    transform: scale(1.04);
    filter: drop-shadow(0 12px 25px rgba(255, 215, 0, 0.15));
}

/* Minimal human avatar reactions - let the 3D model do the heavy lifting */
.human-avatar-container.shake {
    animation: subtle-shake 0.2s ease both;
}

.human-avatar-container.bounce {
    animation: subtle-bounce 0.3s ease both;
}

.human-avatar-container.lean-in {
    transform: scale(1.01);
}

/* Subtle container animations that don't interfere with 3D model */
@keyframes subtle-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-1px); }
    75% { transform: translateX(1px); }
}

@keyframes subtle-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-2px); }
}

/* Human avatar loading indicator */
.human-avatar-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: white;
    z-index: 10;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.human-avatar-loading p {
    margin: 0;
    font-size: 14px;
    opacity: 0.9;
}

/* Accessibility: Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  #readBuddyView .avatar,
  #readBuddyView .avatar *,
  .avatar-panel .avatar,
  .avatar-panel .avatar *,
  .human-avatar-container,
  .human-avatar-container * {
    animation: none !important;
    transition: none !important;
  }
  /* Keep pose transforms neutral to reduce visual jumpiness */
  #readBuddyView .avatar.pose-waiting,
  #readBuddyView .avatar.pose-reading,
  #readBuddyView .avatar.pose-celebrate,
  .avatar-panel .avatar.pose-waiting,
  .avatar-panel .avatar.pose-reading,
  .avatar-panel .avatar.pose-celebrate {
    transform: scale(var(--avatar-scale)) !important;
    filter: none !important;
  }
}

/* Responsive: Scale avatar on small screens */
@media (max-width: 480px) {
  #readBuddyView .avatar-panel .avatar,
  .avatar-panel .avatar {
    --avatar-scale: 0.85;
    transform-origin: center top;
  }
}

@media (max-width: 360px) {
  #readBuddyView .avatar-panel .avatar,
  .avatar-panel .avatar {
    --avatar-scale: 0.75;
  }
}
