/* Pre-K and kindergarten (docs/early-years.md): styles for the levels added
   with the grade split, one section per piece. */

/* ——— Toyland's new levels (js/prek.js) ——— */

/* Color Splash: a balloon, car, crayon, or fish on each button; after a miss,
   a splash of the color to find. Hide and Seek: a little scene on each button;
   after a miss, the place with a glowing spot where the critter goes. */
.pk-colored, .pk-splat, .pk-hide { display: block; overflow: visible; }
.choice .pk-colored { width: clamp(78px, 14vh, 128px); }
.choice .pk-hide { width: 100%; max-width: clamp(130px, 26vh, 220px); }
.pk-show .pk-splat { width: clamp(100px, 17vh, 150px); }
.pk-show .pk-hide { width: clamp(130px, 22vh, 190px); }
.pk-hide-ghost { animation: pk-ghost 1.2s ease-in-out infinite; }
.level-example.art .pk-hide { height: 1.6em; margin: -0.2em 0; } /* the kitten in the box, big enough to see */
@keyframes pk-ghost { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }

@media (max-width: 640px) {
  .choice .pk-colored { width: 74px; }
  .choices.n4 .choice .pk-hide { max-width: 130px; }
}

/* ——— Carousel Park, kindergarten math (js/kmath.js, js/kmath-pictures.js) ——— */

