/*!
 * Bell Hopper — look.
 *
 * Sky Steps: the Whack-a-Bell sky, drifting clouds, and a row of floating
 * platforms whose colour IS the note (the Bell Jump platform, verbatim). The
 * bottom of the screen is the Live Microphone lane from Sing the Interval,
 * renamed but not redesigned — a child who has used that game or the Pitch
 * Trainer should recognise the instrument instantly.
 *
 * PLATFORM ART HOOK: platforms are painted rounded bars by default. Set
 * window.BELL_HOPPER_ART = { platform: (note, state) => url } before the
 * shell loads and each platform renders that image instead (see .has-art).
 */

:root {
  --bh-navy: #1b233e;
  --bh-ink: #1f1d1a;
  --bh-ink-soft: #4a463f;
  --bh-ink-faded: #8a8478;
  --bh-paper: #fdfbf6;
  --bh-paper-light: #fbfbf9;
  --bh-rule: #d8d4cb;
  --bh-teal: #009999;
  --bh-teal-edge: #00706f;
  --bh-green: #6abb4a;
  --bh-green-edge: #4f9636;
  --bh-gold: #ffd25b;
  --bh-sky1: #aedcf2;
  --bh-sky2: #dff0f9;
  --bh-cloud: #ffffff;
  --bh-ease-snap: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }

body {
  font-family: 'Nunito', 'Avenir Next Rounded', 'Trebuchet MS', sans-serif;
  color: var(--bh-ink);
  background: linear-gradient(180deg, var(--bh-sky1) 0%, var(--bh-sky2) 70%, var(--bh-sky2) 100%);
  min-height: 100vh;
  min-height: 100svh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }

/* ── scenery: clouds, pure decoration, never tappable ────────────────────── */
.bh-scenery { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
.bh-scenery svg { width: 100%; height: 100%; display: block; }
.bh-cloud { animation: bh-drift 52s ease-in-out infinite alternate; }
.bh-cloud-b { animation-duration: 70s; animation-delay: -25s; }
.bh-cloud-c { animation-duration: 61s; animation-delay: -40s; }
@keyframes bh-drift { from { transform: translateX(-30px); } to { transform: translateX(50px); } }

.bh-app { position: relative; z-index: 1; min-height: 100svh; display: flex; flex-direction: column; }
.bh-screen { width: min(940px, 100%); margin: 0 auto; padding: 24px max(18px, env(safe-area-inset-right)) 32px max(18px, env(safe-area-inset-left)); }

/* ══════════════════════════════════════════════════════════════════════════
   MENU
   ══════════════════════════════════════════════════════════════════════════ */
/* Room for the arcade Menu pill that floats over the top-left corner, plus the
   safe area: the iPhone Dynamic Island and the iPad status bar. Without it the
   eyebrow and title sat beside the island and under the Menu and coin buttons. */
.bh-menu { padding-top: calc(70px + env(safe-area-inset-top)); }
.bh-eyebrow {
  margin: 0 0 10px; font-size: 10px; font-weight: 900; letter-spacing: 2px;
  text-transform: uppercase; color: var(--bh-navy); opacity: 0.7;
}
.bh-title {
  margin: 0 0 8px; font-size: clamp(30px, 7.4vw, 44px); font-weight: 900;
  letter-spacing: -0.6px; line-height: 1.05; color: var(--bh-navy);
}
.bh-sub { margin: 0 0 24px; font-size: 16px; font-weight: 700; color: var(--bh-ink-soft); line-height: 1.5; }
.bh-sub b { color: var(--bh-ink); }

.bh-levels { display: grid; gap: 10px; }
@media (min-width: 640px) { .bh-levels { grid-template-columns: 1fr 1fr; } }
.bh-level {
  display: flex; align-items: center; gap: 12px; text-align: left;
  background: var(--bh-paper-light);
  border: 2px solid var(--bh-rule); border-bottom-width: 4px; border-radius: 15px;
  padding: 13px 15px 11px; min-height: 64px;
  transition: transform 0.15s, border-color 0.15s;
}
.bh-level:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--bh-teal); }
.bh-level.is-locked { opacity: 0.5; cursor: not-allowed; }
.bh-level-num {
  flex: none; display: grid; place-items: center; width: 30px; height: 30px;
  border-radius: 9px; background: var(--bh-teal); color: #fff; font-weight: 900; font-size: 14px;
}
.bh-level.is-locked .bh-level-num { background: var(--bh-ink-faded); }
.bh-level-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.bh-level-name { font-size: 16px; font-weight: 900; }
.bh-level-blurb { font-size: 12.5px; font-weight: 700; color: var(--bh-ink-soft); }
/* The little staircase of note dots under each card: the level's shape at a glance. */
.bh-level-path { display: flex; gap: 3px; margin-top: 3px; }
.bh-level-path i { width: 7px; height: 7px; border-radius: 50%; display: block; }
.bh-stars i { font-style: normal; color: var(--bh-rule); font-size: 13px; }
.bh-stars i.on { color: #f4b400; }
.bh-mic-note {
  margin: 24px 0 0; font-size: 12.5px; font-weight: 700; line-height: 1.5;
  color: var(--bh-ink-soft); max-width: 52ch;
}

/* ══════════════════════════════════════════════════════════════════════════
   PLAY
   A flex column: HUD → ask → stage (grows) → Live Microphone lane. The stage
   is the world; the lane is the instrument. Both must be on screen at once at
   every size, which is why the stage flexes and the lane does not.
   ══════════════════════════════════════════════════════════════════════════ */
.bh-play {
  flex: 1; display: flex; flex-direction: column; gap: 10px;
  padding-top: calc(14px + env(safe-area-inset-top)); min-height: 100svh;
}

.bh-hud {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  /* 150px clears the arcade's Menu pill; PK-5 has no pill and simply gets
     a roomier left margin. */
  padding: 12px 8px 0 150px; flex-wrap: wrap;
}
@media (max-width: 720px) { .bh-hud { padding: 50px 4px 0; justify-content: center; } }   /* .bh-play already adds the safe area; 50 clears the 48px chrome row */
.bh-quit, .bh-progress {
  background: none; border: none; padding: 6px 0;
  font-size: 11px; font-weight: 900; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--bh-navy); opacity: 0.8;
}
.bh-quit { min-height: 44px; padding: 0 8px; }
.bh-quit:hover { opacity: 1; }
.bh-dots { display: flex; gap: 5px; align-items: center; }
.bh-dots i {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--dot, var(--bh-rule)); opacity: 0.3;
  transition: opacity 0.2s, transform 0.2s;
}
.bh-dots i.is-done { opacity: 1; }
.bh-dots i.is-now { opacity: 1; transform: scale(1.35); box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.8); }

