@font-face {
  font-family: "Noto Music Local";
  src: url("../fonts/NotoMusic-Regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: block;
}

:root {
  --practice-surface: color-mix(in srgb, var(--bs-body-bg) 92%, var(--bs-primary) 8%);
  --piano-white: #fff;
  --piano-black: #20242a;
  --staff-ink: #20242a;
}

[data-bs-theme="dark"] {
  --practice-surface: color-mix(in srgb, var(--bs-body-bg) 88%, var(--bs-info) 12%);
  --staff-ink: #e9ecef;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  background-color: var(--practice-surface);
}

.app-header {
  background-color: var(--bs-body-bg);
}

.navbar-brand {
  font-weight: 750;
  letter-spacing: 0;
}

.brand-mark {
  display: inline-grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  border-radius: 6px;
  color: var(--bs-white);
  background: var(--bs-primary);
}

.theme-picker-group {
  width: 10rem;
}

.icon-button {
  width: 2.35rem;
  height: 2.35rem;
  padding: 0;
  display: inline-grid;
  place-items: center;
}

.section-label {
  color: var(--bs-primary);
  font-size: .75rem;
  font-weight: 750;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.stats-strip {
  overflow: hidden;
  border: 1px solid var(--bs-border-color);
  border-radius: 8px;
  background: var(--bs-body-bg);
}

.stats-strip > div {
  min-width: 5.25rem;
  padding: .55rem .8rem;
  text-align: center;
}

.stats-strip > div + div {
  border-left: 1px solid var(--bs-border-color);
}

.stats-strip span,
.stats-strip small {
  display: block;
}

.progress-stats {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.progress-accuracy-cell {
  min-width: 12rem;
}

.progress-accuracy-cell .progress {
  height: .55rem;
}

.stats-strip span {
  font-size: 1.05rem;
  font-weight: 750;
  line-height: 1.1;
}

.stats-strip small {
  margin-top: .2rem;
  color: var(--bs-secondary-color);
  font-size: .68rem;
  text-transform: uppercase;
}

.practice-card {
  background-color: var(--bs-body-bg);
}

.level-picker {
  width: min(18rem, 42vw);
}

.level-status .progress {
  height: .55rem;
}

.level-settings {
  margin: 0 0 1.25rem;
}

.level-settings > div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: .65rem 0;
  border-bottom: 1px solid var(--bs-border-color);
}

.level-settings dt,
.level-settings dd {
  margin: 0;
}

.level-settings dd {
  color: var(--bs-secondary-color);
  text-transform: capitalize;
}

.midi-status {
  display: flex;
  min-height: 1.25rem;
  align-items: center;
  gap: .45rem;
  color: var(--bs-secondary-color);
  font-size: .82rem;
}

.midi-status .bi {
  font-size: .5rem;
}

.midi-status[data-state="connected"] {
  color: var(--bs-success-text-emphasis);
}

.midi-status[data-state="error"] {
  color: var(--bs-danger-text-emphasis);
}

.feedback-placeholder {
  min-height: 1.75rem;
  color: var(--bs-secondary-color);
  font-weight: 600;
  text-align: center;
}

.feedback-correct {
  color: var(--bs-success);
}

.feedback-incorrect {
  color: var(--bs-danger);
}

.note-timer {
  width: min(100%, 620px);
  height: 5px;
  margin: .5rem auto 0;
  overflow: hidden;
  border-radius: 3px;
  background: var(--bs-secondary-bg);
}

.note-timer span {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--bs-warning);
}

.staff-wrap {
  overflow-x: hidden;
}

.staff {
  position: relative;
  width: min(100%, 620px);
  min-width: 0;
  height: 220px;
  margin: 0 auto;
  color: var(--staff-ink);
}

.staff-lines {
  position: absolute;
  top: 60px;
  right: 3%;
  left: 3%;
  height: 82px;
}

.staff-lines span {
  position: absolute;
  right: 0;
  left: 0;
  height: 2px;
  background: currentColor;
}

.staff-lines span:nth-child(1) { top: 0; }
.staff-lines span:nth-child(2) { top: 20px; }
.staff-lines span:nth-child(3) { top: 40px; }
.staff-lines span:nth-child(4) { top: 60px; }
.staff-lines span:nth-child(5) { top: 80px; }

.staff-position-highlight {
  --highlight-y: 100px;
  --highlight-color: var(--bs-primary);
  position: absolute;
  z-index: 1;
  top: var(--highlight-y);
  right: 3%;
  left: 3%;
  pointer-events: none;
  transform: translateY(-50%);
}

.staff-position-highlight.is-line {
  height: 6px;
  border-radius: 3px;
  background: var(--highlight-color);
}

.staff-position-highlight.is-space {
  height: 18px;
  border-block: 1px solid var(--highlight-color);
  background: var(--highlight-color);
}

.clef {
  position: absolute;
  z-index: 2;
  top: 36px;
  left: 8%;
  font-family: "Noto Music Local";
  font-size: 7rem;
  font-weight: 400;
  line-height: 1;
}

.clef.bass-clef {
  top: 52px;
  font-size: 5.4rem;
}

.staff-note {
  --note-y: 140px;
  --note-x: 58%;
  position: absolute;
  z-index: 3;
  top: var(--note-y);
  left: var(--note-x);
  width: 24px;
  height: 16px;
  transform: translate(-50%, -50%);
}

.note-head {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: currentColor;
  transform: rotate(-18deg);
}

.note-stem {
  position: absolute;
  right: 0;
  bottom: 7px;
  width: 2px;
  height: 56px;
  background: currentColor;
}

.played-staff-note {
  --note-x: 72%;
}

.played-staff-note.is-correct {
  color: var(--bs-success);
}

.played-staff-note.is-incorrect {
  color: var(--bs-danger);
}

.note-accidental {
  position: absolute;
  top: -12px;
  left: -18px;
  font-family: Georgia, serif;
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
}

.ledger-line {
  --ledger-x: 58%;
  position: absolute;
  z-index: 2;
  left: var(--ledger-x);
  width: 42px;
  height: 2px;
  background: currentColor;
  transform: translateX(-50%);
}

#played-ledger-lines .ledger-line.is-correct {
  background: var(--bs-success);
}

