/* Leafy Bugs: screen juice, round 2 (src/ui/juice2.js). body.r2 = round 2 (?rodada=1
   turns it off). Movement by individual properties (translate, rotate, scale) and transitions: the "reduce motion" of
   css/panels.css cuts the animations and the state stays correct. Nothing blinks, nothing goes beyond ±8%. */

/* 216: the button sinks toward the finger; the icon arrives 30 ms later */
body.r2 :is(.pb, .rb, .hb)[data-p='dn'] {
  translate: var(--tx, 0) var(--ty, 0);
}
body.r2 :is(.rb, .hb) .ic {
  transition:
    translate 0.12s ease-out 30ms,
    rotate 0.45s var(--pop),
    scale 0.3s var(--pop);
}

/* 217, 219: the counter basket opens, swallows and bounces; with 1 group missing it hops */
#hud-count .pi {
  transform-origin: 50% 90%;
}
#hud-count .pi.gulp {
  animation: gulp 0.42s var(--pop);
}
@keyframes gulp {
  0% {
    transform: scale(1.06, 0.94);
  }
  35% {
    transform: scale(0.94, 1.07);
  }
  70% {
    transform: scale(1.03, 0.97);
  }
  100% {
    transform: none;
  }
}
#hud-count .pi.hop {
  animation: hhop 0.45s ease-out;
}
@keyframes hhop {
  40% {
    transform: translateY(-22%);
  }
  70% {
    transform: translateY(0) scale(1.05, 0.95);
  }
}
/* 218: the number rolls like a disc */
#count .roll {
  display: inline-block;
}
#count .roll.go {
  animation: roll 0.34s cubic-bezier(0.3, 0.7, 0.4, 1.2);
}
@keyframes roll {
  from {
    transform: perspective(3em) rotateX(-80deg) translateY(30%);
    opacity: 0.2;
  }
}

/* 220: each icon has its own gesture */
.ic.g-undo {
  animation: g-undo 0.5s var(--pop);
}
@keyframes g-undo {
  from {
    rotate: 300deg;
  }
}
.ic.g-shuffle {
  animation: g-shuffle 0.45s ease-in-out;
}
@keyframes g-shuffle {
  50% {
    scale: -1 1;
  }
}
.ic.g-extra {
  animation: g-extra 0.45s var(--pop);
}
@keyframes g-extra {
  40% {
    scale: 1.08 0.93;
  }
}
/* 222: the help badge drops and bounces when the number decreases */
body.r2 .badge.spin {
  animation: badge-drop 0.5s cubic-bezier(0.3, 1.6, 0.5, 1);
}
@keyframes badge-drop {
  from {
    translate: 0 -70%;
    opacity: 0.3;
  }
}
/* 223: emptied help sleeps (icon tilts slightly and lets out bubbles slowly) */
body.r2 .hb.off .ic {
  rotate: -12deg;
  translate: 0 6%;
}
body.r2 .hb.off::after {
  content: '';
  position: absolute;
  right: 2%;
  top: -14%;
  width: 30%;
  height: 30%;
  background: url(../assets/fx/bubbles.webp) center / contain no-repeat;
  opacity: 0.85;
  animation: zz 3s ease-in-out infinite;
  pointer-events: none;
}
@keyframes zz {
  0%,
  100% {
    translate: 0 0;
    opacity: 0.5;
  }
  50% {
    translate: 8% -18%;
    opacity: 0.9;
  }
}
/* 224: the gear turns 60° while the settings are open */
#b-gear .ic {
  transition: rotate 0.45s var(--pop);
}
body.r2.gear-open #b-gear .ic {
  rotate: 60deg;
}
/* 225: the speaker waves follow the volume (the waves are the right part of the art) */
body.r2 #b-sound .ic {
  clip-path: inset(0 calc((1 - var(--vol, 1)) * 40%) 0 0);
  transition: clip-path 0.2s;
}
/* 227: the switch gets a press with weight */
.sw.thunk {
  animation: thunk 0.32s var(--pop);
}
@keyframes thunk {
  30% {
    scale: 1.05 0.94;
  }
  65% {
    scale: 0.98 1.03;
  }
}
/* 232: the X turns 90° when touched */
body.r2 .panel > .x {
  transition:
    rotate 0.25s var(--pop),
    filter 0.1s;
}
body.r2 .panel > .x[data-p='dn'] {
  rotate: 90deg;
}

