/* Listen row (2026-11-11, local trial): the nav's second row on post pages; it plays the post read aloud.
   Same width, same ground and same hairline as the nav, so at the top of the page the two read as one bar.
   If you never press play it scrolls away with the page and the nav stays alone. Once you press play it stays
   under the nav, like the nav, until you close it. It is in the page from the start and always 44px high, so nothing shifts.
   The scrubber is the post's own waveform as ticks, like the context meter above it (drawn into the page by scripts/make_audio.py).
   Audio: assets/listen/post-NAME.mp3. Colours are tokens only (light and dark). */
.listen {
  position: relative; z-index: 101;                     /* under the nav (102) and its open menu, over the page, the grain and the sheets */
  height: 44px; display: flex; align-items: center; gap: 16px;
  padding: 0 var(--margin);
  background: var(--paper); color: var(--ink-2);        /* the nav's ground: clean paper, no grain */
  border-bottom: 1px solid var(--rule);
  --p: 0%;                                              /* how far the audio is, set by r-listen.js */
}
.listen.is-live {
  position: sticky; top: var(--a-top, 72px);
  background: color-mix(in srgb, var(--paper) 72%, transparent);
  -webkit-backdrop-filter: blur(16px) saturate(180%); backdrop-filter: blur(16px) saturate(180%);
}
@media (prefers-reduced-transparency: reduce) { .listen.is-live { background: var(--paper); -webkit-backdrop-filter: none; backdrop-filter: none; } }

.listen button { flex: none; display: inline-grid; place-items: center; height: 44px; padding: 0; border: 0; background: none; color: var(--ink); font: inherit; letter-spacing: inherit; text-transform: inherit; cursor: pointer; }
.listen button:focus-visible, .listen__bar:focus-visible { outline: 1px solid var(--ink); outline-offset: -6px; }
.listen__play { width: 28px; margin-left: -8px; }
.listen__play svg { grid-area: 1 / 1; width: 12px; height: 12px; display: block; }
.listen__play .i-pause, .listen.is-playing .listen__play .i-play { visibility: hidden; }
.listen.is-playing .listen__play .i-pause { visibility: visible; }
.listen__name { flex: none; color: var(--ink); margin-left: -6px; }
.listen__t { flex: none; min-width: 5ch; font-variant-numeric: tabular-nums; }
.listen__t[data-cur] { text-align: right; }

/* the scrubber: the waveform as ticks, ink up to the playhead; the real control is a see-through range input on top */
.listen__track { position: relative; flex: 1 1 0; min-width: 0; height: 44px; }
.listen__wave { position: absolute; left: 0; top: 13px; width: 100%; height: 18px; display: block; overflow: visible; fill: none; stroke: var(--rule); stroke-width: 1.5px; pointer-events: none; }
.listen__wave path { vector-effect: non-scaling-stroke; }
.listen__wave.is-played { stroke: var(--ink); clip-path: inset(0 calc(100% - var(--p)) 0 0); }
.listen__wave--n, .listen__wave--m { display: none; }
.listen__bar { -webkit-appearance: none; appearance: none; position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; background: none; cursor: pointer; }
.listen__bar::-webkit-slider-runnable-track { height: 44px; background: none; }
.listen__bar::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 2px; height: 24px; margin-top: 10px; border: 0; border-radius: 0; background: var(--ink); }
.listen__bar::-moz-range-track { height: 44px; background: none; }
.listen__bar::-moz-range-thumb { width: 2px; height: 24px; border: 0; border-radius: 0; background: var(--ink); }

.listen__rate { min-width: 6ch; justify-items: end; }
.listen__close { width: 28px; margin-right: -8px; visibility: hidden; }      /* its place is kept, so nothing moves when it shows */
.listen.is-live .listen__close { visibility: visible; }
.listen__close svg { width: 10px; height: 10px; display: block; }

/* while the row is up: the reading-progress line (tablets and phones) stays on the nav's edge, over the row;
   the side tracker and the chapter jumps start below it */
:root:has(.listen) .a-bar { z-index: 102; }
@media (min-width: 1101px) { :root:has(.listen) .a-side { top: calc(var(--a-top) + 76px); } }
.listen.is-live ~ main .post__body :is(h2, .a-anchor) { scroll-margin-top: calc(var(--a-offset) + 44px); }

@media (max-width: 1100px) {
  .listen__wave--w { display: none; }
  .listen__wave--m { display: block; }
}
@media (max-width: 760px) {
  .listen { gap: 12px; }
  .listen.is-live { background: var(--paper); -webkit-backdrop-filter: none; backdrop-filter: none; }   /* solid on phones, like the nav */
  .listen__t[data-cur] { display: none; }
  .listen__t { min-width: 4ch; }
  .listen__rate { min-width: 5ch; }
  .listen__wave--m { display: none; }
  .listen__wave--n { display: block; }
}
