﻿/* =========================================
   EBOOK PAGE - MAIN CONTAINER
   ========================================= */
.container.ebook-container {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 10px 15px;
    box-sizing: border-box;
}

/* Prevent Bootstrap row negative margins from causing overflow */
.ebook-container .row-fluid {
    margin-left: 0;
    margin-right: 0;
    width: 100%;
}

.ebook-container .wellcome-msg,
.ebook-container #divError {
    box-sizing: border-box;
    max-width: 100%;
}

/* =========================================
   DESKTOP LAYOUT
   TOC LEFT, CHAPTER RIGHT
   ========================================= */

.ebook-layout {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    width: 100%;
    max-width: 100%;
    gap: 15px;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* =========================================
   TABLE OF CONTENTS
   ========================================= */

.ebook-toc {
    flex: 0 0 25%;
    width: 25%;
    min-width: 0;
    max-width: 25%;
    margin: 0;
    color: #333;
    font-size: 14px;
    line-height: 1.7;
    overflow-wrap: anywhere;
    word-wrap: break-word;
}

/* Collapsible TOC button: hidden on desktop */

.toc-toggle {
    display: none;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #f7f0e5;
    color: #654321;
    font-size: 16px;
    font-weight: bold;
    text-align: left;
    cursor: pointer;
    box-sizing: border-box;
}

    .toc-toggle #tocToggleIcon {
        float: right;
    }

.toc-content {
    display: block;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    overflow-wrap: anywhere;
    word-wrap: break-word;
}

.ebook-toc .nav-header {
    display: block;
    margin: 0 0 10px;
    padding: 8px 0 10px;
    border-bottom: 1px solid #ddd;
    color: #654321;
    font-size: 17px;
    line-height: 1.5;
}

.ebook-toc div {
    max-width: 100%;
    margin-top: 3px;
    margin-bottom: 3px;
    box-sizing: border-box;
}

.ebook-toc a {
    display: block;
    max-width: 100%;
    padding: 6px 8px;
    border-radius: 4px;
    color: #654321;
    text-decoration: none;
    line-height: 1.6;
    overflow-wrap: anywhere;
    word-wrap: break-word;
    box-sizing: border-box;
}

    .ebook-toc a:hover {
        color: #8a5724;
        background-color: #f7f0e5;
        text-decoration: none;
    }

/* =========================================
   CHAPTER CONTENT
   ========================================= */

.ebook-content {
    flex: 1 1 0;
    width: 0;
    min-width: 0;
    max-width: 100%;
    margin: 0;
    border-left: 1px dashed #ccc;
    padding: 0 12px;
    box-sizing: border-box;
    overflow-wrap: anywhere;
    word-wrap: break-word;
}

.ebook-chapter-content {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 0;
    padding: 5px 8px;
    box-sizing: border-box;
    color: #333;
    font-size: 16px;
    line-height: 1.8;
    text-align: justify;
    overflow-wrap: anywhere;
    word-wrap: break-word;
}

    .ebook-chapter-content p {
        margin: 0 0 14px;
        line-height: 1.8;
        text-align: justify;
    }

    .ebook-chapter-content img {
        display: inline-block;
        max-width: 100%;
        height: auto;
    }

    .ebook-chapter-content video,
    .ebook-chapter-content iframe {
        max-width: 100%;
    }

    .ebook-chapter-content table {
        width: auto;
        max-width: 100%;
        border-collapse: collapse;
    }

    .ebook-chapter-content th,
    .ebook-chapter-content td {
        overflow-wrap: anywhere;
        word-wrap: break-word;
    }

    .ebook-chapter-content h1,
    .ebook-chapter-content h2,
    .ebook-chapter-content h3,
    .ebook-chapter-content h4 {
        max-width: 100%;
        line-height: 1.5;
        text-align: left;
        overflow-wrap: anywhere;
        word-wrap: break-word;
        margin-top: 18px;
        margin-bottom: 12px;
    }

/* =========================================
   PREVIOUS / NEXT CHAPTER BUTTONS
   ========================================= */

.chapter-navigation {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    width: 100%;
    margin-top: 25px;
    padding-top: 15px;
    border-top: 1px solid #ddd;
    box-sizing: border-box;
}

    .chapter-navigation a {
        max-width: 100%;
        white-space: normal;
        overflow-wrap: anywhere;
        box-sizing: border-box;
    }

/* =========================================
   TABLET AND MOBILE
   ========================================= */

@media screen and (max-width: 767px) {
    .container.ebook-container {
        width: 100%;
        max-width: 100%;
        padding: 6px 8px;
    }

    .ebook-layout {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        width: 100%;
    }

    .ebook-toc {
        flex: 0 0 auto;
        width: 100%;
        max-width: 100%;
        padding: 0 0 10px;
        border-right: none;
        border-bottom: 1px dashed #ccc;
    }

    .toc-toggle {
        display: block;
    }

    .toc-content {
        display: none;
        width: 100%;
        padding-top: 8px;
    }

    .ebook-toc.toc-expanded .toc-content {
        display: block;
    }

    .ebook-content {
        flex: 1 1 auto;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        padding: 0 5px;
    }

    .ebook-chapter-content {
        width: 100%;
        max-width: 100%;
        font-size: 15px;
        padding: 5px 6px;
        line-height: 1.8;
    }

        .ebook-chapter-content p {
            line-height: 1.8;
            margin-bottom: 12px;
        }

    .chapter-navigation {
        margin-top: 18px;
        padding-top: 12px;
    }
}

