/* ── Shared motion kit: buddies, bubbles, page wipes ─────────── */

html.kit-enter::after {
  content: ''; position: fixed; inset: 0; z-index: 10000;
  background: var(--kit-wipe, #6a5acd);
}

.buddy {
  position: relative; display: inline-block;
  width: var(--bsize, 90px); height: var(--bsize, 90px);
  -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none;
  cursor: pointer; touch-action: manipulation;
}
.buddy svg { width: 100%; height: 100%; overflow: visible; display: block; }

.buddy .bd-body  { transform-box: fill-box; transform-origin: 50% 100%; animation: bdBob 2.8s ease-in-out infinite; }
.buddy .bd-eye   { transform-box: fill-box; transform-origin: 50% 50%; animation: bdBlink 4.6s infinite; }
.buddy .bd-arm   { transform-box: fill-box; transform-origin: 50% 8%; }
.buddy .bd-tail  { transform-box: fill-box; transform-origin: 0% 100%; animation: bdWag 1.8s ease-in-out infinite; }
.bd-dino .bd-tail { transform-origin: 100% 80%; }
.buddy .bd-ear-l { transform-box: fill-box; transform-origin: 90% 50%; animation: bdFlapL 3.2s ease-in-out infinite; }
.buddy .bd-ear-r { transform-box: fill-box; transform-origin: 10% 50%; animation: bdFlapR 3.2s ease-in-out infinite; }
.bd-bunny .bd-ear-l, .bd-bunny .bd-ear-r { transform-origin: 50% 100%; }
.bd-lion .bd-mane { transform-box: fill-box; transform-origin: 50% 50%; animation: bdMane 6s ease-in-out infinite; }
.buddy .bd-light { animation: bdGlow 1.4s ease-in-out infinite; }

.buddy.wave  .bd-arm { animation: bdWave 1.3s ease-in-out; }
.buddy.cheer svg     { animation: bdJump .6s cubic-bezier(.3,1.5,.5,1) 3; }
.buddy.cheer .bd-arm { animation: bdArmUp .6s ease-in-out 3; }
.buddy.hop   svg     { animation: bdHop .5s cubic-bezier(.3,1.6,.5,1); }
.buddy.squish svg    { animation: bdSquish .45s ease-out; }
.buddy.spin  svg     { animation: bdSpin .8s cubic-bezier(.4,1.4,.5,1); }

@keyframes bdBob   { 0%,100% { transform: translateY(0) scale(1,1); } 50% { transform: translateY(-3px) scale(1.02,.98); } }
@keyframes bdBlink { 0%,92%,100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
@keyframes bdWag   { 0%,100% { transform: rotate(0); } 50% { transform: rotate(12deg); } }
@keyframes bdFlapL { 0%,100% { transform: rotate(0); } 50% { transform: rotate(-9deg); } }
@keyframes bdFlapR { 0%,100% { transform: rotate(0); } 50% { transform: rotate(9deg); } }
@keyframes bdMane  { 0%,100% { transform: rotate(0); } 50% { transform: rotate(8deg); } }
@keyframes bdGlow  { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes bdWave  { 0%,100% { transform: rotate(0); } 20%,60% { transform: rotate(-150deg); } 40%,80% { transform: rotate(-110deg); } }
@keyframes bdArmUp { 0%,100% { transform: rotate(0); } 50% { transform: rotate(-160deg); } }
@keyframes bdJump  { 0%,100% { transform: translateY(0); } 40% { transform: translateY(-22%) rotate(-5deg); } 70% { transform: translateY(0) scale(1.1,.9); } }
@keyframes bdHop   { 0%,100% { transform: translateY(0); } 45% { transform: translateY(-12%); } 75% { transform: scale(1.06,.94); } }
@keyframes bdSquish{ 0%,100% { transform: scale(1,1); } 30% { transform: scale(1.18,.8); } 60% { transform: scale(.92,1.1); } }
@keyframes bdSpin  { from { transform: rotate(0) scale(1); } 50% { transform: rotate(180deg) scale(1.15); } to { transform: rotate(360deg) scale(1); } }

/* speech bubble */
.bd-bubble {
  position: absolute; bottom: 96%; left: 50%;
  width: max-content; max-width: 260px;
  transform: translateX(-50%) scale(0); transform-origin: 50% 100%;
  background: #fff; color: #2a2550;
  font: 800 17px/1.25 'Nunito', system-ui, sans-serif;
  padding: 10px 15px; border-radius: 18px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  transition: transform .38s cubic-bezier(.3,1.6,.5,1);
  pointer-events: none; z-index: 3; text-align: center;
}
.bd-bubble::after {
  content: ''; position: absolute; top: 100%; left: 50%; margin-left: -9px;
  border: 9px solid transparent; border-top-color: #fff;
}
.bd-bubble.show { transform: translateX(-50%) translateY(-6px) scale(1); }
.buddy.bubble-left  .bd-bubble { left: auto; right: 30%; transform: scale(0); transform-origin: 100% 100%; }
.buddy.bubble-left  .bd-bubble.show { transform: translateY(-6px) scale(1); }
.buddy.bubble-left  .bd-bubble::after { left: auto; right: 22px; }
.buddy.bubble-right .bd-bubble { left: 62%; transform: scale(0); transform-origin: 0% 100%; }
.buddy.bubble-right .bd-bubble.show { transform: translateY(-6px) scale(1); }
.buddy.bubble-right .bd-bubble::after { left: 22px; margin-left: 0; }

/* in-game mini buddy */
#kitDock {
  position: fixed; z-index: 9000; --bsize: 74px;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  filter: drop-shadow(0 6px 10px rgba(0,0,0,.35));
  animation: kitDockIn .7s cubic-bezier(.3,1.6,.5,1) .4s both;
}
@media (max-width: 600px) { #kitDock { --bsize: 56px; } }
@keyframes kitDockIn { from { transform: translateY(140%) scale(.5); } to { transform: none; } }

/* floating star burst */
.kit-star {
  position: fixed; z-index: 9500; pointer-events: none;
  font-size: 26px; line-height: 1; will-change: transform, opacity;
}

/* calm mode */
html.calm .buddy *, html.calm .buddy svg { animation: none !important; }
html.calm .buddy .bd-eye { animation: bdBlink 4.6s infinite !important; }
html.calm #kitDock { animation: none; }
@media (prefers-reduced-motion: reduce) {
  .buddy .bd-body, .buddy .bd-tail, .buddy .bd-ear-l, .buddy .bd-ear-r { animation: none; }
}