/* 228, 229: the panel is born from the button that opened it and goes back to it; items arrive in cascade only on entrance */
body.r2 .modal.in .panel {
  transform-origin: var(--ox, 50%) var(--oy, 50%);
}
body.r2 .modal.out {
  pointer-events: none;
  animation: dim-out 0.18s both;
}
body.r2 .modal.out .panel {
  transform-origin: var(--ox, 50%) var(--oy, 50%);
  animation: pop-out 0.18s ease-in both;
}
@keyframes pop-out {
  to {
    transform: scale(0.7);
    opacity: 0;
  }
}
@keyframes dim-out {
  to {
    background: rgba(4, 54, 54, 0);
  }
}
body.r2
  .modal.casc
  .panel
  > :is(.pb, .row-set, .stars, #win-moves, .win-btns, .how-steps, #lang-list, .sad, .stuck-helps) {
  animation: item-in 0.32s var(--pop) backwards;
  animation-delay: calc(var(--i, 0) * 45ms + 90ms);
}
@keyframes item-in {
  from {
    opacity: 0;
    translate: 0 calc(var(--u) * 2.4);
  }
}

/* 233: cat peeks over the panel and follows the finger. In the center, BEHIND the title banner, with the whole face above it and
   only the little paws hidden (on a phone it used to sit in the corner, cut by the banner) */
.spy {
  position: absolute;
  z-index: 1;
  width: calc(var(--u) * 21);
  left: 50%;
  bottom: calc(100% + var(--pb) + var(--rh) / 2 - var(--u) * 3.2);
  top: auto;
  pointer-events: none;
  transform-origin: 50% 100%;
  rotate: calc(var(--look, 0) * 6deg);
  translate: calc(-50% + var(--look, 0) * var(--u) * 0.8) 0;
  transition:
    rotate 0.3s ease-out,
    translate 0.3s ease-out;
}
body:not(.r2) .spy {
  display: none;
}

/* 129, 130: combo badge enters like a soft stamp; the glow shows the time left; it leaves floating */
#combo-badge.stamp {
  animation:
    stamp 0.34s cubic-bezier(0.2, 0.9, 0.35, 1.25) both,
    left-glow var(--win, 4s) linear both;
}
@keyframes stamp {
  from {
    scale: 1.6;
    opacity: 0;
  }
  60% {
    scale: 0.94;
    opacity: 1;
  }
}
@keyframes left-glow {
  from {
    box-shadow:
      0 calc(var(--u) * 0.5) 0 rgba(5, 66, 64, 0.3),
      0 0 calc(var(--u) * 3) calc(var(--u) * 0.8) rgba(255, 246, 170, 0.85);
  }
  to {
    box-shadow:
      0 calc(var(--u) * 0.5) 0 rgba(5, 66, 64, 0.3),
      0 0 0 0 rgba(255, 246, 170, 0);
  }
}
#combo-badge.out {
  animation: badge-out 0.5s ease-in both;
}
@keyframes badge-out {
  to {
    translate: -50% calc(var(--u) * -6);
    opacity: 0;
  }
}
/* 136: praise born on the group rises a little (does not reach the faces of the top row) */
.float.near {
  animation: float-near 1.2s ease-out forwards;
  font-size: max(18px, calc(var(--u) * 6));
}
@keyframes float-near {
  0% {
    opacity: 0;
    scale: 0.6;
  }
  20% {
    opacity: 1;
    scale: 1.05;
  }
  32% {
    scale: 1;
  }
  75% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    translate: -50% calc(-50% - var(--u) * 3);
  }
}
/* 137: best combo of the level, badge on the other side of "Perfect" */
.seal.best {
  right: auto;
  left: calc(var(--u) * -12);
  rotate: -8deg;
  min-width: calc(var(--u) * 13);
  border-image-source: url(../assets/ui/pill-violet.webp);
}
/* 231: short wave on the words when changing language (up and down, no blinking) */
.lw {
  animation: lw 0.36s ease-out var(--lw, 0s);
}
@keyframes lw {
  45% {
    transform: translateY(-0.14em);
  }
}

