/* Big Hop (js/arcade/bighop.js). Every class starts with .bh- */

/* --n: how many pads the pond has; --g: the gap between two pads */
.bh-wrap { --g: 10px; position: relative; display: grid; gap: 10px; width: min(100%, 560px); margin: 0 auto; padding-bottom: 14px; }

/* ---------- HUD: the question she is on, the stars she can win, the score ---------- */
.bh-hud { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 4px 14px; font: 700 14px var(--font-ui); color: var(--muted); }
.bh-hud b { color: var(--ink); font-size: 19px; }
.bh-stars { display: inline-flex; gap: 3px; }
.bh-star {
  --f: 0%; width: 24px; height: 24px;
  clip-path: polygon(50% 2%, 62% 36%, 98% 37%, 69% 59%, 80% 94%, 50% 73%, 20% 94%, 31% 59%, 2% 37%, 38% 36%);
  background: linear-gradient(90deg, var(--sun) var(--f), var(--tile-shadow) var(--f));
}
.bh-star.bh-half { --f: 50%; }
.bh-star.bh-full { --f: 100%; animation: bh-pop 0.45s; }
@keyframes bh-pop { 0% { transform: scale(0.6); } 60% { transform: scale(1.25); } 100% { transform: none; } }

/* ---------- the question, its noughts drawn as water lilies, and the small fact under it ---------- */
.bh-goal { display: grid; justify-items: center; gap: 2px; padding: 4px 16px 10px; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow-soft); }
.bh-q { display: flex; align-items: center; font: 900 44px/1.2 var(--font-ui); color: var(--grape-d); letter-spacing: 0.02em; white-space: nowrap; }
/* a nought in the question: a little pink water lily with its 0. It is covered while she does the small fact, and glows when it is time to hop it back */
.bh-z {
  display: inline-grid; place-items: center; width: 0.86em; height: 0.86em; margin: 0 0.03em; border-radius: 50%;
  font: 900 0.62em/1 var(--font-ui); font-style: normal; color: var(--rose-d);
  background: var(--card); box-shadow: 0 0 0 0.09em var(--rose), 0 0 0 0.15em color-mix(in srgb, var(--rose) 35%, white);
  transition: opacity 0.25s, transform 0.25s;
}
.bh-at-fact .bh-z { opacity: 0.4; transform: scale(0.8); filter: grayscale(1); }
.bh-at-hop .bh-z { animation: bh-glow 1.4s ease-in-out infinite; }
.bh-solved .bh-z { animation: none; background: var(--rose); color: var(--card); }
@keyframes bh-glow { 50% { transform: scale(1.12); box-shadow: 0 0 0 0.09em var(--rose-d), 0 0 0 0.22em color-mix(in srgb, var(--rose) 45%, white); } }

.bh-fact { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 2px 10px; }
.bh-tag { font: 700 14px/1.2 var(--font-read); color: var(--muted); }
.bh-sum { font: 900 28px/1.2 var(--font-ui); color: var(--ink); white-space: nowrap; }
.bh-at-hop .bh-sum { color: var(--green-d); }

/* ---------- the pond: a row of pads, and the frogs on them ---------- */
.bh-pond { padding: 14px 10px 10px; border-radius: var(--radius); background: color-mix(in srgb, var(--sky) 28%, white); box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--sky) 60%, white), var(--shadow-soft); }
.bh-row { position: relative; container-type: inline-size; }
.bh-pads { display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: var(--g); }
.bh-pad { display: grid; justify-items: center; gap: 4px; min-width: 0; }
.bh-leaf { position: relative; display: block; width: 100%; aspect-ratio: 1; }
.bh-leaf-art { display: block; width: 100%; height: 100%; }
.bh-leaf-fill { fill: var(--green); stroke: var(--green-d); stroke-width: 3.5; stroke-linejoin: round; }
.bh-leaf-veins { fill: none; stroke: var(--card); stroke-width: 2; stroke-linecap: round; opacity: 0.55; }
.bh-name { font: 700 13px/1.2 var(--font-read); color: var(--ink); white-space: nowrap; }

