/* ============================================================================
   Audiobooks player page
   Layers eco design-system styling on top of home-v2.css (tokens, nav, footer).
   Custom audio UI drives a hidden native <audio> element (the playback engine).
   ============================================================================ */

.audiobooks-wrap {
    max-width: 1180px;
    margin: 0 auto;
    padding: 8rem var(--gutter) 5rem;
}

@media (min-width: 768px) {
    .audiobooks-wrap {
        padding-inline: var(--gutter-lg);
        padding-top: 9rem;
    }
}

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

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--color-eco-ink-soft);
}

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

/* ------------------------------------------------------------------ intro --- */

.ab-intro {
    text-align: center;
    margin-bottom: clamp(2.5rem, 6vw, 4.5rem);
}

.ab-intro .eyebrow {
    margin-bottom: 1.25rem;
}

.ab-title {
    margin: 0;
    font-family: var(--font-display);
    font-weight: 500;
    font-size: clamp(3rem, 9vw, 6rem);
    line-height: 0.95;
    color: var(--color-eco-ink);
}

.ab-title em {
    font-style: italic;
    font-weight: 400;
}

.ab-sub {
    margin: 1.25rem auto 0;
    max-width: 32ch;
    font-family: var(--font-sans);
    font-size: 1.05rem;
    color: var(--color-eco-ink-soft);
}

/* ----------------------------------------------------------------- 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;
    }
}

.card {
    background: var(--color-eco-paper);
    border: 1px solid var(--color-eco-border);
    border-radius: 22px;
    box-shadow: 0 30px 70px -36px rgba(42, 47, 32, 0.4);
}

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

.player-card {
    padding: 28px;
    background: var(--color-eco-cream-warm);
}

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

.player-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.status {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.16em;
    text-transform: lowercase;
    color: var(--color-eco-ink-soft);
    white-space: nowrap;
}

.status.is-playing {
    color: var(--color-eco-olive);
}

/* media row: cover thumb + title */
.media-row {
    display: flex;
    gap: 18px;
    align-items: center;
    margin-bottom: 26px;
}

.cover {
    flex: 0 0 96px;
}

.cover img {
    width: 96px;
    height: 96px;
    object-fit: cover;
    border-radius: 14px;
    display: block;
    border: 1px solid var(--color-eco-border);
    box-shadow: 0 14px 30px -18px rgba(42, 47, 32, 0.5);
}

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

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

.np-chapter {
    margin: 0 0 4px;
    text-align: left;
    font-family: var(--font-display);
    font-weight: 500;
    font-size: clamp(1rem, 2vw, 1.2rem);
    line-height: 1.2;
    color: var(--color-eco-ink-soft);
}

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

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

.play-btn {
    flex: 0 0 auto;
    width: 78px;
    height: 78px;
    border-radius: 50%;
    border: none;
    background: var(--color-eco-cta-tan);
    color: var(--color-eco-cream);
    display: grid;
    place-items: center;
    cursor: pointer;
    box-shadow:
        0 18px 38px -14px rgba(58, 70, 40, 0.65),
        0 0 0 10px rgba(200, 70, 52, 0.05);
    transition:
        transform 0.18s ease,
        background 0.2s ease,
        box-shadow 0.2s ease;
}

.play-btn:hover {
    background: var(--color-eco-cta-tan-hov);
    transform: translateY(-1px);
    box-shadow:
        0 22px 44px -14px rgba(58, 70, 40, 0.7),
        0 0 0 12px rgba(200, 70, 52, 0.07);
}

.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(--color-eco-border);
    background: var(--color-eco-cream);
    color: var(--color-eco-ink);
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition:
        border-color 0.2s,
        background 0.2s;
}

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

.skip small {
    font-size: 8px;
    letter-spacing: 0.06em;
    color: var(--color-eco-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(--color-eco-bone);
    overflow: visible;
}

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

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

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

.time-row {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--color-eco-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(--color-eco-border);
}

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

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

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

.speed label {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--color-eco-ink-soft);
}

.speed select {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    border: 1px solid var(--color-eco-border);
    background: var(--color-eco-cream);
    color: var(--color-eco-ink);
    border-radius: 999px;
    padding: 7px 12px;
    cursor: pointer;
}

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

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

.player-col {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.player-col .download-link {
    align-self: center;
}

/* ------------------------------------------------------- chapters accordion --- */

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

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

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

.chapters-accordion {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.vol-section {
    border-bottom: 1px solid var(--color-eco-border);
}

.vol-section:last-child {
    border-bottom: none;
}

.vol-header {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: left;
    background: transparent;
    border: none;
    padding: 14px 4px;
    cursor: pointer;
    color: var(--color-eco-ink);
}

.vol-heading {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
}

.vol-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.25rem;
    line-height: 1.1;
    color: var(--color-eco-ink);
}

.vol-section.is-expanded .vol-title {
    color: var(--color-eco-olive-deep);
}

.vol-meta {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--color-eco-ink-soft);
    white-space: nowrap;
}

.vol-caret {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    color: var(--color-eco-ink-soft);
    transition: transform 0.28s ease;
}

.vol-section.is-expanded .vol-caret {
    transform: rotate(180deg);
    color: var(--color-eco-olive-deep);
}

.vol-body {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}

.vol-section.is-expanded .vol-body {
    grid-template-rows: 1fr;
}

.vol-body-inner {
    overflow: hidden;
    min-height: 0;
}

.download-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--color-eco-ink-soft);
    text-decoration: none;
    transition: color 0.2s;
}

.download-link:hover {
    color: var(--color-eco-olive-deep);
}

.download-link svg {
    width: 16px;
    height: 16px;
}

/* ------------------------------------------------------- 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: var(--gutter);
    opacity: 0;
    transition: opacity 0.28s ease;
}

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

.chapter-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(42, 47, 32, 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(--color-eco-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;
    }
}

@media (min-width: 768px) {
    .chapter-modal-panel {
        padding: 32px;
    }
}

.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(--color-eco-border);
    background: var(--color-eco-cream);
    color: var(--color-eco-ink);
    display: grid;
    place-items: center;
    cursor: pointer;
    transition:
        border-color 0.2s,
        background 0.2s;
}

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

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

.chapter-modal-panel .chapters-accordion {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: thin;
}

/* In the modal the accordion is the scroll container, so let lists size
   naturally rather than introducing a second nested scrollbar. */
.chapter-modal-panel .chapter-list {
    max-height: none;
    overflow: visible;
}

.chapter-list {
    list-style: none;
    margin: 0;
    padding: 0 0 10px;
    display: grid;
    gap: 1px;
    max-height: 460px;
    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: var(--color-eco-cream);
}

.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;
    word-break: break-word;
    color: var(--color-eco-ink);
}

.chapter-btn.active .chapter-title {
    color: var(--color-eco-olive-deep);
}

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

/* ----------------------------------------------------------- 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;
    }
}