.bh-ask {
  margin: 0; text-align: center;
  font-size: clamp(17px, 4.4vw, 22px); font-weight: 800; color: var(--bh-navy);
}
.bh-ask b { color: var(--target, var(--bh-ink)); font-size: 1.25em; }
.bh-ask .bh-ask-note {
  display: inline-grid; place-items: center; min-width: 1.7em; height: 1.7em; padding: 0 0.3em;
  border-radius: 0.5em; background: var(--target, var(--bh-teal)); color: var(--target-text, #fff);
  font-size: 1.1em; vertical-align: middle; margin: 0 0.15em;
}
.bh-ask small { display: block; font-size: 12.5px; font-weight: 700; color: var(--bh-ink-soft); margin-top: 2px; }

/* ── the stage ─────────────────────────────────────────────────────────── */
.bh-stage {
  position: relative; flex: 1 1 auto;
  min-height: 220px; max-height: 56vh;
  overflow: hidden;
  border-radius: 22px;
  /* A faint frame so the world reads as a place, not loose objects on the page. */
  background: rgba(255, 255, 255, 0.16);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.45);
}
.bh-track {
  position: absolute; left: 0; top: 0; height: 100%;
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}

/* The Bell Jump platform: shadow, note colour, highlight strip, letter. */
.bh-plat {
  position: absolute; height: 22px; border: none; padding: 0;
  border-radius: 11px;
  background: var(--note);
  color: var(--note-text, #fff);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.2);
  font-size: 15px; font-weight: 900; line-height: 22px; text-align: center;
  transition: transform 0.15s, box-shadow 0.25s, filter 0.3s;
}
.bh-plat::before {
  content: ""; position: absolute; left: 5px; right: 5px; top: 4px; height: 5px;
  border-radius: 3px; background: rgba(255, 255, 255, 0.32); pointer-events: none;
}
/* A 22px bar is not a 44pt target; the hit area reaches above and below it. */
.bh-plat::after { content: ""; position: absolute; left: 0; right: 0; top: -12px; bottom: -12px; }
.bh-plat:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2); }
.bh-plat.is-target {
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.2), 0 0 0 4px rgba(255, 255, 255, 0.75), 0 0 18px var(--note);
  animation: bh-glow 1.5s ease-in-out infinite;
}
.bh-plat.is-target.is-near {
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.2), 0 0 0 5px #fff, 0 0 30px var(--note);
  animation: none;
}
.bh-plat.is-done { filter: saturate(0.75) brightness(1.06); }
.bh-plat.is-done::before { background: rgba(255, 255, 255, 0.5); }
.bh-plat.is-ringing { animation: bh-ring 0.35s var(--bh-ease-snap); }
@keyframes bh-glow { 50% { box-shadow: 0 3px 0 rgba(0, 0, 0, 0.2), 0 0 0 4px rgba(255, 255, 255, 0.35), 0 0 6px var(--note); } }
@keyframes bh-ring { 30% { transform: translateY(3px) scaleX(1.06); } }
/* Illustrator art, when it arrives: the bar becomes a picture frame. */
.bh-plat.has-art { background: none; box-shadow: none; color: transparent; }
.bh-plat.has-art::before { display: none; }
.bh-plat-art { position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); height: 200%; pointer-events: none; }

