/* ==========================================================================
   KUN & ANTA - 2D SKELETAL RIGGING & MOTION GRAPHICS ENGINE
   Zero external dependencies - 100% Offline Ready
   ========================================================================== */

:root {
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.22, 1, 0.36, 1);
}

/* Container & Responsive Stage */
.mascot-rig-stage {
  position: relative;
  display: inline-flex;
  align-items: flex-end;
  justify-content: center;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.mascot-char {
  position: relative;
  aspect-ratio: 360 / 450;
  cursor: pointer;
  transform-origin: 50% 95%;
  transition: filter 0.3s ease;
  will-change: transform;
}

.mascot-char:hover {
  filter: drop-shadow(0 16px 28px rgba(11, 27, 61, 0.18));
}

.mascot-rig-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-origin: 50% 92%;
  will-change: transform;
}

/* Ground Shadow that reacts to jump/bounce */
.mascot-shadow {
  position: absolute;
  bottom: 1.5%;
  left: 50%;
  width: 62%;
  height: 6%;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at center, rgba(11, 27, 61, 0.28) 0%, rgba(11, 27, 61, 0) 72%);
  border-radius: 9999px;
  pointer-events: none;
  z-index: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Layered PNG Body Parts (exact 360x450 alignment) */
.rig-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  will-change: transform;
}

