﻿/* ═══════════════════════════════════════════════════════════════
    MARKDIG RENDERED CONTENT
    Markdig outputs semantic HTML: <p>, <em>, <strong>, <blockquote>,
    <ul>, <ol>, <h1>-<h6>, <hr>, <code>, <pre>, etc.
    These styles ensure they look great inside chapter-body.
═══════════════════════════════════════════════════════════════ */
.chapter-body p {
    margin: 0 0 1em;
    text-indent: 1.5em;
}

.chapter-body > p:first-child {
    text-indent: 0;
}

    .chapter-body > p:first-child::first-letter {
        font-family: 'Cormorant Garamond', Georgia, serif;
        font-size: 3.2em;
        float: left;
        line-height: 0.8;
        padding-right: 0.08em;
        margin-top: 0.05em;
        color: var(--reader-chapter-accent);
        font-weight: 700;
    }

.chapter-body em, .chapter-body i {
    font-style: italic;
}

.chapter-body strong, .chapter-body b {
    font-weight: 700;
}

.chapter-body blockquote {
    border-left: 3px solid var(--reader-chapter-accent);
    margin: 1.5em 0;
    padding: 0.75em 1.25em;
    background: var(--reader-surface);
    border-radius: 0 8px 8px 0;
    color: var(--reader-text-muted);
    font-style: italic;
}

    .chapter-body blockquote p {
        text-indent: 0;
        margin-bottom: 0.5em;
    }

        .chapter-body blockquote p:last-child {
            margin-bottom: 0;
        }

.chapter-body ul, .chapter-body ol {
    margin: 1em 0;
    padding-left: 2em;
}

.chapter-body li {
    margin-bottom: 0.35em;
    text-indent: 0;
}

.chapter-body hr {
    border: none;
    height: 1px;
    background: var(--reader-border);
    margin: 2em 0;
}

.chapter-body h1, .chapter-body h2, .chapter-body h3,
.chapter-body h4, .chapter-body h5, .chapter-body h6 {
    font-family: 'Cormorant Garamond', Georgia, serif;
    color: var(--reader-text);
    margin: 1.5em 0 0.75em;
    text-indent: 0;
    line-height: 1.3;
}

.chapter-body h1 {
    font-size: 1.5em;
}

.chapter-body h2 {
    font-size: 1.3em;
}

.chapter-body h3 {
    font-size: 1.15em;
}

.chapter-body code {
    font-family: 'Courier New', monospace;
    background: var(--reader-surface);
    padding: 0.15em 0.4em;
    border-radius: 4px;
    font-size: 0.9em;
}

.chapter-body pre {
    background: var(--reader-surface);
    border: 1px solid var(--reader-border);
    border-radius: 8px;
    padding: 1em;
    overflow-x: auto;
    margin: 1.5em 0;
}

    .chapter-body pre code {
        background: none;
        padding: 0;
    }

.chapter-body a {
    color: var(--reader-chapter-accent);
    text-decoration: underline;
    text-decoration-color: rgba(201, 162, 39, 0.3);
    text-underline-offset: 0.15em;
    transition: text-decoration-color 0.2s;
}

    .chapter-body a:hover {
        text-decoration-color: var(--reader-chapter-accent);
    }

.chapter-body img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 1em 0;
}

/* Section body (front/back matter) also uses Markdig */
.section-body p {
    text-indent: 0;
    margin: 0 0 1em;
}

.section-body blockquote {
    border-left: 3px solid var(--reader-chapter-accent);
    margin: 1em 0;
    padding: 0.5em 1em;
    background: var(--reader-surface);
    border-radius: 0 8px 8px 0;
    font-style: italic;
    color: var(--reader-text-muted);
}

/* ═══════════════════════════════════════════════════════════════
    AUDIO PLAYER BAR
═══════════════════════════════════════════════════════════════ */
.audio-player-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1500;
    background: var(--reader-surface);
    border-top: 1px solid var(--reader-border);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

    .audio-player-bar.visible {
        transform: translateY(0);
    }

.audio-progress-track {
    width: 100%;
    height: 3px;
    background: var(--reader-border);
    cursor: pointer;
    position: relative;
}

.audio-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--gold), var(--gold-muted));
    width: 0%;
    transition: width 0.1s linear;
    position: relative;
}

    .audio-progress-fill::after {
        content: '';
        position: absolute;
        right: -5px;
        top: -4px;
        width: 11px;
        height: 11px;
        border-radius: 50%;
        background: var(--gold);
        box-shadow: 0 1px 4px rgba(0,0,0,0.2);
        opacity: 0;
        transition: opacity 0.2s;
    }

.audio-progress-track:hover .audio-progress-fill::after {
    opacity: 1;
}

.audio-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
}

.audio-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--reader-text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    flex-shrink: 0;
}

    .audio-btn:hover {
        color: var(--reader-chapter-accent);
    }

.audio-btn-play {
    width: 42px;
    height: 42px;
    background: var(--reader-chapter-accent);
    color: white;
    font-size: 1rem;
}

    .audio-btn-play:hover {
        opacity: 0.9;
        color: white;
    }

.audio-info {
    flex: 1;
    min-width: 0;
}

