/* ─────────────────────────────────────────────────────────────────────────
   Sing the Interval — styles.
   Same paper key as What Interval Is It and Major or Minor; the tuning meter
   is the one new element, and it borrows the Pitch Trainer's language.
   ───────────────────────────────────────────────────────────────────────── */

:root {
  --paper: #f5f5f3;
  --paper-light: #fbfbf9;
  --ink: #1f1d1a;
  --ink-soft: #4a463f;
  --ink-faded: #8a8478;
  --rule: #d8d4cb;
  --teal: #009999;
  --teal-edge: #00706f;
  --green: #6ab845;
  --green-edge: #4e9636;
  --gold: #ffc21c;
  --red: #e72829;
  --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; }

.si-screen { max-width: 700px; margin: 0 auto; padding: 24px 18px 48px; }
@media (min-width: 901px) { .si-screen { padding: 32px 24px 56px; } }
/* The play screen carries a lane and a rail side by side, so it gets the
   Pitch Trainer's wider column rather than the menu's reading width. */
.si-play { max-width: 940px; }

.si-eyebrow {
  margin: 0 0 10px; font-size: 10px; font-weight: 900; letter-spacing: 2px;
  text-transform: uppercase; color: var(--ink-faded);
}
.si-title {
  margin: 0 0 8px; font-size: clamp(28px, 7.4vw, 42px); font-weight: 900;
  letter-spacing: -0.6px; line-height: 1.05;
}
.si-sub {
  margin: 0 0 24px; font-size: 16px; font-weight: 700;
  color: var(--ink-soft); line-height: 1.5;
}
.si-sub b { color: var(--ink); }

/* ── Levels ── */
.si-levels { display: grid; gap: 10px; }
@media (min-width: 640px) { .si-levels { grid-template-columns: 1fr 1fr; } }
.si-level {
  display: flex; align-items: center; gap: 12px; 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, border-color 0.15s;
}
.si-level:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--teal); }
.si-level.is-locked { opacity: 0.5; cursor: not-allowed; }
.si-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;
}
.si-level.is-locked .si-level-num { background: var(--ink-faded); }
.si-level-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.si-level-name { font-size: 16px; font-weight: 900; }
.si-level-blurb { font-size: 12.5px; font-weight: 700; color: var(--ink-soft); }
.si-stars i { font-style: normal; color: var(--rule); font-size: 13px; }
.si-stars i.on { color: var(--gold); }
.si-stars.big i { font-size: 30px; }

.si-mic-note {
  margin: 24px 0 0; font-size: 12.5px; font-weight: 700; line-height: 1.5;
  color: var(--ink-faded); max-width: 52ch;
}

/* ── HUD ── */
.si-hud {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 16px;
}
.si-quit, .si-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);
}
.si-quit:hover { color: var(--ink); }
.si-dots { display: flex; gap: 4px; }
.si-dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--rule); }
.si-dots i.g-perfect { background: var(--green); }
.si-dots i.g-great { background: #9ad37c; }
.si-dots i.g-close { background: var(--gold); }
.si-dots i.g-off { background: var(--red); }

/* ══════════════════════════════════════════════════════════════════════════
   THE PLAY SCREEN
   Pitch Trainer's shape — a wide live-microphone lane with a narrow target
   rail beside it — carrying the Compose Tool's staff as the question. A child
   who has used the Pitch Trainer should recognise this instantly; that is the
   point. `--target` is set inline per question to the answer note's chroma
   colour, and the trace, the rail and the hold meter all read from it.
   ══════════════════════════════════════════════════════════════════════════ */

.si-ask {
  margin: 0 0 4px; text-align: center;
  font-size: clamp(16px, 4.4vw, 20px); font-weight: 800; color: var(--ink-soft);
}
.si-ask b { color: var(--ink); }

/* Says the rule out loud. The staff below draws one specific octave because
   notation has to, but any octave is accepted, and a singer who cannot reach
   the printed one needs to be told that rather than left to discover it by
   being marked wrong. Quiet on purpose: it is reassurance, not an instruction. */
.si-anyoctave {
  margin: 0 0 14px; text-align: center;
  font-size: clamp(12px, 3.2vw, 13.5px); font-weight: 700; color: var(--ink-faded, #8a8478);
}

.si-stage { display: grid; gap: 14px; }
@media (min-width: 860px) {
  .si-stage { grid-template-columns: minmax(0, 1fr) 196px; align-items: start; }
}

.si-main { display: grid; gap: 14px; min-width: 0; }

/* ── The staff: the question ── */
.si-staffcard {
  position: relative;
  background: #fff;
  border: 2px solid var(--rule); border-radius: 18px;
  padding: 12px 16px;
}
.si-staffcard svg { display: block; width: 100%; height: auto; max-height: 168px; }

/* Where the answer will appear, until it has been sung. */
.si-mystery {
  position: absolute; left: 62%; top: 50%; transform: translate(-50%, -50%);
  font-size: clamp(34px, 9vw, 54px); font-weight: 900; color: var(--ink-faded);
  opacity: 0.5; pointer-events: none;
  animation: si-bob 1.9s ease-in-out infinite;
}
@keyframes si-bob {
  0%, 100% { transform: translate(-50%, -50%); }
  50% { transform: translate(-50%, -62%); }
}

/* ── Live microphone ── */
.si-mic {
  background: var(--paper-light);
  border: 2px solid var(--rule); border-radius: 18px;
  padding: 12px 14px 14px;
}
.si-mic-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.si-mic-head h2 {
  margin: 0; font-size: 10px; font-weight: 900;
  letter-spacing: 2px; text-transform: uppercase; color: var(--ink-faded);
}
.si-mic-stop {
  border: 2px solid var(--rule); border-radius: 999px; background: #fff;
  padding: 5px 11px; font: inherit; font-size: 11px; font-weight: 900;
  color: var(--ink-soft); cursor: pointer;
}
.si-mic-stop:hover { border-color: var(--ink-faded); color: var(--ink); }

/* The lane. Vertical centre is the target note; the full height is
   ±LANE_RANGE_CENTS, which the canvas and the rungs both map the same way. */
.si-lane {
  position: relative;
  height: clamp(150px, 30vh, 230px);
  border: 2px solid var(--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, background-color 0.2s;
}
.si-lane.is-in-tune { border-color: var(--target, var(--green)); }
.si-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

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

/* ── The call to action, sitting over the lane until the mic is live ── */
.si-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);
}
/* display:grid outranks the UA's [hidden] rule, so hiding it needs saying. */
.si-mic-cta[hidden] { display: none; }
.si-start-mic {
  display: inline-flex; align-items: center; gap: 8px; justify-self: center;
  border: none; border-radius: 999px; padding: 12px 22px;
  background: var(--green); box-shadow: 0 4px 0 var(--green-edge);
  color: #fff; font: inherit; font-size: 16px; font-weight: 900; cursor: pointer;
}
.si-start-mic:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 0 var(--green-edge); }
.si-start-mic:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--green-edge); }
.si-start-mic:disabled { opacity: 0.55; box-shadow: none; }
.si-start-mic svg { width: 20px; height: 20px; }
.si-mic-hint { margin: 0; font-size: 12px; font-weight: 700; color: var(--ink-faded); max-width: 30ch; }

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

