/* ===========================================================================
   PRACTICE — metronome, pulse display, session clock.
   Loaded after cipher.css, whose tokens it uses.

   Same terminal language as the rest: dark ground, one green accent, mono
   figures. The tempo and the clock are the two things a musician reads from
   across a room, so they are the only large type here.
   =========================================================================== */

/* --------------------------------------------------------------- layout */

.pr-main {
  display: grid;
  grid-template-columns: minmax(0, 15rem) minmax(0, 1fr);
  gap: 0 clamp(20px, 4vw, 48px);
  align-items: start;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line-hair);
}

/* ---------------------------------------------------------------- tempo */

.bpm-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.bpm-value {
  width: 5.2ch;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  color: var(--green);
  font-family: var(--f-mono);
  font-size: clamp(42px, 7vw, 62px);
  font-weight: 500;
  line-height: 1;
  text-align: center;
  padding: 0 0 4px;
  letter-spacing: -.02em;
  -moz-appearance: textfield;
}
.bpm-value::-webkit-outer-spin-button,
.bpm-value::-webkit-inner-spin-button { appearance: none; margin: 0; }
.bpm-value:focus { outline: none; border-bottom-color: var(--green); }

.bpm-step {
  background: none;
  border: 1px solid var(--line-soft);
  color: var(--fg-2);
  font-family: var(--f-mono);
  font-size: 18px;
  line-height: 1;
  width: 38px;
  height: 38px;
  cursor: pointer;
  flex: none;
  transition: color .12s var(--ease), border-color .12s var(--ease);
}
.bpm-step:hover { color: var(--green); border-color: var(--green-2); }
.bpm-step:active { background: rgba(86, 217, 138, .12); }

.bpm-unit {
  margin: 4px 0 12px;
  font-size: 10.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--fg-3);
}

/* --------------------------------------------------------- subdivisions */

.sub-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }

.sub-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 62px;
  min-height: 48px;
  padding: 6px 12px;
  background: none;
  border: 1px solid var(--line-soft);
  color: var(--fg-2);
  cursor: pointer;
  transition: color .12s var(--ease), border-color .12s var(--ease);
}
.sub-btn:hover { color: var(--fg); border-color: var(--line); }
/* Selected carries a border and a filled glyph, not colour alone. */
.sub-btn[aria-pressed="true"] {
  color: var(--green);
  border-color: var(--green-2);
  background: rgba(86, 217, 138, .07);
}
.sub-glyph { font-size: 19px; line-height: 1.1; }
.sub-word {
  font-family: var(--f-sans);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--fg-3);
}
.sub-btn[aria-pressed="true"] .sub-word { color: var(--green-2); }

/* ---------------------------------------------------------- pulse view */

.pulse-view {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  padding: 12px 0 4px;
  border-top: 1px solid var(--line-hair);
}

/* Pulses are separated by a real gap, so the beat grouping is visible even
   before the metronome starts — 6/8 must look like 2 + 3, not 6 in a row. */
.pulse-group {
  display: flex;
  gap: 4px;
  padding-right: 10px;
  border-right: 1px solid var(--line-hair);
}
.pulse-group:last-child { border-right: 0; padding-right: 0; }

.pstep {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 26px;
  padding: 4px 2px 3px;
  border-bottom: 2px solid transparent;
}
.pstep-dot { font-size: 13px; line-height: 1; color: var(--fg-3); }
.pstep-label {
  font-size: 9.5px;
  letter-spacing: .06em;
  color: var(--fg-3);
}

.pstep.lvl-0 .pstep-dot { color: var(--line); }
.pstep.lvl-1 .pstep-dot { color: var(--fg-2); }
.pstep.lvl-2 .pstep-dot { color: var(--green-2); }
.pstep.lvl-3 .pstep-dot { color: var(--green); }
.pstep.lvl-2 .pstep-label,
.pstep.lvl-3 .pstep-label { color: var(--fg-2); }

/* The moving highlight: a rule under the step plus a brightened glyph, so it
   is legible without relying on the colour change alone. */
.pstep.is-now { border-bottom-color: var(--green); }
.pstep.is-now .pstep-dot { color: var(--accent-hot); transform: scale(1.25); }
.pstep.is-now .pstep-label { color: var(--fg); }
.pstep-dot { transition: transform .06s linear, color .06s linear; }

/* --------------------------------------------------------------- pattern */

.custom-pattern { display: flex; gap: 6px; margin: 6px 0 18px; }
.cstep {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 46px;
  min-height: 46px;
  padding: 7px 4px;
  background: none;
  border: 1px solid var(--line-soft);
  cursor: pointer;
}
.cstep:hover { border-color: var(--line); }
.cstep.lvl-0 .pstep-dot { color: var(--line); }
.cstep.lvl-1 .pstep-dot { color: var(--fg-2); }
.cstep.lvl-2 .pstep-dot { color: var(--green); }
.cstep.lvl-2 { border-color: var(--green-2); }

