/* The practice page (/practice/). The page hero, pill tabs, practice card and option buttons come from page.css, the
   keyboard and its buttons from keyboard.css. */

:root {
  /* a right answer: the one colour the rest of the site doesn't use */
  --good: #2e7a4c;
  --good-ink: #1f5c37;
  --good-light: #dcefe3;
  /* the right key, spelled another way */
  --near: #7a5200;
  --near-light: #fbefd5;
}

@media screen {
  :root[data-theme="dark"] {
    --good: #3f9a63;
    --good-ink: #8fd4a8;
    --good-light: rgba(63, 154, 99, 0.22);
    --near: #e0b45c;
    --near-light: rgba(224, 180, 92, 0.18);
  }
}

/* Base (phones) */

/* every part of the card can be hidden, whatever its display */
.pr-card [hidden] {
  display: none !important;
}

/* what to practise: four cards, each saying what it asks */
.pr-drills {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.pr-drills button {
  display: grid;
  align-content: start;
  justify-items: start;
  gap: 3px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.2s var(--ease), border-color 0.2s var(--ease), transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
}

.pr-drills strong {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.pr-drills span {
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--muted);
}

@media (hover: hover) {
  .pr-drills button:hover {
    border-color: var(--line-strong);
    box-shadow: var(--shadow-lift);
    transform: translateY(-2px);
  }

  .pr-drills button[aria-pressed="true"]:hover {
    border-color: var(--strong);
    transform: none;
  }
}

/* the drill chosen: lacquered ebony, like the piano's case (on a dark page, the light one stands out instead) */
.pr-drills button[aria-pressed="true"] {
  border-color: var(--ebony);
  background: linear-gradient(180deg, var(--case-top) 0%, var(--case-mid) 60%);
  color: #fff;
}

@media screen {
  :root[data-theme="dark"] .pr-drills button[aria-pressed="true"] {
    border-color: var(--strong);
    background: var(--strong);
    color: var(--on-strong);
  }

  :root[data-theme="dark"] .pr-drills button[aria-pressed="true"] span {
    color: rgba(28, 25, 23, 0.68);
  }
}

.pr-drills button[aria-pressed="true"] span {
  color: rgba(255, 255, 255, 0.72);
}

/* a short line saying what a choice does */
.pr-hint {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--muted);
}

/* what to answer with, and the options under it. The column may shrink below the summary's one long line. */
.pr-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.pr-mode {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

.pr-mode .seg {
  display: flex;
}

/* a choice that can't be made right now (Sound and Both, with the page's sound off) */
.pr-mode .seg button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pr-mode .seg button {
  flex: 1;
  padding: 0 4px;
  font-size: 0.8rem;
}

/* the two ways to answer, side by side */
.pr-mode [data-setting="answer"] {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px;
}

/* under Playing: your own piano, heard through the microphone, as well as the keys here */
.pr-sub-option {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  margin-top: 2px;
}

.pr-sub-option[hidden] {
  display: none;
}

.pr-mode .pr-sub-option .seg {
  display: inline-flex;
}

.pr-mode .pr-sub-option .seg button {
  flex: none;
  padding: 0 14px;
}

.pr-options summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  cursor: pointer;
  list-style: none;
}

.pr-options summary::-webkit-details-marker {
  display: none;
}

.pr-options summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 8px;
}

.pr-options-label {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 0.84rem;
  font-weight: 700;
}

.pr-options-label::after {
  content: "";
  width: 7px;
  height: 7px;
  margin-top: -3px;
  border-right: 1.6px solid currentColor;
  border-bottom: 1.6px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.2s ease;
}

.pr-options[open] .pr-options-label::after {
  margin-top: 3px;
  transform: rotate(-135deg);
}

.pr-summary {
  min-width: 0;
  overflow: hidden;
  font-size: 0.82rem;
  color: var(--muted);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.pr-option-grid {
  display: grid;
  gap: 18px;
  padding: 18px 0 6px;
}

.pr-option {
  display: grid;
  align-content: start; /* a taller neighbour (one with a hint under it) doesn't stretch the buttons */
  gap: 8px;
  justify-items: start;
  min-width: 0;
}

.pr-option .seg {
  max-width: 100%;
}

/* several choices at once */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chips button {
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.chips button[aria-pressed="true"] {
  background: var(--strong);
  border-color: var(--strong);
  color: var(--on-strong);
}

/* the question */
.pr-question {
  margin-bottom: 16px;
}

/* what to do, and at the other end how the session is going */
.pr-ask-row {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 16px;
  margin-bottom: 8px;
}

.pr-ask {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-ink);
}

/* the question, and beside it the hand to play it with */
.pr-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
}

.practice-card .pr-title {
  margin: 0;
  font-size: clamp(2.1rem, 9vw, 3.2rem);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.035em;
}