/* ── Target rail ── */
.si-rail {
  display: grid; gap: 10px; justify-items: center;
  background: var(--paper-light);
  border: 2px solid var(--target, var(--rule)); border-radius: 18px;
  padding: 14px 12px;
}
.si-rail-head { text-align: center; }
.si-rail-label {
  font-size: 9px; font-weight: 900; letter-spacing: 1.6px;
  text-transform: uppercase; color: var(--ink-faded);
}
.si-rail-note {
  font-size: 34px; font-weight: 900; line-height: 1.1;
  color: var(--target, var(--ink));
}
.si-bell-btn {
  border: none; background: none; padding: 0; cursor: pointer;
  display: grid; place-items: center;
}
.si-bell-img { width: 92px; height: 92px; object-fit: contain; display: block; }
.si-bell-img.is-ringing { animation: si-ring 0.45s ease-out; }
@keyframes si-ring {
  0% { transform: rotate(0deg); }
  25% { transform: rotate(-7deg); }
  60% { transform: rotate(5deg); }
  100% { transform: rotate(0deg); }
}
.si-bell-fallback { font-size: 56px; }
.si-rail-actions { display: grid; gap: 6px; width: 100%; }
.si-rail-btn {
  border: 2px solid var(--rule); border-radius: 12px; background: #fff;
  padding: 9px 10px; font: inherit; font-size: 13px; font-weight: 900;
  color: var(--ink-soft); cursor: pointer;
}
.si-rail-btn:hover { border-color: var(--ink-faded); color: var(--ink); }
.si-rail-btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; }

/* The rail sits beside the lane on a laptop and reads as a row on a phone,
   where a 196px column would squeeze the lane to nothing. */
@media (max-width: 859px) {
  .si-rail { grid-template-columns: auto 1fr; justify-items: start; align-items: center; gap: 6px 14px; }
  .si-rail-head { grid-row: 1; }
  .si-bell-btn { grid-row: 1; grid-column: 1; }
  .si-rail-head { grid-column: 2; text-align: left; }
  .si-rail-actions { grid-column: 1 / -1; grid-template-columns: 1fr 1fr; }
  .si-bell-img { width: 68px; height: 68px; }
  .si-rail-note { font-size: 28px; }
}

/* ── Actions ── */
.si-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.si-btn {
  padding: 14px 26px; 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;
}
.si-btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 0 var(--green-edge); }
.si-btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--green-edge); }
.si-btn:disabled { opacity: 0.55; box-shadow: none; }
.si-btn.ghost {
  color: var(--ink-soft); background: var(--paper-light);
  border: 2px solid var(--rule); border-bottom-width: 4px; box-shadow: none;
}
.si-btn.ghost:hover { border-color: var(--ink-faded); box-shadow: none; }

.si-feedback {
  min-height: 28px; margin: 18px 0 0; text-align: center;
  font-size: 16px; font-weight: 800; color: var(--ink-soft);
}
.si-feedback.is-right { color: #2e7d32; }
.si-feedback.is-wrong { color: var(--red); }
.si-feedback.is-soft { color: var(--ink-faded); }
.si-next { display: flex; justify-content: center; margin-top: 14px; min-height: 52px; }

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

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; }
}