/* a digit (a frog) or a 0 (a water lily) sits over pad number --c, counting from the left */
.bh-digits { position: absolute; inset: 0; pointer-events: none; }
.bh-tok {
  position: absolute; top: 0; z-index: 2; display: block; aspect-ratio: 1;
  width: calc((100% - (var(--n) - 1) * var(--g)) / var(--n));
  left: calc(var(--c, 0) * (100% + var(--g)) / var(--n));
  transition: left 0.38s ease-in-out;
}
.bh-tok.bh-still { transition: none; }
.bh-jump { display: block; width: 100%; height: 100%; }
.bh-jump svg { display: block; width: 84%; height: 84%; margin: 8%; overflow: visible; }
.bh-jump.bh-up { animation: bh-up 0.38s ease-out; }
@keyframes bh-up { 50% { transform: translateY(-34%) scale(1.06); } }
/* the frogs of the small fact drop onto the pond from above */
.bh-jump.bh-drop { animation: bh-drop 0.5s cubic-bezier(0.3, 1.4, 0.5, 1); }
@keyframes bh-drop { 0% { transform: translateY(-90%) scale(0.5); opacity: 0; } 60% { opacity: 1; } 100% { transform: none; } }
.bh-skin { fill: var(--lime); stroke: var(--lime-d); stroke-width: 3; stroke-linejoin: round; }
.bh-eye { fill: var(--card); }
.bh-pupil { fill: var(--ink); }
.bh-belly { fill: color-mix(in srgb, var(--lime) 22%, white); }
.bh-digit { font: 900 46px var(--font-ui); fill: var(--ink); text-anchor: middle; dominant-baseline: central; }
/* a 0 that fills a place: it grows where it is needed, a moment after the frogs have left the pad */
.bh-zero { z-index: 1; opacity: 0; transform: scale(0.3); transition: none; }
.bh-zero.bh-on { opacity: 1; transform: none; transition: opacity 0.2s 0.26s, transform 0.3s 0.26s cubic-bezier(0.2, 1.6, 0.4, 1); }
.bh-petal { fill: var(--rose); stroke: var(--rose-d); stroke-width: 2; }
.bh-heart { fill: var(--card); stroke: var(--rose-d); stroke-width: 2; }
.bh-pond.bh-right { box-shadow: inset 0 0 0 4px var(--green-d), var(--shadow-soft); background: color-mix(in srgb, var(--green) 24%, white); }

.bh-msg { min-height: 44px; margin: 0; display: grid; place-items: center; text-align: center; font: 700 16px/1.35 var(--font-read); color: var(--ink); }

/* ---------- the buttons: the answers to the small fact first, then the hops and Check ---------- */
.bh-picks { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.bh-pick { color: var(--ink); min-height: 60px; padding: 8px 4px; font: 900 30px/1 var(--font-ui); touch-action: manipulation; }
.bh-pick.bh-gone { opacity: 0.35; }
.bh-moves { display: grid; gap: 10px; }
.bh-at-fact .bh-moves, .bh-at-hop .bh-picks { display: none; }
.bh-hops { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.bh-hop { color: var(--ink); padding: 12px 8px; white-space: nowrap; touch-action: manipulation; }
.bh-check { justify-self: center; min-width: 200px; touch-action: manipulation; }
.bh-check.bh-off { opacity: 0.45; }

/* a hop that can't be done, a wrong answer, and a Check that is not right yet: a little shake */
.bh-no { animation: bh-no 0.32s; }
@keyframes bh-no { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* iPad: more room */
@media (min-width: 700px) {
  .bh-wrap { gap: 14px; --g: 14px; }
  .bh-q { font-size: 60px; }
  .bh-sum { font-size: 34px; }
  .bh-tag { font-size: 16px; }
  .bh-name { font-size: 16px; }
  .bh-msg { font-size: 19px; }
  .bh-pond { padding: 18px 16px 12px; }
  .bh-pick { min-height: 72px; font-size: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  .bh-star.bh-full, .bh-jump.bh-up, .bh-jump.bh-drop, .bh-no, .bh-at-hop .bh-z { animation: none; }
  .bh-tok, .bh-zero.bh-on, .bh-z { transition: none; }
}