.pr-sub {
  margin: 8px 0 0;
  color: var(--muted);
}

/* the question in sheet music (practice-staff.js): as wide as its notes, or the card. On a dark screen it sits on
   its own sheet of paper (.score, page.css). */
.pr-staff {
  width: fit-content;
  max-width: 100%;
  margin-top: 14px;
}

.pr-staff[hidden],
.pr-staff-note[hidden] {
  display: none;
}

.pr-staff svg {
  max-width: 100%;
  margin: 0;
}

.pr-staff-note {
  margin-top: 10px;
}

/* the session: "4 of 6 right" in a small pill, opening to the details */
.pr-score {
  margin-left: auto; /* on its own line on a phone, still at the right */
}

.pr-score[hidden] {
  display: none;
}

.pr-score summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  list-style: none;
  cursor: pointer;
}

.pr-score summary::-webkit-details-marker {
  display: none;
}

.pr-score summary::after {
  content: "";
  width: 6px;
  height: 6px;
  margin-top: -3px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.2s var(--ease);
}

.pr-score[open] summary::after {
  margin-top: 3px;
  transform: rotate(225deg);
}

.pr-score-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 5;
  width: min(320px, 100%);
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-lift);
}

.pr-score-panel h3 {
  margin: 0 0 10px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.pr-score-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 16px;
  margin: 0 0 12px;
  font-size: 0.88rem;
}

.pr-score-grid dd {
  margin: 0;
  font-weight: 700;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.pr-score-missed {
  margin: 0 0 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 0.86rem;
  line-height: 1.45;
}

.pr-score-missed[hidden] {
  display: none;
}

/* "Left hand" in ebony, "Right hand" in felt red, so the two are told apart at a glance; the mark is a small L or R */
.pr-hand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px 0 5px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 700;
  white-space: nowrap;
}

.pr-hand[hidden] {
  display: none;
}

.pr-hand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 0.78rem;
}

.pr-hand.is-lh {
  background: var(--strong);
  color: var(--on-strong);
}

.pr-hand.is-lh .pr-hand-mark {
  background: var(--on-strong);
  color: var(--strong);
}

.pr-hand.is-lh .pr-hand-mark::before {
  content: "L";
}

.pr-hand.is-rh {
  background: var(--accent-light);
  color: var(--accent-ink);
}

.pr-hand.is-rh .pr-hand-mark {
  background: var(--accent);
  color: #fff;
}

.pr-hand.is-rh .pr-hand-mark::before {
  content: "R";
}

/* the answer so far: one box per note or chord */
.pr-slots {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
}

.pr-slot {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 32px; /* eight fit across a phone */
  height: 44px;
  padding: 0 5px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
}

/* a note or chord typed but not yet checked */
.pr-slot.is-typed {
  border-style: solid;
  border-color: var(--line-strong);
}

.pr-slot.has-label {
  min-width: 56px;
  height: 54px;
}

