/* ========================================= */
/* book.css - v2 (Desktop Fixes)             */
/* ========================================= */

/* --- 1. Base Layout (Same as before) --- */
html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    font-family: 'Inter', sans-serif;
    background-color: #333;
}
body {
    display: flex;
    flex-direction: column;
    margin: 0;
}

/* --- 2. Viewport & Page Styling (Same as before) --- */
.book-viewport {
    flex-grow: 1;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    padding: 1rem;
    min-height: 0;
}

/* Parent <div> */
.book-page {
    display: block;
    position: relative;
    max-width: 100%;
    max-height: 100%;
    overflow: hidden; 
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    opacity: 1;
    /* Updated transition for a smoother fade */
    transition: opacity 0.3s ease-in-out; 
}

.book-page.fading {
    opacity: 0;
}

/* === THE DESKTOP SCALING FIX (Problem 1) === */
.book-page img {
    display: block;
    /* Force the image to fill its parent div */
    width: 100%;
    height: 100%;
    /* This scales the image *inside* the div */
    object-fit: contain; 
    transition: transform 0.2s ease-in-out;
}

/* --- 3. Page Type Classes (THE DESKTOP LOGIC FIX - Problem 2) --- */

/* This resets the img tag for portrait pages */
.portrait-page img {
    width: 100%;
    max-width: 100%;
    transform: translateX(0); /* Reset any mobile transforms */
}

/* This resets the img tag for landscape spreads */
.landscape-spread img {
    width: 100%;
    max-width: 100%;
    transform: translateX(0); /* Reset any mobile transforms */
}

/* --- MOBILE SPLITTING LOGIC (No changes) --- */
.mobile-split-left img,
.mobile-split-right img {
    width: 200%;
    max-width: 200%;
    height: 100%;
    object-fit: cover;
}
.mobile-split-left img {
    transform: translateX(0);
}
.mobile-split-right img {
    transform: translateX(-50%);
}

/* --- 4. Navigation & Close Button (Same as before) --- */
.book-close-btn {
    position: absolute;
    top: 15px;
    right: 25px;
    font-size: 40px;
    color: white;
    cursor: pointer;
    line-height: 1;
    opacity: 0.7;
    transition: opacity 0.2s ease;
    z-index: 2020;
    font-family: Arial, sans-serif;
}
.book-close-btn:hover { opacity: 1; }

.nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    background-color: rgba(255, 255, 255, 0.7);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    z-index: 2005;
}
.nav-arrow:hover { background-color: white; }
.nav-arrow.left-arrow { left: 20px; }
.nav-arrow.right-arrow { right: 20px; }

@media (max-width: 768px) {
    .nav-arrow { display: none; }
}

/* --- 5. UI Controls (Bottom Bar) (Same as before) --- */
.book-ui-controls {
    flex-shrink: 0;
    height: 70px;
    padding: 0 1rem;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 2005;
}

.page-indicator {
    font-family: 'Inter', sans-serif;
    color: #eee;
    font-size: 1rem;
}

.book-download-button {
    font-family: 'Inter', sans-serif;
    display: inline-block;
    padding: 10px 20px;
    background-color: #B8860B;
    color: #1A1A1A;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 700;
    font-size: 0.9rem;
    transition: background-color 0.2s ease;
}
.book-download-button:hover {
    background-color: #dcb036;
}