/**
 * Narrations Page — Chapter List & Player Styles
 */

/* =========================================
   Layout (clears fixed header + sticky player)
   ========================================= */

.narration-layout {
    padding-top: 194px;
}

/* =========================================
   Sticky Player Bar
   ========================================= */

.narration-player-sticky {
    position: fixed;
    top: 112px;
    left: 0;
    right: 0;
    z-index: 999;
    background: #000;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5);
}

.narration-player-bar {
    max-width: 1000px;
    margin: 0 auto;
    padding: 8px 1.5rem;
}

.narration-player-bar .player-bar-inner {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

/* --- Controls --- */

.narration-player-bar .player-controls {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.narration-player-bar .player-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: none;
    border: none;
    color: var(--cream, #E8DCC4);
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.15s;
    position: relative;
}

.narration-player-bar .player-btn:hover {
    color: var(--gold-primary, #C4943A);
    background: rgba(196, 148, 58, 0.15);
}

.narration-player-bar .btn-play {
    width: 42px;
    height: 42px;
    background: var(--gold-primary, #C4943A);
    color: #fff;
}

.narration-player-bar .btn-play:hover {
    background: var(--gold-dark, #A67B2C);
    color: #fff;
}

/* Audio loading state */
.narration-player-bar .player-btn.loading {
    opacity: 0.5;
    pointer-events: none;
    position: relative;
}

.narration-player-bar .player-btn.loading .icon-play,
.narration-player-bar .player-btn.loading .icon-pause {
    visibility: hidden;
}

.narration-player-bar .player-btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: playerSpin 0.8s linear infinite;
}

@keyframes playerSpin {
    to { transform: rotate(360deg); }
}

/* --- Now Playing --- */

.narration-player-bar .now-playing {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    gap: 1px;
}

.narration-player-bar .now-playing-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--cream, #E8DCC4);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.narration-player-bar .now-playing-chapter {
    font-size: 0.7rem;
    color: var(--cream, #E8DCC4);
    opacity: 0.7;
    white-space: nowrap;
}

/* --- Progress Bar (full-width second row) --- */

.narration-player-bar .player-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-basis: 100%;
    order: 10;
}

.narration-player-bar .time-current,
.narration-player-bar .time-total {
    font-size: 0.7rem;
    color: var(--cream, #E8DCC4);
    opacity: 0.6;
    font-variant-numeric: tabular-nums;
    min-width: 32px;
    text-align: center;
    flex-shrink: 0;
}

.narration-player-bar .progress-track {
    position: relative;
    flex: 1;
    height: 5px;
    background: rgba(232, 220, 196, 0.15);
    border-radius: 3px;
    cursor: pointer;
}

.narration-player-bar .progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: var(--gold-primary, #C4943A);
    border-radius: 3px;
    pointer-events: none;
    transition: width 0.1s linear;
}

.narration-player-bar .progress-input {
    position: absolute;
    top: -8px;
    left: 0;
    width: 100%;
    height: 20px;
    margin: 0;
    opacity: 0;
    cursor: pointer;
    -webkit-appearance: none;
}

/* --- Volume --- */

.narration-player-bar .player-volume {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.narration-player-bar .volume-input {
    width: 80px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(232, 220, 196, 0.2);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.narration-player-bar .volume-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--gold-primary, #C4943A);
    cursor: pointer;
}

.narration-player-bar .volume-input::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--gold-primary, #C4943A);
    border: none;
    cursor: pointer;
}

/* =========================================
   Page Content
   ========================================= */

.narration-page {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 1.5rem 4rem;
}

.narration-header {
    text-align: center;
    padding-top: 1.5rem;
    margin-bottom: 2rem;
}

.narration-title {
    font-family: var(--font-serif, 'Crimson Pro', serif);
    font-size: 2.2rem;
    font-weight: 600;
    color: var(--cream, #E8DCC4);
    margin: 0;
}

/* =========================================
   View Text Toggle & Collapsible Panel
   ========================================= */

.view-text-wrapper {
    max-width: 800px;
    margin: 0 auto var(--space-lg, 2rem);
}

.view-text-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 1rem;
    background: rgba(42, 29, 20, 0.5);
    border: 1px solid rgba(196, 148, 58, 0.12);
    border-radius: var(--radius-md, 8px);
    color: var(--cream, #E8DCC4);
    opacity: 0.7;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    transition: opacity 0.15s, background 0.15s;
}

.view-text-toggle:hover {
    opacity: 1;
    background: rgba(42, 29, 20, 0.7);
}

.view-text-toggle-arrow {
    font-size: 0.6rem;
    transition: transform 0.3s ease;
}

.view-text-wrapper.open .view-text-toggle {
    border-radius: var(--radius-md, 8px) var(--radius-md, 8px) 0 0;
    border-bottom-color: transparent;
    opacity: 1;
}

.view-text-wrapper.open .view-text-toggle-arrow {
    transform: rotate(180deg);
}

/* Collapsible body */
.view-text-panel-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease;
}

.view-text-wrapper.open .view-text-panel-body {
    max-height: 80vh;
    overflow-y: auto;
}

.view-text-panel {
    background: rgba(42, 29, 20, 0.5);
    border: 1px solid rgba(196, 148, 58, 0.12);
    border-top: none;
    border-radius: 0 0 var(--radius-lg, 12px) var(--radius-lg, 12px);
    padding: 1.25rem 1.5rem;
}

.view-text-heading {
    font-family: var(--font-serif, 'Crimson Pro', serif);
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--gold-primary, #C4943A);
    margin: 0 0 0.75rem;
}

.view-text-content {
    max-height: 60vh;
    overflow-y: auto;
    padding: 1rem 1.25rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-md, 8px);
    line-height: 1.8;
    color: var(--cream, #E8DCC4);
}

/* Custom scrollbar for View Text */
.view-text-content::-webkit-scrollbar {
    width: 6px;
}

.view-text-content::-webkit-scrollbar-track {
    background: transparent;
}

.view-text-content::-webkit-scrollbar-thumb {
    background: rgba(139, 90, 43, 0.4);
    border-radius: 3px;
}

.view-text-content::-webkit-scrollbar-thumb:hover {
    background: rgba(139, 90, 43, 0.65);
}

.view-text-content {
    scrollbar-width: thin;
    scrollbar-color: rgba(139, 90, 43, 0.4) transparent;
}

/* Podcast gating message */
.view-text-gated {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 120px;
    font-style: italic;
    color: rgba(232, 220, 196, 0.5);
    font-size: 0.95rem;
    text-align: center;
    padding: 2rem 1rem;
}

.no-text {
    color: var(--cream, #E8DCC4);
    opacity: 0.6;
    font-style: italic;
}

/* --- View Text Prose Typography --- */

.view-text-chapter-title {
    font-family: 'Crimson Pro', Georgia, serif;
    font-size: 22px;
    font-weight: 600;
    color: var(--gold-primary, #C4943A);
    text-align: center;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(196, 148, 58, 0.15);
    margin-bottom: 24px;
}

.view-text-prose {
    font-family: 'Crimson Pro', Georgia, serif;
    font-size: 18px;
    line-height: 1.78;
    color: var(--cream, #E8DCC4);
    max-width: 720px;
    margin: 0 auto;
    padding: 24px 0;
}

.view-text-prose p {
    margin-bottom: 20px;
}

.view-text-prose h2 {
    font-size: 22px;
    font-weight: 600;
    margin: 36px 0 16px;
    color: var(--cream, #E8DCC4);
}

.view-text-prose h3 {
    font-size: 19px;
    font-weight: 600;
    margin: 28px 0 12px;
    color: var(--cream, #E8DCC4);
}

.view-text-prose a.scripture-link {
    color: var(--gold-primary, #C4943A);
    text-decoration: none;
    border-bottom: 1px solid rgba(196, 148, 58, 0.35);
}

.view-text-prose a.scripture-link:hover {
    border-bottom-color: var(--gold-primary, #C4943A);
}

.view-text-prose blockquote {
    border-left: 3px solid rgba(196, 148, 58, 0.3);
    padding-left: 1.25rem;
    margin: 1.5rem 0;
    font-style: italic;
    opacity: 0.85;
}

/* =========================================
   Section Headers
   ========================================= */

.narration-section-header {
    padding: 1.25rem 1rem 0.5rem;
}

.narration-section-header--subsequent {
    padding-top: 2rem;
    border-top: 1px solid rgba(196, 148, 58, 0.12);
    margin-top: 0.5rem;
}

.narration-section-header .section-title {
    font-family: var(--font-serif, 'Crimson Pro', serif);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--cream, #E8DCC4);
    margin: 0;
}

.narration-section-header .section-subtitle {
    font-size: 0.8rem;
    color: var(--cream, #E8DCC4);
    opacity: 0.45;
    margin: 0.2rem 0 0;
    font-style: italic;
}

/* =========================================
   UX Orientation Note
   ========================================= */

.narration-how-it-works {
    max-width: 680px;
    margin: 32px auto 40px;
    padding: 20px 24px;
    border-left: 3px solid var(--gold-primary, #C4943A);
    background: rgba(196, 148, 58, 0.06);
    border-radius: 0 6px 6px 0;
}

.narration-note-heading {
    font-family: 'Cinzel', serif;
    font-size: 0.85rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--gold-primary, #C4943A);
    margin-bottom: 12px;
}

.narration-how-it-works p {
    font-size: 0.95rem;
    line-height: 1.65;
    color: rgba(232, 220, 196, 0.85);
    margin-bottom: 10px;
}

.narration-how-it-works p:last-child {
    margin-bottom: 0;
}

.narration-how-it-works strong {
    color: var(--cream, #E8DCC4);
}

/* =========================================
   Read Aloud Button — How This Page Works section
   ========================================= */

.narration-how-ra-btn {
    float: right;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.8rem;
    margin: -4px 0 8px 12px;
    background: rgba(196, 148, 58, 0.1);
    border: 1px solid rgba(196, 148, 58, 0.25);
    border-radius: 20px;
    color: var(--gold-primary, #C4943A);
    font-family: var(--font-sans, system-ui, -apple-system, sans-serif);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: all 0.2s ease;
}

.narration-how-ra-btn:hover {
    background: rgba(196, 148, 58, 0.18);
    border-color: rgba(196, 148, 58, 0.45);
}

.narration-how-ra-btn:active {
    transform: scale(0.97);
}

.narration-how-ra-btn .icon-stop {
    display: none;
}

.narration-how-ra-btn.playing .icon-play {
    display: none;
}

.narration-how-ra-btn.playing .icon-stop {
    display: inline;
}

.narration-how-ra-btn.playing {
    background: rgba(196, 148, 58, 0.2);
    border-color: var(--gold-primary, #C4943A);
    animation: narrationHowRaPulse 2s ease-in-out infinite;
}

.narration-how-ra-btn.playing .narration-how-ra-label::after {
    content: 'Stop';
    font-size: 0.75rem;
}

.narration-how-ra-btn.playing .narration-how-ra-label {
    font-size: 0;
}

@keyframes narrationHowRaPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(196, 148, 58, 0.25); }
    50%      { box-shadow: 0 0 0 4px rgba(196, 148, 58, 0); }
}

/* Loading state (waiting for CDN HEAD check / first audio chunk) */
.narration-how-ra-btn.loading {
    background: rgba(196, 148, 58, 0.15);
    border-color: rgba(196, 148, 58, 0.4);
    pointer-events: none;
}

.narration-how-ra-btn.loading .icon-play,
.narration-how-ra-btn.loading .icon-stop {
    display: none;
}

.narration-how-ra-btn.loading::before {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(196, 148, 58, 0.3);
    border-top-color: var(--gold-primary, #C4943A);
    border-radius: 50%;
    animation: narrationHowRaSpin 0.8s linear infinite;
}

.narration-how-ra-btn.loading .narration-how-ra-label {
    font-size: 0;
}

.narration-how-ra-btn.loading .narration-how-ra-label::after {
    content: 'Loading\2026';
    font-size: 0.75rem;
}

@keyframes narrationHowRaSpin {
    to { transform: rotate(360deg); }
}

/* Word-level highlighting during browser TTS playback */
.narration-tts-word {
    transition: background-color 0.15s ease, color 0.15s ease;
    border-radius: 2px;
    padding: 0 1px;
}

.narration-tts-word.narration-tts-highlight {
    background-color: rgba(196, 148, 58, 0.3);
    color: var(--cream, #E8DCC4);
    box-shadow: 0 0 0 2px rgba(196, 148, 58, 0.15);
}

/* =========================================
   Chapter List — Two-Track Layout
   ========================================= */

.narration-container {
    background: rgba(42, 29, 20, 0.4);
    border: 1px solid rgba(196, 148, 58, 0.15);
    border-radius: var(--radius-lg, 12px);
    overflow: hidden;
}

.narration-chapter-group {
    margin-bottom: 4px;
}

.narration-chapter-header {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 14px 16px 6px;
}

.narration-ch-num {
    font-family: 'Cinzel', serif;
    font-size: 0.8rem;
    color: var(--gold-primary, #C4943A);
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.narration-ch-title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--cream, #E8DCC4);
}

.narration-chapter-link {
    color: rgba(232, 220, 196, 0.4);
    margin-left: auto;
    flex-shrink: 0;
    transition: color 0.2s;
    display: inline-flex;
    align-items: center;
}

.narration-chapter-link:hover {
    color: var(--gold-primary, #C4943A);
}

.narration-track-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px 8px 48px;
    cursor: pointer;
    transition: background 0.15s;
    border-radius: 4px;
    position: relative;
}

.narration-track-row:hover {
    background: rgba(196, 148, 58, 0.08);
}

.narration-track-row.playing {
    background: rgba(196, 148, 58, 0.12);
    border-left: 3px solid var(--gold-primary, #C4943A);
    padding-left: 45px;
}

.narration-track-label {
    font-size: 0.9rem;
    color: rgba(232, 220, 196, 0.75);
}

.narration-track-row.playing .narration-track-label {
    color: var(--cream, #E8DCC4);
    font-weight: 600;
}

.narration-track-duration {
    font-size: 0.85rem;
    color: rgba(232, 220, 196, 0.5);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* --- Completion Checkmark --- */

.track-completed {
    color: var(--gold-primary, #C4943A);
    font-size: 0.8rem;
    position: absolute;
    right: 64px;
}

/* --- Resume Prompt --- */

.narration-resume-prompt {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px 10px 48px;
    background: rgba(196, 148, 58, 0.08);
    border-left: 3px solid var(--gold-primary, #C4943A);
    border-radius: 0 4px 4px 0;
    margin-bottom: 2px;
}

.resume-text {
    font-size: 0.88rem;
    color: rgba(232, 220, 196, 0.7);
    flex: 1;
}

.resume-text strong {
    color: var(--cream, #E8DCC4);
}

.resume-btn {
    background: none;
    border: 1px solid var(--gold-primary, #C4943A);
    color: var(--gold-primary, #C4943A);
    font-size: 0.8rem;
    font-weight: 600;
    padding: 4px 14px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}

.resume-btn:hover {
    background: var(--gold-primary, #C4943A);
    color: #fff;
}

.resume-dismiss {
    background: none;
    border: none;
    color: rgba(232, 220, 196, 0.35);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.15s;
}

.resume-dismiss:hover {
    color: rgba(232, 220, 196, 0.7);
}

/* =========================================
   Footer
   ========================================= */

.narration-footer {
    text-align: center;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid rgba(196, 148, 58, 0.12);
    color: var(--cream, #E8DCC4);
    opacity: 0.55;
    font-size: 0.9rem;
    line-height: 1.7;
}

.narration-footer a {
    color: var(--gold-primary, #C4943A);
    text-decoration: none;
}

.narration-footer a:hover {
    text-decoration: underline;
}

/* =========================================
   Responsive — Tablet / Small Desktop
   ========================================= */

@media (max-width: 768px) {
    .narration-layout {
        padding-top: 168px;
    }

    .narration-player-sticky {
        top: 96px;
    }

    .narration-player-bar {
        padding: 6px 0.75rem;
    }

    .narration-player-bar .player-bar-inner {
        gap: 10px;
    }

    .narration-player-bar .player-controls {
        gap: 0;
    }

    /* 44px touch targets on mobile */
    .narration-player-bar .player-btn {
        width: 44px;
        height: 44px;
    }

    .narration-player-bar .btn-play {
        width: 44px;
        height: 44px;
    }

    /* Hide volume on mobile */
    .narration-player-bar .player-volume {
        display: none;
    }

    .narration-player-bar .player-progress {
        gap: 6px;
    }

    /* Page content */
    .narration-title {
        font-size: 1.6rem;
    }

    .view-text-panel {
        padding: 1rem 1rem;
    }

    .view-text-content {
        max-height: 300px;
        padding: 0.75rem 1rem;
    }

    /* Tighten track row padding */
    .narration-track-row {
        padding: 8px 12px 8px 36px;
    }

    .narration-track-row.playing {
        padding-left: 33px;
    }

    .narration-chapter-header {
        padding: 12px 12px 4px;
    }

    .narration-section-header .section-title {
        font-size: 1.1rem;
    }

    .narration-how-it-works {
        margin: 24px auto 32px;
        padding: 16px 18px;
    }

    .narration-how-ra-btn {
        padding: 0.35rem 0.65rem;
        font-size: 0.7rem;
        margin: -2px 0 6px 8px;
    }

    .narration-resume-prompt {
        padding: 8px 12px 8px 36px;
        gap: 8px;
    }
}

/* =========================================
   Responsive — Phone
   ========================================= */

@media (max-width: 480px) {
    .narration-track-row {
        padding: 7px 10px 7px 28px;
    }

    .narration-track-row.playing {
        padding-left: 25px;
    }

    .narration-track-duration {
        display: none;
    }

    .track-completed {
        right: 10px;
    }

    .narration-section-header {
        padding: 1rem 0.75rem 0.4rem;
    }

    .narration-section-header--subsequent {
        padding: 1.5rem 0.75rem 0.5rem;
    }
}
