/* Character states and idle animations for the SVG sprites in js/sprites.js. */
.char * { transform-box: fill-box; }

/* State parts: hidden unless their state is on; `unless-` rules win. */
.char [class*="when-"] { display: none; }
.char.talking .when-talking,
.char.nervous .when-nervous,
.char.scared .when-scared,
.char.relieved .when-relieved,
.char.angry .when-angry,
.char.pleased .when-pleased { display: inline; }
.char.talking .unless-talking,
.char.nervous .unless-nervous,
.char.scared .unless-scared,
.char.relieved .unless-relieved,
.char.angry .unless-angry,
.char.pleased .unless-pleased { display: none; }

/* Talking mouth flaps. */
.talk-mouth { transform-origin: center top; animation: flap .17s ease-in-out infinite alternate; }
@keyframes flap { from { transform: scaleY(.25); } to { transform: scaleY(1.1); } }

/* Everyone breathes. */
.char .rig { transform-origin: 50% 100%; animation: breathe 3.2s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scaleY(1.015) scaleX(.995); } }

/* Mood filters on customers. */
.char.angry { animation: rage .12s infinite; filter: drop-shadow(0 0 18px #ff2a1a) saturate(1.4); }
.char.pleased { filter: drop-shadow(0 0 16px #7be08a88); }
@keyframes rage { 50% { transform: translateX(2px) scale(1.02); } }

/* Carol */
.carol .blink { transform-origin: center; animation: blink 4.5s infinite; }
@keyframes blink { 0%, 95%, 100% { transform: scaleY(1); } 97% { transform: scaleY(.1); } }
.carol.scared .mug { animation: jitter .09s infinite; }
.carol .steam { animation: steam 2.4s ease-in-out infinite; }
.carol .sweat { animation: sweat 1.4s ease-in infinite; }
@keyframes steam { 0% { opacity: 0; transform: translateY(6px); } 40% { opacity: .55; } 100% { opacity: 0; transform: translateY(-8px); } }
@keyframes sweat { from { transform: translateY(0); opacity: 1; } to { transform: translateY(16px); opacity: 0; } }
@keyframes jitter { 50% { transform: translate(1px, -1px) rotate(2deg); } }

/* Goblin */
.goblin .glow { filter: drop-shadow(0 0 4px #ffe14d); animation: glare .6s infinite alternate; }
.goblin .fist { transform-origin: 80% 100%; animation: shake-fist .5s ease-in-out infinite alternate; }
.goblin.pleased .fist { animation: none; }
.goblin .steam circle { animation: puff 1s ease-out infinite; }
.goblin .steam circle:nth-child(2n) { animation-delay: .5s; }
@keyframes glare { to { filter: drop-shadow(0 0 8px #ff8a1a); } }
@keyframes shake-fist { from { transform: rotate(-6deg); } to { transform: rotate(6deg); } }
@keyframes puff { from { transform: translateY(6px) scale(.6); opacity: .9; } to { transform: translateY(-10px) scale(1.3); opacity: 0; } }

/* Slime */
.slime .wobble { transform-origin: 50% 100%; animation: wobble 1.3s ease-in-out infinite; }
.slime .jitter { animation: jitter .15s infinite; }
.slime.pleased .jitter { animation: none; }
.slime .drip { animation: drip 2s ease-in infinite; }
.slime .d2 { animation-delay: 1s; }
@keyframes wobble { 25% { transform: scale(1.04, .96); } 75% { transform: scale(.97, 1.03); } }
@keyframes drip { from { transform: translateY(-14px); opacity: 1; } to { transform: translateY(6px) scaleY(.4); opacity: 0; } }

/* Dragon */
.dragon .smoke circle { animation: puff 2s ease-out infinite; }
.dragon .smoke circle:nth-child(2) { animation-delay: 1s; }
.dragon .flame { transform-origin: 50% 0; animation: flame .12s infinite alternate; }
@keyframes flame { from { transform: scale(.9, .85); fill: #ff6a1a; } to { transform: scale(1.1, 1.1); fill: #ffd21a; } }

/* Ghost */
.ghost { opacity: .92; }
.ghost .float { animation: float 3s ease-in-out infinite; }
.ghost .tear { animation: tear 1.6s ease-in infinite; }
.ghost .t2 { animation-delay: .8s; }
@keyframes float { 50% { transform: translateY(-10px) rotate(1.5deg); } }
@keyframes tear { from { transform: translateY(0); opacity: 1; } to { transform: translateY(26px); opacity: 0; } }

/* Elder */
.tentacle .tent { transform-origin: 50% 0; animation: sway-t 2.4s ease-in-out infinite alternate; }
.tentacle .tent:nth-child(2) { animation-delay: .4s; }
.tentacle .tent:nth-child(3) { animation-delay: .8s; }
.tentacle .tent:nth-child(4) { animation-delay: 1.2s; }
@keyframes sway-t { from { transform: rotate(-5deg); } to { transform: rotate(5deg); } }

@media (prefers-reduced-motion: reduce) {
    .char *, .char, .drapes, .light-cone { animation: none !important; }
    .talk-mouth { animation: flap .3s infinite alternate !important; }
}
