/*--------------------------------------------------------------
# MangaVerse High-Performance 3D Book Spread Engine (StPageFlip Architecture)
--------------------------------------------------------------*/

/* Root Lock when Flip Mode is Active */
html.mv-flip-mode-active,
body.mv-flip-mode-active {
    overflow-x: hidden;
}

/* Hide Default Webtoon Scroll Container when Flip Mode is Active */
body.mv-flip-mode-active .entry-single .entry-content > *:not(#mv-flipbook-viewport) {
    display: none !important;
}

/* Main Flip Book Viewport Shell */
#mv-flipbook-viewport {
    position: relative;
    width: 100%;
    max-width: 1320px;
    margin: 20px auto 40px;
    background-color: var(--mv-color-background-alt);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.09);
    border: 1px solid var(--mv-color-border-light);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-user-select: none;
    transition: background-color 0.3s ease, border-color 0.3s ease;
    overflow: hidden;
}

.dark-mode #mv-flipbook-viewport {
    background-color: var(--mv-dark-background-alt);
    border-color: var(--mv-dark-border);
    box-shadow: 0 14px 45px rgba(0, 0, 0, 0.5);
}

/* Stage Area (3D Perspective Container) */
.mv-fb-stage {
    position: relative;
    width: 100%;
    height: 78vh;
    min-height: 540px;
    max-height: 940px;
    perspective: 3000px;
    -webkit-perspective: 3000px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 15px;
    overflow: visible;
    touch-action: pan-y pinch-zoom;
}

/* 2-Page Book Spread Foundation */
.mv-fb-spread {
    position: relative;
    width: 98%;
    height: 100%;
    display: flex;
    align-items: stretch;
    justify-content: center;
    box-shadow: 0 15px 45px rgba(0, 0, 0, 0.18);
    border-radius: 6px;
    background-color: #ffffff;
    transform-style: preserve-3d;
    -webkit-transform-style: preserve-3d;
    overflow: visible;
}

.dark-mode .mv-fb-spread {
    background-color: #121624;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6);
}

/* Center Binding Crease & Gradient Spine */
.mv-fb-spread::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 36px;
    transform: translateX(-50%);
    background: linear-gradient(to right, 
        rgba(0, 0, 0, 0.25) 0%, 
        rgba(0, 0, 0, 0.06) 35%, 
        rgba(0, 0, 0, 0.01) 50%, 
        rgba(0, 0, 0, 0.06) 65%, 
        rgba(0, 0, 0, 0.25) 100%);
    z-index: 20;
    pointer-events: none;
}

.dark-mode .mv-fb-spread::after {
    background: linear-gradient(to right, 
        rgba(0, 0, 0, 0.65) 0%, 
        rgba(0, 0, 0, 0.15) 35%, 
        rgba(0, 0, 0, 0.02) 50%, 
        rgba(0, 0, 0, 0.15) 65%, 
        rgba(0, 0, 0, 0.65) 100%);
}

/* Static Base Slots (Left & Right) */
.mv-fb-base-page {
    position: absolute;
    top: 0;
    width: 50%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #ffffff;
    box-sizing: border-box;
    overflow: hidden;
    cursor: grab;
    z-index: 2;
}

.dark-mode .mv-fb-base-page {
    background-color: #161b2a;
}

.mv-fb-base-left {
    left: 0;
    border-right: 1px solid rgba(0, 0, 0, 0.08);
}

.mv-fb-base-right {
    left: 50%;
    border-left: 1px solid rgba(0, 0, 0, 0.08);
}

.dark-mode .mv-fb-base-left {
    border-right-color: rgba(255, 255, 255, 0.06);
}
.dark-mode .mv-fb-base-right {
    border-left-color: rgba(255, 255, 255, 0.06);
}

.mv-fb-base-page:active {
    cursor: grabbing;
}

/* Double-Sided Turning Sheet (The True 3D Page Turn) */
.mv-fb-turning-sheet {
    position: absolute;
    top: 0;
    width: 50%;
    height: 100%;
    transform-style: preserve-3d;
    -webkit-transform-style: preserve-3d;
    z-index: 15;
    pointer-events: none;
    will-change: transform;
}

/* Forward Turn: Anchored at Center Spine (Turning from Right to Left) */
.mv-fb-turning-sheet.mv-turn-forward {
    left: 50%;
    transform-origin: left center;
}

/* Backward Turn: Anchored at Center Spine (Turning from Left to Right) */
.mv-fb-turning-sheet.mv-turn-backward {
    left: 0;
    transform-origin: right center;
}

/* Front and Back Faces of the Turning Sheet */
.mv-fb-face {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-sizing: border-box;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.dark-mode .mv-fb-face {
    background-color: #161b2a;
}

/* Front Face */
.mv-fb-face-front {
    transform: rotateY(0deg);
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.15);
}

/* Back Face */
.mv-fb-face-back {
    transform: rotateY(180deg);
    box-shadow: 5px 0 25px rgba(0, 0, 0, 0.15);
}

