/* Animations de la grenouille, partagées par le bureau et l'habitat.
   La classe d'état est posée sur l'élément .frog (ex. .frog.anim-eat, .frog.asleep). */

.frog { position: relative; transform-origin: 50% 100%; }
.frog .frog-svg { width: 100%; height: 100%; overflow: visible; display: block; }
.frog .body { transform-origin: 60px 104px; transform-box: view-box; animation: breathe 3.2s ease-in-out infinite; }
.frog .pupil { transition: transform .18s ease-out; }
.frog .lid { transform-box: fill-box; transform-origin: 50% 0; transform: scaleY(0); animation: blink 5.5s infinite; }
.frog .lid-line, .frog .mouth-sad, .frog .tongue, .frog .fly,
.frog .fx-bubbles, .frog .fx-hearts, .frog .fx-zzz, .frog .fx-sweat { opacity: 0; }
.frog .tongue { stroke-dasharray: 100; stroke-dashoffset: 100; }
.frog .fx-bubbles circle { fill: #d9f1ff; stroke: #8fcdf2; stroke-width: 1.2; }

@keyframes breathe { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(1.015, 1.035); } }
@keyframes blink { 0%, 95%, 100% { transform: scaleY(0); } 97% { transform: scaleY(1); } }

/* Sommeil */
.frog.asleep .lid { animation: none; transform: scaleY(1); }
.frog.asleep .lid-line { opacity: 1; }
.frog.asleep .body { animation-duration: 5s; }
.frog.asleep .fx-zzz { opacity: 1; animation: zzz 2.6s ease-in-out infinite; }
@keyframes zzz { 0% { transform: translate(0, 4px); opacity: 0; } 30% { opacity: 1; } 100% { transform: translate(4px, -6px); opacity: 0; } }

/* Besoin bas : mine un peu triste */
.frog.low .mouth { opacity: 0; }
.frog.low .mouth-sad { opacity: 1; }

/* Saut (déplacement) */
.frog.anim-hop-left, .frog.anim-hop-right { animation: hop .42s ease-out; }
.frog.anim-hop-left .frog-svg { transform: scaleX(-1); }
@keyframes hop {
  0% { transform: translateY(0) scale(1.08, .9); }
  40% { transform: translateY(-34%) scale(.94, 1.08); }
  80% { transform: translateY(0) scale(1.1, .88); }
  100% { transform: translateY(0) scale(1, 1); }
}

/* Manger */
.frog.anim-eat .tongue { opacity: 1; animation: tongue .9s ease-in-out; }
.frog.anim-eat .fly { animation: fly .9s ease-in-out; }
@keyframes tongue { 0% { stroke-dashoffset: 100; } 45% { stroke-dashoffset: 0; } 100% { stroke-dashoffset: 100; } }
@keyframes fly { 0%, 40% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translate(-48px, 40px) scale(.3); } }

/* Laver */
.frog.anim-wash { animation: wiggle .3s ease-in-out 4; }
.frog.anim-wash .fx-bubbles { opacity: 1; animation: rise 1.6s ease-out; }
@keyframes rise { 0% { transform: translateY(16px); opacity: 0; } 30% { opacity: 1; } 100% { transform: translateY(-22px); opacity: 0; } }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-4deg); } 75% { transform: rotate(4deg); } }

/* Jouer */
.frog.anim-play { animation: play 1s ease-in-out; }
@keyframes play {
  0% { transform: translateY(0) rotate(0); }
  30% { transform: translateY(-40%) rotate(-180deg); }
  60% { transform: translateY(-40%) rotate(-360deg); }
  85% { transform: translateY(0) rotate(-360deg) scale(1.1, .9); }
  100% { transform: translateY(0) rotate(-360deg); }
}

/* Affection */
.frog.anim-love .fx-hearts { opacity: 1; animation: hearts 1.4s ease-out; }
.frog.anim-love .lid { animation: none; transform: scaleY(.55); }
@keyframes hearts { 0% { transform: translateY(8px) scale(.6); opacity: 0; } 30% { opacity: 1; } 100% { transform: translateY(-16px) scale(1.1); opacity: 0; } }

/* Refus */
.frog.anim-refuse { animation: shake .45s ease-in-out; }
.frog.anim-refuse .mouth { opacity: 0; }
.frog.anim-refuse .mouth-sad { opacity: 1; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-6%); } 40%, 80% { transform: translateX(6%); } }

/* Besoin exprimé */
.frog.anim-need .fx-sweat { opacity: 1; animation: rise 1.5s ease-out; }
.frog.anim-need { animation: wiggle .5s ease-in-out 2; }

/* Étirement (rappel de pause) */
.frog.anim-stretch { animation: stretch 1.6s ease-in-out; }
@keyframes stretch { 0%, 100% { transform: scale(1, 1); } 40%, 60% { transform: scale(.9, 1.2); } }

/* Réveil / endormissement */
.frog.anim-wake { animation: stretch 1s ease-in-out; }

/* Animations réduites (réglage ou préférence système) */
.reduced-motion .frog, .reduced-motion .frog * { animation-duration: 0.01s !important; animation-iteration-count: 1 !important; }
.reduced-motion .frog .lid { animation: none !important; }
.reduced-motion .frog.asleep .fx-zzz { animation: none !important; opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  .frog, .frog * { animation-duration: 0.01s !important; animation-iteration-count: 1 !important; }
  .frog .lid { animation: none !important; }
}
