/* Mascot moments (2026-09-25 brand sweep). The approved 2026 T-rex head
   (/brand/mascot-384.webp, the only approved mascot art: there are no pose
   cutouts) given a mood with transforms and filters only. Markup is a
   <span class="mm-wrap mm-MOOD"><img class="mm-mascot"></span> placed in
   game.html; tap handling is public/mascot-moments.js. Colours are from
   docs/brand/brand.json productPalette (reward #FBBF24, primary #F093FB,
   foreground #FFFFFF). */

.mm-wrap {
  position: relative;
  display: block;
  width: clamp(60px, 18vw, 84px);
  margin: 0 auto 0.35rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}
.mm-wrap .mm-mascot {
  display: block;
  width: 100%;
  height: auto;
  transform-origin: 50% 85%;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.4));
  pointer-events: none;
}
@media (max-height: 640px) {
  .modal .mm-wrap {
    width: 54px;
    margin-bottom: 0.15rem;
  }
}

/* Level complete: pop in, then a happy hop, with two twinkling sparkles. */
.mm-cheer .mm-mascot {
  animation:
    mm-pop 0.9s cubic-bezier(0.3, 1.5, 0.5, 1) both,
    mm-hop 1.8s ease-in-out 0.9s infinite;
}
.mm-cheer::before,
.mm-cheer::after {
  content: '\2726';
  position: absolute;
  color: #fbbf24;
  text-shadow: 0 0 8px rgba(251, 191, 36, 0.7);
  pointer-events: none;
  animation: mm-twinkle 1.4s ease-in-out infinite;
}
.mm-cheer::before {
  top: 2%;
  left: -18%;
  font-size: 1.1rem;
}
.mm-cheer::after {
  top: 30%;
  right: -20%;
  font-size: 0.8rem;
  color: #f093fb;
  text-shadow: 0 0 8px rgba(240, 147, 251, 0.7);
  animation-delay: 0.7s;
}
@keyframes mm-pop {
  0% {
    transform: translateY(20px) scale(0.4) rotate(-14deg);
    opacity: 0;
  }
  60% {
    transform: translateY(-8px) scale(1.1) rotate(4deg);
    opacity: 1;
  }
  100% {
    transform: none;
  }
}
@keyframes mm-hop {
  0%,
  100% {
    transform: translateY(0);
  }
  35% {
    transform: translateY(-7px) rotate(-4deg);
  }
  65% {
    transform: translateY(-7px) rotate(4deg);
  }
}
@keyframes mm-twinkle {
  0%,
  100% {
    transform: scale(0.5) rotate(0deg);
    opacity: 0.2;
  }
  50% {
    transform: scale(1.2) rotate(45deg);
    opacity: 1;
  }
}

/* Game over: head tilted in worry, a nervous shake, a bead of sweat. */
.mm-worried .mm-mascot {
  transform: rotate(-9deg);
  animation: mm-worry 2.6s ease-in-out infinite;
}
.mm-worried::after {
  content: '';
  position: absolute;
  top: 12%;
  right: 4%;
  width: 9px;
  height: 13px;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.5);
  animation: mm-sweat 2.6s ease-in infinite;
}
@keyframes mm-worry {
  0%,
  100% {
    transform: rotate(-9deg);
  }
  6% {
    transform: rotate(-5deg) translateX(2px);
  }
  12% {
    transform: rotate(-12deg) translateX(-2px);
  }
  18% {
    transform: rotate(-6deg) translateX(1px);
  }
  24% {
    transform: rotate(-9deg);
  }
}
@keyframes mm-sweat {
  0%,
  30% {
    transform: translateY(0) scale(0.6);
    opacity: 0;
  }
  45% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    transform: translateY(22px) scale(1);
    opacity: 0;
  }
}

/* Out of lives / broken streak: drowsy tilt, slow breathing, floating zzz.
   No colour filters: BRAND.md forbids tinting or recolouring the logo. */
.mm-sleepy .mm-mascot {
  transform: rotate(12deg);
  animation: mm-breathe 3.4s ease-in-out infinite;
}
.mm-sleepy::before,
.mm-sleepy::after {
  content: 'z';
  position: absolute;
  top: 0;
  right: -6%;
  font-weight: 800;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.8);
  pointer-events: none;
  animation: mm-zzz 2.8s ease-out infinite;
}
.mm-sleepy::after {
  content: 'Z';
  font-size: 1.05rem;
  animation-delay: 1.4s;
}
@keyframes mm-breathe {
  0%,
  100% {
    transform: rotate(12deg) scale(1);
  }
  50% {
    transform: rotate(12deg) scale(1.04, 0.97);
  }
}
@keyframes mm-zzz {
  0% {
    transform: translate(0, 10px) scale(0.6);
    opacity: 0;
  }
  25% {
    opacity: 1;
  }
  100% {
    transform: translate(12px, -18px) scale(1.1);
    opacity: 0;
  }
}
.streak-broken .mm-wrap {
  width: 52px;
  margin-bottom: 0.2rem;
  font-size: 1rem;
}

/* Tutorial welcome: a friendly lean-in-and-bob hello. */
.tutorial-demo .mm-wrap {
  width: 84px;
  font-size: 1rem;
}
.mm-wave .mm-mascot {
  animation: mm-hello 2.4s ease-in-out infinite;
}
@keyframes mm-hello {
  0%,
  100% {
    transform: rotate(0deg) translateY(0);
  }
  20% {
    transform: rotate(-8deg) translateY(-3px);
  }
  40% {
    transform: rotate(6deg) translateY(-5px);
  }
  60% {
    transform: rotate(-3deg) translateY(-2px);
  }
}

/* Settings > About: mascot plus wordmark lockup. */
.mm-about {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.mm-about .mm-wrap {
  width: 52px;
  margin: 0;
}
.mm-about .mm-wordmark {
  display: block;
  width: min(180px, 48vw);
  height: auto;
}
.mm-idle .mm-mascot {
  animation: mm-bob 3.2s ease-in-out infinite;
}

/* Splash: a gentler idle bob with a slight head tilt; tappable. */
#splash .logo-icon {
  cursor: pointer;
  transform-origin: 50% 85%;
  animation: mm-bob 3.2s ease-in-out infinite;
}
@keyframes mm-bob {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }
  30% {
    transform: translateY(-7px) rotate(-2.5deg);
  }
  70% {
    transform: translateY(-4px) rotate(2deg);
  }
}

/* Tap: squash-and-stretch boop (added by mascot-moments.js). */
.mm-wrap.mm-boop .mm-mascot,
#splash .logo-icon.mm-boop {
  animation: mm-boop 0.55s cubic-bezier(0.3, 1.6, 0.5, 1);
}
@keyframes mm-boop {
  0% {
    transform: scale(1);
  }
  30% {
    transform: scale(0.84, 1.16) translateY(-6px);
  }
  60% {
    transform: scale(1.12, 0.9);
  }
  100% {
    transform: scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .mm-wrap .mm-mascot,
  .mm-wrap::before,
  .mm-wrap::after,
  #splash .logo-icon {
    animation: none !important;
  }
  .mm-sleepy::after {
    opacity: 1;
    transform: translate(10px, -10px);
  }
  .mm-cheer::before,
  .mm-cheer::after {
    opacity: 1;
  }
  .mm-worried::after {
    opacity: 0;
  }
}
