﻿/* ============================= */
/* READER CONTAINER */
/* ============================= */

.reader {
    position: fixed;
    inset: 0;
    display: none;
    flex-direction: column;
    z-index: 10;
}

/* ============================= */
/* HEADER */
/* ============================= */

.reader-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: var(--card);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-soft);
    padding: 14px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: transform 0.3s ease;
    z-index: 30;
}

    .reader-header.hidden {
        transform: translateY(-100%);
    }

/* ============================= */
/* FOOTER */
/* ============================= */

.reader-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--card);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-soft);
    padding: 12px 28px;
    display: flex;
    justify-content: space-between;
    transition: transform 0.3s ease;
    z-index: 30;
}

    .reader-footer.hidden {
        transform: translateY(100%);
    }

/* ============================= */
/* READER CONTENT AREA */
/* ============================= */

.reader-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden; /* prevent horizontal shift */
    padding: 120px 20px 120px 20px;
}

/* ============================= */
/* BOOK CONTENT CARD */
/* ============================= */

.book-content {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 860px;
    margin: auto;
    font-family: Georgia, serif;
    font-size: 19px;
    line-height: 1.95;
    background: var(--card);
    padding: 70px 60px;
    border-radius: 32px;
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-soft);
    box-shadow: 0 30px 80px rgba(0,0,0,0.45);
    overflow-wrap: break-word;
    word-break: break-word;
}

/* Wider Screens */
@media (min-width: 1400px) {
    .book-content {
        max-width: 1000px;
    }
}

@media (min-width: 1800px) {
    .book-content {
        max-width: 1100px;
    }
}

/* ============================= */
/* HEADINGS */
/* ============================= */

.book-content h1 {
    font-size: 36px;
    margin-bottom: 40px;
}

.book-content h2 {
    font-size: 26px;
    margin-top: 60px;
}

.book-content h3 {
    font-size: 21px;
    margin-top: 45px;
}

/* ============================= */
/* PARAGRAPHS */
/* ============================= */

.book-content p {
    margin: 18px 0;
    text-align: justify;
}

/* ============================= */
/* TABLES */
/* ============================= */

.book-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 40px 0;
    font-size: 17px;
}

.book-content th,
.book-content td {
    border: 1px solid var(--border-soft);
    padding: 12px;
    text-align: left;
    vertical-align: top;
    word-break: normal;
    overflow-wrap: break-word;
}

.book-content th {
    font-weight: 600;
    background: rgba(255,255,255,0.05);
}

/* ============================= */
/* IMAGES */
/* ============================= */

.book-content img {
    display: block;
    max-width: 100%;
    width: 100%;
    height: auto;
    margin: 45px auto 12px auto;
    border-radius: 18px;
    box-shadow: 0 15px 50px rgba(0,0,0,0.5);
    cursor: pointer;
}

/* ============================= */
/* SECTION PANEL */
/* ============================= */

.section-panel {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    width: 380px;
    max-height: 65vh;
    overflow-y: auto;
    background: var(--card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-soft);
    border-radius: 22px;
    padding: 16px 0;
    display: none;
    z-index: 200;
    box-shadow: 0 40px 120px rgba(0,0,0,0.7);
}

.section-item {
    padding: 12px 22px;
    cursor: pointer;
    transition: background 0.2s ease;
    font-size: 15px;
}

    .section-item:hover {
        background: rgba(255,255,255,0.06);
    }

    .section-item.active {
        background: var(--primary);
        color: white;
    }

/* ============================= */
/* IMAGE MODAL — CLASS BASED */
/* ============================= */

.image-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.96);
    display: none;
    justify-content: center;
    align-items: center;
    padding: 40px;
    z-index: 9999;
}

    .image-modal.active {
        display: flex;
    }

    .image-modal img {
        max-width: 95vw;
        max-height: 90vh;
        object-fit: contain;
    }

/* ============================= */
/* BACK TO TOP — FIXED & STABLE */
/* ============================= */

.back-to-top {
    position: fixed;
    right: 30px;
    bottom: 140px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    background: var(--primary);
    color: white;
    display: none;
    z-index: 500; /* above reader */
    font-size: 18px;
    box-shadow: 0 12px 35px rgba(0,0,0,0.45);
    transition: transform 0.2s ease;
}

    .back-to-top:hover {
        transform: translateY(-4px);
    }

    .back-to-top.show {
        display: block;
    }

/* Hide button in library mode */
#libraryView:not([style*="display: none"]) ~ .back-to-top {
    display: none !important;
}

/* ============================= */
/* MOBILE */
/* ============================= */

@media (max-width: 768px) {

    .reader-content {
        padding: 100px 16px 120px 16px;
    }

    .book-content {
        padding: 40px 26px;
        font-size: 17px;
        border-radius: 24px;
    }

        .book-content table {
            font-size: 13.5px;
        }

        .book-content th,
        .book-content td {
            padding: 8px;
        }

    .section-panel {
        width: 90%;
    }
}
