/**
 * [BLOCK STYLE: MODAL]
 * STATUS: HARDENED (Forced Fixed Position)
 */

.block-modal {
    /* CRITICAL: This pulls the modal out of the document flow */
    position: fixed !important; 
    top: 0;
    left: 0;
    width: 100vw; /* Viewport Width */
    height: 100vh; /* Viewport Height */
    
    background-color: var(--modal-overlay, rgba(0, 0, 0, 0.85)); /* Darker overlay */
    z-index: 99999; /* Extremely high to sit on top of everything */
    
    /* Flexbox centering */
    display: none; /* Hidden by default (JS toggles this to Flex) */
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    
    /* Reset any transforms from parent containers */
    transform: none;
    
    /* Animation */
    opacity: 0;
    animation: block-modal-fade-in 0.3s forwards;
    backdrop-filter: blur(5px); /* Optional: Blurs the website behind it */
}

@keyframes block-modal-fade-in {
    to { opacity: 1; }
}

.block-modal__card {
    background: var(--modal-bg, #ffffff);
    color: var(--modal-text, #222);
    border-radius: var(--modal-border-radius, 8px);
    width: 100%;
    position: relative;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5); /* Deep shadow */
    display: flex;
    flex-direction: column;
    max-height: 85vh; /* Prevent it from being taller than screen */
    border: 1px solid rgba(255,255,255,0.1); /* Subtle border */
}

/* --- Header --- */
.block-modal__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 2px solid var(--c-accent, #c5a059);
    background: rgba(0,0,0,0.2);
}

.block-modal__title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #fff;
}

.block-modal__close {
    background: transparent;
    border: none;
    font-size: 2rem;
    line-height: 0.5;
    cursor: pointer;
    color: #fff;
    opacity: 0.5;
    padding: 0.5rem;
    transition: all 0.2s;
}

.block-modal__close:hover {
    opacity: 1;
    color: var(--c-accent, #c5a059);
    transform: rotate(90deg);
}

/* --- Body --- */
.block-modal__body {
    padding: 2rem;
    overflow-y: auto;
    font-size: 1rem;
    line-height: 1.6;
    color: #e2e8f0;
}

/* --- Footer --- */
.block-modal__footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: rgba(0,0,0,0.2);
}

/* --- VARIANTS --- */

/* Dark Mode (Default for this site) */
.block-modal--dark .block-modal__card {
    background: #111827; /* Dark Slate */
    color: #f3f4f6;
}

/* --- VARIANT: BOOK / STORY MODE (Responsive Fix) --- */

/* 1. The Container */
.block-modal--book .block-modal__card {
    background: #0f172a; /* Deep Navy */
    border: 1px solid rgba(255,255,255,0.1);
    color: #fff;
    overflow: hidden;
    /* Reset max-height to ensure it fits mobile screens nicely */
    max-height: 90vh; 
    display: flex;
    flex-direction: column;
}

.block-modal--book .block-modal__body {
    padding: 0;
    display: flex;
    flex-direction: column;
    /* desktop default */
    height: 600px; 
    overflow: hidden;
    position: relative;
    flex: 1; /* Take all available space in the card */
}

/* 2. Top: Static Image */
.book-static-image {
    width: 100%;
    /* DESKTOP HEIGHT */
    height: 300px; 
    flex-shrink: 0;
    position: relative;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.book-static-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* 3. Middle: Swipeable Text Area */
.book-text-slider {
    flex-grow: 1; /* Fill all remaining vertical space */
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    cursor: grab;
    user-select: none;
    scrollbar-width: none;
}
.book-text-slider::-webkit-scrollbar { display: none; }
.book-text-slider.active { cursor: grabbing; scroll-snap-type: none; scroll-behavior: auto; }

/* 4. The Slides */
.book-slide {
    flex: 0 0 100%;
    width: 100%;
    height: 100%; /* Fill the slider height */
    
    scroll-snap-align: center;
    scroll-snap-stop: always;
    
    padding: 2rem;
    box-sizing: border-box;
    
    /* DEFAULT (Desktop): Center text */
    display: flex;
    flex-direction: column;
    justify-content: center; 
    align-items: center;
    
    /* CRITICAL: Allow text to scroll vertically if it's too long */
    overflow-y: auto; 
}

.book-slide p {
    font-size: 1.15rem;
    line-height: 1.8;
    color: #cbd5e1;
    text-align: center;
    max-width: 500px;
    margin: 0 auto;
}

/* 5. Bottom: Pagination */
.book-pagination {
    display: flex;
    justify-content: center;
    gap: 12px;
    padding: 1rem 0 1.5rem 0;
    background: #0f172a;
    flex-shrink: 0; /* Never shrink dots */
    z-index: 10;
}

.book-dot {
    width: 10px; height: 10px; border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.2);
    cursor: pointer; transition: all 0.3s ease;
}
.book-dot.active {
    background-color: var(--c-accent, #c5a059);
    transform: scale(1.2);
}

/* --- MOBILE OPTIMIZATIONS (< 768px) --- */
@media (max-width: 768px) {
    
    /* 1. Modal Body Size */
    .block-modal--book .block-modal__body {
        height: auto; /* Let flexbox handle height */
    }

    /* 2. Shrink Image to give text room */
    .book-static-image {
        height: 200px; /* Much smaller on phone */
    }

    /* 3. Text Slide Adjustment */
    .book-slide {
        display: block; /* Disable Flex centering to prevent top-clipping */
        padding: 1.5rem 1.5rem 4rem 1.5rem; /* Extra bottom padding for safety */
    }
    
    .book-slide p {
        font-size: 1rem; /* Slightly smaller text */
        line-height: 1.6;
    }
}