/* ======================================================
   1. PAGE BASE (A4 – desktop)
   ====================================================== */

.book-page {
    width: 210mm;
    min-height: 297mm;
    margin: 0 auto 30px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    /* chừa vùng an toàn cho header / footer */
    padding: 35mm 20mm 30mm;

    background: #fff;
    box-shadow: 0 0 12px rgba(0, 0, 0, .2);
    box-sizing: border-box;
    position: relative;


    font-size: 14pt;
    line-height: 1.7;
}

.page-content {
    text-align: justify;
}

/* ======================================================
   2. HEADERS / TITLES
   ====================================================== */

.book-header,
.book-title,
.book-center {
    text-align: center;
}

.book-header {
    margin: 14mm 0 8mm;
    font-weight: 700;
    font-size: 120%;
    letter-spacing: 1px;
}

.book-subheader {
    margin: 6mm 0 4mm;
    font-weight: 600;
    font-size: 105%;
    text-align: left;
}

/* ======================================================
   3. PARAGRAPH – CORE LOGIC (SÁCH IN)
   ====================================================== */

/* MẶC ĐỊNH: mọi đoạn đều thụt */
.book-paragraph {
    text-indent: 2em;
    margin-bottom: 1em;
    text-align: left;
}

/* đoạn mở chương / sau header */
.book-paragraph.no-indent {
    text-indent: 0;
}

/* đoạn có drop cap */
.book-paragraph.has-dropcap {
    text-indent: 0;
}

/* ======================================================
   4. FLOW TEXT (gộp các dòng trong 1 đoạn)
   ====================================================== */

.book-paragraph>div {
    display: inline-block;
}

.book-paragraph>div::after {
    content: " ";
}

/* ======================================================
   5. DROP CAP
   ====================================================== */

.paragraph-dropcap {
    text-indent: -1px;
}

.paragraph-dropcap::first-letter {
    float: left;
    font-size: 3.1em;
    line-height: 0.95;
    margin-right: 4px;
    margin-top: 2px;
    font-weight: bold;
}

/* ======================================================
   6. QUOTE / NOTE
   ====================================================== */

.book-quote,
.book-note {
    text-indent: 0;
}

.book-quote {
    margin: 8mm 0 8mm 12mm;
    padding: 6px 12px;
    border-left: 4px solid #e5e5e5;
    background: #fafafa;
    font-weight: 500;
}

.book-note {
    margin: 6mm 0 6mm 14mm;
    padding-left: 10px;
    border-left: 2px solid #ededed;
    font-size: 90%;
    line-height: 1.5;
    color: #666;
}

/* ======================================================
   7. IMAGE / AUDIO
   ====================================================== */

.book-image {
    margin: 20px auto;
    text-align: center;
}

.book-image img,
.book-page img,
.book-page audio {
    max-width: 100%;
    display: block;
}

.book-image figcaption {
    font-size: 12pt;
    opacity: .7;
    margin-top: 8px;
}

.book-audio {
    margin: 16px 0;
    padding: 12px;
    background: #faf7ef;
    border-left: 4px solid #c9a13a;
}

/* ======================================================
   8. HEADER / FOOTER
   ====================================================== */

.page-header {
    position: absolute;
    top: 12mm;
    left: 20mm;
    right: 20mm;
    display: flex;
    justify-content: space-between;
    font-size: 11pt;
}

.page-footer {
    position: absolute;
    bottom: 12mm;
    left: 20mm;
    right: 20mm;
    text-align: center;
    font-size: 11pt;
}

/* ======================================================
   9. FRONT MATTER
   ====================================================== */

.book-front-matter {
    margin-top: 35mm;
    margin-bottom: 25mm;
    text-align: center;
    line-height: 1.8;
    font-size: 120%;
}

.book-layout {
    display: flex;
}

.book-toc {
    width: 260px;
    border-right: 1px solid #ddd;
    padding: 12px;
    overflow-y: auto;
}

.toc-item {
    cursor: pointer;
    padding: 6px 4px;
}

.toc-item:hover {
    background: #f5f5f5;
}

.toc-page {
    color: #888;
    font-size: 0.85em;
    margin-left: 4px;
}

.book-reader {
    flex: 1;
    height: 100vh;
    overflow: hidden;
    background: #f3f3f3;
}

.book-reader-inner {
    height: 100%;
    overflow-y: auto;
    padding: 24px;
}

/* ======================================================
   READ MODE – SECTION FRAME (AN TOÀN)
   ====================================================== */

.read-mode .book-section {
    max-width: 820px;
    /* độ rộng đọc lý tưởng */
    margin: 32px auto;
    padding: 48px 56px;

    background: #ffffff;
    border-radius: 6px;

    /* bóng nhẹ – KHÔNG phá page */
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.08);
}

/* khoảng cách đoạn cho dễ thở */
.read-mode .book-paragraph {
    margin-bottom: 1.2em;
}

/* list rõ ràng */
.read-mode .book-list {
    margin: 1.2em 0;
    padding-left: 2.2em;
}

/* =========================
   READING PROGRESS BAR
   ========================= */

.reading-progress {
    position: sticky;
    top: 0;
    z-index: 10;

    height: 6px;
    background: #e0e0e0;
}

.reading-progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg,
            #4caf50,
            #81c784);
    transition: width 0.15s linear;
}

.reading-progress-text {
    position: absolute;
    right: 12px;
    top: 8px;
    font-size: 12px;
    color: #555;
}

/* ======================================================
   10. MOBILE
   ====================================================== */

@media (max-width: 768px) {

    .book-page {
        width: 100%;
        padding: 16px 14px;
        box-shadow: none;
        font-size: 1rem;
        line-height: 1.65;
    }

    /* bỏ drop cap trên mobile */
    .paragraph-dropcap::first-letter {
        float: none;
        font-size: inherit;
        margin: 0;
        font-weight: inherit;
    }

    /* gộp dòng nhẹ */
    .book-paragraph>div {
        display: inline;
    }

    .book-paragraph {
        text-indent: 2em;
        margin-bottom: 1em;
        text-align: justify;
        font-size: 1.05rem;
        line-height: 1.75;
    }

    .book-paragraph.no-indent,
    .book-paragraph.has-dropcap {
        text-indent: 0;
    }

    .book-quote,
    .book-note {
        text-indent: 0;
    }
}