* { box-sizing: border-box; }

body {
  margin: 0;
  background: #0f1117;
  color: #e6e8ee;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

h1 {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.015em;
  margin: 0 0 6px;
}

.sub {
  margin: 0 0 20px;
  color: #9aa0b0;
  font-size: 14px;
  line-height: 1.5;
}

kbd {
  background: #262b38;
  border: 1px solid #3a4150;
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 7px;
  font-family: ui-monospace, monospace;
  font-size: 13px;
}

/* Links. The browser defaults (#0000EE blue / #551A8B purple) are close to
   unreadable on this dark background, so BOTH states get explicit, bright
   colors: periwinkle unvisited, lavender once visited — distinguishable from
   each other but each legible on its own.
   Note: components with their own link color (.pagenav) sit later in this file
   and so keep it even when visited, which is what we want for nav chrome. */
a { color: #8fa3ff; text-underline-offset: 3px; }
a:visited { color: #c3a8ff; }
a:hover { color: #b8c5ff; }
a:visited:hover { color: #d9c6ff; }

/* ---- lesson template sections ---- */
.lesson-intro { font-size: 15px; color: #c7cbd6; }

/* Every lesson page is exactly TWO steps: (1) hear it, (2) play it. Both get
   the SAME card + header so the eye parses "two parts", not a pile of widgets.
   The only asymmetry is what sits in the header's right slot: a hint for the
   reference, the live score for the game. */
.step {
  margin: 0 0 16px;
  background: #12151d;
  border: 1px solid #2c3242;
  border-radius: 14px;
  overflow: hidden;
}

.step-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 16px;
  background: #171c26;
  border-bottom: 1px solid #232838;
}

.step-num {
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #2b3345;
  color: #c7cbd6;
  font-size: 12px;
  font-weight: 700;
}

/* The auto right margin absorbs the free space, so the header's right slot
   (the scorebar on step 2) lines up on the right. */
.step-titles { margin-right: auto; }

.step-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: #e6e8ee;
}

/* The goal, stated right under the step title. Tinted with the streak-dot
   green so it reads as "this is what you're aiming for". */
.step-sub {
  margin: 3px 0 0;
  font-size: 14px;
  font-weight: 500;
  color: #8fd9a0;
}

.step-body { padding: 14px 16px 16px; }

/* The reference is deliberately compact: the game grid below already shows the
   pattern, so the piano roll's real value is the AUDIO. The thing you actually
   interact with earns the space. */
.step midi-visualizer {
  display: block;
  overflow: hidden;
  border-radius: 6px;
  background: #0f1117;
}
.step midi-visualizer svg { max-height: 120px; width: 100%; }
.step midi-player {
  display: block;
  width: 100%;
  margin-top: 8px;
}
.step .lesson-detail { margin: 14px 0 0; }

.step #viz { border: none; border-radius: 6px; } /* the card already frames it */
.step .controls { margin-top: 16px; }

#viz {
  width: 100%;
  display: block;
  background: #0f1117;
  border: 1px solid #262b38;
  border-radius: 10px;
}

/* Score group: combo + clean-loop streak share one card, top right of the
   game header. */
.scorebar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 16px;
  background: #0f1117;
  border: 1px solid #262b38;
  border-radius: 12px;
}

.score-label {
  font-family: ui-monospace, monospace;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #8b90a0;
}

.score-divider {
  width: 1px;
  align-self: stretch;
  background: #262b38;
}

.score-loops {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dots { display: flex; gap: 8px; }

.dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #262b38;
  border: 1px solid #3a4150;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  color: transparent;
  transition: background 0.15s, box-shadow 0.15s;
}
.dot::after { content: "✓"; }
.dot.on {
  background: #57d977;
  border-color: #57d977;
  color: #0f1117;
  box-shadow: 0 0 10px rgba(87, 217, 119, 0.6);
  animation: dot-pop 0.22s ease-out;
}
@keyframes dot-pop {
  0% { transform: scale(0.6); }
  60% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

/* All three earned: gentle celebratory pulse. */
.dots.passed .dot {
  animation: dot-pulse 1.2s ease-in-out infinite;
}
@keyframes dot-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 10px rgba(87, 217, 119, 0.6); }
  50% { transform: scale(1.12); box-shadow: 0 0 16px rgba(87, 217, 119, 0.95); }
}

.status {
  font-size: 14px;
  color: #9aa0b0;
}
.status.pass {
  color: #57d977;
  font-weight: 600;
}

/* Combo: consecutive correct notes. Flashes red when it breaks. */
.combo {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 3.5em;
}
.combo #comboVal {
  font-family: ui-monospace, monospace;
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
  color: #57d977;
}
.combo.broke #comboVal {
  color: #ff5a5a;
  animation: combo-broke 0.6s ease;
}
@keyframes combo-broke {
  0% { transform: scale(1.4); }
  100% { transform: scale(1); }
}