.pr-slot-label {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.66rem;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.pr-slot.is-right,
.pr-slot.is-shown,
.pr-slot.is-wrong,
.pr-slot.is-spelling {
  border-style: solid;
  border-color: transparent;
}

.pr-slot.is-right {
  background: var(--good-light);
  color: var(--good-ink);
}

.pr-slot.is-right .pr-slot-label {
  color: var(--good-ink);
}

.pr-slot.is-shown {
  background: var(--bg-alt);
  border-color: var(--line);
}

.pr-slot.is-wrong {
  background: var(--accent-light);
  color: var(--accent-ink);
  text-decoration: line-through;
}

.pr-slot.is-spelling {
  background: var(--near-light);
  color: var(--near);
}

/* "Name it": four answers */
.pr-choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.pr-choice {
  position: relative;
  display: grid;
  align-content: start;
  justify-items: start;
  gap: 2px;
  padding: 12px 12px 12px 40px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.pr-choice strong {
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.pr-choice span {
  font-size: 0.78rem;
  color: var(--muted);
}

.pr-choice kbd {
  position: absolute;
  top: 14px;
  left: 12px;
  padding: 0 5px;
  border: 1px solid var(--line);
  border-radius: 5px;
  font: inherit;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
}

.pr-choice:hover:not(:disabled) {
  background: var(--bg-alt);
}

.pr-choice:disabled {
  cursor: default;
}

.pr-choice.is-right {
  border-color: var(--good);
  background: var(--good-light);
}

.pr-choice.is-wrong {
  border-color: var(--accent);
  background: var(--accent-light);
}

/* typing */
.pr-type {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.pr-input-text {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
}

.pr-input-text:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.pr-input-text:disabled {
  background: var(--bg-alt);
}

.pr-type .kb-btn {
  height: 44px;
}

/* what happened in bold ("Right first time!"), then the answer in plain type */
.pr-feedback {
  min-height: 1.5em;
  margin: 0 0 14px;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.5;
  color: var(--muted);
}

.pr-feedback strong {
  font-weight: 700;
}

.pr-feedback-detail {
  font-weight: 400;
  color: var(--text);
}

.pr-feedback.is-good {
  color: var(--good-ink);
}

.pr-feedback.is-bad {
  color: var(--accent-ink);
}

.pr-feedback.is-info {
  color: var(--text);
}

/* the keys: right ones turn green, wrong ones red with a cross (picked and shown keys are styled in keyboard.css) */
.pkey.white.is-right {
  background: #c6e5d1; /* a little stronger than --good-light, to show on a white key */
  color: #1f5c37;
}

.pkey.black.is-right {
  background: var(--good);
  color: #fff;
}

.pkey.white.is-wrong,
.pkey.black.is-wrong {
  background: var(--accent);
  color: #fff;
  animation: pr-shake 0.3s ease;
}

@keyframes pr-shake {
  25% { translate: -2px 0; }
  75% { translate: 2px 0; }
}

@media (prefers-reduced-motion: reduce) {
  .pkey.is-wrong {
    animation: none !important;
  }
}

/* the main button for the next step, and small links beside it */
.pr-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
  margin-bottom: 18px;
}

.pr-actions .kb-btn {
  height: 42px;
  padding: 0 20px;
}

/* the next step is the page's one felt button */
.pr-actions .kb-btn.is-primary {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: 0 1px 2px rgba(150, 38, 34, 0.25), 0 6px 14px -6px rgba(150, 38, 34, 0.5);
}

.pr-actions .kb-btn.is-primary:hover:not(:disabled) {
  background: var(--accent-deep);
  opacity: 1;
}

/* as tall as the button beside them, to tap */
.pr-actions .pr-link {
  min-height: 40px;
  font-size: 0.88rem;
}

/* the page's own sound, on or off, at the end of the row (a struck-through speaker when off) */
.pr-sound {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  margin-left: auto;
  padding: 0 14px 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.2s var(--ease), border-color 0.2s var(--ease), color 0.2s var(--ease);
}

.pr-sound svg {
  width: 17px;
  height: 17px;
}

.pr-sound .sound-off,
.pr-sound[aria-pressed="false"] .sound-on {
  display: none;
}

.pr-sound[aria-pressed="false"] .sound-off {
  display: block;
}

.pr-sound[aria-pressed="false"] {
  background: var(--bg-alt);
  color: var(--muted);
}

@media (hover: hover) {
  .pr-sound:hover {
    border-color: var(--line-strong);
  }
}

.pr-actions .pr-link:disabled {
  opacity: 0.4;
}

/* MIDI */
.pr-midi {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.pr-status {
  font-size: 0.84rem;
  color: var(--muted);
}

.pr-status:empty {
  display: none;
}

.pr-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-ink);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* Listening: the page asks for the microphone first, then shows that it is listening */
.pr-listen {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-alt);
}

.pr-mic-ask {
  display: grid;
  gap: 10px;
  justify-items: start;
}

.pr-mic-ask h3 {
  margin: 0;
  font-size: 1.02rem;
  letter-spacing: -0.01em;
}

.pr-mic-ask p {
  max-width: 62ch;
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--muted);
}

.pr-mic-ask .pr-mic-error {
  color: var(--accent-ink);
  font-weight: 600;
}

.pr-mic-error:empty {
  display: none;
}

.pr-mic-on {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
}

/* the red light of a recording device: the microphone is on */
.pr-mic-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  animation: pr-pulse 1.6s ease-in-out infinite;
}

@keyframes pr-pulse {
  50% { opacity: 0.35; }
}

@media (prefers-reduced-motion: reduce) {
  .pr-mic-dot {
    animation: none;
  }
}

.pr-meter {
  width: 120px;
  height: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}

.pr-meter span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--good);
  transition: width 0.08s linear;
}

.pr-note {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--muted);
}

/* Tablet */
@media (min-width: 768px) {
  .pr-mode {
    align-items: flex-start;
  }

  .pr-mode .seg button {
    flex: none;
    padding: 0 14px;
    font-size: 0.84rem;
  }

  .pr-mode [data-setting="answer"] {
    display: inline-flex;
    gap: 0;
  }

  .pr-listen {
    padding: 18px 20px;
  }

  .pr-option-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px 28px;
  }

  .pr-slots {
    gap: 6px;
  }

  .pr-slot {
    min-width: 46px;
    padding: 0 10px;
  }

  .pr-option-wide {
    grid-column: 1 / -1;
  }

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

/* Desktop */
@media (min-width: 1024px) {
  /* as wide as the keyboard (880px) plus the card's padding, like the keyboard page */
  .pr-card,
  .pr-drills {
    max-width: 952px;
  }

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

  .pr-option-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
