/* --- Integrated Gallery UI Framework Styles --- */
.banner-carousel {
    position: relative;
    width: 100%;
    height: 450px; 
    background-color: #4a4a4a;
    border-radius: 20px;
    margin-bottom: 30px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    overflow: hidden;
    isolation: isolate;
}

.banner-slide {
    display: none;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    animation: fadeEffect 0.6s ease-in-out;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 1;
}

.banner-slide.active {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
}

.slide-caption {
    width: 100%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.4) 70%, transparent 100%);
    color: white;
    font-size: 1.2rem;
    text-align: center;
    padding: 70px 80px 25px 80px;
    box-sizing: border-box;
    z-index: 2;
}

.carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #ffffff !important;
    font-size: 3rem;
    cursor: pointer;
    user-select: none;
    transition: transform 0.2s, opacity 0.2s;
    z-index: 50 !important;
    text-shadow: 0 2px 8px rgba(0,0,0,0.6);
    opacity: 0.85;
}

.carousel-btn:hover {
    transform: translateY(-50%) scale(1.15);
    opacity: 1;
}

.prev-btn { left: 25px; }
.next-btn { right: 25px; }

/* --- Category Filter Tabs --- */
.filter-container {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    width: 100%;
    flex-wrap: wrap; 
    justify-content: center;
}

.filter-btn {
    background-color: #4a4a4a;
    color: white;
    border: none;
    padding: 10px 18px;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.3s, transform 0.1s;
}

.filter-btn:hover {
    background-color: #333333;
}

.filter-btn.active {
    background-color: #1a1a1a;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.3);
}

/* --- Interactive Content Grid & Overlays --- */
.content-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 25px;
    width: 100%;
}

.grid-item {
    height: 220px;
    border-radius: 15px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    cursor: pointer;
    overflow: hidden;
    position: relative;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 1;
    transform: scale(1);
    transition: opacity 0.4s ease, transform 0.4s ease, filter 0.2s;
}

.grid-item:hover {
    filter: brightness(1.08);
}

.grid-item.hidden {
    opacity: 0;
    transform: scale(0.8);
    position: absolute;
    width: 0;
    height: 0;
    padding: 0;
    margin: 0;
    border: none;
    overflow: hidden;
}

.grid-item-caption {
    width: 100%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.4) 65%, transparent 100%);
    color: white;
    padding: 35px 15px 15px 15px;
    box-sizing: border-box;
}

.grid-item-title {
    font-size: 22px;
    font-weight: 500;
    margin-bottom: 4px;
    text-transform: capitalize;
}

.grid-item-desc {
    font-size: 18px;
    font-weight: 400;
    opacity: 0.9;
    line-height: 1.1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden; 
}

/* --- Fullscreen Fixed Centered Popup Modal --- */
/* --- Fullscreen Fixed Centered Popup Modal --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.85); /* Slightly darker for better layout pop contrast */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 99999 !important;
    padding: 20px;
    box-sizing: border-box;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Base Modal Container Wrapper Box */
.modal-content {
    background-color: #fff; 
    width: 90%;
    max-width: 960px;
    height: auto;
    border-radius: 25px;
    position: relative;
    padding: 0; 
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    box-shadow: 0 15px 40px rgba(0,0,0,0.5);
    overflow: hidden; 
    transform: translateY(30px) scale(0.92);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.2), max-width 0.3s ease;
    isolation: isolate;
}

.modal-overlay.active .modal-content {
    transform: translateY(0) scale(1);
}

/* --- Contextual Layout Sizing Rules for Different Formats --- */

/* 1. Video Specific Presentation (16:9 widescreen scaling configuration) */
.modal-content.media-video {
    max-width: 850px;
}
.modal-content.media-video #modalVideoPlayer {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    display: block !important;
    border: none;
    background-color: #000000;
}

/* 2. PDF Specific Presentation (Taller reading workspace configuration) */
.modal-content.media-pdf {
    max-width: 1000px;
}
.modal-content.media-pdf #modalPdfViewer {
    width: 100%;
    height: 75vh;
    display: block !important;
    border: none;
    background-color: #4a4a4a;
}

/* 3. Image Specific Presentation (Locks down structural aspect layout bounds) */
.modal-content.media-image {
    max-width: 750px;
}
/* This provides a structural aspect height basis so the absolutely positioned container doesn't collapse */
.modal-content.media-image .zoom-container {
    position: relative;
    width: 100%;
    height: 513px; /* Forces standard desktop frame aspect area boundaries */
    display: block !important;
}

