/* Bar models and number bonds (js/bar-model.js): story-problem help, Bar
   Model Puzzles' cards and picks, and the number bonds in Sparkle Meadow and
   Mermaid Lagoon. Everything here is bm-*, so it can't restyle anything else. */

.bm { display: block; max-width: 100%; height: auto; margin: 0 auto; }
.bm .bm-piece { animation: pop-in 0.35s var(--bounce) backwards; animation-delay: calc(var(--i, 0) * 45ms); transform-box: fill-box; transform-origin: center; }

/* After a miss, above the steps. */
.bm-help { margin: 0 auto 8px; max-width: 440px; }
.bm-help .bm { width: 100%; max-height: 240px; }

/* On the card, with the question (Bar Model Puzzles' first rungs). */
.bm-up { margin: 4px auto 8px; max-width: 420px; }
.bm-up .bm { width: 100%; max-height: 200px; }

/* Pick the bar model that matches the story: four big buttons, two by two. */
.bm-pick { margin: 6px auto 4px; max-width: 560px; }
.bm-pick-head { margin: 0 0 8px; display: flex; align-items: center; justify-content: center; gap: 12px; }
.bm-pick-ask { margin: 0; font-size: clamp(17px, 2.4vw, 21px); font-weight: 700; color: var(--ink); }
/* The 💡 (the keypad's own hint key, which is hidden while picking). */
.bm-hint.key { flex: 0 0 auto; width: 64px; aspect-ratio: 1.15; border-radius: 18px; font-size: 30px; }
.bm-hint.key:disabled { opacity: 0.35; }
.bm-pick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.bm-choice {
  position: relative;
  min-height: 96px;
  padding: 30px 8px 6px; /* room for the number above the bars */
  display: grid;
  place-items: center;
  border-radius: 20px;
  border: 4px solid var(--lilac-soft, #ecdff9);
  background: #fff;
  box-shadow: 0 4px 0 rgba(91, 58, 110, 0.15);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.15s var(--bounce);
}
.bm-choice:active { transform: scale(0.97); }
.bm-choice .bm { width: 100%; max-height: 170px; pointer-events: none; }
.bm-num {
  position: absolute;
  top: 6px;
  left: 8px;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--lilac-soft, #ecdff9);
  color: var(--lilac-deep, #7d58d6);
  font-size: 15px;
  font-weight: 700;
}
.bm-choice.right { border-color: var(--mint); background: #e2fbf2; animation: pop-big 0.5s var(--bounce); }
.bm-choice.wrong { opacity: 0.45; border-style: dashed; }
.bm-choice.wrong::after { content: '✕'; position: absolute; top: 2px; right: 10px; font-size: 22px; font-weight: 700; color: #e25c5c; }
.bm-choice.shake { animation: shake 0.45s; }
.bm-choice.pulse { border-color: var(--gold); background: #fff8dc; outline: 5px solid var(--gold); outline-offset: 2px; animation: pulse 0.9s ease-in-out infinite; }

/* A number bond above the ten-frames. */
.bm-bondwrap { margin: 0 auto 8px; display: flex; flex-direction: column; align-items: center; }
.bm-bondwrap .bm-bond { width: auto; height: 150px; }
.bm-cap { margin: 2px 0 0; font-size: clamp(17px, 2.4vw, 21px); font-weight: 600; color: var(--ink); }
.bm-then { margin: 0 0.5em; font-weight: 500; color: var(--ink-soft); }

/* Phones: one model a row, as wide as the card, so the names and numbers on
   the bars are big enough to read. The number sits to the left. */
@media (max-width: 640px) {
  .bm-pick-grid { grid-template-columns: 1fr; gap: 8px; }
  .bm-choice { min-height: 80px; padding: 6px 8px 6px 40px; border-radius: 16px; }
  .bm-choice .bm { max-height: 124px; }
  .bm-num { top: 50%; left: 8px; transform: translateY(-50%); width: 28px; height: 28px; }
  .bm-hint.key { width: 54px; font-size: 26px; }
  .bm-up .bm { max-height: 160px; }
  .bm-help .bm { max-height: 190px; }
  .bm-bondwrap .bm-bond { height: 112px; }
}

@media (prefers-reduced-motion: reduce) {
  .bm .bm-piece, .bm-choice.pulse, .bm-choice.right { animation: none; }
}