/* =========================================
   SMALL MOBILE
   ========================================= */

@media screen and (max-width: 480px) {
    .container.ebook-container {
        padding: 4px 6px;
    }

    .ebook-chapter-content {
        font-size: 14px;
        line-height: 1.75;
    }

        .ebook-chapter-content h1 {
            font-size: 24px;
        }

        .ebook-chapter-content h2 {
            font-size: 21px;
        }

        .ebook-chapter-content h3 {
            font-size: 18px;
        }

    .chapter-navigation {
        gap: 8px;
    }

        .chapter-navigation a {
            padding: 7px 9px;
            font-size: 12px;
        }
}

#socialicons > a span {
    top: 0px;
    left: -100%;
    -webkit-transition: all 0.3s ease;
    -moz-transition: all 0.3s ease-in-out;
    -o-transition: all 0.3s ease-in-out;
    -ms-transition: all 0.3s ease-in-out;
    transition: all 0.3s ease-in-out;
}

#socialicons > ahover div {
    left: 0px;
}

.ebook-chapter {
    width: 100%;
    margin-bottom: 40px;
    padding-bottom: 30px;
    border-bottom: 1px solid #e5e5e5;
    overflow-wrap: break-word;
}

.ebook-chapter-title {
    text-align: center;
    margin: 25px 0;
    line-height: 1.5;
}

.ebook-chapter img {
    max-width: 100%;
    height: auto;
}

.ebook-chapter p {
    line-height: 1.8;
    text-align: justify;
}

.ebook-chapter {
    display: none;
    width: 100%;
    margin-bottom: 30px;
    padding-bottom: 20px;
}

.ebook-chapter-title {
    text-align: center;
    margin: 20px 0 30px;
}

.ebook-chapter img {
    max-width: 100%;
    height: auto;
}

.ebook-navigation {
    display: flex;
    justify-content: space-between;
    margin-top: 30px;
    padding: 15px 0;
    border-top: 1px solid #ddd;
}

    .ebook-navigation button:disabled {
        opacity: 0.4;
        cursor: not-allowed;
    }

.ebook-toc .toc-content a.active {
    font-weight: bold;
    color: #c46a22;
}


/* ================================
   EPUB Chapter Reading Typography
================================ */

.ebook-content {
    color: #333333 !important;
    font-family: "Noto Sans", "Nirmala UI", Arial, sans-serif;
    font-size: 17px !important;
    line-height: 1.9 !important;
    text-align: justify;
    padding: 20px 25px;
}

    /* Chapter paragraphs */
    .ebook-content .ebook-chapter p,
    .ebook-content .ebook-chapter div,
    .ebook-content .ebook-chapter li {
        color: #333333 !important;
        font-size: 17px !important;
        line-height: 1.9 !important;
        text-align: justify;
    }

    /* Chapter headings */
    .ebook-content .ebook-chapter h1,
    .ebook-content .ebook-chapter h2,
    .ebook-content .ebook-chapter h3,
    .ebook-content .ebook-chapter h4 {
        color: #292929 !important;
        line-height: 1.5 !important;
        text-align: center;
        margin-top: 25px;
        margin-bottom: 20px;
    }

    /* Main chapter title */
    .ebook-content .ebook-chapter-title {
        color: #8b4513 !important;
        font-size: 25px !important;
        font-weight: 600;
        line-height: 1.5 !important;
        text-align: center;
        margin: 20px 0 30px;
    }

    /* Lists */
    .ebook-content .ebook-chapter li {
        margin-bottom: 8px;
    }

    /* Links */
    .ebook-content .ebook-chapter a {
        color: #8b4513 !important;
        text-decoration: underline;
    }

    /* Images */
    .ebook-content .ebook-chapter img {
        max-width: 100%;
        height: auto;
        display: block;
        margin: 15px auto;
    }

    /* Tables */
    .ebook-content .ebook-chapter table {
        max-width: 100%;
        border-collapse: collapse;
        margin: 15px 0;
    }

    .ebook-content .ebook-chapter td,
    .ebook-content .ebook-chapter th {
        color: #333333 !important;
        font-size: 16px !important;
        padding: 8px;
    }

/* Mobile reading */
@media (max-width: 767px) {
    .ebook-content {
        font-size: 16px !important;
        line-height: 1.85 !important;
        padding: 15px 10px;
    }

        .ebook-content .ebook-chapter p,
        .ebook-content .ebook-chapter div,
        .ebook-content .ebook-chapter li {
            font-size: 16px !important;
            line-height: 1.85 !important;
        }

        .ebook-content .ebook-chapter-title {
            font-size: 21px !important;
        }
}
