/* Mochi Mountain — motion.
   Contract: every @keyframes-driven rule lives inside
   @media (prefers-reduced-motion: no-preference). Outside that query the .a-*
   classes still EXIST and simply do nothing, so markup never has to branch.

   One-shot utilities honour an optional per-element delay:  style="--d:.15s"
   (handy for staggering three stars or a row of cards).

   Keyframe names are prefixed mm- so no screen stylesheet can collide with them. */

/* --- the classes always exist; with reduced motion they are inert --- */
.a-pop, .a-shake, .a-bob, .a-pulse, .a-slide-up,
.a-fade-in, .a-star-pop, .a-flame, .a-wobble{
  animation:none;
}

@media (prefers-reduced-motion: no-preference){

  /* pop in — new content, correct answers, chips */
  @keyframes mm-pop{
    0%  { transform:scale(.72); opacity:0; }
    60% { transform:scale(1.06); opacity:1; }
    100%{ transform:scale(1);    opacity:1; }
  }
  .a-pop{ animation:mm-pop .3s var(--ease-pop) var(--d, 0s) both; }

  /* shake — a wrong answer. Horizontal only, small amplitude. */
  @keyframes mm-shake{
    0%,100%{ transform:translateX(0); }
    15%    { transform:translateX(-7px); }
    30%    { transform:translateX(6px); }
    45%    { transform:translateX(-5px); }
    60%    { transform:translateX(4px); }
    80%    { transform:translateX(-2px); }
  }
  .a-shake{ animation:mm-shake .42s ease-in-out var(--d, 0s) both; }

  /* bob — Mochi idling, the START bubble on the path */
  @keyframes mm-bob{
    0%,100%{ transform:translateY(0); }
    50%    { transform:translateY(-6px); }
  }
  .a-bob{ animation:mm-bob 2.2s ease-in-out var(--d, 0s) infinite; }

  /* pulse — the ring around the current path node */
  @keyframes mm-pulse{
    0%  { transform:scale(1);    opacity:.55; }
    70% { transform:scale(1.35); opacity:0; }
    100%{ transform:scale(1.35); opacity:0; }
  }
  .a-pulse{ animation:mm-pulse 1.8s ease-out var(--d, 0s) infinite; }

  /* slide-up — feedback banner, toast, sheets */
  @keyframes mm-slide-up{
    from{ transform:translateY(110%); opacity:0; }
    to  { transform:translateY(0);    opacity:1; }
  }
  .a-slide-up{ animation:mm-slide-up .28s var(--ease-pop) var(--d, 0s) both; }

  @keyframes mm-fade-in{
    from{ opacity:0; }
    to  { opacity:1; }
  }
  .a-fade-in{ animation:mm-fade-in .3s ease-out var(--d, 0s) both; }

  /* star-pop — lesson-complete star rating, stagger with --d */
  @keyframes mm-star-pop{
    0%  { transform:scale(0) rotate(-40deg); opacity:0; }
    55% { transform:scale(1.35) rotate(8deg); opacity:1; }
    75% { transform:scale(.92) rotate(-3deg); }
    100%{ transform:scale(1) rotate(0deg);   opacity:1; }
  }
  .a-star-pop{ animation:mm-star-pop .5s var(--ease-pop) var(--d, 0s) both; }

  /* flame — the streak flame breathing */
  @keyframes mm-flame{
    0%,100%{ transform:scale(1) rotate(0deg); }
    30%    { transform:scale(1.12) rotate(-4deg); }
    65%    { transform:scale(.96) rotate(3deg); }
  }
  .a-flame{ animation:mm-flame 1.3s ease-in-out var(--d, 0s) infinite; }

  /* wobble — Mochi is squishy; use on tap or on a milestone */
  @keyframes mm-wobble{
    0%,100%{ transform:rotate(0deg) scale(1); }
    20%    { transform:rotate(-5deg) scale(1.04, .96); }
    45%    { transform:rotate(4deg)  scale(.97, 1.03); }
    70%    { transform:rotate(-2deg) scale(1.02, .99); }
  }
  .a-wobble{ animation:mm-wobble .7s ease-in-out var(--d, 0s) both; }
}

/* Belt and braces: if any stylesheet anywhere asks for motion, reduced-motion users
   still get instant state changes rather than movement. */
@media (prefers-reduced-motion: reduce){
  *, *::before, *::after{
    animation-duration:.001ms !important;
    animation-delay:0s !important;
    animation-iteration-count:1 !important;
    transition-duration:.001ms !important;
    transition-delay:0s !important;
    scroll-behavior:auto !important;
  }
}
