/**
 * Qouran — live recitation checker. Mobile-first.
 *
 * ARABIC RENDERING RULES — these are load-bearing, not taste. They survived a
 * full redesign unchanged and must survive the next one:
 *   - ONE <span> per word, display:inline. NEVER block/flex/inline-block on a
 *     word: it cuts the Arabic text run at the span boundary, which breaks
 *     contextual shaping and re-anchors diacritics to the wrong glyph.
 *   - dir + unicode-bidi on the CONTAINER only.
 *   - no letter-spacing (kills joins), line-height 2.1 (harakat + madd marks
 *     need vertical room), box-decoration-break:clone so a background that
 *     wraps across lines is drawn on both fragments.
 *   - underlines via text-decoration (never border-bottom — a border needs a
 *     box, and wanting a box is how people end up at inline-block).
 *
 * Verdict colours are copied verbatim from
 * /Users/zonnet/Qouran/src/constants/word-colors.ts (dark column) and
 * READ_TRAIL_COLOR from the reading screen. Do not invent new ones here.
 *
 * THE PALETTE IS WARM, AND THAT IS A DECISION.
 * A mushaf is ink on paper, and the ink is oak-gall brown-black, not the
 * blue-black of a code editor. Every neutral here carries a brown undertone so
 * the four verdict colours — which are fixed by contract and cannot be tuned —
 * read as ink on a page rather than as syntax highlighting. The one bright
 * chrome colour, gold, is the colour of the illumination around an ayah
 * rosette, and it is spent on exactly two things: the ayah marks and the
 * listening light. Nothing else in the chrome is allowed to be bright.
 */