.rig-tail { z-index: 1; }
.rig-arm-wave { z-index: 2; }
.rig-body { z-index: 3; }
.rig-head-wrap {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  will-change: transform;
}
.rig-head-img {
  position: relative;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Pivot Origins (calibrated to exact sleeve cuffs, collars, & tails) */
.mascot-kun .rig-body { transform-origin: 50% 92%; }
.mascot-kun .rig-head-wrap { transform-origin: 51% 49%; }
.mascot-kun .rig-arm-wave { transform-origin: 31% 53%; }
.mascot-kun .rig-tail { transform-origin: 31% 75%; }

.mascot-anta .rig-body { transform-origin: 50% 92%; }
.mascot-anta .rig-head-wrap { transform-origin: 51% 50%; }
.mascot-anta .rig-arm-wave { transform-origin: 32% 55%; }
.mascot-anta .rig-tail { transform-origin: 68% 80%; }

/* ==================== EYE BLINK & EXPRESSION OVERLAYS ==================== */
.rig-eyelid {
  position: absolute;
  border-radius: 50%;
  transform-origin: center top;
  transform: scaleY(0);
  opacity: 0;
  pointer-events: none;
  z-index: 6;
}

/* Kun Eyelids (exact eye boxes mapped to 360x450) */
.mascot-kun .eyelid-l {
  left: 38.2%; top: 21.8%; width: 12.2%; height: 10.6%;
  background: radial-gradient(circle at 50% 35%, #d6c5db 0%, #c1aec9 75%, #ad98b6 100%);
  box-shadow: inset 0 -2px 3px rgba(90, 70, 105, 0.25);
}
.mascot-kun .eyelid-r {
  left: 64.5%; top: 20.6%; width: 8.2%; height: 7.4%;
  background: radial-gradient(circle at 50% 35%, #d6c5db 0%, #c1aec9 75%, #ad98b6 100%);
  box-shadow: inset 0 -2px 3px rgba(90, 70, 105, 0.25);
}

/* Anta Eyelids (exact eye boxes mapped to 360x450) */
.mascot-anta .eyelid-l {
  left: 37.6%; top: 24.0%; width: 9.2%; height: 11.2%;
  background: radial-gradient(circle at 50% 35%, #fbf3e8 0%, #f1e3cf 75%, #e2cfb6 100%);
  box-shadow: inset 0 -2px 3px rgba(130, 105, 80, 0.2);
}
.mascot-anta .eyelid-r {
  left: 60.0%; top: 27.2%; width: 11.2%; height: 12.2%;
  background: radial-gradient(circle at 50% 35%, #fbf3e8 0%, #f1e3cf 75%, #e2cfb6 100%);
  box-shadow: inset 0 -2px 3px rgba(130, 105, 80, 0.2);
}

/* Automatic Natural Blink */
@keyframes mascotBlink {
  0%, 92%, 100% { transform: scaleY(0); opacity: 0; }
  94%, 96% { transform: scaleY(1.04); opacity: 1; }
}
.mascot-char:not([data-expr="happy"]):not([data-expr="cheer"]) .rig-eyelid {
  animation: mascotBlink 4.2s ease-in-out infinite;
}
.mascot-anta:not([data-expr="happy"]):not([data-expr="cheer"]) .rig-eyelid {
  animation-delay: 1.4s;
}

/* Happy/Cheer Curved Eyes Overlay (^ ^) */
.rig-happy-eye {
  position: absolute;
  opacity: 0;
  transform: scale(0.7);
  transition: opacity 0.22s ease, transform 0.28s var(--ease-spring);
  z-index: 7;
  pointer-events: none;
}
.mascot-kun .happy-eye-l { left: 38.2%; top: 22.8%; width: 12.2%; height: 9%; }
.mascot-kun .happy-eye-r { left: 64.2%; top: 21.2%; width: 8.6%; height: 7%; }
.mascot-anta .happy-eye-l { left: 37.4%; top: 25.0%; width: 9.4%; height: 9%; }
.mascot-anta .happy-eye-r { left: 60.0%; top: 28.2%; width: 11.2%; height: 10%; }

/* Rosy Cheeks for Happy/Wave/Cheer */
.rig-blush {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(251, 113, 133, 0.55) 0%, rgba(251, 113, 133, 0) 72%);
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 5;
  pointer-events: none;
}
.mascot-kun .blush-l { left: 32%; top: 34%; width: 13%; height: 7%; }
.mascot-kun .blush-r { left: 68%; top: 31%; width: 10%; height: 6%; }
.mascot-anta .blush-l { left: 33%; top: 36%; width: 11%; height: 7%; }
.mascot-anta .blush-r { left: 62%; top: 39%; width: 12%; height: 7%; }

/* ==================== SKELETAL MOTION KEYFRAMES ==================== */

/* 1. IDLE: Organic Breathing, Gentle Head Sway, Micro Wing/Arm & Tail Wag */
@keyframes bodyBreathe {
  0%, 100% { transform: scaleY(1) scaleX(1); }
  50% { transform: scaleY(1.022) scaleX(0.988); }
}
@keyframes headIdle {
  0%, 100% { transform: translateY(0px) rotate(0deg); }
  35% { transform: translateY(-2.5px) rotate(-2.2deg); }
  70% { transform: translateY(-1px) rotate(2.5deg); }
}
@keyframes armIdle {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(-6deg); }
}
@keyframes tailWag {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(8deg); }
  75% { transform: rotate(-6deg); }
}

.mascot-char .rig-body { animation: bodyBreathe 3.4s ease-in-out infinite; }
.mascot-char .rig-head-wrap { animation: headIdle 4.8s ease-in-out infinite; }
.mascot-char .rig-arm-wave { animation: armIdle 3.2s ease-in-out infinite; }
.mascot-char .rig-tail { animation: tailWag 2.6s ease-in-out infinite; }
.mascot-anta .rig-head-wrap { animation-delay: -1.6s; }
.mascot-anta .rig-arm-wave { animation-delay: -0.9s; }

/* 2. WAVE: Friendly Greeting Wave */
@keyframes armWaveActive {
  0% { transform: rotate(0deg); }
  20% { transform: rotate(-17deg); }
  40% { transform: rotate(10deg); }
  60% { transform: rotate(-16deg); }
  80% { transform: rotate(8deg); }
  100% { transform: rotate(0deg); }
}
@keyframes headWave {
  0%, 100% { transform: rotate(0deg) translateY(0); }
  25% { transform: rotate(-5deg) translateY(-4px); }
  65% { transform: rotate(4deg) translateY(-2px); }
}

.mascot-char[data-expr="wave"] .rig-arm-wave {
  animation: armWaveActive 1.25s ease-in-out infinite;
}
.mascot-char[data-expr="wave"] .rig-head-wrap {
  animation: headWave 2.2s ease-in-out infinite;
}
.mascot-char[data-expr="wave"] .rig-blush {
  opacity: 0.75;
}

/* 3. HAPPY / CHEER: Squash-and-Stretch Jump, ^ ^ Eyes, Rapid Wag */
@keyframes rigJump {
  0%, 100% { transform: translateY(0) scaleX(1) scaleY(1); }
  15% { transform: translateY(3px) scaleX(1.06) scaleY(0.93); }
  45% { transform: translateY(-16px) scaleX(0.96) scaleY(1.05); }
  75% { transform: translateY(2px) scaleX(1.04) scaleY(0.95); }
}
@keyframes shadowJump {
  0%, 100% { transform: translateX(-50%) scale(1); opacity: 0.9; }
  45% { transform: translateX(-50%) scale(0.76); opacity: 0.45; }
}
@keyframes armCheer {
  0%, 100% { transform: rotate(-14deg) scale(1.03); }
  50% { transform: rotate(12deg) scale(1); }
}

.mascot-char[data-expr="happy"] .mascot-rig-inner,
.mascot-char[data-expr="cheer"] .mascot-rig-inner {
  animation: rigJump 0.95s var(--ease-smooth) infinite;
}
.mascot-char[data-expr="happy"] .mascot-shadow,
.mascot-char[data-expr="cheer"] .mascot-shadow {
  animation: shadowJump 0.95s var(--ease-smooth) infinite;
}
.mascot-char[data-expr="happy"] .rig-arm-wave,
.mascot-char[data-expr="cheer"] .rig-arm-wave {
  animation: armCheer 0.55s ease-in-out infinite;
}
.mascot-char[data-expr="happy"] .rig-tail,
.mascot-char[data-expr="cheer"] .rig-tail {
  animation: tailWag 0.6s ease-in-out infinite;
}
.mascot-char[data-expr="happy"] .rig-eyelid,
.mascot-char[data-expr="cheer"] .rig-eyelid {
  transform: scaleY(1.05) !important;
  opacity: 1 !important;
  animation: none !important;
}
.mascot-char[data-expr="happy"] .rig-happy-eye,
.mascot-char[data-expr="cheer"] .rig-happy-eye {
  opacity: 1;
  transform: scale(1);
}
.mascot-char[data-expr="happy"] .rig-blush,
.mascot-char[data-expr="cheer"] .rig-blush {
  opacity: 1;
  transform: scale(1.1);
}

/* 4. CURIOUS: Head Tilt + Thoughtful Sway */
@keyframes headCurious {
  0%, 100% { transform: rotate(9deg) translateY(-2px); }
  50% { transform: rotate(12deg) translateY(-4px); }
}
.mascot-char[data-expr="curious"] .rig-head-wrap {
  animation: headCurious 2.4s ease-in-out infinite;
}
.mascot-char[data-expr="curious"] .rig-arm-wave {
  animation: armIdle 2.2s ease-in-out infinite;
}

/* 5. TALK: Rhythmic Head Nodding while Speaking */
@keyframes headTalk {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  25% { transform: translateY(-4px) rotate(2deg); }
  50% { transform: translateY(1px) rotate(-2deg); }
  75% { transform: translateY(-3px) rotate(3deg); }
}
.mascot-char[data-expr="talk"] .rig-head-wrap {
  animation: headTalk 0.65s ease-in-out infinite;
}
.mascot-char[data-expr="talk"] .rig-arm-wave {
  animation: armWaveActive 1.4s ease-in-out infinite;
}
.mascot-char[data-expr="talk"] .rig-blush {
  opacity: 0.65;
}

/* ==================== FLOATING SPARKLES & PARTICLES ==================== */
.rig-particles {
  position: absolute;
  inset: -10%;
  pointer-events: none;
  z-index: 10;
  overflow: visible;
}
.rig-particle {
  position: absolute;
  font-size: 1.15rem;
  opacity: 0;
  animation: particleFloatUp 1.4s var(--ease-smooth) forwards;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
}
@keyframes particleFloatUp {
  0% { opacity: 0; transform: translateY(10px) scale(0.4) rotate(-15deg); }
  25% { opacity: 1; transform: translateY(-8px) scale(1.1) rotate(8deg); }
  100% { opacity: 0; transform: translateY(-48px) scale(0.75) rotate(22deg); }
}

/* ==================== GLOBAL PAGE MOTION GRAPHICS ==================== */
.reveal-on-scroll {
  opacity: 0;
  transform: translateY(26px);
  transition: opacity 0.7s var(--ease-smooth), transform 0.7s var(--ease-smooth);
}
.reveal-on-scroll.is-visible {
  opacity: 1;
  transform: translateY(0);
}
.reveal-delay-1 { transition-delay: 0.08s; }
.reveal-delay-2 { transition-delay: 0.16s; }
.reveal-delay-3 { transition-delay: 0.24s; }
.reveal-delay-4 { transition-delay: 0.32s; }

@keyframes floatSlow {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-10px); }
}
.animate-float-slow {
  animation: floatSlow 5.5s ease-in-out infinite;
}

@keyframes gradientFlow {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}
.animate-gradient-text {
  background-size: 200% auto;
  animation: gradientFlow 6s ease infinite;
}

/* Interactive Mascot Speech Bubble */
.mascot-speech-bubble {
  position: relative;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  border: 2px solid rgba(13, 148, 136, 0.25);
  box-shadow: 0 18px 40px -12px rgba(11, 27, 61, 0.22);
  transition: opacity 0.3s ease, transform 0.35s var(--ease-spring);
}
.mascot-speech-bubble.is-hidden {
  opacity: 0;
  transform: translateY(10px) scale(0.92);
  pointer-events: none;
}

/* Reduced Motion Respect */
@media (prefers-reduced-motion: reduce) {
  .mascot-char *, .reveal-on-scroll, .animate-float-slow {
    animation: none !important;
    transition: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}
