/* Original Math Meadow cast. Load after the shared/page stylesheets. */
.monster-cast {
  --blink-time: 6.8s;
  --blink-delay: -.3s;
  --wave-time: 9s;
  --wave-delay: -.3s;
  isolation: isolate;
}
.monster-moss { --blink-time: 7.5s; --blink-delay: -.7s; --wave-time: 10s; --wave-delay: -.45s; }
.monster-pip { --blink-time: 6.3s; --blink-delay: -.1s; --wave-time: 8.6s; --wave-delay: -.6s; }
.monster-pebble { --blink-time: 8.1s; --blink-delay: -.9s; --wave-time: 11s; --wave-delay: -.2s; }

/* Keep legacy .crumb-monster sizing/reward hooks, not its perpetual bobbing. */
.monster-cast .monster-svg,
.lab-page .monster-cast .monster-svg {
  overflow: visible;
  animation: none;
  translate: none;
  rotate: none;
  filter: none; /* Ground shadow is drawn in SVG; avoid filter repaint flicker. */
}
/* No head, eyeball, or pupil geometry animation, including cookie rewards.
   This avoids SVG transform-box differences between browser engines. */
.monster-cast .monster-body,
.monster-cast .monster-eye,
.monster-cast .monster-gaze {
  animation: none !important;
  transition: none !important;
  transform: none !important;
}
.monster-cast .monster-eye-anchor { animation: none; transition: none; }
.monster-cast .monster-lid {
  opacity: 0;
  transform: none;
  pointer-events: none;
  animation: cast-lid-blink var(--blink-time) ease-in-out var(--blink-delay) infinite;
}
.monster-cast .monster-wave {
  transform-box: view-box;
  transform-origin: 136px 85px;
  animation: cast-hand-wave var(--wave-time) ease-in-out var(--wave-delay) infinite;
}
.monster-cast .monster-mouth { transform-box: fill-box; transform-origin: center; }
.monster-cast.feeding .monster-mouth { animation: mouth-crunch .25s ease-in-out .65s 2; }
.monster-cast .snack-cheer { font-size: 9px; letter-spacing: .1px; }

/* Crossfade only a closed-lid overlay; the original eye never moves or scales. */
@keyframes cast-lid-blink {
  0%, 92%, 97%, 100% { opacity: 0; }
  94%, 95% { opacity: 1; }
}
/* A small hello from the hand, not a continuous whole-character wobble. */
@keyframes cast-hand-wave {
  0%, 8%, 27%, 100% { transform: rotate(0deg); }
  12%, 21% { transform: rotate(-16deg); }
  16% { transform: rotate(10deg); }
}

/* All page controls stop the entire cast, including chomp and cookie rewards. */
body.motion-paused .monster-cast,
body.motion-paused .monster-cast *,
body.lab-motion-paused .monster-cast,
body.lab-motion-paused .monster-cast *,
[data-motion="paused"] .monster-cast,
[data-motion="paused"] .monster-cast *,
[data-motion-paused="true"] .monster-cast,
[data-motion-paused="true"] .monster-cast * {
  animation: none !important;
  transition: none !important;
}
body.motion-paused .monster-cast .snack-cookie,
body.motion-paused .monster-cast .cookie-crumbs,
body.lab-motion-paused .monster-cast .snack-cookie,
body.lab-motion-paused .monster-cast .cookie-crumbs,
[data-motion="paused"] .monster-cast .snack-cookie,
[data-motion="paused"] .monster-cast .cookie-crumbs,
[data-motion-paused="true"] .monster-cast .snack-cookie,
[data-motion-paused="true"] .monster-cast .cookie-crumbs { display: none; }
body.motion-paused .monster-cast.feeding .snack-cheer,
body.lab-motion-paused .monster-cast.feeding .snack-cheer,
[data-motion="paused"] .monster-cast.feeding .snack-cheer,
[data-motion-paused="true"] .monster-cast.feeding .snack-cheer { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .monster-cast,
  .monster-cast * { animation: none !important; transition: none !important; }
  .monster-cast .snack-cookie,
  .monster-cast .cookie-crumbs { display: none; }
  .monster-cast.feeding .snack-cheer { opacity: 1; }
}