@font-face {
  font-family: 'Amiri Quran';
  /* Relative to THIS file: public/styles.css -> public/fonts/... */
  src: url('fonts/AmiriQuran_400Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  /* block, not swap: a flash of Geeza Pro followed by a reflow of the whole
     mushaf reads as a bug. Better to show nothing for a beat. */
  font-display: block;
}

/* Tajawal — the project's established UI face (src/constants/fonts.ts).
   NEVER used for ayah text: it has no Uthmani tashkeel/rasm support. */
@font-face {
  font-family: 'Tajawal';
  src: url('fonts/Tajawal-400.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Tajawal';
  src: url('fonts/Tajawal-500.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Tajawal';
  src: url('fonts/Tajawal-700.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  /* ground */
  --bg: #12100c;          /* oak-gall ink pooled thick */
  --bg-raised: #1b1813;
  --bg-sunken: #0c0a08;
  --line: #2b2620;
  --line-soft: #201c17;

  /* ink */
  --text: #e7e2d8;        /* WORD_COLORS.pending.dark, warmed to the page */
  --text-dim: #a39a8c;
  --text-faint: #786f63;

  /* verdict colours — word-colors.ts, dark column. FIXED BY CONTRACT. */
  --w-pending: #e7e2d8;
  --w-correct: #7cd992;
  --w-wrong: #ff8a80;
  --w-missing: #9aa0aa;
  --w-tashkeel: #ffca6b;

  /* READ_TRAIL_COLOR.dark — the per-word "we think you're here" wash.
     NEVER a verdict. Cool on purpose: it is the one colour on the page that
     cannot be confused with green/amber/red/grey. */
  --trail: #8fb3d6;

  /* illumination gold — ayah rosettes and the listening light. Nothing else. */
  --gold: #d9a441;

  --ok: #7cd992;
  --warn: #ffca6b;
  --bad: #ff8a80;

  --radius: 14px;
  --radius-sm: 9px;

  /* Live microphone level, 0..1, written by js/main.js at frame rate.
     Declared here so the page has a sane value before the first audio frame. */
  --voice: 0;

  /* Sized off BOTH axes: the mushaf pane is short once the identity bar, the
     voice bar and the sheet have taken their cut, and text that overflows
     vertically is worse than text that is a point smaller. */
  --mushaf-size: clamp(1.55rem, min(7.2vw, 4.4vh), 2.9rem);

  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Tajawal', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  /* Positioning context for the mistakes sheet, which floats above the mushaf
     rather than compressing it. */
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Recitation is a two-handed, held-phone activity. Nothing here should
     select, callout or zoom under a stray touch. */
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

/* ------------------------------------------------- the listening light --- */
/*
 * THE SIGNATURE. A warm luminance behind the whole page whose size and opacity
 * track the live microphone level. It answers the voice in ~20 ms; a verdict
 * takes 400 ms or more. That gap is the entire reason this exists: without it
 * the page feels dead for the length of a word, and "dead" reads as "broken".
 *
 * It is BACKGROUND light, never letterform colour, and it is anchored to the
 * bottom of the viewport (where the microphone button is) rather than to the
 * reading position — so it can never be read as pointing at a word. The
 * verdicts own the ink; this owns the paper.
 */
.listening-light {
  position: fixed;
  left: 50%;
  bottom: 0;
  width: min(150vw, 900px);
  aspect-ratio: 1;
  translate: -50% 42%;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(
    circle at center,
    rgba(217, 164, 65, 0.30) 0%,
    rgba(217, 164, 65, 0.11) 34%,
    rgba(217, 164, 65, 0) 68%
  );
  /* Scale and opacity are driven by --voice. The 0.55 floor keeps a faint
     ember while the mic is open but silent, so "listening" and "off" are
     visually distinct states. */
  scale: calc(0.55 + var(--voice) * 0.75);
  opacity: 0;
  transition: opacity 420ms ease;
  will-change: scale, opacity;
}
body.is-listening .listening-light {
  opacity: calc(0.35 + var(--voice) * 0.65);
  /* No transition on opacity while live: the whole point is that it tracks the
     voice instantly. The transition above only covers the fade in/out of the
     listening state itself. */
  transition: none;
}

/* --------------------------------------------------------- identity bar --- */

.identity {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(10px + var(--safe-t)) 16px 10px;
  background: linear-gradient(to bottom, var(--bg) 55%, rgba(18, 16, 12, 0));
  min-height: 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.01em;
  color: var(--text);
  flex: 0 0 auto;
}

/*
 * The mark is a single gold hairline ring — the geometry of an ayah rosette
 * reduced to its outline. It is the only ornament on the page.
 */
.brand-mark {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1.5px solid var(--gold);
  position: relative;
}
.brand-mark::after {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--gold);
  opacity: 0.55;
}

.field { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.field-label {
  font-size: 12px;
  color: var(--text-faint);
  flex: 0 0 auto;
}
.spacer { flex: 1 1 auto; }

#surah-picker {
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  min-height: 36px;
  max-width: 42vw;
  text-overflow: ellipsis;
}
#surah-picker:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-faint);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
  white-space: nowrap;
}
.chip .led {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-faint);
  flex: 0 0 auto;
}
.chip[data-status='live'] { color: var(--ok); border-color: #2d5138; }
.chip[data-status='live'] .led { background: var(--ok); }
.chip[data-status='connecting'],
.chip[data-status='reconnecting'] { color: var(--warn); border-color: #5b4626; }
.chip[data-status='connecting'] .led { background: var(--warn); animation: pulse 1s ease-in-out infinite; }
.chip[data-status='reconnecting'] .led { background: var(--warn); animation: pulse 0.6s ease-in-out infinite; }
.chip[data-status='offline'] { color: var(--bad); border-color: #5e2b27; }
.chip[data-status='offline'] .led { background: var(--bad); }
.chip[data-status='demo'] { color: var(--gold); border-color: #5a4520; }
.chip[data-status='demo'] .led { background: var(--gold); }

/* On the narrowest phones the chip text is the first thing to go — the LED
   alone still carries the state, and the surah name matters more. */
@media (max-width: 360px) {
  .chip span { display: none; }
  .chip { padding: 7px; }
  .field-label { display: none; }
}

/* ---------------------------------------------------------------- banner -- */

.banner {
  position: relative;
  z-index: 2;
  display: none;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 500;
  padding: 9px 16px;
  background: #3a2f18;
  color: var(--warn);
  border-block: 1px solid #4d3d1e;
}
.banner.is-visible { display: flex; }
.banner[data-tone='bad'] { background: #40201d; color: var(--bad); border-block-color: #5e2b27; }

/* ----------------------------------------------------------------- stage -- */

.stage {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.mushaf-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  /* Bottom padding clears the sheet's collapsed handle, which floats over this
     scroller — without it the last line of the surah is unreachable. */
  padding: 18px clamp(16px, 5vw, 80px) 56px;
}

.mushaf {
  /* Container-level bidi ONLY. Never on a word span.
     NOT `plaintext`: plaintext ignores the element's own direction and infers
     it from the first strong character per bidi-paragraph, which laid the ayah
     sequence out left-to-right (ayah 1 ended up at the LEFT edge). We know the
     direction — state it, and isolate the run from the LTR page around it. */
  direction: rtl;
  unicode-bidi: isolate;
  font-family: 'Amiri Quran', serif;
  font-size: var(--mushaf-size);
  line-height: 2.1;
  letter-spacing: normal; /* explicit: any letter-spacing breaks Arabic joins */
  text-align: start;
  color: var(--w-pending);
  max-width: 1100px;
  margin: 0 auto;
}

.ayah {
  /* INLINE, so the surah flows as one continuous mushaf paragraph instead of
     one short line per ayah. (An ayah wrapper is allowed to be a box; a WORD
     span is not — that is the rule that protects shaping.) */
  display: inline;
}

.w {
  display: inline; /* NON-NEGOTIABLE */
  color: var(--w-pending);
  border-radius: 6px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  text-underline-offset: 0.34em;
  text-decoration-thickness: 0.055em;
  transition: color 140ms ease, background-color 140ms ease,
              text-decoration-color 140ms ease, opacity 140ms ease;
}

/* Tier 2: committedIndex < i <= predictIndex. A neutral wash — this band is
   "we think you are reading here", and it MUST NOT assert a verdict. */
.w.is-wash {
  /* Text-colour-neutral on purpose. No box-shadow — inline backgrounds already
     cover the full ascent/descent of a 2.1 line-height, and a spread turns
     each word into a hard-edged chip. */
  color: var(--w-pending);
  background-color: rgba(143, 179, 214, 0.13);
}

/* Tier 1: i <= committedIndex. Real verdicts only. */
.w.v-correct { color: var(--w-correct); }
.w.v-wrong {
  color: var(--w-wrong);
  text-decoration: underline dotted var(--w-wrong);
}
.w.v-tashkeel {
  color: var(--w-tashkeel);
  text-decoration: underline dotted var(--w-tashkeel);
}
.w.v-missing {
  color: var(--w-missing);
  opacity: 0.68;
  text-decoration: underline dashed var(--w-missing);
}

/* NO-REWIND. Any backwards pointer move gets this class for exactly one
   frame: the move happens instantly, never as a visible glide. A backwards
   glide reads as the app being wrong, and that is not recoverable on stage. */
.w.snap,
.mushaf.snap .w {
  transition: none !important;
}

.ayah-mark {
  font-family: 'Amiri Quran', serif;
  color: var(--gold);
  opacity: 0.62;
  padding: 0 0.15em;
}

/*
 * ayah 0 — the basmala PREFIX (surah 112 and every surah but al-Fatiha and
 * at-Tawbah). Hidden: it opens the surah, it is not part of it, and showing it
 * made every surah look like it began with بسم الله.
 *
 * Hidden, NOT removed from the DOM. mushaf.js keys `spans[flatIndex]` off these
 * elements and the server still sends, scores-as-exempt and can highlight them,
 * so deleting the nodes would punch holes in that array. `display:none` keeps
 * every index intact and makes this a one-line decision to reverse.
 *
 * al-Fatiha is NOT affected: there the basmala is genuinely ayah 1 (Kufi count,
 * the Madani mushaf), so it arrives as `ayah: 1` and renders like any ayah.
 */
.basmala-line {
  display: none;
}

/* ------------------------------------------------------------ voice bar -- */

.voicebar {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 16px calc(14px + var(--safe-b));
  background: linear-gradient(to top, var(--bg-sunken) 60%, rgba(12, 10, 8, 0.82));
  border-top: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.progress { display: flex; flex-direction: column; gap: 7px; }

.accuracy-track {
  height: 3px;
  border-radius: 999px;
  background: var(--line-soft);
  overflow: hidden;
}
.accuracy-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--text-faint);
  transition: width 260ms ease, background-color 260ms ease;
}
.accuracy-fill[data-grade='good'] { background: var(--ok); }
.accuracy-fill[data-grade='mid'] { background: var(--warn); }
.accuracy-fill[data-grade='poor'] { background: var(--bad); }

.progress-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
}
.accuracy-figure {
  font-weight: 700;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
  flex: 0 0 auto;
}
.accuracy-figure[data-grade='good'] { color: var(--ok); }
.accuracy-figure[data-grade='mid'] { color: var(--warn); }
.accuracy-figure[data-grade='poor'] { color: var(--bad); }
.accuracy-sub {
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

/*
 * The primary action. Full-width and 56px tall because it is pressed with a
 * thumb, on a phone, by someone who is about to start reciting and should not
 * have to look at it.
 */
.record {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  max-width: 460px;
  min-height: 56px;
  padding: 0 22px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  color: #17130c;
  background: var(--gold);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background-color 160ms ease, transform 120ms ease, opacity 160ms ease;
}
.record:active { transform: scale(0.985); }
.record:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
.record:disabled { opacity: 0.42; cursor: not-allowed; transform: none; }
.record .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #17130c;
  flex: 0 0 auto;
}
.record.is-recording {
  background: var(--bad);
  color: #2a0f0d;
}
.record.is-recording .dot {
  background: #2a0f0d;
  animation: pulse 1.1s ease-in-out infinite;
}

.mic-label {
  font-size: 12px;
  color: var(--text-faint);
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mic-label strong { color: var(--text-dim); font-weight: 500; }
.mic-label.is-warn { color: var(--warn); }
.mic-label.is-warn strong { color: var(--warn); }

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 16px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 11.5px;
  color: var(--text-faint);
}
.legend li { display: inline-flex; align-items: center; }
.legend i {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 2px;
  margin-inline-end: 5px;
}

/* -------------------------------------------------------------- mistakes -- */

/*
 * A bottom sheet that OVERLAYS the mushaf instead of compressing it.
 *
 * The first build made it a flex sibling, and on a 390px phone the result was
 * unusable: an open sheet plus the voice bar plus the banner left the mushaf
 * about 90px tall — one clipped line, showing the harakat with the letterforms
 * cut off below, which read as a broken font rather than a squeezed box.
 *
 * The mushaf is the hero and its height is not negotiable. So the sheet is
 * pulled out of flow and floats above it, anchored to the top of the voice bar
 * so that opening it never moves the mic button either.
 */
.sheet {
  position: absolute;
  z-index: 3;
  inset-inline: 0;
  bottom: var(--voicebar-h, 132px);
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-raised);
  border-top: 1px solid var(--line);
  box-shadow: 0 -18px 40px rgba(8, 6, 4, 0.55);
}

/* With nothing in it the sheet is a labelled empty bar sitting between the
   mushaf and the mic button, which is worse than absent: it occupies the one
   band of screen the reciter's eye crosses most and reports nothing. It exists
   from the first mistake onward and not before. */
.sheet.is-empty { display: none; }

.sheet-head {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  background: none;
  border: none;
  cursor: pointer;
  text-align: start;
}
.sheet-head:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
.sheet-grip {
  width: 26px;
  height: 3px;
  border-radius: 999px;
  background: var(--line);
  flex: 0 0 auto;
}
.sheet-title { flex: 0 0 auto; }
.sheet-count {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-dim);
}

#sheet-body {
  display: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  /* Capped so that even fully open, several lines of mushaf stay visible
     behind it — the reciter must never lose sight of where they are. */
  max-height: min(28vh, 260px);
  padding: 0 16px 14px;
}
.sheet.is-open #sheet-body { display: block; }

.sheet-empty {
  font-size: 14px;
  color: var(--text-faint);
  padding: 4px 0 2px;
}

.group { margin-bottom: 12px; }
.group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.group[data-kind='missing'] .group-head { color: var(--w-missing); }
.group[data-kind='wrong'] .group-head { color: var(--w-wrong); }
.group[data-kind='tashkeel'] .group-head { color: var(--w-tashkeel); }
.group[data-kind='debug'] .group-head { color: var(--gold); }

/*
 * MOBILE ROW SHAPE. Two competing constraints:
 *   - the whole purpose of a mistake row is comparing two vocalised words at a
 *     size where the harakat are legible, so the Arabic cannot shrink much;
 *   - the sheet floats over the mushaf, so every pixel a row wastes is a line
 *     of Quran the reciter cannot see.
 * The first attempt stacked the cells full-width and cost ~250px per row —
 * two mistakes filled the sheet. These are single words, so they sit side by
 * side instead, with the ayah reference riding along the top line. One row is
 * now ~86px and four fit where one and a half did.
 */
.row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-template-areas:
    'loc  loc   loc'
    'exp  arrow rec';
  align-items: center;
  column-gap: 10px;
  padding: 7px 0 9px;
  border-top: 1px solid var(--line-soft);
}
.row-loc {
  grid-area: loc;
  font-size: 11.5px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.row-arrow {
  grid-area: arrow;
  color: var(--text-faint);
  font-size: 14px;
  line-height: 1;
}

.cell-expected {
  grid-area: exp;
  /* Harakat are illegible at body size — the expected Arabic is deliberately
     rendered LARGE here, that is the whole point of the row. */
  unicode-bidi: plaintext;
  font-family: 'Amiri Quran', serif;
  font-size: 24px;
  line-height: 1.75;
  color: var(--text);
}
.cell-recited {
  grid-area: rec;
  /* The phoneme string AS THE MODEL EMITTED IT. Converting phonemes back to
     Arabic script is exactly the lossy auto-correction this model was chosen
     to avoid, so it is never done here. */
  unicode-bidi: plaintext;
  font-family: 'Amiri Quran', serif;
  font-size: 21px;
  line-height: 1.75;
  color: var(--text-dim);
  word-break: break-word;
}
.cell-recited.is-absent {
  font-family: inherit;
  font-size: 13px;
  color: var(--text-faint);
  font-style: italic;
}
.row-note {
  grid-area: loc;
  justify-self: end;
  font-size: 11.5px;
  color: var(--text-faint);
}

.debug-dump {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--text-dim);
  white-space: pre-wrap;
  word-break: break-all;
}

/* ------------------------------------------------------------------ misc -- */

.hidden { display: none !important; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.32; }
}

