/* Practice Mode: reuses style.css's look (gradient background, container, .piano,
   .key, .controls, .status) and only adds what's unique to the guided lesson. */

.practice-container {
  max-width: 1000px;
}

.back-link {
  display: inline-block;
  margin-bottom: 15px;
  color: #fff;
  opacity: 0.8;
  text-decoration: none;
  font-weight: bold;
}

.back-link:hover {
  opacity: 1;
}

.start-hint {
  font-weight: bold;
  opacity: 0.9;
}

.stats-bar {
  display: flex;
  gap: 8px;
  justify-content: center;
  font-size: 14px;
  opacity: 0.85;
  margin-bottom: 10px;
}

.stats-bar strong {
  color: #ffe08a;
}

#loop-label {
  transition: color 0.15s ease, transform 0.15s ease;
  display: inline-block;
}

.loop-pulse {
  color: #4caf50;
  transform: scale(1.3);
}

.progress-panel {
  margin: 20px auto;
  max-width: 500px;
}

.progress-status {
  display: flex;
  justify-content: space-between;
  font-size: 15px;
  margin-bottom: 8px;
}

.progress-bar-track {
  height: 14px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.15);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0;
  background: #4caf50;
  transition: width 0.2s ease;
}

.progress-count {
  margin-top: 6px;
  font-size: 13px;
  opacity: 0.8;
}

/* --- Practice sequence: the guided note-by-note strip --- */

.practice-sequence-wrapper {
  width: 100%;
  overflow-x: auto;
  margin: 25px 0;
  padding: 5px 0 15px;
  scroll-behavior: smooth;
}

.practice-sequence {
  display: flex;
  gap: 10px;
  width: max-content;
  min-width: 100%;
  margin: 0 auto;
  padding: 0 24px;
  box-sizing: border-box;
}

.seq-note {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  opacity: 0.45;
  transition: opacity 0.15s ease, transform 0.15s ease, background 0.15s ease;
}

.seq-note-key {
  font-weight: bold;
  font-size: 22px;
}

.seq-note.completed {
  opacity: 0.35;
  background: rgba(76, 175, 80, 0.25);
}

.seq-note.completed::after {
  content: '✓';
  position: absolute;
  font-size: 12px;
  transform: translate(16px, -16px);
}

.seq-note.current {
  opacity: 1;
  background: #ffe08a;
  color: #333;
  transform: scale(1.15);
}

.seq-note.upcoming {
  opacity: 0.6;
}

.seq-note.wrong {
  background: #d9534f;
  opacity: 1;
}

/* --- Practice piano: note name + keyboard key always visible, no hover needed ---
   Sizes come from CSS custom properties set in practice.js (getPianoDimensions),
   so the black-key JS offsets and the rendered width/height always agree. */

.practice-piano .key.white {
  width: var(--white-w, 60px);
  height: var(--white-h, 220px);
}

.practice-piano .key.black {
  width: var(--black-w, 40px);
  height: var(--black-h, 140px);
}

.practice-piano .key {
  flex-direction: column;
  justify-content: flex-end;
  gap: 10px;
  padding-bottom: 20px;
  font-size: 20px;
}

.key-note-label {
  font-weight: bold;
}

.key-letter-label {
  font-size: 16px;
  background: #4caf50;
  color: #fff;
  border-radius: 6px;
  padding: 2px 10px;
}

.practice-piano .key.black .key-note-label {
  font-size: 13px;
}

.practice-piano .key.black .key-letter-label {
  font-size: 13px;
  padding: 1px 7px;
}

/* Current target: same note the practice sequence highlights (single source of
   truth - see sequence[currentIndex] in practice.js). Subtle ring, labels stay visible. */
.practice-piano .key.target {
  box-shadow: inset 0 0 0 4px #ffe08a;
}

.practice-piano .key.white.target {
  background: #fff8e1;
}

