/* Ear training: only what differs from ../metronome/style.css, loaded before this file. Same colours as rhythm practice. */
:root[data-theme="light"] { --bg: #eee5ee; --field-border: #d3c2d3; --btn-hover: #f6eef6; }
.app { overflow-y: auto; }   /* very short screens scroll */
.modes, .choices { width: min(100%, 560px); }
/* the answer panels: only the shown one takes room, so the block is as tall as its answers (switching exercise may
   move the transport) */
.choices .dlg-panel.off { display: none; }
/* short windows (the page scrolls, .app above): the answers stay pinned at the bottom, just above the home page's
   footer, and what is above them scrolls under them (no fill: transparent between the buttons) */
.choices { position: sticky; bottom: 0; z-index: 1; }
.question { width: min(100%, 560px); text-align: center; }
.question p { margin: 0; color: var(--muted); }
.question .hint { margin: 0 auto 12px; max-width: 34ch; font-size: .95rem; line-height: 1.35; color: var(--muted); }   /* what to do, per tab */
.question .timer { margin: 4px 0 0; font-size: 1.1rem; font-variant-numeric: tabular-nums; color: var(--text); }   /* time of the current question */
.question .score .avg-time { margin-left: 1.2em; }   /* right of the score */
.question .score { margin-top: 8px; font-size: .85rem; font-variant-numeric: tabular-nums; }
/* the answer LED: off, or lit by data-state="right" (green) / "wrong" (red). The colour is a layer over the unlit disk,
   so that it can dim off: it lights at once and fades when the state is removed. */
/* the question fills the stage's height and the LED takes what is left of it, 72–132 px (its height, flexed; the
   width follows) */
.question { align-self: stretch; display: flex; flex-direction: column; justify-content: center; }
.question .led { position: relative; flex: 0 1 132px; min-height: 72px; width: auto; aspect-ratio: 1; margin: 0 auto; border-radius: 50%; background: #5a5a5a; box-shadow: inset 0 3px 8px #0006; }   /* 1.5 × (56px, 12dvh, 88px) */
.question .led::before, .question .led::after { content: ""; position: absolute; inset: 0; border-radius: 50%; opacity: 0; transition: opacity .8s ease-out; }
.question .led::before { background: radial-gradient(circle at 35% 30%, #b9ffbf, #2fcf45 45%, #168a28); box-shadow: 0 0 20px #2fcf45aa; }
.question .led::after { background: radial-gradient(circle at 35% 30%, #ffc1bb, #f0392b 45%, #a31b12); box-shadow: 0 0 20px #f0392baa; }
.question .led[data-state="right"]::before, .question .led[data-state="wrong"]::after { opacity: 1; transition: none; }
.stage { min-height: 150px; }

/* Settings: on tall screens as they were (the wrapper takes no box). Short screens (720 px or less: the home page's
   iframe on a phone): those of Tonal grades collapsed into one line with their values (#settingsSum, as tall as a
   select), shown under it when tapped (data-open); those of the other exercises (Intervals and Chords: Play style
   toggle, Difficulty; Maqam: Root note, Speed, System) stay as they are, without the line; score and timer on one
   line. */
.settings { display: contents; }
.settings-sum { display: none; }
@media (max-height: 720px) {
  .settings:not([data-open]) > #scaleRow { display: none; }
  .app:has(#scaleRow[hidden]) .settings-sum { display: none; }
  .app:has(.settings[data-open]) :is(.stage, .transport, .choices) { display: none; }   /* settings shown: only they, under the tabs */
  .settings-sum {
    display: flex; align-items: center; gap: 8px; flex-shrink: 0;
    width: min(100%, 560px); height: 44px; padding: 0 12px; border-radius: 10px;
    border: 1px solid var(--field-border); background: var(--field); color: var(--text);
    font: 600 .95rem system-ui, sans-serif; text-align: left; cursor: pointer;
  }
  .settings-sum span { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .settings-sum svg { flex: none; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform 150ms; }
  .settings-sum[aria-expanded="true"] svg { transform: rotate(180deg); }
  .settings-sum:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
  .question .readout { display: flex; justify-content: center; align-items: baseline; gap: 1.2em; margin-top: 8px; }
  .question .readout .score, .question .readout .timer { margin: 0; }
}
@media (prefers-reduced-motion: reduce) { .settings-sum svg { transition: none; } }

/* The LED: one disk; on short screens a row of 5 identical ones, which all light together (they follow the row's
   data-state). The row takes the stage's spare height (at least 36 px) and is a size container: each disk is as big
   as fits both its height and the width (the 5 and their gaps, inside 16 px margins), at most 132 px. */
.question .led > i { display: none; }
@media (max-height: 720px) {
  .question .led {
    flex: 1 1 0; min-height: 36px; width: 100%; margin: 0; padding: 0 16px; aspect-ratio: auto; container-type: size;
    display: flex; align-items: center; justify-content: center; gap: 10px;
    background: none; box-shadow: none; border-radius: 0;
  }
  .question .led::before, .question .led::after { display: none; }
  .question .led > i { display: block; position: relative; flex: none; width: min(100cqh, (100cqw - 40px) / 5, 132px); aspect-ratio: 1; border-radius: 50%; background: #5a5a5a; box-shadow: inset 0 2px 5px #0006; }
  .question .led > i::before, .question .led > i::after { content: ""; position: absolute; inset: 0; border-radius: 50%; opacity: 0; transition: opacity .8s ease-out; }
  .question .led > i::before { background: radial-gradient(circle at 35% 30%, #b9ffbf, #2fcf45 45%, #168a28); box-shadow: 0 0 12px #2fcf45aa; }
  .question .led > i::after { background: radial-gradient(circle at 35% 30%, #ffc1bb, #f0392b 45%, #a31b12); box-shadow: 0 0 12px #f0392baa; }
  .question .led[data-state="right"] > i::before, .question .led[data-state="wrong"] > i::after { opacity: 1; transition: none; }
}
.answers { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.answers .btn { height: 44px; padding: 0 4px; }
.answers.intervals .btn { font-family: Georgia, "Times New Roman", serif; }   /* roman numerals, as in the player */
/* Intervals: one .kind per numeral (minor + major, Vb + V), fused into one segmented control.
   Rows: II III / IV Vb-V VIII / VI VII, so the inversions II-VII and III-VI face each other.
   The DOM stays in semitone order (app.js maps button i to i+1 semitones); dense flow lifts VIII into row 2. */
.answers.intervals { grid-auto-flow: row dense; column-gap: 10px; row-gap: 10px; }
.answers.intervals .kind { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 2px; grid-column: span 2; }
.answers.intervals .kind:has(> :only-child) { grid-column: span 1; }
.answers.intervals .kind > .btn:not(:first-child) { border-top-left-radius: 3px; border-bottom-left-radius: 3px; }
.answers.intervals .kind > .btn:not(:last-child) { border-top-right-radius: 3px; border-bottom-right-radius: 3px; }
/* Maqam: one .kind per group of similar maqams (app.js MAQAMS), fused into one segmented control as the intervals;
   the groups wrap, each as wide as its number of buttons (--n) */
.answers.maqams { display: flex; flex-wrap: wrap; gap: 10px; }
.answers.maqams .kind { display: flex; gap: 2px; flex: var(--n) 1 calc(var(--n) * 4.5rem); min-width: 0; }
.answers.maqams .kind > .btn { flex: 1 1 0; min-width: 0; }
.answers.maqams .kind > .btn:not(:first-child) { border-top-left-radius: 3px; border-bottom-left-radius: 3px; }
.answers.maqams .kind > .btn:not(:last-child) { border-top-right-radius: 3px; border-bottom-right-radius: 3px; }
.scale-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; width: min(100%, 560px); }
.scale-row[hidden] { display: none; }
/* small screens: Tonic and Base scale on one line, Mode (the longest names) on the next, full width, with its label
   on its left (saves a line) */
@media (max-width: 600px) {
  #scaleRow { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #scaleRow .field:last-child { grid-column: 1 / -1; flex-direction: row; }
  #scaleRow .field:last-child select { flex: 1 1 0; min-width: 0; }
}
.scale-row select { width: 100%; height: 44px; padding: 0 6px; border-radius: 10px; border: 1px solid var(--field-border); background: var(--field); color: var(--text); font: 600 .95rem system-ui, sans-serif; }
.scale-row select:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
#drone[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg); }
/* microphone level under the score, -60..0 dB (--lvl, set by app.js): shown while the mic is on, its place kept when off.
   The colours are fixed along the bar (green, amber near the top, red at the end) and the level reveals them. */
/* Intonation bar (see showTune in app.js), as the tap meter of ../rhythm/style.css: the note to guess as a viewfinder
   centre in the middle (32 px ring, overflows the bar), the heard pitch as a ball at --x (-1..1 of the half width).
   Zones from the thresholds (app.js sets them as % of the whole width): green in tune (--right), yellow still that note
   (--late), red beyond. Shown while the mic is on, its place kept when off (as the level bar). */
.tune-meter {
  position: relative; width: min(80%, 320px); height: 14px; margin: 16px auto 0; border-radius: 7px; border: 1px solid var(--field-border);
  visibility: hidden;
  --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);
}
.tune-meter.on { visibility: visible; }
.tune-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; }
.tune-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; }
.tune-meter .ball[hidden] { display: none; }
.mic-level { width: min(60%, 200px); height: 6px; margin: 10px auto 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 heard as a sound (MIC_RMS_GATE, --gate set by app.js): a tick across the bar, the bar red under it */
.mic-level { position: relative; }
.mic-level::after { content: ""; position: absolute; top: 0; bottom: 0; left: var(--gate, 33%); width: 2px; margin-left: -1px; background: var(--text); opacity: .7; }
.mic-level.low span { background: #d63527; }
.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); }
/* Replay: round and as big as Play, with the play symbol, but neutral so that Play stays the main button */
.play.replay { background: var(--field); color: var(--text); border: 1px solid var(--field-border); box-shadow: none; }
.play.replay:hover { background: var(--btn-hover); }
/* microphone toggle, left of Play: an icon button, inverted when on like Drone */
.transport .btn.mic { width: 44px; height: 44px; padding: 0; display: grid; place-items: center; }
.btn.mic svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
#mic[aria-pressed="true"], #droneCut[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg); }
.transport #droneCut { width: 77px; }   /* wider than the mic button (44 px): room for the long arrow */
#droneCut svg { width: 100%; height: 22px; }   /* viewBox 82 × 24 for the 75 × 22 px inside of the button, the scale of the mic icon; the arrow 80% of it */
#droneCut[aria-pressed="true"] .cut-off, #droneCut:not([aria-pressed="true"]) .cut-on { display: none; }   /* off: the plain arrow; on: with the filter */
#droneCut { align-content: center; gap: 1px; }   /* the icon, and "filter" in small type below it */
#droneCut .cut-label { font-size: .6rem; line-height: 1; font-weight: 600; }
#droneCut .cut-label::after { content: " OFF"; }   /* the state after "filter", the same in every language */
#droneCut[aria-pressed="true"] .cut-label::after { content: " ON"; }
#drone[hidden], #mic[hidden], #droneCut[hidden] { display: none; }   /* Tonal grades only */
/* Play while a question is on: red (the shared pressed style) with a trash icon, to clear the score */
.play .icon-trash { display: none; width: 50%; height: 50%; justify-self: center; align-self: center; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.play[aria-pressed="true"] .icon-trash { display: block; }
.play .icon-restart { width: 52%; height: 52%; justify-self: center; align-self: center; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.answers .btn.sounding { background: var(--ink-amber); border-color: var(--ink-amber); color: var(--bg); }   /* the tonic, while it sounds */
/* Chords: one row per family (minor, dominant, major and others), each fused into one segmented control as the
   interval numerals; chord symbols in the numerals' serif */
/* Chords: rows (built by app.js per difficulty level), one fixed gap between all buttons; the buttons of a row share
   its width. Its groups (.kind) are only for the layout table, not visible. */
.answers.chords { display: flex; flex-direction: column; gap: 8px; }
.answers.chords .row { display: flex; gap: 8px; }
.answers.chords .kind { display: contents; }
.answers.chords .btn { flex: 1 1 0; min-width: 0; font-family: Georgia, "Times New Roman", serif; }
/* Hard: each group fused into one segmented control (2 px inside, 10 px between groups and rows), as wide as its
   buttons (--n, set by app.js), so that the buttons of a row are of equal width */
.answers.chords[data-level="hard"], .answers.chords[data-level="hard"] .row { gap: 10px; }
.answers.chords[data-level="hard"] .kind { display: flex; gap: 2px; flex: var(--n, 1) 1 0; min-width: 0; }
.answers.chords[data-level="hard"] .kind > .btn:not(:first-child) { border-top-left-radius: 3px; border-bottom-left-radius: 3px; }
.answers.chords[data-level="hard"] .kind > .btn:not(:last-child) { border-top-right-radius: 3px; border-bottom-right-radius: 3px; }
/* Melodic / Harmonic (intervals): its own row under the tabs, as wide and tall as the selects of the other tabs */
#playing { width: 100%; }
#harmonicRow:not([data-chords]) .chords-only, #harmonicRow[data-chords] .not-chords { display: none; }   /* Melodic / Harmonic, or Arpeggio / Chord on Chords */
#harmonicRow[data-chords] { grid-template-columns: repeat(2, minmax(0, 12rem)); }   /* Chords: Play style and Difficulty side by side */
#playing label { height: 42px; }
.field-label { font-size: .85rem; font-weight: 600; color: var(--muted); }   /* like a <label>, for the radio group */
/* the buttons centred as one group (the side groups are just wrappers) */
.transport { display: flex; justify-content: center; gap: clamp(6px, 3vw, 24px); }
.transport .side { display: contents; }
.transport .btn { padding: 0 12px; }
.root-row { grid-template-columns: minmax(0, 12rem); justify-content: center; }
#rootRow { grid-template-columns: repeat(3, minmax(0, 12rem)); }   /* Maqam: Root note, Speed and System */
/* a pressed answer (grades, intervals): lit at once, then fades back to normal in .8 s like the LED (flash() in app.js).
   Green if right, red if wrong (data-state, the LED's colours darkened for white text), amber if the press did not count. */
.answers .btn.flash { --lit: var(--ink-amber); --lit-text: var(--bg); animation: answer-flash .8s ease-out; }
.answers .btn.flash[data-state="right"] { --lit: #1e9e35; --lit-text: #fff; }
.answers .btn.flash[data-state="wrong"] { --lit: #d63527; --lit-text: #fff; }
@keyframes answer-flash { from { background: var(--lit); border-color: var(--lit); color: var(--lit-text); } }
@media (prefers-reduced-motion: reduce) { .answers .btn.flash { animation-duration: .3s; animation-timing-function: steps(1, end); } }
