/* Zero Hop (js/arcade/zerohop.js). Every class starts with .zh- */

/* --n: how many pads the pond has; --g: the gap between two pads (the decimal point sits in one) */
.zh-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 ---------- */
.zh-hud { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 4px 14px; font: 700 14px var(--font-ui); color: var(--muted); }
.zh-hud b { color: var(--ink); font-size: 19px; }
.zh-stars { display: inline-flex; gap: 3px; }
.zh-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));
}
.zh-star.zh-half { --f: 50%; }
.zh-star.zh-full { --f: 100%; animation: zh-pop 0.45s; }
@keyframes zh-pop { 0% { transform: scale(0.6); } 60% { transform: scale(1.25); } 100% { transform: none; } }

/* ---------- the question ---------- */
.zh-goal { display: flex; justify-content: center; padding: 4px 16px; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow-soft); }
.zh-q { font: 900 46px/1.2 var(--font-ui); color: var(--grape-d); letter-spacing: 0.02em; white-space: nowrap; }

/* ---------- the pond: a row of pads, and the digits on them ---------- */
.zh-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); }
.zh-row { position: relative; container-type: inline-size; }
.zh-pads { display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: var(--g); }
.zh-pad { display: grid; justify-items: center; gap: 4px; min-width: 0; }
.zh-leaf { position: relative; display: block; width: 100%; aspect-ratio: 1; }
.zh-leaf-art { display: block; width: 100%; height: 100%; }
.zh-leaf-fill { fill: var(--green); stroke: var(--green-d); stroke-width: 3.5; stroke-linejoin: round; }
.zh-leaf-veins { fill: none; stroke: var(--card); stroke-width: 2; stroke-linecap: round; opacity: 0.55; }
/* the pads after the point (tenths, hundredths) are another green, so the two sides of the point look different */
.zh-small .zh-leaf-fill { fill: var(--teal); stroke: var(--teal-d); }
.zh-name { font: 700 13px/1.2 var(--font-read); color: var(--ink); white-space: nowrap; }
.zh-dec .zh-name { font-size: 11px; letter-spacing: -0.2px; }
/* the decimal point: it sits in the gap after the ones pad and never moves */
.zh-ones .zh-leaf::after { content: ''; position: absolute; right: calc(var(--g) / -2 - 5px); bottom: 6%; width: 10px; height: 10px; border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 2px var(--card); z-index: 3; }

/* a digit (a frog) or a 0 (a water lily) sits over pad number --c, counting from the left */
.zh-digits { position: absolute; inset: 0; pointer-events: none; }
.zh-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;
}
.zh-tok.zh-still { transition: none; }
.zh-jump { display: block; width: 100%; height: 100%; }
.zh-jump svg { display: block; width: 84%; height: 84%; margin: 8%; overflow: visible; }
.zh-jump.zh-up { animation: zh-up 0.38s ease-out; }
@keyframes zh-up { 50% { transform: translateY(-34%) scale(1.06); } }
.zh-skin { fill: var(--lime); stroke: var(--lime-d); stroke-width: 3; stroke-linejoin: round; }
.zh-eye { fill: var(--card); }
.zh-pupil { fill: var(--ink); }
.zh-belly { fill: color-mix(in srgb, var(--lime) 22%, white); }
.zh-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 */
.zh-zero { z-index: 1; opacity: 0; transform: scale(0.3); transition: none; }
.zh-zero.zh-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); }
.zh-petal { fill: var(--rose); stroke: var(--rose-d); stroke-width: 2; }
.zh-heart { fill: var(--card); stroke: var(--rose-d); stroke-width: 2; }
.zh-pond.zh-right { box-shadow: inset 0 0 0 4px var(--green-d), var(--shadow-soft); background: color-mix(in srgb, var(--green) 24%, white); }

.zh-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 ---------- */
.zh-hops { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.zh-hop { color: var(--ink); padding: 12px 8px; white-space: nowrap; touch-action: manipulation; }
.zh-check { justify-self: center; min-width: 200px; touch-action: manipulation; }
.zh-check.zh-off { opacity: 0.45; }

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

/* iPad: more room */
@media (min-width: 700px) {
  .zh-wrap { gap: 14px; --g: 14px; }
  .zh-q { font-size: 60px; }
  .zh-name, .zh-dec .zh-name { font-size: 16px; letter-spacing: 0; }
  .zh-msg { font-size: 19px; }
  .zh-pond { padding: 18px 16px 12px; }
}

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