/* Caly plant mascot ? idle breath, blink, speak bob, age-scaled motion */

.caly-motion-root {
  --caly-speak-amp: 1;
  --caly-bounce: 1;
  --caly-idle-duration: 3.2s;
}

.caly-mascot-stage.caly-motion-root,
header.caly-motion-root {
  transform-origin: center bottom;
}

/* Idle breathing / stem sway by band */
.caly-motion-idle-baby .caly-mascot-img,
.caly-motion-idle-baby .play-mascot,
.caly-motion-idle-baby #mascot-img {
  animation: caly-idle-breathe-baby calc(var(--caly-idle-duration) * 1.15) ease-in-out infinite;
}

.caly-motion-idle-toddler .caly-mascot-img,
.caly-motion-idle-toddler .play-mascot,
.caly-motion-idle-toddler #mascot-img {
  animation: caly-idle-breathe-toddler var(--caly-idle-duration) ease-in-out infinite;
}

.caly-motion-idle-child .caly-mascot-img,
.caly-motion-idle-child .play-mascot {
  animation: caly-idle-breathe-child 3.6s ease-in-out infinite;
}

.caly-motion-idle-tween .caly-mascot-img,
.caly-motion-idle-tween .play-mascot {
  animation: caly-idle-breathe-tween 3.8s ease-in-out infinite;
}

.caly-motion-idle-teen .caly-mascot-img,
.caly-motion-idle-teen .play-mascot {
  animation: caly-idle-sway-teen 4.2s ease-in-out infinite;
}

.caly-motion-idle-adult .caly-mascot-img,
.caly-motion-idle-adult .play-mascot,
.caly-motion-idle-caregiver .caly-mascot-img,
.caly-motion-idle-caregiver .play-mascot {
  animation: caly-idle-sway-calm 5s ease-in-out infinite;
}

@keyframes caly-idle-breathe-baby {
  0%, 100% { transform: translateY(0) rotate(-1deg) scale(calc(var(--caly-bounce, 1) * 0.98)); }
  50% { transform: translateY(calc(-6px * var(--caly-bounce, 1))) rotate(1deg) scale(calc(var(--caly-bounce, 1) * 1.02)); }
}

@keyframes caly-idle-breathe-toddler {
  0%, 100% { transform: translateY(0) rotate(-2deg) scale(calc(var(--caly-bounce, 1) * 1)); }
  50% { transform: translateY(calc(-10px * var(--caly-bounce, 1))) rotate(2deg) scale(calc(var(--caly-bounce, 1) * 1.03)); }
}

@keyframes caly-idle-breathe-child {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50% { transform: translateY(-7px) rotate(1deg) scale(1.02); }
}

@keyframes caly-idle-breathe-tween {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50% { transform: translateY(-5px) rotate(1deg) scale(1.015); }
}

@keyframes caly-idle-sway-teen {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50% { transform: translateY(-4px) rotate(1deg); }
}

@keyframes caly-idle-sway-calm {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

/* Blink ? quick vertical squash (face expressiveness on plant) */
.caly-motion-blink .caly-mascot-img,
.caly-motion-blink .play-mascot,
.caly-motion-blink #mascot-img {
  animation: caly-blink-squash 0.12s ease-in-out !important;
}

@keyframes caly-blink-squash {
  0%, 100% { transform: scaleY(1); }
  45% { transform: scaleY(0.88); }
}

/* Speak bob ? layered on idle when TTS active */
.caly-motion-speaking .caly-motion-speak-bob {
  animation: caly-speak-bob 0.45s ease-in-out infinite !important;
}

@keyframes caly-speak-bob {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(calc(-6px * var(--caly-speak-amp, 1))) rotate(calc(-2deg * var(--caly-speak-amp, 1))); }
  75% { transform: translateY(calc(-3px * var(--caly-speak-amp, 1))) rotate(calc(2deg * var(--caly-speak-amp, 1))); }
}

/* Leaf flutter accent on speak (stem lean on container) */
.caly-motion-speaking.caly-mascot-stage {
  animation: caly-stem-lean 0.5s ease-in-out infinite;
}

@keyframes caly-stem-lean {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(calc(1.5deg * var(--caly-speak-amp, 1))); }
}

.caly-mascot-shadow {
  transition: transform 0.35s ease, opacity 0.35s ease;
}

.caly-motion-speaking .caly-mascot-shadow {
  transform: scaleX(1.08);
  opacity: 0.85;
}

/* Reduced motion ? static pose, optional single nod via speak class only at 0 amplitude */
.caly-motion-reduced .caly-mascot-img,
.caly-motion-reduced .play-mascot,
.caly-motion-reduced #mascot-img {
  animation: none !important;
}

.caly-motion-reduced.caly-motion-speaking .caly-motion-speak-bob {
  animation: caly-speak-nod-once 0.4s ease-out 1 !important;
}

@keyframes caly-speak-nod-once {
  0% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
  100% { transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .caly-motion-root .caly-mascot-img,
  .caly-motion-root .play-mascot,
  .caly-motion-root #mascot-img,
  .caly-motion-speaking.caly-mascot-stage {
    animation: none !important;
  }
}
