/* ============================================================
   Audiobook — tasteful custom player (matches Hotel Earth palette)
   Per-chapter player (in reader) + Listen page playlist
   ============================================================ */

/* ---- shared player shell ---- */
.aplayer {
  display: flex; align-items: center; gap: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 0.7rem 0.95rem;
  box-shadow: var(--shadow-sm);
}

/* play/pause button */
.aplayer__play {
  flex: 0 0 auto;
  width: 46px; height: 46px;
  display: grid; place-items: center;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  color: #fff;
  transition: background .18s ease, transform .12s ease;
}
.aplayer__play:hover { background: var(--color-primary-hover); }
.aplayer__play:active { transform: scale(0.94); }
.aplayer__play svg { width: 20px; height: 20px; display: block; }
.aplayer__play .ico-pause { display: none; }
.aplayer.is-playing .aplayer__play .ico-play { display: none; }
.aplayer.is-playing .aplayer__play .ico-pause { display: block; }
.aplayer.is-loading .aplayer__play { opacity: .6; pointer-events: none; }

/* middle: label + scrubber */
.aplayer__body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.aplayer__meta { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); }
.aplayer__label {
  font-family: var(--font-body); font-weight: 600; font-size: var(--text-sm);
  color: var(--color-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.aplayer__label small { display: block; font-weight: 500; font-size: var(--text-xs); color: var(--color-text-faint); letter-spacing: .04em; text-transform: uppercase; }
.aplayer__time { flex: 0 0 auto; font-size: var(--text-xs); color: var(--color-text-muted); font-variant-numeric: tabular-nums; }

/* scrubber */
.aplayer__bar {
  position: relative; height: 6px; border-radius: var(--radius-full);
  background: var(--color-surface-offset); cursor: pointer; overflow: hidden;
}
.aplayer__fill {
  position: absolute; inset: 0 auto 0 0; width: 0%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-gold));
  border-radius: var(--radius-full); transition: width .08s linear;
}

/* right: speed control */
.aplayer__rate {
  flex: 0 0 auto;
  font-size: var(--text-xs); font-weight: 600; color: var(--color-text-muted);
  border: 1px solid var(--color-border); border-radius: var(--radius-full);
  padding: 0.3em 0.6em; min-width: 3.1em; text-align: center;
  transition: color .15s ease, border-color .15s ease;
}
.aplayer__rate:hover { color: var(--color-primary); border-color: var(--color-primary); }

/* ---- in-reader per-chapter player ---- */
.reader__audio {
  margin: 0 0 var(--space-6);
}
.reader__audio .aplayer__label small { color: var(--color-gold); }

/* ---- Listen page ---- */
.listen { padding: var(--space-10) 0 var(--space-12); }
.listen__head { text-align: center; max-width: 44ch; margin: 0 auto var(--space-8); }
.listen__head h1 { font-size: var(--text-2xl); margin-bottom: var(--space-3); }
.listen__head p { color: var(--color-text-muted); font-size: var(--text-base); }
.listen__voice {
  display: inline-flex; align-items: center; gap: .5em; margin-top: var(--space-4);
  font-size: var(--text-xs); font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--color-text-faint);
}
.listen__voice svg { width: 14px; height: 14px; }

/* the now-playing big player */
.listen__now { max-width: 640px; margin: 0 auto var(--space-8); }
.listen__now .aplayer { padding: 1rem 1.2rem; }

/* playlist */
.listen__list { max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; gap: 2px; }
.listen__item {
  display: flex; align-items: center; gap: var(--space-4);
  padding: 0.72rem 0.85rem; border-radius: var(--radius-md);
  text-align: left; width: 100%;
  transition: background .15s ease;
}
.listen__item:hover { background: var(--color-surface); }
.listen__item.is-active { background: var(--color-primary-soft); }
.listen__num {
  flex: 0 0 auto; width: 26px; height: 26px; display: grid; place-items: center;
  font-size: var(--text-xs); font-weight: 600; color: var(--color-text-faint);
  font-variant-numeric: tabular-nums;
}
.listen__item.is-active .listen__num { color: var(--color-primary); }
.listen__item.is-playing .listen__num { color: var(--color-primary); }
/* little equalizer bars when playing */
.listen__eq { display: none; gap: 2px; align-items: flex-end; height: 14px; }
.listen__item.is-playing .listen__eq { display: inline-flex; }
.listen__item.is-playing .listen__num span { display: none; }
.listen__eq i { width: 3px; background: var(--color-primary); border-radius: 2px; animation: eq 0.9s ease-in-out infinite; }
.listen__eq i:nth-child(1){ animation-delay: 0s; height: 6px; }
.listen__eq i:nth-child(2){ animation-delay: .25s; height: 12px; }
.listen__eq i:nth-child(3){ animation-delay: .5s; height: 8px; }
@keyframes eq { 0%,100%{ transform: scaleY(.4);} 50%{ transform: scaleY(1);} }
.listen__tt { flex: 1 1 auto; min-width: 0; overflow: hidden; }
.listen__title { display: block; font-weight: 500; font-size: var(--text-sm); color: var(--color-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.listen__dur { flex: 0 0 auto; font-size: var(--text-xs); color: var(--color-text-faint); font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) {
  .listen__eq i { animation: none; }
  .aplayer__fill { transition: none; }
}

@media (max-width: 600px) {
  .aplayer { gap: var(--space-3); padding: 0.6rem 0.7rem; }
  .aplayer__play { width: 42px; height: 42px; }
  .aplayer__rate { padding: 0.28em 0.5em; min-width: 2.9em; }
}