.controls {
  display: flex;
  align-items: stretch;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 16px;
}
.controls > button {
  min-width: 130px;
  padding: 10px 20px;
  font-size: 16px;
  border-radius: 12px;
}

/* Tempo panel: slider, readout, and click toggle grouped in one card. */
.tempo-panel {
  flex: 1;
  min-width: 280px;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 20px;
  background: #0f1117;
  border: 1px solid #262b38;
  border-radius: 12px;
}

.tempo-readout {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tempo-value {
  display: flex;
  align-items: baseline;
  gap: 5px;
}
.tempo-value #bpmVal {
  font-family: ui-monospace, monospace;
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  color: #8fa3ff;
  min-width: 3ch;
}
.tempo-unit {
  font-family: ui-monospace, monospace;
  font-size: 12px;
  color: #8b90a0;
}

.tempo-inputs {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tempo-inputs input[type="range"] { width: 100%; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 18px;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: #262b38;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -6px;
  border-radius: 50%;
  background: #8fa3ff;
  box-shadow: 0 0 10px rgba(143, 163, 255, 0.6);
}
input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: #262b38;
}
input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 50%;
  background: #8fa3ff;
  box-shadow: 0 0 10px rgba(143, 163, 255, 0.6);
}

button {
  background: #3d5afe;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 22px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
button:disabled { opacity: 0.6; cursor: default; }
button:hover:not(:disabled) { background: #4f6bff; }

.ctrl.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #9aa0b0;
}

/* ---- page navigation (lesson pages) ----
   Lives at the FOOT of the page only: you navigate on once you've finished the
   unit, so the rule sits above it and there's no nav competing with the title
   for attention at the top. */
.pagenav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  margin-top: 32px;
  padding-top: 14px;
  border-top: 1px solid #1e2330;
}
.pagenav a {
  color: #8fa3ff;
  text-decoration: none;
}
.pagenav a:hover { text-decoration: underline; }
.nav-pos { color: #6b7183; }
.nav-next-disabled { color: #454b5a; }

/* ---- landing page ---- */
.landing { text-align: center; padding-top: 64px; }
.hero-title { font-size: 34px; margin-bottom: 12px; }
.hero-sub {
  font-size: 16px;
  max-width: 620px;
  margin: 0 auto 36px;
}
.landing .sub { max-width: 620px; margin-left: auto; margin-right: auto; }

.landing-lead {
  max-width: 720px;
  margin: 0 auto 14px;
  text-align: left;
  font-size: 17px;
  line-height: 1.6;
  color: #c7cbd6;
}

/* The final-result preview: same card as the lessons' "Hear it first", but
   headerless — it needs no step number out here. */
.landing-demo {
  max-width: 720px;
  margin: 0 auto 32px;
  text-align: left;
}

/* Unlike a lesson demo (a compact reference beside the real grid), this one IS
   the point of the page: show the WHOLE pattern at once, no scrolling.
   Two things have to give way, hence the !importants:
   1. The waterfall SVG has no viewBox, so a max-height CLIPS notes instead of
      scaling them — the cap has to go entirely.
   2. Magenta inline-styles its notes container to a fixed 130px tall window
      (with a matching padding-top) and scrolls the notes through it. Inline
      styles outrank plain selectors, so overriding needs !important. */
.landing-demo midi-visualizer svg { max-height: none; }
.landing-demo midi-visualizer .waterfall-notes-container {
  height: auto !important;
  padding-top: 0 !important;
  overflow: visible !important;
}

.landing-links {
  max-width: 720px;
  margin: 0 auto;
  text-align: left;
  font-size: 17px;
  line-height: 1.6;
  color: #c7cbd6;
}
.landing-links p { margin: 0 0 12px; }

/* Source-code link: a quiet footer note. It shares the 720px column with the
   links above, but stays dimmer — it's an aside, not a place to send someone
   who came here to learn the rhythm. */
.landing-source {
  max-width: 720px;
  margin: 36px auto 0;
  text-align: left;
  font-size: 15px;
  color: #6b7183;
}
/* No color here on purpose: these inherit the global link colors so they get
   the visited state too. Underline (rather than a border) follows the text
   color automatically, including once visited. */
.landing-links a {
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 1px;
}

/* ---- conclusion page ---- */
.next-steps {
  max-width: 720px;
  margin: 0;
  padding-left: 22px;
  font-size: 15px;
  line-height: 1.7;
  color: #9aa0b0;
}
.next-steps li { margin-bottom: 14px; }
.next-steps li::marker { color: #57d977; }
.next-steps strong { color: #e6e8ee; }