#played-ledger-lines .ledger-line.is-incorrect {
  background: var(--bs-danger);
}

.keyboard-wrap {
  position: relative;
  z-index: 1;
  overflow-x: auto;
  padding-bottom: .25rem;
}

.piano-keyboard {
  --white-key-width: 44px;
  --white-note-label-size: .7rem;
  --black-note-label-size: .62rem;
  position: relative;
  display: flex;
  width: calc(var(--white-key-width) * var(--practice-white-keys, 15));
  height: 168px;
  margin: 0 auto;
  user-select: none;
}

.piano-key {
  border: 1px solid #8b929a;
  cursor: pointer;
  transition: transform .08s ease, background-color .08s ease;
}

.piano-key:focus-visible {
  z-index: 5;
  outline: 3px solid var(--bs-primary);
  outline-offset: 2px;
}

.piano-key.white {
  position: relative;
  flex: 0 0 var(--white-key-width);
  width: var(--white-key-width);
  height: 168px;
  border-radius: 0 0 5px 5px;
  color: #343a40;
  background: var(--piano-white);
}

.piano-key.black {
  position: absolute;
  z-index: 2;
  top: 0;
  width: 28px;
  height: 102px;
  border-color: #08090a;
  border-radius: 0 0 4px 4px;
  color: #f8f9fa;
  background: var(--piano-black);
  left: var(--practice-left);
  transform: translateX(-50%);
}

.piano-key:hover,
.piano-key.is-active {
  background: var(--bs-primary-bg-subtle);
  transform: translateY(2px);
}

.piano-key.black:hover,
.piano-key.black.is-active {
  background: var(--bs-primary);
}

.piano-key.is-answer {
  z-index: 4;
  box-shadow: inset 0 0 0 4px var(--bs-success);
}

.key-label {
  position: absolute;
  right: 0;
  bottom: .55rem;
  left: 0;
  font-size: var(--white-note-label-size);
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
}

.enharmonic-label {
  bottom: .45rem;
  display: grid;
  gap: .18rem;
  font-size: var(--black-note-label-size);
}

.piano-keyboard.hide-note-labels .key-label {
  display: none;
}

.key-color-guide {
  position: absolute;
  right: 20%;
  bottom: .4rem;
  left: 20%;
  display: none;
  height: .3rem;
  border-radius: 2px;
}

.piano-keyboard.show-color-guide .key-color-guide {
  display: block;
}

.piano-keyboard.show-color-guide .key-label {
  bottom: 1.05rem;
}

.piano-keyboard.show-color-guide .enharmonic-label {
  bottom: 1rem;
}

.piano-key.black .key-color-guide {
  right: 14%;
  bottom: .32rem;
  left: 14%;
}

.enharmonic-colors {
  overflow: hidden;
}

.enharmonic-colors i {
  display: block;
  float: left;
  width: 50%;
  height: 100%;
}

.note-color-legend {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: .35rem;
}

.note-color-legend span {
  display: grid;
  place-items: center;
  gap: .2rem;
  color: var(--bs-secondary-color);
  font-size: .7rem;
  font-weight: 700;
}

.note-swatch {
  display: block;
  width: .8rem;
  height: .8rem;
  border: 1px solid color-mix(in srgb, currentColor 25%, transparent);
  border-radius: 50%;
}

