/* ─────────────────────────────────────────────────────────────────────────
   What Interval Is It? — styles.

   The compose tool became a game, so the page is built around its staff:
   paper, brown ink, chroma noteheads, Nunito. Same light key as Major or
   Minor, which is its sibling.
   ───────────────────────────────────────────────────────────────────────── */

:root {
  --paper: #f5f5f3;
  --paper-light: #fbfbf9;
  --ink: #1f1d1a;
  --ink-soft: #4a463f;
  --ink-faded: #8a8478;
  --rule: #d8d4cb;
  --brown: #512d1b;

  --teal: #009999;
  --teal-edge: #00706f;
  --green: #6ab845;
  --green-edge: #4e9636;
  --red: #e72829;
  --gold: #ffc21c;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-snap: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Nunito', sans-serif;
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }

.wi-screen { max-width: 820px; margin: 0 auto; padding: 24px 18px 48px; }
@media (min-width: 901px) { .wi-screen { padding: 32px 24px 56px; } }

.wi-eyebrow {
  margin: 0 0 10px; font-size: 10px; font-weight: 900; letter-spacing: 2px;
  text-transform: uppercase; color: var(--ink-faded);
}
.wi-title {
  margin: 0 0 8px; font-size: clamp(28px, 7.4vw, 44px); font-weight: 900;
  letter-spacing: -0.6px; line-height: 1.05;
}
.wi-title.small { font-size: clamp(24px, 6vw, 32px); }
.wi-sub {
  margin: 0 0 24px; max-width: 48ch; font-size: 16px; font-weight: 700;
  color: var(--ink-soft); line-height: 1.5;
}
.wi-mini-title {
  margin: 22px 0 8px; font-size: 9px; font-weight: 900; letter-spacing: 2px;
  text-transform: uppercase; color: var(--ink-faded);
}

/* ── Level menu ── */
.wi-levels { display: grid; gap: 10px; }
@media (min-width: 680px) { .wi-levels { grid-template-columns: 1fr 1fr; } }

.wi-level {
  display: flex; align-items: center; gap: 13px; text-align: left;
  background: var(--paper-light);
  border: 2px solid var(--rule); border-bottom-width: 4px; border-radius: 15px;
  padding: 13px 15px 11px;
  transition: transform 0.15s var(--ease-out), border-color 0.15s;
}
.wi-level:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--teal); }
.wi-level.is-locked { opacity: 0.5; cursor: not-allowed; }
.wi-level-num {
  flex: none; display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--teal); color: #fff; font-weight: 900; font-size: 14px;
}
.wi-level.is-locked .wi-level-num { background: var(--ink-faded); }
.wi-level-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.wi-level-name { font-size: 16px; font-weight: 900; }
.wi-level-blurb { font-size: 12.5px; font-weight: 700; color: var(--ink-soft); }

.wi-stars i { font-style: normal; color: var(--rule); font-size: 13px; }
.wi-stars i.on { color: var(--gold); }
.wi-stars.big i { font-size: 30px; }

.wi-menu-foot { margin-top: 26px; display: grid; gap: 10px; justify-items: start; }
.wi-mastered { margin: 0; font-size: 12.5px; font-weight: 800; color: var(--ink-faded); }

/* ── HUD ── */
.wi-hud {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 12px;
}
.wi-quit, .wi-progress {
  background: none; border: none; padding: 4px 0;
  font-size: 11px; font-weight: 900; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--ink-faded);
}
.wi-quit:hover { color: var(--ink); }
.wi-streak { font-size: 15px; font-weight: 900; color: var(--ink-soft); }

.wi-dots { display: flex; gap: 5px; margin-bottom: 14px; flex-wrap: wrap; }
.wi-dots i {
  width: 9px; height: 9px; border-radius: 50%; background: var(--rule);
  transition: background 0.2s, transform 0.2s;
}
.wi-dots i.hit { background: var(--green); }
.wi-dots i.miss { background: var(--gold); }   /* amber, not red — a retry is not a failure */
.wi-dots i.now { background: var(--ink-faded); transform: scale(1.4); }

/* ── Staff ── */
.wi-stage { position: relative; margin-bottom: 14px; }
.wi-staff {
  display: grid; place-items: center;
  background: #fff; border: 2px solid var(--rule); border-radius: 16px;
  padding: 10px; overflow: hidden;
}
/* The Prodigies clef is drawn far taller than the staff it sits on, so the
   score's natural aspect is too tall for one question. Cap and letterbox. */
.wi-staff svg { display: block; width: 100%; height: auto; max-height: 190px; }
@media (min-width: 620px) { .wi-staff svg { max-height: 230px; } }

/* Guided mode's ghost note: the answer is on the staff, but translucent and
   gently bobbing, so it reads as a question being asked rather than an answer
   printed. transform-box keeps the bob centred on each SVG element. */