.audio-chapter-label {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--reader-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.audio-time {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.6rem;
    color: var(--reader-text-muted);
    margin-top: 0.1rem;
}

.audio-volume-group {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.audio-volume-slider {
    width: 60px;
    -webkit-appearance: none;
    appearance: none;
    height: 3px;
    border-radius: 2px;
    background: var(--reader-border);
    outline: none;
}

    .audio-volume-slider::-webkit-slider-thumb {
        -webkit-appearance: none;
        width: 12px;
        height: 12px;
        border-radius: 50%;
        background: var(--reader-chapter-accent);
        cursor: pointer;
    }

.audio-speed-btn {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.6rem;
    font-weight: 700;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    border: 1px solid var(--reader-border);
    background: transparent;
    color: var(--reader-text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

    .audio-speed-btn:hover {
        border-color: var(--reader-chapter-accent);
        color: var(--reader-chapter-accent);
    }

body.audio-active .reader-body {
    padding-bottom: 8rem;
}

body.audio-active .return-position {
    bottom: 5.5rem;
}

.header-btn-audio.has-audio {
    color: var(--reader-chapter-accent);
}

@media (max-width: 640px) {
    .audio-volume-group {
        display: none;
    }

    .audio-controls {
        padding: 0.5rem 0.75rem;
    }
}

/* ═══════════════════════════════════════════════════════════════
                                         READING STATS PANEL
                        ═══════════════════════════════════════════════════════════════ */
.stats-panel {
    background: var(--reader-surface);
    border: 1px solid var(--reader-border);
    border-radius: 16px;
    padding: 1.75rem;
    margin: 2rem 0;
}

.stats-panel-title {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.25rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 1.25rem;
    color: var(--reader-text);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
}

.stat-card {
    text-align: center;
    padding: 0.75rem 0.5rem;
    background: var(--reader-bg);
    border-radius: 12px;
    border: 1px solid var(--reader-border);
}

.stat-value {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--reader-chapter-accent);
    line-height: 1.2;
}

.stat-label {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--reader-text-muted);
    margin-top: 0.25rem;
}

.stats-progress-bar {
    margin-top: 1.25rem;
    background: var(--reader-border);
    border-radius: 6px;
    height: 8px;
    overflow: hidden;
}

.stats-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--gold), var(--gold-muted));
    border-radius: 6px;
    transition: width 0.6s ease;
}

.stats-progress-label {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.65rem;
    color: var(--reader-text-muted);
    text-align: center;
    margin-top: 0.5rem;
}

/* ═══════════════════════════════════════════════════════════════
                                         SHARE PASSAGE MODAL
  ═══════════════════════════════════════════════════════════════ */
.share-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(3px);
    z-index: 3000;
    display: none;
    align-items: center;
    justify-content: center;
}

    .share-modal-overlay.open {
        display: flex;
    }

.share-modal {
    background: var(--reader-surface);
    border-radius: 16px;
    padding: 2rem;
    width: 460px;
    max-width: 92vw;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

    .share-modal h4 {
        font-family: 'Cormorant Garamond', Georgia, serif;
        font-size: 1.25rem;
        font-weight: 700;
        margin: 0 0 0.75rem;
        color: var(--reader-text);
    }

.share-passage-preview {
    background: var(--reader-bg);
    border-left: 3px solid var(--reader-chapter-accent);
    padding: 1rem 1.25rem;
    border-radius: 0 10px 10px 0;
    margin-bottom: 1rem;
    font-style: italic;
    font-size: 0.85rem;
    color: var(--reader-text-muted);
    line-height: 1.6;
    max-height: 120px;
    overflow-y: auto;
}

.share-passage-attribution {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.65rem;
    color: var(--reader-text-muted);
    margin-bottom: 1.25rem;
}

.share-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.share-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1rem;
    border-radius: 20px;
    border: 1px solid var(--reader-border);
    background: var(--reader-surface);
    color: var(--reader-text-muted);
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

    .share-btn:hover {
        border-color: var(--reader-chapter-accent);
        color: var(--reader-chapter-accent);
    }

.share-btn-twitter:hover {
    border-color: #1da1f2;
    color: #1da1f2;
}

.share-btn-facebook:hover {
    border-color: #1877f2;
    color: #1877f2;
}

.share-btn-copy.copied {
    background: var(--reader-chapter-accent);
    color: white;
    border-color: var(--reader-chapter-accent);
}

.share-modal-close {
    display: flex;
    justify-content: flex-end;
    margin-top: 0.75rem;
}

/* ═══════════════════════════════════════════════════════════════
                                         DRAWER ACTIONS & META CHIPS
═══════════════════════════════════════════════════════════════ */
.drawer-item-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.drawer-action-btn {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--reader-text-muted);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.2rem 0;
    transition: color 0.2s;
}

    .drawer-action-btn:hover {
        color: var(--reader-chapter-accent);
    }

    .drawer-action-btn.danger:hover {
        color: #e74c3c;
    }

.book-meta-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.25rem;
}

.meta-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.85rem;
    border-radius: 20px;
    background: var(--reader-surface);
    border: 1px solid var(--reader-border);
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--reader-text-muted);
}

    .meta-chip i {
        color: var(--reader-chapter-accent);
        font-size: 0.7rem;
    }




.lightbox {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    overflow: auto;
    justify-content: center;
    align-items: center;
}

    .lightbox.active {
        display: flex;
    }

.lightbox-content {
    max-width: 90%;
    max-height: 90%;
    margin: auto;
    display: block;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 35px;
    font-weight: bold;
    cursor: pointer;
}

.lightbox-info {
    position: absolute;
    bottom: 20px;
    color: white;
    text-align: center;
    width: 100%;
}