.note-c { background: #e63946; }
.note-d { background: #f08c2e; }
.note-e { background: #d4a017; }
.note-f { background: #2a9d5b; }
.note-g { background: #168aad; }
.note-a { background: #3f6fd8; }
.note-b { background: #9b4dcc; }

.keyboard-range-label {
  font-size: .78rem;
  font-weight: 700;
}

.staff-mnemonics {
  position: relative;
  z-index: 10;
  width: min(100%, 620px);
  margin: 1rem auto 0;
  padding-top: .8rem;
  border-top: 1px solid var(--bs-border-color);
}

.staff-mnemonics-direction {
  display: block;
  margin-bottom: .45rem;
  color: var(--bs-secondary-color);
  font-size: .68rem;
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
}

.staff-mnemonic-row {
  display: grid;
  grid-template-columns: 5rem repeat(2, minmax(0, 1fr));
  align-items: center;
  gap: .75rem;
  padding: .4rem 0;
}

.staff-mnemonic-row + .staff-mnemonic-row {
  border-top: 1px solid var(--bs-border-color);
}

.staff-mnemonic-row > span {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: .5rem;
}

.staff-mnemonic-row small {
  color: var(--bs-secondary-color);
}

.mnemonic-trigger {
  padding: 0;
  border: 0;
  border-bottom: 1px dotted currentColor;
  color: inherit;
  background: transparent;
  font-size: 1rem;
  font-weight: 700;
  line-height: inherit;
  cursor: help;
}

.mnemonic-trigger:focus-visible {
  border-radius: 2px;
  outline: 2px solid var(--bs-primary);
  outline-offset: 3px;
}

.mnemonic-control {
  position: relative;
  display: inline-block;
}

.mnemonic-context {
  position: absolute;
  z-index: 20;
  bottom: calc(100% + .6rem);
  left: 50%;
  display: grid;
  width: max-content;
  max-width: min(15rem, 70vw);
  padding: .65rem .8rem;
  gap: .2rem;
  border: 1px solid var(--bs-border-color);
  border-radius: 6px;
  color: var(--bs-body-color);
  background: var(--bs-body-bg);
  box-shadow: 0 .35rem 1rem rgba(0, 0, 0, .16);
  font-size: .85rem;
  font-weight: 400;
  line-height: 1.35;
  text-align: left;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, .25rem);
  transition: opacity .12s ease, transform .12s ease, visibility .12s;
}

.mnemonic-context::after {
  position: absolute;
  top: 100%;
  left: 50%;
  width: .65rem;
  height: .65rem;
  border-right: 1px solid var(--bs-border-color);
  border-bottom: 1px solid var(--bs-border-color);
  background: var(--bs-body-bg);
  content: "";
  transform: translate(-50%, -50%) rotate(45deg);
}

.mnemonic-control:hover .mnemonic-context,
.mnemonic-control:focus-within .mnemonic-context {
  visibility: visible;
  opacity: 1;
  transform: translate(-50%, 0);
}

.mnemonic-context > strong {
  font-size: 1rem;
}

.mnemonic-context b {
  color: var(--bs-primary);
}

.mnemonic-context > span {
  display: block;
  white-space: nowrap;
}

.offcanvas {
  --bs-offcanvas-width: min(390px, 100vw);
}

@media (max-width: 767.98px) {
  .practice-shell {
    padding-top: 1.5rem !important;
  }

  .theme-picker-group {
    width: 8.5rem;
  }

  .practice-heading-actions {
    width: 100%;
    margin-left: 0 !important;
  }

  .level-picker {
    width: 100%;
  }

  .stats-strip {
    flex: 1;
  }

  .stats-strip > div {
    flex: 1;
    min-width: 0;
  }

  .progress-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .progress-stats > div:nth-child(3) {
    border-left: 0;
    border-top: 1px solid var(--bs-border-color);
  }

  .progress-stats > div:nth-child(4) {
    border-top: 1px solid var(--bs-border-color);
  }

  .staff-mnemonic-row {
    grid-template-columns: 4rem repeat(2, minmax(0, 1fr));
    gap: .35rem;
  }

  .staff-mnemonic-row > span {
    display: grid;
    gap: 0;
    text-align: center;
  }

}

@media (max-width: 420px) {
  .navbar-brand > span:last-child {
    display: none;
  }

  .theme-picker-group {
    width: 8rem;
  }
}

@media (max-width: 739.99px) {
  .piano-keyboard {
    --white-key-width: 12.5%;
    width: min(352px, 100%);
  }

  .piano-key.mobile-octave-hidden {
    display: none;
  }

  .piano-key.black {
    left: var(--mobile-left);
    width: 8%;
  }

  .keyboard-wrap {
    overflow-x: hidden;
  }
}

@media (min-width: 740px) and (max-width: 1199.98px) {
  .piano-key.practice-range-hidden {
    display: none;
  }
}

@media (min-width: 1200px) {
  .keyboard-range-label {
    display: none;
  }

  .piano-keyboard {
    --white-key-width: calc(100% / 52);
    width: 100%;
    max-width: 1240px;
    height: clamp(112px, 9.2vw, 128px);
  }

  .piano-key.white {
    height: 100%;
  }

  .piano-key.black {
    left: var(--full-left);
    width: 1.2%;
    height: 62%;
  }
}