/* This is a <g> wrapping the answer note, not the note's own shapes — see
   tagGhost(). Animating the shapes would overwrite the notehead's rotate()
   attribute and tip it the wrong way. */
.wi-ghost {
  opacity: 0.45;
  transform-box: fill-box;
  transform-origin: center;
  animation: wi-ghost-bob 1.7s ease-in-out infinite;
}
@keyframes wi-ghost-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

/* The hidden second note: a question mark where it will appear. */
.wi-mystery {
  position: absolute; left: 62%; top: 50%; transform: translate(-50%, -50%);
  font-size: clamp(40px, 10vw, 64px); font-weight: 900; color: var(--brown);
  opacity: 0.55; pointer-events: none;
  animation: wi-bob 1.9s ease-in-out infinite;
}
@keyframes wi-bob {
  0%, 100% { transform: translate(-50%, -50%); }
  50% { transform: translate(-50%, -62%); }
}

/* ── Listen ── */
.wi-controls { display: flex; gap: 10px; margin-bottom: 16px; }
.wi-listen {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 14px 20px; font-size: 17px; font-weight: 900; color: #fff;
  background: var(--teal); border: none; border-radius: 15px;
  box-shadow: 0 4px 0 var(--teal-edge);
  transition: transform 0.14s var(--ease-snap), box-shadow 0.14s;
}
.wi-listen svg { width: 21px; height: 21px; }
.wi-listen:hover { transform: translateY(-2px); box-shadow: 0 6px 0 var(--teal-edge); }
.wi-listen:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--teal-edge); }
.wi-slow {
  flex: none; padding: 12px 16px; font-size: 13px; font-weight: 900;
  color: var(--ink-soft); background: var(--paper-light);
  border: 2px solid var(--rule); border-bottom-width: 4px; border-radius: 13px;
}
.wi-slow.on { color: #fff; background: var(--ink-soft); border-color: var(--ink-soft); }

/* ── Bells ── */
.wi-bells {
  display: flex; gap: 7px; flex-wrap: wrap; justify-content: center;
}
.wi-bell {
  position: relative; flex: 1 1 64px; max-width: 92px; min-width: 56px;
  display: grid; justify-items: center; gap: 2px;
  padding: 8px 4px 6px; background: none; border: none; border-radius: 14px;
  transition: transform 0.14s var(--ease-snap), filter 0.14s;
}
.wi-bell img { width: 100%; height: auto; display: block; pointer-events: none; }
.wi-bell span {
  font-size: 13px; font-weight: 900; color: var(--ink);
  padding: 1px 7px; border-radius: 999px; background: var(--bell); color: #fff;
}
.wi-bell:hover:not(:disabled) { transform: translateY(-4px); }
.wi-bell:active:not(:disabled) { transform: translateY(1px) scale(0.97); }
.wi-bell:disabled { opacity: 0.34; }

.wi-bell.is-right {
  animation: wi-pop 0.5s var(--ease-snap);
  filter: drop-shadow(0 0 12px rgba(106, 184, 69, 0.85));
}
.wi-bell.is-wrong { animation: wi-shake 0.4s ease; }
.wi-bell.is-hint { animation: wi-pulse 1.3s ease-in-out infinite; }

/* ── Interval-name answers ── */
.wi-names { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.wi-name-btn {
  padding: 16px 12px; font-size: clamp(15px, 3.6vw, 18px); font-weight: 900;
  color: var(--ink); background: var(--paper-light);
  border: 2px solid var(--rule); border-bottom-width: 4px; border-radius: 15px;
  transition: transform 0.14s var(--ease-snap), border-color 0.14s;
}
.wi-name-btn:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--teal); }
.wi-name-btn:disabled { opacity: 0.36; }
.wi-name-btn.is-right {
  color: #fff; background: var(--green); border-color: var(--green-edge);
  animation: wi-pop 0.5s var(--ease-snap);
}
.wi-name-btn.is-wrong { animation: wi-shake 0.4s ease; }
.wi-name-btn.is-hint { animation: wi-pulse 1.3s ease-in-out infinite; }

@keyframes wi-pop { 0% { transform: scale(1); } 45% { transform: scale(1.12); } 100% { transform: scale(1); } }
@keyframes wi-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); } 60% { transform: translateX(4px); } 80% { transform: translateX(-2px); }
}
@keyframes wi-pulse { 0%, 100% { transform: none; } 50% { transform: translateY(-5px); } }

