/* Rhythm practice: only what differs from ../metronome/style.css, loaded before this file. */
:root[data-theme="light"] { --bg: #eee5ee; --field-border: #d3c2d3; --btn-hover: #f6eef6; }

.embedded .title { display: block; }   /* its tab is too narrow for the whole name */
.head .subtitle { margin: 4px 0 0; font-size: .85rem; color: var(--muted); text-align: center; }
.head .title { text-align: center; }
.disk { cursor: default; }   /* the measure is random: the disks are a display only */

/* Two rows: the measure being played and, below it at 2/3 of its size, the upcoming one. Both fit the stage's height
   (1 + 2/3 diameters and the row gap). --n (beats) is set on each row by JS. */
.stage[data-nohandle] .measures .beats { --d: min(88px, 100cqw / (var(--n) * 1.25 - 0.25), (100cqh - 2 * var(--pad-y) - var(--row-gap)) * 0.6); }
.stage[data-nohandle] .measures .beats.next { --d: calc(2 / 3 * min(88px, 100cqw / (var(--n) * 1.25 - 0.25), (100cqh - 2 * var(--pad-y) - var(--row-gap)) * 0.6)); }

/* microphone level above the controls row, -60..0 dB (--lvl, set by app.js): shown while the mic is on, its place kept
   when off (as in ../ear/style.css; no margin: the .app gap spaces it) */
.mic-level { width: min(60%, 200px); height: 6px; margin: 0; border-radius: 3px; background: var(--field); border: 1px solid var(--field-border); overflow: hidden; visibility: hidden; }
.mic-level.on { visibility: visible; }
/* the least level detected as a hit (HIT_GATE, --gate set by app.js): a tick across the bar; under it nothing counts */
.mic-level { position: relative; }
.mic-level.low span { background: #d63527; }   /* the level under the mark (app.js): too soft to count */
.mic-level::after { content: ""; position: absolute; top: 0; bottom: 0; left: var(--gate, 50%); width: 2px; margin-left: -1px; background: var(--text); opacity: .7; }
.mic-level span { display: block; height: 100%; --lvl: 0%; background: linear-gradient(90deg, var(--play) 70%, var(--ink-amber) 88%, #d63527); clip-path: inset(0 calc(100% - var(--lvl)) 0 0); }

/* Calibrate, left of the sound type: an icon button, as the microphone's: the tap meter's aim with the ball centred in it
   (a hit right on the beat), drawn under the aim
   (with its label, icon only on small devices, as the sound type) */
.transport .calib-btn { height: 44px; padding: 0 12px; display: inline-flex; align-items: center; gap: 6px; }
@media (max-width: 600px), (max-height: 480px) {
  .transport .calib-btn { width: 44px; padding: 0; justify-content: center; }
  .calib-btn .txt { display: none; }
}
.calib-btn svg { flex: none; width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.calib-btn svg .dot { fill: #1e9e35; stroke: none; }

/* microphone toggle, left of Play: an icon button, inverted when on (as in ../ear/style.css) */
.transport .btn.mic { width: 44px; height: 44px; padding: 0; display: grid; place-items: center; }
.btn.mic svg, .pad svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
#mic[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg); }

/* tap pad, right of Play: a disk of the play button's size (same --size and small-device rule as .play in
   ../metronome/style.css), inverted for a moment when tapped */
.pad {
  --size: clamp(56px, 12dvh, 84px);
  width: var(--size); height: var(--size); padding: 0; border-radius: 50%;
  border: 1px solid var(--field-border); background: var(--field); color: var(--text);
  display: grid; place-items: center; cursor: pointer; touch-action: manipulation;
  box-shadow: 0 6px 18px var(--shadow);
}
@media (max-width: 600px), (max-height: 480px) {
  .pad { --size: max(44px, calc(clamp(56px, 12dvh, 84px) * 0.7)); }
}
.pad svg { width: 50%; height: 50%; }
.pad:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.pad.hit { background: var(--text); border-color: var(--text); color: var(--bg); }

/* Calibration dialog: the text of its input only (data-input, set by askCalib in app.js) */
#calibDialog .for-mic, #calibDialog .for-pad { display: flex; flex-direction: column; gap: 10px; }
#calibDialog[data-input="mic"] .for-pad, #calibDialog[data-input="pad"] .for-mic { display: none; }

/* "Calibration", just above the panel while the calibration measures play (out of the flow: the disks keep their size) */
.panel { position: relative; }
.calib-label { position: absolute; bottom: 100%; left: 0; right: 0; margin: 0 0 6px; text-align: center; color: var(--ink-amber); }
.calib-label b { font-weight: 600; }
.calib-label span { color: var(--muted); }
.calib-label[data-input="mic"] .for-pad { display: none; }   /* the hint of the tap only; the microphone's: just "Calibration" (startCalib) */

/* Tap meter, above the beats: a bar 50% of the window wide, the beat as a viewfinder centre in the middle (a ring with
   four ticks, 32 px: overflows the bar, within the .app gap), the last hit as a ball that fits inside the ring, at
   --x (-1..1 of the half width, set by app.js) from it. Zones, as the rings, from the thresholds (app.js sets them,
   as % of the half width from the middle): green for right (±HIT_TOL: --right), yellow for early/late (±2 HIT_TOL:
   --late), red beyond it, for a miss (farther hits, whose ball stops in it). Translucent, so the ball stands out. */
.tap-meter {
  position: relative; width: 50vw; height: 14px; border-radius: 7px; border: 1px solid var(--field-border);
  --right: 40%; --late: 80%;
  --g0: calc(50% - var(--right) / 2); --g1: calc(50% + var(--right) / 2);
  --y0: calc(50% - var(--late) / 2); --y1: calc(50% + var(--late) / 2);
  background: linear-gradient(90deg, #d6352766 var(--y0), #f2c21b66 var(--y0) var(--g0), #1e9e3566 var(--g0) var(--g1),
    #f2c21b66 var(--g1) var(--y1), #d6352766 var(--y1)), var(--field);
}
.tap-meter .aim { position: absolute; left: 50%; top: 50%; width: 32px; height: 32px; margin: -16px 0 0 -16px; fill: none; stroke: var(--text); stroke-width: 2; stroke-linecap: round; }
.tap-meter .ball { position: absolute; top: 50%; left: calc(50% + var(--x, 0) * 50%); width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: #1e9e35; box-shadow: 0 0 0 1.5px var(--bg); transition: left 80ms ease-out; }

/* Score, below the beats: the aim (green: right, yellow: almost) and a red cross (wrong), each with its count */
.score { display: flex; justify-content: center; gap: 22px; margin: 0; font: 600 1.05rem system-ui, sans-serif; font-variant-numeric: tabular-nums; }
.score span { display: inline-flex; align-items: center; gap: 6px; }
.score svg { width: 22px; height: 22px; fill: none; stroke-width: 2.5; stroke-linecap: round; }
.score .right svg { stroke: #1e9e35; }
.score .almost svg { stroke: #f2c21b; }
.score .wrong svg { stroke: #d63527; stroke-width: 3; }

/* tap meter and score: shown from the start of a game (see startGame / endGame in app.js) */
.tap-meter[hidden], .score[hidden] { display: none; }

/* Game layout (from the start of a game or a calibration to Stop, see setGameLayout in app.js), small devices only:
   the control rows hidden, the play row at the bottom (the stage takes the freed height); a tap anywhere but on the
   controls is a hit (app.js), so no double-tap zoom or text selection */
@media (max-width: 600px), (max-height: 480px) {
  .app.in-game .controls { display: none; }
  .app.in-game { touch-action: manipulation; user-select: none; -webkit-user-select: none; }
}

/* "Get Ready..." over the beats while the lead-in measure of a game is on top (see leadMeasure in app.js): white on a
   dimmed panel, the beats still visible (and lighting) under it */
.ready-label {
  position: absolute; inset: 0; z-index: 2; margin: 0; display: grid; place-items: center; pointer-events: none;
  border-radius: inherit; background: #0007; color: #fff; text-shadow: 0 2px 10px #000c;
  font: 700 clamp(1.4rem, 6vw, 2.4rem) system-ui, sans-serif;
}
.ready-label[hidden] { display: none; }

/* Judged hits (data-hit, set by app.js while the microphone listens): the ring of the beat, kept until the measure
   changes. After .disk.lit (same specificity, this file loads later), so it also colours the lit ring. */
.disk[data-hit] { outline-color: var(--hit); }
.disk[data-hit="right"] { --hit: #1e9e35; }
.disk[data-hit="early"], .disk[data-hit="late"] { --hit: #f2c21b; }
.disk[data-hit="wrong"] { --hit: #d63527; }

.up-form { width: 200px; }
.up-form .seg { gap: 0; }
.up-form .seg legend { width: 100%; text-align: center; margin-bottom: 8px; font-weight: 600; color: var(--muted); }
.up-form .seg-opts { height: 44px; }
.up-form .seg-opts label { height: 100%; }
/* small devices: Beats and Accents show their value in the label ("Beats 8"), their steppers only − and + (the
   number field hidden), so that the three controls fit in one row */
.controls label .val { display: none; }
@media (max-width: 600px), (max-height: 480px) {
  .controls label .val { display: inline; margin-left: .35em; color: var(--text); font-variant-numeric: tabular-nums; }
  #total, #active { display: none; }
}

/* small devices: a narrower toggle, "Up beats" above it as elsewhere */
@media (max-width: 600px), (max-height: 480px) {
  .up-form { width: 120px; }
  /* normal / silent: the dot only (bigger), the word kept for screen readers (it names the radio) and as tooltip */
  .up-form .seg-opts .dot { width: 14px; height: 14px; }
  .up-form .seg-opts .txt { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}

/* phones in landscape: no room for the title */
@media (max-height: 480px) and (orientation: landscape) {
  .app { gap: 8px; }
  .head { display: none; }
}
