/* ==========================================================================
   Edge to Path: Listen to the essay
   Loaded only on essay pages that have a recording, after design.css.
   The button sits in the intro on slate; once started it becomes the player,
   and a slim bar keeps the controls at hand while the reader scrolls on.
   Colours and type come from tokens.css. No storage, no tracking.
   ========================================================================== */

.listen { margin-top:2rem; }
.listen :focus-visible { outline:2px solid var(--bone); outline-offset:3px; }

/* ---------- the start button ---------- */
.listen-start {
  display:inline-flex; align-items:center; gap:.95rem; min-height:44px;
  padding:0; background:none; border:0; cursor:pointer; color:var(--bone); text-align:left;
  touch-action:manipulation;
}
.listen-start[hidden] { display:none; }
.listen-ring {
  flex:none; width:2.9rem; height:2.9rem; border-radius:50%;
  display:inline-flex; align-items:center; justify-content:center;
  border:1px solid rgba(242,237,228,.45); transition:border-color .2s ease, background .2s ease;
}
.listen-start:hover .listen-ring { border-color:var(--bone); background:rgba(242,237,228,.06); }
.listen-ring svg { width:.95rem; height:.95rem; margin-left:.12rem; fill:currentColor; }
.listen-label {
  font-family:var(--sans); font-weight:600; font-size:.76rem;
  letter-spacing:.18em; text-transform:uppercase;
}
.listen-length {
  font-family:var(--mono); font-size:.72rem; letter-spacing:.08em; text-transform:uppercase;
  color:var(--muted-dark); font-variant-numeric:tabular-nums;
}

/* ---------- the player ---------- */
.listen-player {
  display:flex; flex-wrap:wrap; align-items:center; gap:.5rem .9rem;
  max-width:41rem; padding:.9rem 0; color:var(--bone);
  border-top:1px solid var(--hairline-dark); border-bottom:1px solid var(--hairline-dark);
}
.listen-player[hidden] { display:none; }
.lp-btn {
  flex:none; display:inline-flex; align-items:center; justify-content:center;
  min-width:44px; height:44px; padding:0 .3rem; background:none; border:0; color:var(--bone);
  cursor:pointer; touch-action:manipulation; font-family:var(--mono); font-size:.72rem; letter-spacing:.04em;
}
.lp-play { width:2.9rem; height:2.9rem; border-radius:50%; border:1px solid rgba(242,237,228,.45); }
.lp-play:hover { border-color:var(--bone); background:rgba(242,237,228,.06); }
.lp-play svg { width:.95rem; height:.95rem; fill:currentColor; }
.lp-play .i-play { margin-left:.12rem; }
.lp-play .i-pause, .lp-play.is-playing .i-play { display:none; }
.lp-play.is-playing .i-pause { display:block; }
.lp-play[aria-busy="true"] { border-style:dashed; }
.lp-back svg { width:1.35rem; height:1.35rem; fill:none; stroke:currentColor; stroke-width:1.4; }
.lp-back .n { margin-left:.15rem; }
.lp-back:hover, .lp-speed:hover, .ld-close:hover { color:var(--bone); text-decoration:underline; text-underline-offset:.25em; }
.lp-speed { min-width:3.2rem; color:var(--voice, var(--bone)); }

.lp-track { position:relative; flex:1 1 9rem; min-width:9rem; height:44px; display:flex; align-items:center; }
.lp-ticks { position:absolute; left:0; right:0; top:50%; height:0; pointer-events:none; }
.lp-ticks i {
  position:absolute; top:-5px; width:1px; height:10px; background:rgba(242,237,228,.42);
  transform:translateX(-50%);
}
.lp-seek {
  --p:0%;
  -webkit-appearance:none; appearance:none; width:100%; height:44px; margin:0;
  background:transparent; cursor:pointer; touch-action:pan-y;
}
.lp-seek::-webkit-slider-runnable-track {
  height:2px; border-radius:1px;
  background:linear-gradient(to right, var(--ember) 0 var(--p), rgba(242,237,228,.22) var(--p) 100%);
}
.lp-seek::-moz-range-track { height:2px; border-radius:1px; background:rgba(242,237,228,.22); }
.lp-seek::-moz-range-progress { height:2px; border-radius:1px; background:var(--ember); }
.lp-seek::-webkit-slider-thumb {
  -webkit-appearance:none; appearance:none; width:14px; height:14px; margin-top:-6px;
  border-radius:50%; background:var(--bone); border:0;
}
.lp-seek::-moz-range-thumb { width:14px; height:14px; border-radius:50%; background:var(--bone); border:0; }
.lp-seek:focus-visible { outline:none; }
.lp-seek:focus-visible::-webkit-slider-thumb { box-shadow:0 0 0 3px var(--slate), 0 0 0 5px var(--bone); }
.lp-seek:focus-visible::-moz-range-thumb { box-shadow:0 0 0 3px var(--slate), 0 0 0 5px var(--bone); }

.lp-time {
  flex:none; font-family:var(--mono); font-size:.72rem; letter-spacing:.06em;
  color:var(--muted-dark); font-variant-numeric:tabular-nums; white-space:nowrap;
}
.lp-time .now { color:var(--bone); }
.lp-note {
  flex:1 0 100%; font-family:var(--serif); font-style:italic; font-size:.95rem; line-height:1.5;
  color:var(--muted-dark);
}
.lp-note[hidden] { display:none; }

/* on phones the track takes its own row under the buttons */
@media (max-width:520px) {
  .lp-track { order:5; flex-basis:100%; }
  .lp-time { margin-left:auto; }
}
@media (max-width:400px) {
  /* the label keeps one line; the length moves under it */
  .listen-start { display:grid; grid-template-columns:auto auto; justify-content:start; column-gap:.95rem; row-gap:.2rem; }
  .listen-ring { grid-row:span 2; }
  .listen-label, .listen-length { white-space:nowrap; }
  .listen-player { column-gap:.5rem; }
  .lp-speed { min-width:44px; }
  .lp-time { letter-spacing:.02em; }
}

/* ---------- the bar that follows the reader ---------- */
.listen-dock {
  position:fixed; left:0; right:0; bottom:0; z-index:18;
  background:var(--slate); color:var(--bone);
  border-top:1px solid var(--hairline-dark);
  padding:.35rem max(clamp(1rem,4vw,2.6rem), env(safe-area-inset-right)) calc(.35rem + env(safe-area-inset-bottom)) max(clamp(1rem,4vw,2.6rem), env(safe-area-inset-left));
  transform:translateY(110%); transition:transform .3s ease; visibility:hidden;
}
.listen-dock.shown { transform:none; visibility:visible; }
.listen-dock .ld-row { max-width:72rem; margin:0 auto; display:flex; align-items:center; gap:.4rem .9rem; }
.listen-dock .ld-line { position:absolute; left:0; top:-1px; height:2px; width:0; background:var(--ember); }
.listen-dock .lp-play { width:2.6rem; height:2.6rem; }
.ld-title {
  flex:1 1 auto; min-width:0; overflow:hidden; white-space:nowrap; text-overflow:ellipsis;
  font-family:var(--serif); font-style:italic; font-size:.98rem; color:var(--voice, var(--bone));
}
.ld-close { font-family:var(--mono); font-size:1.1rem; color:var(--muted-dark); }
html.listen-docked footer { padding-bottom:calc(6rem + env(safe-area-inset-bottom)); }
@media (max-width:520px) { .listen-dock .lp-back { display:none; } }

@media (prefers-reduced-motion:reduce) {
  .listen-dock, .listen-ring, .lp-play { transition:none; }
}