/* The bell. The wrapper is positioned by transform each frame; the image
   inside carries the squash so the two transforms never fight. */
.bh-bell-wrap {
  position: absolute; left: 0; top: 0;
  width: var(--bell, 60px); height: var(--bell, 60px);
  pointer-events: none; will-change: transform;
}
.bh-bell {
  display: block; width: 100%; height: 100%; object-fit: contain; object-position: bottom;
  transform-origin: 50% 100%;             /* no drop-shadow: the bell sits ON the platform (Rob, 2026-09-26) */
}
svg.bh-bell.bh-rig { position: absolute; inset: 0; height: 100%; overflow: visible; }
.bh-bell-wrap.is-landing .bh-bell { animation: bh-squash 0.28s var(--bh-ease-snap); }
.bh-bell-wrap.is-hopping .bh-bell { animation: bh-stretch 0.5s ease-in-out; }
@keyframes bh-squash { 30% { transform: scale(1.12, 0.84); } 100% { transform: scale(1, 1); } }
@keyframes bh-stretch { 40% { transform: scale(0.92, 1.1); } 100% { transform: scale(1, 1); } }
/* Shadow on the platform below the floating bell, so height reads as height. */

/* Hear button and the hint line float over the stage's top corners. */
.bh-hear {
  position: absolute; right: 12px; top: 10px; z-index: 2;
  border: none; border-radius: 999px; padding: 0 16px; min-height: 44px;
  background: var(--bh-paper-light); color: var(--bh-navy);
  box-shadow: 0 3px 0 rgba(27, 35, 62, 0.18);
  font-size: 14px; font-weight: 900;
}
.bh-hear:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(27, 35, 62, 0.18); }
.bh-hear.is-pulsing { animation: bh-pulse 1s ease-in-out 3; }
@keyframes bh-pulse { 50% { transform: scale(1.08); box-shadow: 0 3px 0 rgba(27, 35, 62, 0.18), 0 0 0 6px rgba(255, 255, 255, 0.6); } }
.bh-hint {
  position: absolute; left: 12px; top: 12px; z-index: 2; margin: 0; max-width: 60%;
  padding: 8px 12px; border-radius: 12px;
  background: rgba(253, 251, 246, 0.92); color: var(--bh-ink-soft);
  font-size: 13px; font-weight: 800; line-height: 1.35;
  opacity: 0; transform: translateY(-4px); transition: opacity 0.25s, transform 0.25s;
}
.bh-hint.is-on { opacity: 1; transform: none; }

/* ── Live microphone (Sing the Interval's lane, renamed) ────────────────── */
.bh-mic {
  background: var(--bh-paper-light);
  border: 2px solid var(--bh-rule); border-radius: 18px;
  padding: 10px 14px 12px;
}
/* Fixed height: the Stop Mic button appearing must not move the stage above. */
.bh-mic-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; min-height: 32px; }
.bh-mic-head h2 {
  margin: 0; font-size: 10px; font-weight: 900;
  letter-spacing: 2px; text-transform: uppercase; color: var(--bh-ink-faded);
}
.bh-mic-stop {
  border: 2px solid var(--bh-rule); border-radius: 999px; background: #fff;
  padding: 5px 11px; font-size: 11px; font-weight: 900; color: var(--bh-ink-soft);
  min-height: 32px;
}
.bh-mic-stop:hover { border-color: var(--bh-ink-faded); color: var(--bh-ink); }