.dark-mode .mv-fb-face-front,
.dark-mode .mv-fb-face-back {
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
}

/* Dynamic Paper Cast Shadow */
.mv-fb-sheet-shadow {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.1s linear;
    z-index: 5;
}

/* Manga Page Images */
.mv-fb-base-page img,
.mv-fb-face img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    margin: auto;
    pointer-events: none;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,0.04));
}

/* Seamless Ad Page Leaf Container (Renders as a clean normal slide) */
.mv-fb-base-page.mv-fb-ad-leaf,
.mv-fb-face.mv-fb-ad-leaf {
    background-color: transparent;
    padding: 0;
    cursor: grab;
    pointer-events: auto;
    z-index: 20;
}

.mv-fb-ad-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    text-align: center;
    position: relative;
    pointer-events: auto;
    cursor: grab;
}

.mv-fb-ad-content {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    max-height: 100%;
    overflow: visible;
    pointer-events: auto !important;
    cursor: pointer !important;
    position: relative;
    z-index: 30;
}

.mv-fb-ad-content * {
    pointer-events: auto !important;
    cursor: pointer !important;
}

/* Bottom Toolbar & Modern Slim Scrubber (Explicit Form Reset) */
.mv-fb-toolbar {
    width: 100%;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--mv-color-background);
    border-top: 1px solid var(--mv-color-border-light);
    gap: 15px;
    flex-wrap: wrap;
    z-index: 30;
    box-sizing: border-box;
}

.dark-mode .mv-fb-toolbar {
    background-color: var(--mv-dark-background);
    border-top-color: var(--mv-dark-border);
}

.mv-fb-page-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--mv-color-text);
}

.dark-mode .mv-fb-page-info {
    color: var(--mv-dark-text);
}

.mv-fb-page-pill {
    background-color: var(--mv-color-background-alt);
    padding: 5px 12px;
    border-radius: 14px;
    border: 1px solid var(--mv-color-border-light);
    font-size: 0.82rem;
}

.dark-mode .mv-fb-page-pill {
    background-color: var(--mv-dark-background-alt);
    border-color: var(--mv-dark-border);
}

/* Explicit Reset to Override WordPress Input Rules and Eliminate the Gray Box */
input[type="range"].mv-fb-scrubber {
    -webkit-appearance: none !important;
    appearance: none !important;
    flex: 1 1 200px !important;
    max-width: 450px !important;
    width: 100% !important;
    height: 4px !important;
    min-height: 4px !important;
    max-height: 4px !important;
    border-radius: 2px !important;
    background: var(--mv-color-border) !important;
    border: none !important;
    outline: none !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    cursor: pointer !important;
}

.dark-mode input[type="range"].mv-fb-scrubber {
    background: var(--mv-dark-border) !important;
}

input[type="range"].mv-fb-scrubber::-webkit-slider-thumb {
    -webkit-appearance: none !important;
    appearance: none !important;
    width: 16px !important;
    height: 16px !important;
    border-radius: 50% !important;
    background: var(--mv-color-primary) !important;
    cursor: pointer !important;
    border: none !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25) !important;
    margin-top: 0 !important;
}

.dark-mode input[type="range"].mv-fb-scrubber::-webkit-slider-thumb {
    background: var(--mv-dark-primary) !important;
}

input[type="range"].mv-fb-scrubber::-moz-range-thumb {
    width: 16px !important;
    height: 16px !important;
    border-radius: 50% !important;
    background: var(--mv-color-primary) !important;
    cursor: pointer !important;
    border: none !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25) !important;
}

.dark-mode input[type="range"].mv-fb-scrubber::-moz-range-thumb {
    background: var(--mv-dark-primary) !important;
}

/* Mobile Responsive Single-Page Reader (Matching StPageFlip Portrait Mode) */
@media (max-width: 768px) {
    .mv-fb-stage {
        height: 74vh;
        min-height: 460px;
        padding: 10px 5px;
    }

    .mv-fb-spread {
        width: 100%;
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
        background: #ffffff;
    }

    .dark-mode .mv-fb-spread {
        background: #121624;
    }

    .mv-fb-spread::after {
        display: none;
    }

    .mv-fb-base-page {
        width: 100%;
        left: 0;
        border: none;
    }

    .mv-fb-base-right {
        display: none;
    }

    /* Full-Width Mobile Turning Sheet */
    .mv-fb-turning-sheet {
        width: 100%;
        display: none;
    }

    .mv-fb-turning-sheet.mv-mobile-turn-forward {
        left: 0;
        transform-origin: left center;
    }

    .mv-fb-turning-sheet.mv-mobile-turn-backward {
        left: 0;
        transform-origin: right center;
    }

    .mv-fb-toolbar {
        padding: 10px 15px;
        flex-direction: column;
        gap: 8px;
        border-top: none;
    }

    input[type="range"].mv-fb-scrubber {
        width: 90% !important;
        max-width: 100% !important;
        margin: 4px auto 0 !important;
    }
}