/* ------------------------------------------------------------- controls */

.pr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0 clamp(12px, 2vw, 22px);
  padding-top: 16px;
}
.pr-check { align-self: end; margin-bottom: 14px; }

/* Meter is the one setting left out beside the pulse, so it takes the width of
   a setting rather than the width of the page. */
.pr-grid.pr-grid-tight { grid-template-columns: minmax(120px, 12rem); padding-top: 0; }

.quick-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding-bottom: 16px; }
.quick-row .field-label { margin: 0; }
.quick-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.act-small { font-size: 9.5px; padding: 6px 11px; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 2px; background: var(--line-soft);
}
input[type="range"]::-moz-range-track { height: 2px; background: var(--line-soft); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px; height: 12px;
  margin-top: -5px;
  background: var(--green);
  border: 0;
}
input[type="range"]::-moz-range-thumb {
  width: 12px; height: 12px; background: var(--green); border: 0; border-radius: 0;
}

/* ------------------------------------------------------------ transport */

.pr-transport {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 12px clamp(16px, 3vw, 36px);
  padding: 16px 0;
  border-top: 1px solid var(--line-hair);
  border-bottom: 1px solid var(--line-hair);
}

.clock {
  font-family: var(--f-mono);
  font-size: clamp(34px, 5.5vw, 50px);
  font-weight: 500;
  line-height: 1;
  letter-spacing: .02em;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}
.clock.is-running { color: var(--green); }
.clock.is-low { color: var(--amber); }

.clock-meta {
  font-size: 10px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--fg-3);
  flex: 1;
}

.act-big { font-size: 11px; padding: 11px 22px; }

.keys { margin-top: 14px; color: var(--fg-3); font-size: 11px; }
.keys kbd {
  font-family: var(--f-mono);
  font-size: 10px;
  border: 1px solid var(--line-soft);
  padding: 1px 5px;
  margin: 0 1px;
  color: var(--fg-2);
}

/* --------------------------------------------------------------- presets */

.preset-list { border-top: 1px solid var(--line-hair); }
.preset-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line-hair);
}
.preset-load {
  flex: 1;
  min-width: 0;
  text-align: left;
  background: none;
  border: 0;
  color: var(--fg);
  cursor: pointer;
  padding: 0;
}
.preset-load b {
  font-family: var(--f-sans);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
}
.preset-load:hover b { color: var(--green); }
.preset-meta { display: block; font-size: 10.5px; color: var(--fg-3); margin-top: 2px; }

/* ------------------------------------------------ running flag in header */

.metro-flag {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px solid var(--green-2);
  color: var(--green);
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: .08em;
  padding: 2px 8px;
  cursor: pointer;
}
.metro-flag[hidden] { display: none; }
.metro-flag:hover { background: rgba(86, 217, 138, .1); }
.metro-dot { font-size: 8px; animation: metro-blink 1s steps(2, end) infinite; }

@keyframes metro-blink { 50% { opacity: .25; } }

/* ------------------------------------------------------------ responsive */

@media (max-width: 900px) {
  .pr-main { grid-template-columns: 1fr; gap: 18px; }

  /* Thumb-sized controls: this gets used standing up, holding a phone. A
     metronome is set with a thumb mid-piece, so every control here clears the
     44px target, not just the transport. */
  .bpm-step { width: 52px; height: 52px; font-size: 22px; }
  .sub-btn { min-width: 74px; min-height: 56px; flex: 1; }
  .cstep { min-width: 56px; min-height: 56px; }
  .act-big { padding: 15px 22px; font-size: 12px; }

  /* Sizes the shared rule cannot know about. */
  #practice .act-small { padding: 0 16px; }
  #practice #tap { min-width: 72px; }
  #practice .quick-btns { gap: 8px; }
  input[type="range"]::-webkit-slider-thumb { width: 20px; height: 20px; margin-top: -9px; }
  input[type="range"]::-moz-range-thumb { width: 20px; height: 20px; }

  .pr-transport { flex-direction: column; align-items: stretch; }
  .clock-meta { flex: none; }
  .pstep { min-width: 30px; }
  .keys { display: none; }
}

/* -------------------------------------------------------- reduced motion */

@media (prefers-reduced-motion: reduce) {
  .metro-dot { animation: none; }
  .pstep.is-now .pstep-dot { transform: none; }
  .pstep-dot { transition: none; }
}

/* Full-bleed only where there is genuinely no room beside it. */
@media (max-width: 620px) {
  .act-big { width: 100%; }
  .pr-grid.pr-grid-tight { grid-template-columns: 1fr; }
}