.bh-lane {
  position: relative;
  height: clamp(120px, 22vh, 190px);
  border: 2px solid var(--bh-rule); border-radius: 14px;
  background: linear-gradient(180deg, rgba(30, 127, 195, 0.05), rgba(255, 255, 255, 0) 45%), #fff;
  overflow: hidden;
  transition: border-color 0.2s;
}
.bh-lane.is-in-tune { border-color: var(--target, var(--bh-green)); }
.bh-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.bh-ladder { position: absolute; inset: 0; pointer-events: none; }
.bh-ladder-edge {
  position: absolute; right: 8px; top: 4px;
  font-size: 8px; font-weight: 900; letter-spacing: 1.5px; color: var(--bh-ink-faded); opacity: 0.6;
}
.bh-ladder-edge.low { top: auto; bottom: 4px; }
.bh-rung { position: absolute; left: 8px; display: flex; align-items: center; gap: 6px; transform: translateY(-50%); }
.bh-rung-dot { width: 8px; height: 8px; border-radius: 50%; opacity: 0.55; }
.bh-rung-label { font-size: 11px; font-weight: 900; color: var(--bh-ink-faded); }
.bh-rung.is-target .bh-rung-dot { width: 12px; height: 12px; opacity: 1; }
.bh-rung.is-target .bh-rung-label { font-size: 15px; }

.bh-mic-cta {
  position: absolute; inset: 0; display: grid; place-content: center; gap: 8px;
  padding: 12px; text-align: center; background: rgba(255, 255, 255, 0.86);
}
.bh-mic-cta[hidden] { display: none; }
.bh-start-mic {
  display: inline-flex; align-items: center; gap: 8px; justify-self: center;
  border: none; border-radius: 999px; padding: 12px 22px; min-height: 48px;
  background: var(--bh-green); box-shadow: 0 4px 0 var(--bh-green-edge);
  color: #fff; font-size: 16px; font-weight: 900;
}
.bh-start-mic:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 0 var(--bh-green-edge); }
.bh-start-mic:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--bh-green-edge); }
.bh-start-mic:disabled { opacity: 0.55; box-shadow: none; }
.bh-start-mic svg { width: 20px; height: 20px; }
.bh-mic-hint { margin: 0; font-size: 12px; font-weight: 700; color: var(--bh-ink-faded); max-width: 34ch; }

.bh-mic-foot { margin-top: 8px; display: grid; gap: 6px; }
.bh-status { margin: 0; font-size: 13px; font-weight: 800; color: var(--bh-ink-soft); min-height: 20px; }
.bh-hold { display: flex; align-items: center; gap: 9px; }
.bh-hold-track { flex: 1; height: 8px; border-radius: 999px; background: var(--bh-rule); overflow: hidden; }
.bh-hold-fill { height: 100%; width: 0; border-radius: 999px; background: var(--target, var(--bh-green)); transition: width 0.08s linear; }
.bh-hold-count {
  font-family: 'JetBrains Mono', monospace; font-size: 10px; font-weight: 700;
  color: var(--bh-ink-faded); min-width: 62px; text-align: right;
}

/* ══════════════════════════════════════════════════════════════════════════
   RESULTS — the Musical Pipes card: one door forward, held wide open
   ══════════════════════════════════════════════════════════════════════════ */
.bh-veil {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(27, 35, 62, 0.55);
  display: grid; place-items: center; padding: 18px;
}
.bh-panel {
  width: min(430px, 94vw);
  background: var(--bh-navy);
  border: 3px solid rgba(253, 248, 238, 0.22); border-radius: 22px;
  padding: 26px 22px 22px; text-align: center; color: #fdf8ee;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  animation: bh-panel-in 0.3s cubic-bezier(0.34, 1.45, 0.64, 1);
}
@keyframes bh-panel-in { from { transform: scale(0.85); opacity: 0; } }
.bh-panel h2 { margin: 0 0 4px; font-size: 27px; font-weight: 900; color: var(--bh-gold); }
.bh-panel-sub { margin: 0 0 10px; font-weight: 800; font-size: 15px; color: rgba(253, 248, 238, 0.8); }
.bh-star-row { font-size: 42px; letter-spacing: 6px; margin: 4px 0 8px; color: var(--bh-gold); }
.bh-star-row .off { color: rgba(253, 248, 238, 0.18); }
.bh-star-row .pop { display: inline-block; animation: bh-star-pop 0.45s cubic-bezier(0.34, 1.6, 0.64, 1) backwards; }
.bh-star-row .pop:nth-child(2) { animation-delay: 0.18s; }
.bh-star-row .pop:nth-child(3) { animation-delay: 0.36s; }
@keyframes bh-star-pop { from { transform: scale(0); } }
.bh-stat { font-size: 15px; font-weight: 800; margin: 2px 0; color: rgba(253, 248, 238, 0.85); }
.bh-stat b { color: #fff; }
.bh-panel-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
.bh-action {
  appearance: none; border: none; border-radius: 14px; padding: 13px 26px; min-height: 44px;
  font-size: 17px; font-weight: 900; letter-spacing: 0.02em; color: #fff;
  background: var(--bh-teal); box-shadow: 0 4px 0 rgba(0, 0, 0, 0.28);
}
.bh-action:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.28); }
.bh-action.small { padding: 9px 16px; font-size: 14px; border-radius: 11px; }
.bh-action.next-big {
  flex: 1 0 100%; padding: 18px 26px; font-size: 22px; border-radius: 18px;
  background: var(--bh-green);
  animation: bh-breathe 1.6s ease-in-out 0.8s infinite;
}
@keyframes bh-breathe { 50% { transform: scale(1.035); } }
.bh-quiet-link {
  appearance: none; border: none; background: none; font-size: 14px; font-weight: 800;
  color: rgba(253, 248, 238, 0.75); text-decoration: underline; padding: 10px 14px; min-height: 44px;
}
/* The card lands while a child may still be singing at the screen; until it
   is armed a stray tap must fall on nothing. */