.practice-piano .key.target::before {
  content: 'NEXT';
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: bold;
  letter-spacing: 1px;
  color: #333;
  background: #ffe08a;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

/* Brief, non-blocking feedback for an incorrect press - never advances progress. */
.practice-piano .key.wrong {
  box-shadow: inset 0 0 0 4px #d9534f;
}

.practice-piano .key:focus-visible {
  outline: 3px solid #4caf50;
  outline-offset: 2px;
}

.practice-container .piano-wrapper {
  margin-bottom: 15px;
}

.practice-container .controls {
  margin-top: 45px;
}

@media (prefers-reduced-motion: reduce) {
  .seq-note,
  .progress-bar-fill,
  .practice-sequence-wrapper {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* Practice workstation ---------------------------------------------------- */

.practice-page {
  align-items: flex-start;
  background: linear-gradient(135deg, #211d31 0%, #3a3452 52%, #77718e 100%);
  font-family: 'Avenir Next', 'Trebuchet MS', sans-serif;
}

.practice-workspace {
  width: min(100%, 1120px);
  max-width: 1120px;
  margin: 0 auto;
  padding: 26px clamp(18px, 4vw, 54px) 38px;
  text-align: left;
}

.practice-page .back-link {
  display: inline-flex;
  margin: 0 0 19px;
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 7px;
  color: #d9d3e7;
  font-size: 13px;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.practice-page .back-link:hover,
.practice-page .back-link:focus-visible {
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
  transform: translateX(-2px);
}

.practice-header {
  margin-bottom: 21px;
}

.practice-eyebrow,
.section-label,
.target-label {
  margin: 0;
  color: #ffe08a;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.8px;
}

.practice-eyebrow {
  margin-bottom: 7px;
}

.practice-header h1 {
  margin: 0;
  color: #fff;
  font-size: clamp(32px, 4vw, 42px);
  line-height: 1.08;
  letter-spacing: -0.5px;
}

.practice-page .hint {
  max-width: 580px;
  margin: 9px 0 0;
  color: #c9c3da;
  font-size: 15px;
  line-height: 1.45;
}

.practice-status-card,
.sequence-section {
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 10px;
  background: rgba(17, 14, 30, 0.22);
}

.practice-status-card {
  padding: 0 18px;
}

.practice-page .stats-bar,
.practice-page .stats-bar:not([hidden]) {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  width: 100%;
  margin: 0;
  padding: 12px 0;
  opacity: 1;
}

.practice-page .stat-item {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 9px;
  border-right: 1px solid rgba(255, 255, 255, 0.12);
}

.practice-page .stat-item:last-child {
  border-right: 0;
}

.practice-page .stat-item span {
  color: #aaa3be;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.practice-page .stats-bar strong {
  color: #ffe08a;
  font-size: 19px;
}

.practice-page #loop-label {
  transition: color 0.15s ease, transform 0.15s ease;
}

.target-panel {
  margin: 18px 0 16px;
  padding: 17px 20px 16px;
  border: 1px solid rgba(255, 224, 138, 0.22);
  border-radius: 10px;
  background: rgba(255, 224, 138, 0.055);
  text-align: center;
}

.target-label {
  color: #c9c3da;
  font-size: 10px;
}

.practice-page .start-hint {
  margin: 10px 0 0;
  color: #ffe08a;
  font-size: 18px;
  font-weight: 700;
}

.practice-page .progress-panel {
  width: 100%;
  max-width: none;
  margin: 9px auto 0;
}

.practice-page .progress-status,
.practice-page .progress-status:not([hidden]) {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 24px;
  margin: 0;
  color: #c9c3da;
  font-size: 14px;
}

.practice-page .progress-status > span:first-child {
  color: #e7e2f1;
  font-size: 18px;
  font-weight: 700;
}

.practice-page .progress-status > span:first-child strong {
  display: inline-block;
  min-width: 48px;
  margin-left: 5px;
  color: #ffe08a;
  font-size: 40px;
  line-height: 0.9;
  text-align: center;
}

.practice-page .next-note {
  color: #aaa3be;
}

.practice-page .next-note strong {
  color: #d9d3e7;
}

.practice-page .progress-count {
  margin: 13px 0 6px;
  color: #d9d3e7;
  font-size: 12px;
  opacity: 1;
}

.practice-page .progress-bar-track {
  height: 7px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.11);
}

.practice-page .progress-bar-fill {
  background: #ffe08a;
  box-shadow: 0 0 10px rgba(255, 224, 138, 0.25);
}

.sequence-section {
  padding: 14px 0 2px;
}

.sequence-heading,
.piano-stage-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding: 0 17px;
}

.sequence-heading > span,
.piano-stage-heading > span {
  color: #aaa3be;
  font-size: 12px;
}

.practice-page .practice-sequence-wrapper {
  width: 100%;
  max-width: 100%;
  margin: 11px 0 0;
  padding: 7px 0 15px;
  scrollbar-color: rgba(255, 224, 138, 0.45) rgba(255, 255, 255, 0.08);
  scrollbar-width: thin;
}

.practice-page .practice-sequence {
  min-width: max-content;
  gap: 9px;
  padding: 0 18px;
}

.practice-page .seq-note {
  width: 46px;
  height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.075);
  transition: opacity 0.15s ease, transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.practice-page .seq-note-key {
  color: #d9d3e7;
  font-size: 19px;
}

.practice-page .seq-note.completed {
  border-color: rgba(76, 175, 80, 0.2);
  background: rgba(76, 175, 80, 0.18);
}

.practice-page .seq-note.current {
  border-color: #ffe08a;
  background: #ffe08a;
  box-shadow: 0 5px 14px rgba(255, 224, 138, 0.18);
  color: #312b40;
  transform: scale(1.12) translateY(-1px);
}

.practice-page .seq-note.current .seq-note-key {
  color: #312b40;
}

.practice-piano-stage {
  margin-top: 16px;
  padding: 14px 14px 9px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  background: rgba(17, 14, 30, 0.28);
  box-shadow: 0 18px 42px rgba(13, 9, 27, 0.2);
}

.practice-piano-stage .piano-stage-heading {
  padding: 0 3px 10px;
}

.practice-page .piano-wrapper {
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 10px 0 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  scrollbar-color: rgba(255, 224, 138, 0.45) rgba(255, 255, 255, 0.08);
  scrollbar-width: thin;
}

.practice-page .practice-piano {
  margin: 0 auto;
}

.practice-page .practice-piano .key {
  transition: transform 0.08s ease, background 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.practice-page .practice-piano .key:hover {
  filter: brightness(1.05);
}

.practice-page .practice-piano .key.white {
  border-color: #c9c8d1;
  background: linear-gradient(180deg, #fff 0%, #f0eef3 100%);
  box-shadow: inset 0 -8px 12px rgba(82, 72, 103, 0.08);
}

.practice-page .practice-piano .key.black {
  border-color: #0f0d18;
  border-radius: 0 0 6px 6px;
  background: linear-gradient(180deg, #393442 0%, #121018 80%);
  box-shadow: 0 5px 8px rgba(8, 5, 16, 0.4);
}

.practice-page .practice-piano .key-letter-label {
  border-radius: 5px;
  background: #4caf50;
  font-size: 13px;
  padding: 2px 8px;
}

.practice-page .practice-piano .key-note-label {
  font-size: 17px;
}

.practice-page .practice-piano .key.black .key-note-label {
  font-size: 12px;
}

.practice-page .practice-piano .key.target {
  border-color: #ffe08a;
  box-shadow: inset 0 0 0 4px #ffe08a, 0 0 16px rgba(255, 224, 138, 0.2);
}

.practice-page .practice-piano .key.white.target {
  background: #fff8e1;
}

.practice-page .practice-piano .key.target::before {
  top: -21px;
  color: #302a40;
  background: #ffe08a;
}

.practice-page .practice-piano .key.white.active {
  background: #ffe08a;
  box-shadow: inset 0 -7px 0 rgba(178, 132, 23, 0.22);
}

.practice-page .practice-piano .key.black.active {
  background: #80600d;
}

.practice-sound-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  margin-top: 12px;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(17, 14, 30, 0.16);
  color: #ded9ec;
  font-size: 13px;
  font-weight: 700;
}

.practice-sound-controls select {
  min-height: 34px;
  min-width: 220px;
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  background: #302a47;
  color: #fff;
  font: inherit;
  font-size: 13px;
}

.practice-sound-controls input[type='range'] {
  width: 150px;
  accent-color: #ffe08a;
}

.practice-sound-controls select:focus-visible,
.practice-sound-controls input:focus-visible {
  outline: 2px solid #ffe08a;
  outline-offset: 3px;
}

.practice-page .practice-controls {
  justify-content: center;
  margin: 16px 0 0;
  padding: 11px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(17, 14, 30, 0.16);
}

.practice-page .practice-controls button {
  min-height: 35px;
  padding: 7px 16px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.09);
  color: #e7e2f1;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.practice-page .practice-controls button:hover,
.practice-page .practice-controls button:focus-visible {
  border-color: rgba(255, 224, 138, 0.42);
  background: rgba(255, 224, 138, 0.12);
  color: #ffe08a;
  transform: translateY(-1px);
}

.practice-page .status {
  margin: 9px 2px 0;
  color: #aaa3be;
  font-size: 12px;
  text-align: left;
}

.practice-page button:focus-visible,
.practice-page a:focus-visible {
  outline: 2px solid #ffe08a;
  outline-offset: 3px;
}

@media (max-width: 700px) {
  .practice-workspace {
    width: 100%;
    padding: 20px 12px 28px;
  }

  .practice-page .back-link {
    margin-bottom: 16px;
  }

  .practice-header h1 {
    font-size: 32px;
  }

  .practice-page .hint {
    font-size: 14px;
  }

  .practice-status-card {
    padding: 0 8px;
  }

  .practice-page .stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
  }

  .practice-page .stats-bar strong {
    font-size: 17px;
  }

  .target-panel {
    padding: 14px 11px 13px;
  }

  .practice-page .progress-status > span:first-child {
    font-size: 16px;
  }

  .practice-page .progress-status > span:first-child strong {
    font-size: 36px;
  }

  .practice-page .progress-status {
    gap: 14px;
  }

  .sequence-heading > span,
  .piano-stage-heading > span {
    display: none;
  }

  .sequence-section {
    padding-top: 13px;
  }

  .practice-piano-stage {
    padding: 13px 9px 8px;
  }

  .practice-sound-controls {
    flex-wrap: wrap;
  }

  .practice-sound-controls select {
    flex: 1 1 180px;
    min-width: 0;
  }

  .practice-sound-controls input[type='range'] {
    flex: 1 1 120px;
    min-width: 100px;
  }

  .practice-page .practice-controls {
    margin-top: 13px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .practice-page .back-link,
  .practice-page .practice-controls button,
  .practice-page .practice-piano .key,
  .practice-page .seq-note {
    transition: none;
  }
}

@media (max-width: 900px) and (orientation: landscape) {
  .practice-workspace {
    padding: 14px 18px 24px;
  }

  .practice-page .back-link {
    margin-bottom: 10px;
  }

  .practice-header {
    margin-bottom: 12px;
  }

  .practice-header h1 {
    font-size: 30px;
  }

  .practice-page .hint {
    margin-top: 5px;
  }

  .practice-status-card {
    padding: 0 12px;
  }

  .practice-page .stats-bar,
  .practice-page .stats-bar:not([hidden]) {
    padding: 8px 0;
  }

  .target-panel {
    margin: 10px 0;
    padding: 10px 14px;
  }

  .practice-page .progress-panel {
    margin-top: 6px;
  }

  .practice-page .progress-count {
    margin: 8px 0 4px;
  }

  .sequence-section {
    padding-top: 9px;
  }

  .practice-page .practice-sequence-wrapper {
    margin-top: 6px;
    padding-bottom: 10px;
  }

  .practice-piano-stage {
    margin-top: 10px;
    padding: 9px 10px 6px;
  }

  .practice-piano-stage .piano-stage-heading {
    padding-bottom: 6px;
  }

  .practice-page .piano-wrapper {
    padding: 6px 0 9px;
  }

  .practice-sound-controls {
    margin-top: 8px;
    padding: 7px 10px;
  }

  .practice-page .practice-controls {
    margin-top: 8px;
    padding: 7px;
  }
}