.wt-carousel, .wp-carousel, .w-carousel { --w: #22b38a; --w-deep: #14896a; --w-soft: #c6f1e2; --w-bg: linear-gradient(140deg, #8fe5c8, #22b38a); }
.w-carousel .card { border-color: #c9f1e3; box-shadow: 0 10px 0 #9fe2cb, 0 22px 40px rgba(30, 150, 110, 0.2); }
.w-carousel .card::before { content: '🎠'; }
html[data-theme='town'] .w-carousel .card::before { content: '🚂'; }
.w-carousel .level-tag { background: #e6faf2; }
.level-example .km-mini { font-size: 0.8em; }

/* A number's badge pops up as the buddy counts it (data-count, js/screens/play.js). */
.km-badge {
  position: absolute;
  top: -0.4em;
  right: -0.4em;
  z-index: 2;
  min-width: 1.5em;
  height: 1.5em;
  padding: 0 0.2em;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 2px solid #fff;
  background: var(--gold);
  color: #6b4300;
  font-size: clamp(10px, 1.7vh, 14px);
  font-weight: 700;
  line-height: 1;
  opacity: 0;
  scale: 0;
  transition: opacity 0.2s, scale 0.3s var(--bounce);
}
.counted > .km-badge { opacity: 1; scale: 1; }

/* Ten-frames: two rows of five spots (a five-frame is one row). */
.km-frames, .km-fill { --cell: clamp(26px, 6.6vw, 50px); display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.km-fill { --cell: clamp(36px, 8.4vw, 60px); }
.km-frame {
  display: grid;
  grid-template-columns: repeat(5, var(--cell));
  grid-auto-rows: var(--cell);
  gap: 3px;
  padding: 5px;
  border: 3px solid #d9c6f7;
  border-radius: 12px;
  background: #fff;
}
.km-cell { position: relative; display: grid; place-items: center; border-radius: 8px; background: #f7f2fd; }
.km-cell .km-em { font-size: calc(var(--cell) * 0.76); line-height: 1; }
.km-cell.full { animation: pop-in 0.4s var(--bounce) backwards; animation-delay: calc(var(--i, 0) * 45ms); }
.km-cell.counted { background: #fff3c4; animation: count-hop 0.45s var(--bounce); }
.km-counter { display: block; width: 78%; aspect-ratio: 1; border-radius: 50%; border: 2px solid rgba(91, 58, 110, 0.35); background: radial-gradient(circle at 34% 30%, #fff 0 12%, var(--c) 14% 100%); }
.km-counter.ghost { border: 3px dashed var(--gold-deep); background: #fff8dc; opacity: 0; transition: opacity 0.25s; }
.km-cell.empty.counted .km-counter.ghost { opacity: 1; }

/* Teen numbers: a ten-stick of cubes and loose ones, in columns of five. */
.km-teen, .km-tens { display: flex; align-items: flex-end; justify-content: center; gap: clamp(10px, 3vw, 22px); }
.km-tens { --u: clamp(14px, 2.5vh, 21px); }
.choice .km-tens { --u: clamp(8px, 1.5vh, 13px); gap: clamp(6px, 1.6vw, 12px); }
.km-rod { position: relative; display: grid; grid-template-rows: repeat(10, var(--u)); border: 3px solid var(--ink); border-radius: 6px; background: #5bb0ff; transition: box-shadow 0.3s; }
.km-rod i { width: var(--u); border-bottom: 2px solid rgba(91, 58, 110, 0.35); background: linear-gradient(90deg, rgba(255, 255, 255, 0.4), transparent 45%); }
.km-rod i:last-child { border-bottom: 0; }
.km-rod.counted { box-shadow: 0 0 0 5px var(--gold); animation: sing 0.5s var(--bounce); }
.km-ones { display: grid; grid-template-rows: repeat(var(--rows), var(--u)); grid-auto-flow: column; grid-auto-columns: var(--u); gap: 4px; }
.km-cube { position: relative; border: 3px solid var(--ink); border-radius: 4px; background: #ffd84d; animation: pop-in 0.35s var(--bounce) backwards; animation-delay: calc(var(--i) * 50ms + 0.2s); }
.km-cube.counted { animation: count-hop 0.45s var(--bounce); box-shadow: 0 0 0 3px var(--gold); }
.km-cube > .km-badge { top: 50%; right: auto; left: 50%; translate: -50% -50%; min-width: 1.6em; height: 1.6em; font-size: clamp(9px, 1.4vh, 12px); }
.km-mine { display: flex; align-items: center; justify-content: center; gap: clamp(16px, 4vw, 40px); }
.km-card { padding: 4px 22px; border-radius: 26px; border: 4px dashed #c9f1e3; background: #f4fdf9; }

/* What only the help shows: the ten-stick for a numeral, a solid to match, a bond's ten-frame. */
.km-show { display: none; }
.scene.helping .km-show { display: flex; animation: pop-in 0.45s var(--bounce); }
.km-show .km-solid { width: clamp(100px, 17vh, 150px); }

/* What comes next: numerals in a row, then the ❓. */
.km-run { --s: clamp(48px, 12vw, 92px); display: flex; align-items: center; justify-content: center; gap: clamp(4px, 1.4vw, 12px); }
.km-run .pk-item { width: auto; min-width: var(--s); padding: 0 6px; }
.km-run .pk-num { font-size: calc(var(--s) * 0.78); }
.km-run .km-step.counted { background: #fff3c4; animation: sing 0.45s var(--bounce); }
.km-run .pk-slot.counted { animation: look 0.6s ease-in-out, blank-glow 1.6s ease-in-out infinite; }

/* Adding and taking away: two groups, or some crossed out. */
.km-sum { --cell: clamp(30px, 7vw, 52px); position: relative; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: clamp(6px, 2.4vw, 20px); }
.km-sum.story { --cell: clamp(36px, 9vw, 60px); }
.km-bunch { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(var(--cols), var(--cell)); grid-auto-rows: var(--cell); gap: 3px; padding: 6px; border: 3px dashed #f3d2e4; border-radius: 18px; background: #fff7fb; }
.km-bunch.join { border-color: #cfe3fb; background: #f4f9ff; }
.km-bunch .km-cell { background: none; }
.km-bunch .km-cell.counted { background: #fff3c4; }
.km-op { color: var(--lilac); font-size: clamp(32px, 6vh, 50px); font-weight: 800; line-height: 1; }
.km-cell.away .km-em { opacity: 0.4; filter: grayscale(0.5); }
.km-cell.away::after { content: ''; position: absolute; inset: 8%; background: linear-gradient(to top right, transparent 44%, #ff5b6e 44% 56%, transparent 56%); }
/* A story plays out: the others arrive, or the leaving ones go, a moment after the card appears. */
.km-sum.story .km-bunch { border: 0; background: none; }
.km-where { position: absolute; z-index: 0; font-size: clamp(110px, 21vh, 180px); line-height: 1; opacity: 0.2; }
.km-sum.story .km-bunch.join { animation: km-arrive 0.8s var(--bounce) 1.3s backwards; }
.km-sum.story .km-cell.away .km-em { animation: km-leave 0.6s ease-in 1.3s backwards; }
.km-sum.story .km-cell.away::after { animation: km-cross 0.3s ease-out 1.8s backwards; }
.km-eq { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 8px 0 0; }
.km-eq .pk-num { font-size: clamp(34px, 6vh, 52px); }
.km-q { color: var(--lilac); font-size: clamp(34px, 6vh, 52px); }

/* A number bond: 10 on top, the part on the card, and the ❓. The legs meet
   the middle of each part (a part is --b wide, with 0.76 --b between them). */
.km-bond-wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: clamp(14px, 4vw, 36px); }
.km-bond { --b: clamp(62px, 11vh, 90px); display: grid; justify-items: center; }
.km-ball { display: grid; place-items: center; width: var(--b); aspect-ratio: 1; border: 4px solid #d9c6f7; border-radius: 50%; background: #fff; }
.km-ball .pk-num { font-size: calc(var(--b) * 0.56); }
.km-ball.whole { border-color: var(--w); }
.km-ball.ask { border-style: dashed; border-color: var(--lilac); color: var(--lilac); font-size: calc(var(--b) * 0.5); animation: blank-glow 1.6s ease-in-out infinite; }
.km-legs { width: 100%; height: calc(var(--b) * 0.3); overflow: visible; }
.km-legs path { fill: none; stroke: #d9c6f7; stroke-width: 4; vector-effect: non-scaling-stroke; }
.km-parts { display: flex; gap: calc(var(--b) * 0.76); }

/* Bigger or smaller: the help lines up a dot for each, under the numeral. */
.km-cmp { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.pk-row.km-dots { display: none; font-size: clamp(11px, 2.4vw, 17px); }
.lined .pk-row.km-dots { display: flex; }
.km-dots .pk-critter { width: 1em; }
.km-dots .pk-critter:nth-child(5n) { margin-right: 0.45em; }
.km-dot { display: block; width: 0.8em; height: 0.8em; border: 2px solid rgba(91, 58, 110, 0.3); border-radius: 50%; background: var(--pink); }
.choices.rows .c-km-cmp { min-height: clamp(96px, 15vh, 140px); }

/* Solid shapes and the everyday things shaped like them. */
.km-solid, .km-thing-art { display: block; overflow: visible; }
.choice .km-solid { width: clamp(78px, 14vh, 128px); }
.choice .km-solid.small { width: clamp(52px, 9.5vh, 88px); }
.choice .km-thing-art { width: clamp(84px, 15vh, 136px); }
.km-flat > ellipse { display: none; } /* flat: no shine */

.pk-num.wide { font-size: clamp(48px, 9vh, 82px); }

@media (max-width: 640px) {
  .km-frames { --cell: 32px; }
  .km-sum { --cell: 25px; }
  .km-sum.story { --cell: 34px; }
  .km-bunch { padding: 4px; }
  .choice .km-rod, .choice .km-cube { border-width: 2px; }
  .choice .km-solid { width: 72px; }
  .choice .km-solid.small { width: 50px; }
  .choice .km-thing-art { width: 78px; }
  .pk-num.wide { font-size: 50px; }
}

@keyframes km-arrive { from { opacity: 0; translate: 70px 0; } }
@keyframes km-leave { from { opacity: 1; filter: none; } }
@keyframes km-cross { from { opacity: 0; scale: 0.4; } }

/* ——— The Sound Garden and Word Workshop (js/sounds.js) ——— */

/* Their colors: the Sounds subject has two worlds now, so its world tabs show. */
.wt-sounds, .wp-sounds, .w-sounds { --w: #45bf6e; --w-deep: #2e9653; --w-soft: #cdf2d9; --w-bg: linear-gradient(140deg, #a6ecbd, #45bf6e); }
.wt-workshop, .wp-workshop, .w-workshop { --w: #eea21c; --w-deep: #c47f00; --w-soft: #ffe9b8; --w-bg: linear-gradient(140deg, #ffe08a, #eea21c); }
.w-sounds .card { border-color: #cdf2d9; box-shadow: 0 10px 0 #a9e6be, 0 22px 40px rgba(40, 150, 80, 0.18); }
.w-workshop .card { border-color: #ffe9b8; box-shadow: 0 10px 0 #ffd88a, 0 22px 40px rgba(200, 130, 0, 0.18); }
.w-sounds .card::before { content: '🌷'; }
.w-workshop .card::before { content: '✏️'; }
.w-sounds .level-tag { background: #e3f8ea; }
.w-workshop .level-tag { background: #fff4d9; }

/* Letters and words drawn just as they're written: capitals for Pre-K, small
   letters and first words for K. */
.pk-cap-i { display: inline-block; padding: 0 0.12em; border-block: 0.085em solid currentColor; line-height: 0.74; }
.pk-glyph { display: inline-flex; align-items: baseline; font-size: clamp(54px, 10vh, 84px); font-weight: 700; line-height: 1; color: var(--ink); }
.pk-glyph.pk-text { font-size: clamp(36px, 6.5vh, 56px); letter-spacing: 0.02em; }
.pk-glyph.pk-big { font-size: clamp(96px, 18vh, 150px); }
.pk-glyph.pk-read { font-size: clamp(76px, 14vh, 120px); letter-spacing: 0.06em; }
.pk-show .pk-glyph { font-size: clamp(80px, 15vh, 120px); }
.pk-show .pk-glyph.pk-text { font-size: clamp(56px, 10vh, 84px); }
/* Little Letters: after a miss, the small letter joins its capital ("Dd"). */
.pk-glyph .pk-pair { display: inline-block; color: var(--lilac-deep); }
/* Read It: after a miss, the word's letters bounce one by one as it's stretched out. */
.pk-read b { display: inline-block; font-weight: inherit; }
.helping .pk-read b { animation: sing 0.6s var(--bounce) backwards; animation-delay: calc(2.3s + var(--i) * 0.9s); }

/* Clap It: the picture to clap, and under it a clap for each part of the
   word, hidden until a miss counts them. The answers: a number and its claps. */
.pk-clap-word { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.pk-clap-word .pk-word { font-size: clamp(70px, 13vh, 110px); }
.pk-claps { display: flex; gap: 6px; min-height: 1.2em; font-size: clamp(26px, 4.6vh, 38px); line-height: 1.2; }
.pk-clap { font-style: normal; visibility: hidden; }
.pk-clap.counted { visibility: visible; animation: pop-in 0.35s var(--bounce); }
.pk-claps-n { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.pk-claps-n .pk-num { font-size: clamp(48px, 8.5vh, 76px); }
.pk-clap-row { display: flex; flex-wrap: wrap; justify-content: center; max-width: 5.4em; font-size: clamp(18px, 3.2vh, 26px); line-height: 1.2; }
.pk-clap-row i { font-style: normal; }

@media (max-width: 640px) {
  .pk-glyph { font-size: 54px; }
  .pk-glyph.pk-text { font-size: 34px; }
  .pk-glyph.pk-big { font-size: 92px; }
  .pk-glyph.pk-read { font-size: 72px; }
  .pk-claps-n .pk-num { font-size: 46px; }
  .pk-clap-row { font-size: 18px; }
}

/* ——— More for Pre-K and K (2026-10-29, docs/early-years.md "Runway") ——— */

/* Toyland. One More, One Less: the newcomers hop in a moment after the card
   appears; the ones leaving hop away and fade. */
.pk-change .pk-critter.pk-comes { animation: km-arrive 0.8s var(--bounce) 1.3s backwards; }
.pk-change .pk-critter.pk-goes { opacity: 0.18; filter: grayscale(0.6); animation: pk-hop-away 0.8s ease-in 1.3s backwards; }
@keyframes pk-hop-away { from { opacity: 1; filter: none; translate: 0 0; } 60% { translate: 30px -18px; } }

/* Number Match: the numeral on a card; after a miss, its dots to count. */
.pk-numcard-wrap { display: flex; align-items: center; justify-content: center; gap: clamp(14px, 4vw, 36px); }
.pk-numcard { padding: 4px 24px; border-radius: 26px; border: 4px dashed #d9c6f7; background: #faf6ff; }
.pk-numcard .pk-num { font-size: clamp(70px, 13vh, 110px); }
.pk-numdots { display: grid; grid-template-columns: repeat(var(--cols), auto); gap: 6px; }
.pk-numdots[hidden] { display: none; }
.pk-numdots i { position: relative; width: clamp(20px, 3.6vh, 30px); aspect-ratio: 1; border-radius: 50%; border: 2px solid rgba(91, 58, 110, 0.35); background: var(--pink); animation: pop-in 0.3s var(--bounce) backwards; animation-delay: calc(var(--i) * 50ms); }
.pk-numdots i.counted { box-shadow: 0 0 0 4px var(--gold); animation: count-hop 0.45s var(--bounce); }
.choice .pk-cluster { max-width: 100%; }

/* Match It: the picture to match, big. */
.pk-match { display: grid; place-items: center; min-width: 1.4em; padding: 4px 18px; border-radius: 26px; border: 4px dashed #d9c6f7; background: #faf6ff; font-size: clamp(70px, 13vh, 110px); line-height: 1.15; }
.pk-match .pk-em { font-size: 1em; }
.pk-match .pk-shape { width: clamp(80px, 14vh, 120px); }

/* Carousel Park. Longer or shorter: each thing is --n tenths of the row,
   starting --shift tenths in; the help (.lined) lines the starts up. */
.km-len { display: flex; align-items: center; width: calc(var(--n) * 9%); min-width: 40px; height: clamp(30px, 5vh, 44px); margin-left: calc(var(--shift) * 9%); transition: margin-left 0.8s var(--bounce); }
.lined .km-len { margin-left: 0; }
.choices.rows .choice:has(.km-len) { justify-items: stretch; }
.km-len-body { flex: 1; height: 62%; border: 3px solid var(--ink); border-radius: 6px 3px 3px 6px; background: linear-gradient(180deg, rgba(255, 255, 255, 0.45), transparent 50%), var(--c); }
.km-len-tip { width: 0; height: 0; border-top: calc(clamp(30px, 5vh, 44px) * 0.31) solid transparent; border-bottom: calc(clamp(30px, 5vh, 44px) * 0.31) solid transparent; border-left: 18px solid #f1c27d; }
.km-len-body.km-len-ribbon { height: 44%; border-radius: 999px; background: repeating-linear-gradient(90deg, var(--c) 0 14px, #fff 14px 18px); }
.km-len-body.km-len-cars { height: 70%; border-radius: 8px; background: repeating-linear-gradient(90deg, #ff6b6b 0 calc(100% / 6 - 4px), transparent calc(100% / 6 - 4px) calc(100% / 6)), #fff; background-size: 46px 100%; background-repeat: repeat-x; }
.km-len-engine { font-size: clamp(30px, 5vh, 42px); line-height: 1; scale: -1 1; }

/* Heavier or lighter: a balance tipped toward the heavy side. */
.km-scale { position: relative; display: grid; justify-items: center; width: min(86%, 340px); padding-top: 10px; }
.km-beam { display: flex; justify-content: space-between; align-items: flex-end; width: 100%; height: clamp(76px, 14vh, 110px); border-bottom: 6px solid var(--ink); border-radius: 0 0 4px 4px; rotate: var(--tilt); transform-origin: 50% 100%; animation: km-tip 1s var(--bounce) 0.3s backwards; }
.km-post { width: 10px; height: clamp(40px, 7vh, 60px); border-radius: 0 0 4px 4px; background: var(--ink); }
.km-post::after { content: ''; position: absolute; left: 50%; bottom: 0; translate: -50% 0; width: 90px; height: 10px; border-radius: 6px; background: var(--ink); }
.km-pan { position: relative; display: grid; justify-items: center; align-items: end; min-width: 40%; }
.km-load { font-size: clamp(40px, 7vh, 56px); line-height: 1; rotate: calc(var(--tilt) * -1); }
.km-load.big { font-size: clamp(66px, 11vh, 92px); }
.km-arrow { position: absolute; top: -1.2em; font-size: clamp(26px, 4.5vh, 36px); }
.scene.helping .km-arrow { animation: count-hop 0.6s var(--bounce) infinite alternate; }
@keyframes km-tip { from { rotate: 0deg; } }

/* Counting one kind in a mix. */
.km-mix { --cell: clamp(36px, 8vw, 54px); display: grid; grid-template-columns: repeat(6, var(--cell)); grid-auto-rows: var(--cell); gap: 4px; justify-content: center; }
.km-mix .km-cell { background: none; }
.km-mix .km-cell.counted { background: #fff3c4; }

@media (max-width: 640px) {
  .pk-numcard .pk-num { font-size: 64px; }
  .pk-match { font-size: 70px; }
  .km-mix { --cell: 38px; grid-template-columns: repeat(5, var(--cell)); }
  /* A word's three sounds and the 🔊 fit side by side on a phone (Sound It Out, Blend Band). */
  .sc-sounds .pk-listen { width: 84px; font-size: 40px; }
  .pk-sounds b { font-size: 44px; padding: 4px 6px; }
}
