/* ============================================================
   Listening: speed dial, chapter scrubbing, "Where you left off",
   the sleep timer's last minute, the Listening settings
   ============================================================ */

/* ---------- speed ---------- */
.pop-rate { width: 272px; padding: 6px 10px 12px; }
.rate-dial { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; align-items: center; margin: 2px 0 12px; }
.rate-now {
  text-align: center; font: 500 32px/1 var(--serif); font-variation-settings: "opsz" 48;
  letter-spacing: -0.02em; font-variant-numeric: tabular-nums lining-nums;
}
.rate-step { width: 44px; height: 44px; background: var(--bg-2); color: var(--ink); }
.rate-step:hover { background: color-mix(in oklab, var(--bg-2) 80%, var(--ink) 8%); }
.rate-step:active { transform: scale(.94); }
.rate-step svg { width: 20px; height: 20px; }
.rate-step:disabled { opacity: .35; cursor: default; }
.rate-presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; padding: 3px; border-radius: 12px; background: var(--bg-2); }
.rate-presets button {
  height: 34px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--ink-2);
  font-variant-numeric: tabular-nums; transition: background-color .2s, color .2s, box-shadow .2s;
}
.rate-presets button:hover { color: var(--ink); }
.rate-presets button[aria-checked="true"] { background: var(--surface); color: var(--crimson); box-shadow: 0 1px 3px rgba(var(--shade), .14); }
.rate-note { display: flex; align-items: center; gap: 10px; margin: 10px 4px 0; font-size: 12px; color: var(--ink-3); }
.rate-for { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rate-for i { font-family: var(--serif); color: var(--ink-2); }
.rate-keys { flex: none; display: flex; gap: 3px; }
.rate-keys kbd {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 5px;
  font: 600 11px/1 var(--ui); color: var(--ink-2); background: var(--bg-2); box-shadow: inset 0 -1px 0 var(--line);
}
@media (pointer: coarse) {
  .rate-keys { display: none; } /* no [ and ] keys on a phone */
  .pop-rate .rate-presets button { height: 42px; font-size: 14px; }
}

/* ---------- scrubbers: chapter marks, the hovered chapter, the tooltip ---------- */
/* the marks and the band stay inside the track: the thumb rides above them */
.scrub-track, .np-track { isolation: isolate; }
.scrub-band {
  position: absolute; top: 50%; height: 3px; margin-top: -10px; pointer-events: none;
  border-radius: 2px; background: var(--gold);
  opacity: 0; transform: scaleY(.4); transition: opacity .2s ease, transform .2s var(--ease-out);
}
.ch-on .scrub-band { opacity: .9; transform: none; }
.scrub-tip.ch-tip { z-index: 3; text-align: center; box-shadow: 0 8px 24px -10px rgba(var(--shade), .55); }
.scrub-tip.ch-tip span { font-family: var(--serif); font-size: 12.5px; }
/* the Now playing sheet's scrubber: the same marks, and the tooltip rides above the finger */
.np-ticks i { width: 1px; opacity: .65; }
.np-scrub .scrub-band { margin-top: -14px; }
.np-scrub .scrub-tip.np-tip { bottom: 38px; padding: 7px 12px; border-radius: 10px; font-size: 13px; max-width: min(300px, calc(100vw - 48px)); }
.np-scrub .scrub-tip.np-tip span { max-width: min(280px, calc(100vw - 72px)); font-size: 13.5px; }

/* ---------- sleep timer ---------- */
.chip.is-fading svg { animation: ls-breathe 2.6s ease-in-out infinite; }
@keyframes ls-breathe { 50% { opacity: .35; } }

.sleep-pill {
  position: fixed; z-index: 26;
  right: max(var(--gutter), env(safe-area-inset-right));
  bottom: calc(var(--player-h, 0px) + 14px);
  display: inline-flex; align-items: center; gap: 10px;
  padding: 5px 5px 5px 14px; border-radius: 999px;
  background: var(--ink); color: var(--bg);
  font-size: 13.5px; font-weight: 500; white-space: nowrap;
  max-width: calc(100vw - 24px);
  box-shadow: 0 12px 32px -10px rgba(var(--shade), .55);
  opacity: 0; transform: translateY(12px) scale(.96);
  transition: opacity .25s ease, transform var(--spring-d, 420ms) var(--spring, var(--ease-out));
}
.sleep-pill.in { opacity: 1; transform: none; }
.sleep-pill > svg { width: 16px; height: 16px; flex: none; color: var(--gold); }
.sleep-pill.is-fading > svg { animation: ls-breathe 2.6s ease-in-out infinite; }
.sp-n { font-weight: 700; font-variant-numeric: tabular-nums; }
.sleep-pill button { height: 32px; padding: 0 12px; border-radius: 999px; font-size: 13px; font-weight: 650; transition: background-color .2s, transform .15s var(--ease); }
.sleep-pill button:active { transform: scale(.96); }
.sp-more { background: var(--crimson); color: #FFF7F4; }
.sp-more:hover { background: color-mix(in oklab, var(--crimson) 88%, black); }
.sp-off { color: color-mix(in oklab, var(--bg) 78%, transparent); margin-left: -6px; }
.sp-off:hover { color: var(--bg); background: color-mix(in oklab, var(--bg) 12%, transparent); }
.sleep-pill :focus-visible { outline-color: var(--gold); }

/* ---------- where you left off ---------- */
.recap {
  position: fixed; z-index: 31; left: 50%;
  bottom: calc(var(--player-h, 0px) + 16px);
  width: min(500px, calc(100vw - 2 * max(var(--gutter), 12px)));
  padding: 14px 16px 16px 20px;
  background: var(--surface); background-image: var(--paper); color: var(--ink);
  border-radius: 18px;
  box-shadow: 0 0 0 1px color-mix(in oklab, var(--line) 80%, transparent), 0 26px 60px -20px rgba(var(--shade), .55), 0 4px 14px -6px rgba(var(--shade), .2);
  opacity: 0; transform: translate(-50%, 18px) scale(.97); transform-origin: 50% 100%;
  transition: opacity .3s ease, transform var(--spring-d, 520ms) var(--spring, var(--ease-out));
}
.recap.in { opacity: 1; transform: translate(-50%, 0); }
.recap.out { opacity: 0; transform: translate(-50%, 10px) scale(.985); transition: opacity .2s ease, transform .3s var(--ease-out); pointer-events: none; }
.recap-head { display: flex; align-items: center; gap: 8px; margin: -4px -8px 6px 0; min-height: 34px; }
.recap-kicker { font: 650 11px/1 var(--ui); letter-spacing: .1em; text-transform: uppercase; color: var(--gold); }
.recap-when { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; }
.recap-when::before { content: "·"; margin-right: 8px; color: var(--ink-3); }
.recap-x { margin-left: auto; width: 34px; height: 34px; }
.recap-x svg { width: 18px; height: 18px; }
.recap-chap { margin: 0 0 10px; font: 500 18px/1.25 var(--serif); font-variation-settings: "opsz" 36; letter-spacing: -0.01em; text-wrap: balance; }
.recap-text {
  display: flex; flex-direction: column; justify-content: flex-end; gap: .45em;
  max-height: 8.6em; overflow: hidden; /* anchored at its end: the last words heard always show */
  margin: 0 0 14px; padding: 1px 0 1px 14px;
  border-left: 2px solid color-mix(in oklab, var(--crimson) 50%, transparent);
  font: 400 15.5px/1.55 var(--read-font); color: var(--ink-2);
}
.recap-text.is-over {
  -webkit-mask-image: linear-gradient(to bottom, rgba(0, 0, 0, .2), #000 2.6em);
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, .2), #000 2.6em);
}
.recap-text p { margin: 0; flex: none; }
/* where the narration stopped */
.recap-text p:last-child::after {
  content: ""; display: inline-block; width: 7px; height: 7px; margin: 0 0 .12em 6px; border-radius: 50%;
  background: var(--crimson); box-shadow: 0 0 0 3px color-mix(in oklab, var(--crimson) 18%, transparent); vertical-align: middle;
}
.recap-text p:last-child { color: var(--ink); }
.recap-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.recap-actions .btn svg { width: 16px; height: 16px; }
.recap-dur { margin-left: 2px; font-size: 12.5px; font-weight: 500; color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* ---------- the Listening settings ---------- */
.ls-sec { display: flex; flex-direction: column; gap: 12px; }
.ls-skips { gap: 8px; }
.ls-skips .opt-row .seg button { font-variant-numeric: tabular-nums; }
.ls-clarity { gap: 8px; }
.ls-clarity.is-off .seg { opacity: .5; }
.ls-clarity.is-off .seg button { cursor: default; }
.ls-note { margin-top: 0; line-height: 1.4; }

/* ---------- phones ---------- */
@media (max-width: 720px), (pointer: coarse) and (max-height: 500px) {
  .recap {
    bottom: calc(var(--player-h, 0px) + 10px);
    width: calc(100vw - 2 * max(12px, env(safe-area-inset-left)));
    padding: 12px 14px 14px 18px; border-radius: 20px;
  }
  .recap-chap { font-size: 17px; }
  .recap-text { font-size: 15px; max-height: 7.8em; }
  .recap-actions .btn { flex: 1 1 auto; justify-content: center; height: 44px; }
  .sleep-pill { right: auto; left: 50%; translate: -50% 0; bottom: calc(var(--player-h, 0px) + 12px); }
  .sleep-pill button { height: 36px; }
}

/* the narration's "back to" button and the sleep pill share the bottom edge: stack them */
body:has(.follow:not([hidden])) .sleep-pill { bottom: calc(var(--player-h, 0px) + 68px); }

/* ---------- motion ---------- */
:root[data-motion="gentle"] .recap { transform: translate(-50%, 8px); transition: opacity .3s ease, transform .4s var(--ease-out); }
:root[data-motion="gentle"] .recap.in { transform: translate(-50%, 0); }
:root[data-motion="gentle"] .sleep-pill { transform: translateY(6px); }
:root[data-motion="gentle"] .sleep-pill.in { transform: none; }
:root[data-motion="still"] .recap, :root[data-motion="still"] .recap.out { transform: translate(-50%, 0); }
:root[data-motion="still"] .sleep-pill { transform: none; }
:root[data-motion="still"] .chip.is-fading svg, :root[data-motion="still"] .sleep-pill.is-fading > svg { animation: none; }
@media (prefers-reduced-motion: reduce) {
  .recap, .recap.out { transform: translate(-50%, 0); transition: opacity .2s ease; }
  .sleep-pill { transform: none; transition: opacity .2s ease; }
  .chip.is-fading svg, .sleep-pill.is-fading > svg { animation: none; }
}