.bh-veil.is-arming .bh-panel { pointer-events: none; }
.bh-panel .pgc-exit { display: block; margin-top: 12px; color: rgba(253, 248, 238, 0.7); font-weight: 800; font-size: 13px; }

/* ── responsive ────────────────────────────────────────────────────────── */
/* Pre-readers on an iPad are never told about keys. */
.bh-hint-keys { display: inline; }
.bh-hint-touch { display: none; }
@media (pointer: coarse) { .bh-hint-keys { display: none; } .bh-hint-touch { display: inline; } }

@media (max-width: 560px) {
  .bh-screen { padding: 14px max(12px, env(safe-area-inset-right)) 20px max(12px, env(safe-area-inset-left)); }
  .bh-menu { padding-top: calc(70px + env(safe-area-inset-top)); }
  .bh-play { padding-top: calc(14px + env(safe-area-inset-top)); }
  .bh-play { gap: 8px; }
  .bh-ask { font-size: 16px; }
  .bh-stage { min-height: 200px; max-height: 46vh; border-radius: 16px; }
  .bh-lane { height: clamp(110px, 20vh, 160px); }
  .bh-hint { max-width: 56%; font-size: 12px; }
  .bh-hear { padding: 0 12px; font-size: 13px; }
}
@media (max-height: 560px) {
  /* A landscape phone: keep the world, shrink the instrument. */
  .bh-lane { height: 96px; }
  .bh-stage { min-height: 160px; }
  .bh-hud { padding-top: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .bh-cloud, .bh-cloud-b, .bh-cloud-c { animation: none; }
  .bh-plat.is-target, .bh-action.next-big, .bh-hear.is-pulsing { animation: none; }
  .bh-bell-wrap.is-landing .bh-bell, .bh-bell-wrap.is-hopping .bh-bell { animation: none; }
  .bh-track { transition: none; }
  .bh-panel, .bh-star-row .pop { animation: none; }
}

/* ── Adventures (trail levels, 2026-09-26) ───────────────────────────────
   hopper-trail.js paints the world on .bh-scene BEHIND the track; the note
   ledges stand on stone pillars that reach the ground strip. */
.bh-stage.is-trail { background: #8fe4fa; }
.bh-scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; }
.bh-stage.is-trail .bh-track { transition: none; }          /* the camera is eased in JS */
.bh-stage.is-trail .bh-plat { height: 22px; border-radius: 8px; }
.bh-pillar {
  position: absolute; top: 100%; left: 14%; right: 14%; height: var(--pillar, 0px);
  background:
    repeating-linear-gradient(0deg, rgba(0,0,0,0.10) 0 2px, transparent 2px 16px),
    linear-gradient(90deg, #b9ab97, #d9ccb8 45%, #a99a85);
  border-radius: 0 0 4px 4px; pointer-events: none; z-index: -1;
}
.bh-adv-title { margin: 22px 0 4px; font-size: 20px; font-weight: 900; color: var(--bh-ink, #1b233e); display: flex; align-items: center; gap: 8px; }
.bh-new { font-size: 11px; font-weight: 900; color: #fff; background: #e72829; padding: 2px 8px; border-radius: 999px; letter-spacing: .5px; }
.bh-adv-sub { margin-top: 0; }
.bh-level.is-trail .bh-level-num { font-size: 22px; background: none; }