/* --------------------------------------------------------------- larger -- */

@media (min-width: 720px) {
  :root { --mushaf-size: clamp(1.9rem, min(3.4vw, 5vh), 3.1rem); }

  .identity { padding: 14px 26px; gap: 16px; }
  .brand { font-size: 16px; }
  #surah-picker { max-width: none; font-size: 14px; }

  .mushaf-scroll { padding: 30px clamp(26px, 6vw, 90px) 50px; }

  .voicebar {
    flex-direction: row;
    align-items: center;
    gap: 26px;
    padding: 16px 26px;
  }
  .voicebar .progress { flex: 1 1 auto; order: 2; }
  .voicebar .controls { order: 1; flex: 0 0 auto; flex-direction: row; gap: 14px; }
  .voicebar .legend { order: 3; flex: 0 0 auto; justify-content: flex-start; }
  .record { width: auto; min-width: 190px; }
  .mic-label { text-align: start; }

  #sheet-body { padding: 0 26px 18px; max-height: 30vh; }
  .sheet-head { padding: 10px 26px; }

  /* The four-column comparison grid earns its keep once there is width for it:
     the ayah reference moves onto the same line as the words. */
  .row {
    grid-template-columns: 62px minmax(120px, 0.42fr) 28px minmax(220px, 1fr);
    grid-template-areas: 'loc exp arrow rec';
    gap: 14px;
  }
  .row-arrow { text-align: center; }
  .row-note { grid-area: auto; grid-column: 2 / -1; justify-self: start; }
  .cell-expected { font-size: 29px; line-height: 1.9; }
  .cell-recited { font-size: 25px; line-height: 1.9; }
}

/* ------------------------------------------------------------ a11y prefs -- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  /* The listening light stops breathing but stays as a static presence: it is
     a state indicator ("the mic is open"), not decoration, so removing it
     entirely would remove information. */
  body.is-listening .listening-light { opacity: 0.4; scale: 1; }
}