/* ---- how the game teaches (src/ui/teach.js) ---- */
/* lesson/warning strip: straight plate, clean text, never catches touch; teach.js puts it in the free space */
#teach {
  position: fixed;
  z-index: 4;
  translate: -50% 0;
  --h: max(34px, calc(var(--u) * 7.6));
  min-width: calc(var(--u) * 30);
  max-width: 94vw;
  pointer-events: none;
}
#teach .face {
  font-size: calc(var(--h) * 0.44);
}
#teach.in {
  animation: teach-in 0.3s ease-out;
}
@keyframes teach-in {
  from {
    opacity: 0;
    translate: -50% calc(var(--u) * 1.6);
  }
}
#stuck-tip {
  font-size: calc(var(--u) * 4);
  text-align: center;
  max-width: calc(var(--u) * 52);
  white-space: normal;
  color: #fff6c8;
}

/* How to play: 6 cards, one at a time */
#m-how .panel {
  width: calc(var(--u) * 88);
  gap: calc(var(--u) * 2.4);
}
.how-track {
  position: relative;
  width: 100%;
  touch-action: pan-y;
}
.how-card {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: calc(var(--u) * 1.6);
  width: 100%;
}
.how-card.on {
  display: flex;
  animation: card-in 0.3s ease-out;
}
@keyframes card-in {
  from {
    opacity: 0;
    translate: calc(var(--u) * 3) 0;
  }
}
.how-card .lbl {
  font-size: calc(var(--u) * 5);
  text-align: center;
  white-space: normal;
  text-wrap: balance;
  max-width: 100%;
  min-height: 2.4em;
  display: flex;
  align-items: center;
  justify-content: center;
}
.how-card .lbl:lang(ja) {
  word-break: auto-phrase;
}
.how-card .lbl:lang(ko) {
  word-break: keep-all;
} /* ja: breaks between sentences (Chrome); ko: only between words */
#m-how .how-card .how-art {
  --aw: calc(var(--u) * 76);
  --ar: 1.6;
  width: var(--aw);
  aspect-ratio: var(--ar);
  position: relative;
  flex: none;
}
.how-art > * {
  position: absolute;
  display: block;
  pointer-events: none;
}
.how-art .dim {
  filter: brightness(0.72) saturate(0.8);
}
.how-art .off {
  opacity: 0.55;
  filter: saturate(0.6);
}
.how-art .c-glow {
  opacity: 0.75;
  aspect-ratio: 2.4 / 1;
  object-fit: fill;
  translate: 0 -45%;
} /* (not used in this game: the lit leaf is art) */
.how-nav {
  display: flex;
  align-items: center;
  gap: calc(var(--u) * 3);
}
.how-nav .arrow {
  --s: max(44px, calc(var(--u) * 9));
}
#how-dots {
  display: flex;
  gap: calc(var(--u) * 2);
}
#how-dots .mdot {
  position: relative;
  width: max(14px, calc(var(--u) * 2.4));
  height: max(14px, calc(var(--u) * 2.4));
  cursor: pointer;
}
.how-art .hand {
  animation: h-tap 2.4s ease-in-out infinite;
}
@keyframes h-tap {
  0%,
  100% {
    translate: 0 0;
  }
  18% {
    translate: 0 -10%;
  }
  26% {
    translate: 0 4%;
    scale: 0.94;
  }
  40% {
    translate: 0 0;
  }
}
.how-art .lift {
  animation: h-lift 2.4s ease-in-out infinite;
}
.how-art .d1 {
  animation-delay: 0.1s;
}
.how-art .d2 {
  animation-delay: 0.2s;
}
.how-art .d3 {
  animation-delay: 0.3s;
}
@keyframes h-lift {
  0%,
  24% {
    translate: 0 0;
  }
  40%,
  82% {
    translate: 0 -30%;
  }
  100% {
    translate: 0 0;
  }
}
.how-art .float {
  animation: h-float 1.6s ease-in-out infinite;
}
@keyframes h-float {
  50% {
    translate: 0 -8%;
  }
}
.how-art .pop {
  animation: h-pop 2.4s var(--pop) infinite;
}
@keyframes h-pop {
  0%,
  20% {
    scale: 0.4;
    opacity: 0;
  }
  34%,
  100% {
    scale: 1;
    opacity: 1;
  }
}
.how-art .go {
  animation: h-go 3s ease-in-out infinite;
}
@keyframes h-go {
  0%,
  20% {
    translate: 0 0;
    scale: 1;
    opacity: 1;
  }
  55% {
    translate: 160% -140%;
    scale: 0.4;
    opacity: 1;
  }
  62%,
  100% {
    translate: 160% -140%;
    scale: 0.4;
    opacity: 0;
  }
}
.how-art .balloon {
  position: absolute;
  animation: none;
}
.how-art .b5 {
  animation: h-in 3.2s ease-out infinite;
}
@keyframes h-in {
  0% {
    translate: 120% 0;
    opacity: 0;
  }
  30%,
  100% {
    translate: 0 0;
    opacity: 1;
  }
}
.how-art .zz {
  animation: h-zz 3.2s ease-out infinite;
}
.how-art .cat.zz {
  animation: none;
}
@keyframes h-zz {
  0%,
  40% {
    opacity: 0.9;
    translate: 0 0;
  }
  52%,
  100% {
    opacity: 0;
    translate: 0 -30%;
  }
}
.how-art .ghost {
  opacity: 0;
}
.how-art .cat.up {
  opacity: 0;
  animation: h-wake 3.2s ease-out infinite;
}
@keyframes h-wake {
  0%,
  44% {
    opacity: 0;
  }
  50%,
  92% {
    opacity: 1;
    translate: 0 0;
  }
  58% {
    translate: 0 -8%;
  }
  100% {
    opacity: 0;
  }
}
.how-art .hbx {
  position: absolute;
  width: 18%;
  aspect-ratio: 1;
}
.how-art .hbx img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.how-art .hbx .ic {
  left: 22%;
  top: 19%;
  width: 56%;
  height: 56%;
}
.how-art .hbx .lbl {
  position: absolute;
  left: 50%;
  top: 104%;
  translate: -50% 0;
  width: 150%;
  max-width: none;
  text-align: center;
  font-size: calc(var(--u) * 3.6);
  white-space: nowrap;
} /* width ~ gap between the buttons (29% / 18% = 161%, minus some room): before, it used the button width and the label shrank */
body.land #m-how .panel {
  width: calc(var(--u) * 120);
}
body.land #m-how .how-card .how-art {
  --aw: calc(var(--u) * 84);
}

/* shuffle calculating (Worker, up to ~0.7 s): the icon spins slowly like a whirlpool; reduce motion: only fades */
@keyframes swirl {
  to {
    rotate: 360deg;
  }
}
.hb.busy .ic {
  animation: swirl 0.9s linear infinite;
}
body.reduced .hb.busy .ic {
  animation-play-state: paused;
  opacity: 0.6;
}
/* End of css/juice2.css (complete file). */