/* --- Dedicated Zoom / Panning Canvas Container --- */
.zoom-container {
    width: 100%;
    height: 100%;
    background-size: contain;
    background-color: #fff; 
    background-position: center;
    background-repeat: no-repeat;
    transition: transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transform-origin: center center;
    z-index: 1;
    cursor: grab;
    user-select: none;
}

.zoom-container:active {
    cursor: grabbing;
}

/* --- UI Controls Layout Overlays --- */
.modal-static-ui {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        pointer-events: none; /* Allows click-throughs to content when clicking outside buttons */
        z-index: 100;
    }

    .modal-controls, .modal-close-btn {
        pointer-events: auto; /* Restores clicking behavior specifically for the elements */
    }

    /* Shifted entirely to the right side, aligning right before the close button */
    .modal-controls {
        position: absolute;
        top: 25px;
        right: 95px; /* Positioned to the left of the 50px close button + margin spacing */
        display: flex;
        gap: 8px;
        z-index: 100;
    }

    .control-btn {
        background: rgba(0, 0, 0, 0.6);
        border: 1px solid rgba(255, 255, 255, 0.3);
        color: white;
        width: 38px;
        height: 38px;
        border-radius: 8px;
        font-size: 1.2rem;
        font-weight: bold;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: background 0.2s, transform 0.1s;
        user-select: none;
        backdrop-filter: blur(4px);
    }

    .control-btn:hover {
        background: rgba(0, 0, 0, 0.85);
        transform: scale(1.05);
    }

    .control-btn:active {
        transform: scale(0.95);
    }

    .modal-close-btn {
        position: absolute;
        top: 19px; /* Slightly adjusted to align visually with the center axis of the control buttons */
        right: 30px;
        color: white;
        font-size: 2.5rem;
        font-family: Arial, sans-serif;
        font-weight: bold;
        cursor: pointer;
        user-select: none;
        transition: transform 0.2s, color 0.2s;
        line-height: 1;
        z-index: 100;
        text-shadow: 0 2px 6px rgba(0,0,0,0.5);
        display: flex;
        align-items: center;
        justify-content: center;
        width: 50px;
        height: 50px;
    }

    .modal-close-btn::before {
        content: "";
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        border-radius: 50%;
        background: radial-gradient(circle, rgba(0,0,0,0.4) 0%, rgba(0,0,0,0.1) 50%, transparent 70%);
        z-index: -1;
        pointer-events: none;
    }

    .modal-close-btn:hover { 
        transform: scale(1.15); 
        color: #cccccc; 
    }

    /* --- Responsive Adaptations --- */
    @media (max-width: 600px) {
        .modal-controls {
            top: 20px;
            right: 75px; /* Shifted tracking space dynamically closer for smaller devices */
        }
        .control-btn {
            width: 34px;
            height: 34px;
            font-size: 1.1rem;
        }
        .modal-close-btn {
            top: 12px;
            right: 20px;
            font-size: 2rem;
            width: 44px;
            height: 44px;
        }
    }

@keyframes fadeEffect {
    from { opacity: 0.4; }
    to { opacity: 1; }
}

/* --- Responsive Media Constraints --- */
@media (max-width: 900px) {
    .content-grid { grid-template-columns: repeat(2, 1fr); }
    .banner-carousel { height: 350px; }
    .slide-caption { font-size: 1rem; padding: 50px 40px 20px 40px; }
    .modal-content.media-pdf #modalPdfViewer { height: 65vh; }
}

@media (max-width: 600px) {
    .content-grid { grid-template-columns: 1fr; }
    .banner-carousel { height: 260px; }
    .slide-caption { font-size: 0.85rem; padding: 40px 30px 15px 30px; }
    .carousel-btn { font-size: 2rem; }
    .modal-content.media-image .zoom-container { height: 350px; }
    .modal-text { font-size: 0.95rem; padding: 50px 20px 25px 20px; }
    .modal-close-btn { top: 15px; right: 20px; font-size: 2rem; }
}

@media (max-width: 497px) {
    .modal-content { 
        max-width: 370px;
        width: 95vw;
    }
    .modal-content.media-image .zoom-container { 
        height: 250px; 
    }
}