/* ── Feedback ── */
.wi-feedback {
  min-height: 28px; margin: 18px 0 0; text-align: center;
  font-size: 16px; font-weight: 800; color: var(--ink-soft);
}
.wi-feedback b { color: var(--ink); }
.wi-feedback.is-right { color: #2e7d32; }
.wi-feedback.is-soft { color: var(--ink-soft); }
.wi-next { display: flex; justify-content: center; margin-top: 12px; min-height: 52px; }

.wi-btn {
  padding: 13px 24px; font-size: 16px; font-weight: 900; color: #fff;
  background: var(--green); border: none; border-radius: 14px;
  box-shadow: 0 4px 0 var(--green-edge);
  transition: transform 0.14s var(--ease-snap), box-shadow 0.14s;
}
.wi-btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 0 var(--green-edge); }
.wi-btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--green-edge); }
.wi-btn:disabled { opacity: 0.45; box-shadow: none; }
.wi-btn.ghost {
  color: var(--ink-soft); background: var(--paper-light);
  border: 2px solid var(--rule); border-bottom-width: 4px; box-shadow: none;
}
.wi-btn.ghost:hover { border-color: var(--ink-faded); box-shadow: none; transform: translateY(-1px); }

/* ── Practice ── */
.wi-presets { display: flex; flex-wrap: wrap; gap: 8px; }
.wi-preset {
  padding: 9px 14px; font-size: 13px; font-weight: 900; color: var(--ink-soft);
  background: var(--paper-light); border: 2px solid var(--rule); border-radius: 999px;
}
.wi-preset:hover { border-color: var(--teal); color: var(--ink); }

.wi-checks { display: flex; flex-wrap: wrap; gap: 7px; }
.wi-check {
  padding: 8px 12px; font-size: 12.5px; font-weight: 700; color: var(--ink-soft);
  background: var(--paper-light); border: 2px solid var(--rule); border-radius: 11px;
}
.wi-check b { font-weight: 900; color: var(--ink); margin-right: 4px; }
.wi-check.on { background: var(--teal); border-color: var(--teal-edge); color: #fff; }
.wi-check.on b { color: #fff; }

.wi-seg { display: flex; flex-wrap: wrap; gap: 7px; }
.wi-seg-btn {
  padding: 9px 14px; font-size: 13px; font-weight: 800; color: var(--ink-soft);
  background: var(--paper-light); border: 2px solid var(--rule); border-radius: 11px;
}
.wi-seg-btn.on { background: var(--ink); border-color: var(--ink); color: #fff; }

.wi-practice-foot {
  margin-top: 26px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.wi-valid { margin: 0; font-size: 13px; font-weight: 800; color: var(--ink-faded); }
.wi-valid.is-bad { color: var(--red); max-width: 42ch; }

/* ── Results ── */
.wi-results { text-align: center; }
.wi-result-head { margin: 0 0 18px; font-size: clamp(25px, 6.6vw, 36px); font-weight: 900; }
.wi-scorecard {
  background: var(--paper-light); border: 2px solid var(--rule);
  border-radius: 20px; padding: 22px 18px 18px; margin-bottom: 8px;
}
.wi-big { margin: 0; font-size: 54px; font-weight: 900; line-height: 1; }
.wi-big span { font-size: 22px; color: var(--ink-faded); margin-left: 5px; }
.wi-big-note {
  margin: 2px 0 8px; font-size: 10px; font-weight: 900; letter-spacing: 2px;
  text-transform: uppercase; color: var(--ink-faded);
}
.wi-streak-note { margin: 8px 0 0; font-size: 13px; font-weight: 700; color: var(--ink-faded); }

.wi-practised { margin: 0 0 20px; padding: 0; list-style: none; text-align: left; }
.wi-practised li {
  display: flex; align-items: center; gap: 8px; padding: 9px 2px;
  border-top: 1px solid var(--rule); font-size: 14px; font-weight: 700; color: var(--ink-soft);
}
.wi-practised li b {
  flex: none; min-width: 34px; font-weight: 900; color: var(--ink);
}
.wi-practised li span { margin-left: auto; font-weight: 900; color: var(--ink-faded); }

.wi-result-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
#classScoreSlot { max-width: 560px; margin: 0 auto 18px; text-align: left; }

@media (prefers-reduced-motion: reduce) {
  .wi-mystery, .wi-bell, .wi-name-btn, .wi-ghost { animation: none !important; }
  * { transition-duration: 0.01ms !important; }
}

/* ── continue where she left off ─────────────────────────────────────────
   One big resume tap above the level list, so a returning kid never has to
   re-find her place in sixteen rows (and never "starts at level 1" just
   because it was the first thing her finger reached). */
.wi-continue {
  display: block;
  width: min(440px, 100%);
  margin: 4px auto 16px;
  font-size: 17px;
  padding: 15px 18px;
  min-height: 54px;
}

/* difficulty bands: quiet grown-up headers over the ladder */
.wi-band {
  margin: 14px 2px 4px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--ink-soft, #5a6479);
  opacity: 0.75;
  text-align: left;
}
.wi-band:first-child { margin-top: 0; }
/* the level list is a 2-column grid on wide screens — a band header must
   span the full row or it becomes a lonely grid cell */
.wi-levels .wi-band { grid-column: 1 / -1; margin-bottom: 0; }
