/* Book template styles extracted from book.php */

#flipbook-root {
    margin: 60px auto 160px;
    max-width: 100%;
}

#flipbook-viewport {
    margin: 0 auto;
}

/* Safety: keep modals hidden until Bootstrap CSS is ready */
.modal {
    display: none;
}

.modal.show {
    display: block;
}

.flip-book {
    background-size: cover;
    display: block;
}

.page {
    line-height: 1.4;
    padding: 20px;
    background-color: #fff;
    /* solid white, no transparency */
    /* color: hsl(35, 35, 35);
    border: solid 1px hsl(35, 20, 70); */
    overflow: hidden;
}

.page .page-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 0;
    min-height: 0;
    /* allow inner flex child to shrink for scrolling */
    min-width: 0;
}

/* .page .page-header { height: 30px; font-size: 100%; text-transform: uppercase; text-align: center; padding: 10px 12px; } */
/* .page .page-image {
    height: 100%;
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
} */

.page .page-text {
    height: 100%;
    flex-grow: 1;
    flex-basis: 0;
    /* help flexbox give this area scrollable space */
    font-size: 90%;
    text-align: justify;
    margin: 0;
    padding: 0;
    /* no side paddings to allow full width */
    box-sizing: border-box;
    border: 0;
    /* remove top border that constrained content area */
    width: 100%;
    overflow-y: auto;
    /* allow scrolling for long content */
    -webkit-overflow-scrolling: touch;
    /* smooth iOS scroll */
    touch-action: pan-y;
    /* prevent accidental horizontal pan from blocking scroll */
    overflow-wrap: anywhere;
    word-break: break-word;
    overscroll-behavior: contain;
}

/* .page .page-footer {
    height: 30px;
    border-top: solid 1px hsl(35, 55, 90);
    font-size: 80%;
    color: hsl(35, 20, 50);
    text-align: center;
    padding: 8px 12px;
    pointer-events: none; 
} */

/* Make any inner wrappers full width too */
#flipbook .page .book-content,
#flipbook .page .page-text>* {
    max-width: 100%;
}

/* Hide any page numbers (both legacy overlay and footer area) */
#flipbook .page-number {
    display: none !important;
}

#flipbook .page-footer {
    display: block !important;
}

/* Responsive media and tables inside page text */
#flipbook .page .page-text img {
    max-width: 100% !important;
    display: block;
}

#flipbook .page .page-text table {
    width: 100% !important;
    table-layout: fixed;
    border-collapse: collapse;
}

#flipbook .page .page-text th,
#flipbook .page .page-text td {
    word-break: break-word;
}

.page.--left {
    border-right: 0;
    box-shadow: inset -7px 0 30px -7px rgba(0, 0, 0, 0.4);
}

.page.--right {
    border-left: 0;
    box-shadow: inset 7px 0 30px -7px rgba(0, 0, 0, 0.4);
}

.page.hard {
    background-color: #fff;
    /* solid white */
    border: solid 1px hsl(35, 20, 50);
}

.page.page-cover {
    background-color: #fff;
    /* solid white */
    color: hsl(35, 35, 35);
    border: solid 1px hsl(35, 20, 50);
    padding: 0;
    /* no inner padding for full-bleed cover image */
}

.page.page-cover h2 {
    text-align: center;
    padding-top: 50%;
    font-size: 210%;
}

.page.page-cover-top {
    box-shadow: inset 0px 0 30px 0px rgba(36, 10, 3, 0.5), -2px 0 5px 2px rgba(0, 0, 0, 0.4);
}

.page.page-cover-bottom {
    box-shadow: inset 0px 0 30px 0px rgba(36, 10, 3, 0.5), 10px 0 8px 0px rgba(0, 0, 0, 0.4);
}

/* Layout helpers */
#flipbook-root {
    display: flex;
    justify-content: center;
    margin-bottom: 60px;
}

#flipbook-viewport {
    display: flex;
    justify-content: center;
    width: 100%;
}

#flipbook {
    margin-left: auto;
    margin-right: auto;
    position: relative;
    z-index: 1;
}

/* Book-like frame */
#flipbook-viewport {
    padding: 18px;
    border-radius: 8px;
    background: #f7f7f7;
    box-shadow: 0 10px 25px rgba(0, 0, 0, .15), inset 0 0 0 1px rgba(0, 0, 0, .06);
}

#flipbook {
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, .12);
    background: #fff;
    height: 100%;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    #flipbook-root {
        margin: 8px auto 80px;
        /* smaller margins to gain vertical space */
    }

    #flipbook-viewport {
        padding: 10px;
        /* slimmer frame padding */
        /* Make the book area use the full device viewport height on mobile */
        /* height: 95dvh; */
        /* use 95% of device viewport height */
    }

    .page {
        padding: 10px;
        /* smaller inner padding on pages */
    }

    /* Maximize text area: remove header/footer and let text fill the page */
    .page .page-header,
    .page .page-footer {
        display: none !important;
    }

    .page .page-content {
        justify-content: flex-start;
        /* no empty space below */
    }

    .page .page-text {
        font-size: 85%;
        min-height: 0;
        /* ensure scrollable child can shrink */
    }
}

/* Desktop-only height: make the book a bit shorter on large screens */
@media (min-width: 1024px) {
    #flipbook-viewport {
        /* height: 80vh; */
        /* change to 70vh if you want it smaller */
    }
}

/* Subtle spine shadow in the middle */
#flipbook::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 2px;
    transform: translateX(-50%);
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.08), rgba(0, 0, 0, 0.02));
    pointer-events: none;
}

/* Cover image helpers: place a full-bleed image via background on .page-cover */
.page.page-cover .page-content {
    padding: 0;
}

.page.page-cover .page-header,
.page.page-cover .page-footer {
    display: none !important;
}

.page.page-cover .page-text {
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    display: flex;
    /* allow children to stretch */
    align-items: stretch;
}

/* Make the cover image fill full page height without cropping */
.page.page-cover .page-image {
    height: 100%;
    background-size: contain !important;
    /* ensure full height fits */
    background-position: center center;
    background-repeat: no-repeat;
}

/* If the cover uses an <img>, scale it to full height of the page */
.page.page-cover img {
    display: block;
    height: 100%;
    width: auto;
    max-height: 100%;
    max-width: none;
    /* allow natural proportional width */
    margin: 0 auto;
    object-fit: contain;
    /* keep entire image visible */
}

/* If cover content is wrapped in a div, make it fill the height */
.page.page-cover .page-text>* {
    flex: 1 1 auto;
    height: 100%;
}

/* When the book is at the first page, make it look closed from the front */
#flipbook.book-closed-front {
    box-shadow: 0 6px 18px rgba(0, 0, 0, .18), inset 0 0 0 1px rgba(0, 0, 0, .06);
}

/* When the book is at the last page, make it look closed from the back */
#flipbook.book-closed-back {
    box-shadow: 0 6px 18px rgba(0, 0, 0, .18), inset 0 0 0 1px rgba(0, 0, 0, .06);
}

/* Optional: subtle tilt/edge emphasis for cover states */
#flipbook.book-closed-front .page.page-cover-top {
    box-shadow: inset 0 0 30px rgba(0, 0, 0, .2), -4px 0 10px rgba(0, 0, 0, .25);
}

#flipbook.book-closed-back .page.page-cover-bottom {
    box-shadow: inset 0 0 30px rgba(0, 0, 0, .2), 4px 0 10px rgba(0, 0, 0, .25);
}