/* ============================================================================
   Audiobook player page
   Ported from the System or Ecosystem audiobooks page onto the site.css
   tokens. Custom audio UI drives a hidden native <audio> element.
   ============================================================================ */

.audiobook-wrap {
  max-width: 72rem;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

@media (min-width: 768px) {
  .audiobook-wrap {
    padding-top: 3rem;
    padding-bottom: 5rem;
  }
}

/* ---------------------------------------------------------------- eyebrow --- */

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.eyebrow .rule {
  display: inline-block;
  width: 28px;
  height: 1px;
  background: var(--border);
}

/* ----------------------------------------------------------------- layout --- */

.ab-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: 28px;
  align-items: start;
}

@media (max-width: 880px) {
  .ab-layout {
    grid-template-columns: 1fr;
  }
}

.ab-card {
  background: rgba(255, 255, 255, 0.35);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 30px 70px -36px var(--shadow);
}

/* --------------------------------------------------------------- player --- */

.player-card {
  padding: 24px;
}

@media (min-width: 768px) {
  .player-card {
    padding: 36px;
  }
}

.player-top {
  margin-bottom: 20px;
}

.media-row {
  display: flex;
  gap: 18px;
  align-items: center;
  margin-bottom: 26px;
}

.cover {
  flex: 0 0 96px;
}

.cover img {
  display: block;
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: 10px;
  background: var(--paper-deep);
  box-shadow: 0 14px 30px -18px var(--shadow);
}

.np-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  line-height: 1.08;
  color: var(--ink);
}

.np-byline {
  margin: 6px 0 0;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.np-chapter {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.1rem, 2vw, 1.3rem);
  line-height: 1.2;
  color: var(--green);
}

.np-chapter:empty {
  display: none;
}

/* transport: big play flanked by skip buttons */
.transport {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  margin: 8px 0 4px;
}

.play-btn {
  flex: 0 0 auto;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  border: none;
  background: var(--green);
  color: var(--paper);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow:
    0 18px 38px -14px rgba(36, 56, 42, 0.65),
    0 0 0 10px rgba(47, 74, 50, 0.06);
  transition:
    transform 0.18s ease,
    background 0.2s ease,
    box-shadow 0.2s ease;
}

.play-btn:hover {
  background: var(--green-deep);
  transform: translateY(-1px);
}

.play-btn:active {
  transform: translateY(0);
}

.play-btn svg {
  width: 30px;
  height: 30px;
}

.play-btn .icon-pause {
  display: none;
}

.play-btn[data-playing="true"] .icon-play {
  display: none;
}

.play-btn[data-playing="true"] .icon-pause {
  display: block;
}

.skip {
  flex: 0 0 auto;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition:
    border-color 0.2s,
    background 0.2s;
}

.skip:hover {
  border-color: var(--leaf);
  background: var(--color-eco-green-muted);
}

.skip small {
  font-size: 8px;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  text-transform: uppercase;
}

/* scrubber */
.scrubber {
  position: relative;
  padding: 10px 0;
  cursor: pointer;
  touch-action: none;
}

.scrubber .bar {
  position: relative;
  height: 6px;
  border-radius: 999px;
  background: var(--paper-deep);
}

.scrubber .fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  border-radius: 999px;
  background: var(--leaf);
}

.scrubber .handle {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--green-deep);
  border: 2px solid var(--paper);
  transform: translate(-50%, -50%);
  box-shadow: 0 2px 6px var(--shadow);
  opacity: 0;
  transition: opacity 0.15s ease;
}

.scrubber:hover .handle,
.scrubber:focus-visible .handle,
.scrubber.is-scrubbing .handle {
  opacity: 1;
}

.time-row {
  display: flex;
  justify-content: space-between;
  margin: 6px 0 20px;
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

/* secondary actions */
.secondary-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
}

.ghost {
  font-family: var(--font-sans);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--ink);
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 0.9rem;
  cursor: pointer;
  transition:
    border-color 0.2s,
    background 0.2s;
}

.ghost:hover {
  border-color: var(--leaf);
  background: var(--color-eco-green-muted);
}

.speed {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.speed label {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.speed select {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  border: 1px solid var(--border);
  background-color: var(--paper);
  color: var(--ink);
  border-radius: 999px;
  /* Native arrows ignore padding and hug the pill's edge, so draw our own
     chevron inset from the right. */
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231c2418' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 12px;
  padding: 7px 36px 7px 14px;
  cursor: pointer;
}

.speed select:hover {
  border-color: var(--leaf);
}

/* ---------------------------------------------------------- chapter list --- */

.chapters-panel {
  padding: 24px;
  display: flex;
  flex-direction: column;
}

@media (min-width: 768px) {
  .chapters-panel {
    padding: 28px;
  }
}

.chapters-panel .eyebrow {
  margin-bottom: 14px;
}

.chapter-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1px;
  max-height: 560px;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
}

.chapter-btn {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 9px;
  padding: 8px 12px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  cursor: pointer;
  transition: background 0.18s ease;
}

.chapter-btn:hover {
  background: rgba(255, 255, 255, 0.55);
}

.chapter-btn.active {
  background: var(--color-eco-green-muted);
}

.chapter-title {
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 0.95rem;
  line-height: 1.3;
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
}

.chapter-btn.active .chapter-title {
  color: var(--green);
  font-weight: 650;
}

.chapter-time {
  font-family: var(--font-sans);
  color: var(--ink-soft);
  font-size: 0.78rem;
  white-space: nowrap;
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------- chapters button --- */

.chapters-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.chapters-btn svg {
  width: 16px;
  height: 16px;
}

/* -------------------------------------------------------- chapters modal --- */

.chapter-modal[hidden] {
  display: none;
}

.chapter-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  opacity: 0;
  transition: opacity 0.28s ease;
}

.chapter-modal.is-open {
  opacity: 1;
}

.chapter-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(28, 36, 24, 0.5);
  backdrop-filter: blur(3px);
}

.chapter-modal-panel {
  position: relative;
  width: min(640px, 100%);
  max-height: min(82vh, 760px);
  display: flex;
  flex-direction: column;
  padding: 24px;
  background: var(--paper);
  opacity: 0;
  transform: translateY(14px) scale(0.97);
  transform-origin: center bottom;
  transition:
    transform 0.32s cubic-bezier(0.16, 1, 0.3, 1),
    opacity 0.26s ease;
}

.chapter-modal.is-open .chapter-modal-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
}

@media (prefers-reduced-motion: reduce) {
  .chapter-modal,
  .chapter-modal-panel {
    transition: none;
  }
}

.chapter-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.chapter-modal-close {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--paper);
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.chapter-modal-close:hover {
  border-color: var(--leaf);
  background: var(--color-eco-green-muted);
}

.chapter-modal-close svg {
  width: 18px;
  height: 18px;
}

/* The modal panel is height-capped, so its list scrolls within it. */
.chapter-modal-panel .chapter-list {
  flex: 1 1 auto;
  max-height: none;
}

/* ----------------------------------------------------------- responsive --- */

/* Desktop shows the chapters panel inline; the modal button is mobile-only. */
@media (min-width: 881px) {
  .chapters-btn {
    display: none;
  }
}

@media (max-width: 880px) {
  .chapters-panel {
    display: none;
  }
}

@media (max-width: 600px) {
  .media-row {
    gap: 14px;
  }

  .cover,
  .cover img {
    flex-basis: 72px;
    width: 72px;
    height: 72px;
  }

  .transport {
    gap: 16px;
  }

  .speed {
    margin-left: 0;
  }
}
