
/* 
 * "Bento" Grid Gallery (Light Theme)
 * 1 Large + 4 Small items per view.
 * 3 Views per carousel.
 */

body {
    background: linear-gradient(135deg, #fdfbfb 0%, #ebedee 100%); /* Modern Platinum / Cloudy */
    color: #1a202c; /* Dark Text */
    min-height: 100vh;
    font-family: 'Inter', sans-serif;
    margin: 0;
    overflow-x: hidden;
}

.gallery-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px 0 80px 0;
}

.gallery-header {
    padding: 20px 40px;
    margin-bottom: 20px;
}
.gallery-title { 
    font-size: 2rem; 
    font-weight: 700; 
    margin: 0; 
    color: #1a202c; /* Dark Title */
}
.gallery-subtitle { color: #4a5568; margin-top: 5px; } /* Darker gray subtitle */

/* Section & Header */
.video-section { margin-bottom: 60px; }
.section-topic {
    padding: 0 50px;
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: #2d3748; /* Dark Heading */
}
.section-topic:after {
    content: ""; flex-grow: 1; height: 1px; background: rgba(0,0,0,0.1); /* Light divider */
}

/* CAROUSEL CONTAINER */
.section-carousel-container { position: relative; width: 100%; z-index: 1; }
/* INCREASED PADDING BOTTOM TO PREVENT CLIPPING OF POP-DOWN DRAWER */
.carousel-viewport { width: 100%; overflow: hidden; padding: 20px 0 320px 0; }
.grid-wrapper { 
    display: flex; 
    gap: 40px; 
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1); 
}

/* THE "BENTO" MIXED GRID */
.prime-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(2, 220px);
    gap: 20px;
    width: 100%;
    min-width: 100%;
    padding: 0 50px;
    box-sizing: border-box;
    flex-shrink: 0;
    /* Ensure grid items can participate in z-index stacking */
    transform-style: preserve-3d;
}

/* Media Card Styling - LIGHT THEME (Dual Metallic Border) */
.media-card {
    position: relative; border-radius: 12px; 
    overflow: hidden; 
    cursor: pointer;
    background: #ffffff; 
    transition: transform 0.3s, box-shadow 0.3s, z-index 0s;
    border: 2px solid #5b9bd5; 
    box-shadow: 0 0 0 2px #d4afb9, 0 4px 15px rgba(0,0,0,0.08); 
    z-index: 1;
}

/* The First Item (Large) spans 2 cols & 2 rows */
.media-card.featured {
    grid-column: span 2;
    grid-row: span 2;
}

.media-card:hover { 
    transform: scale(1.1); /* Increased bulge per request */
    z-index: 1000; /* Super high z-index */
    overflow: visible; 
    box-shadow: 0 25px 50px rgba(0,0,0,0.25), 0 0 0 2px #d4afb9; 
    border-color: #5b9bd5;
}

/* Internal Card Elements */
.card-media { 
    width: 100%; height: 100%; position: relative; 
    overflow: hidden; 
    border-radius: 10px; 
    background: #e2e8f0; /* LIGHT PLACEHOLDER */
}
.video-poster { 
    width: 100%; height: 100%; object-fit: cover; 
    transition: opacity 0.5s ease; /* Smooth fade out */
    opacity: 1; /* Always start visible */
    position: absolute; top:0; left:0; z-index: 10;
    pointer-events: none; /* Prevent interaction with the poster video */
}
.preview-video { 
    position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; 
    opacity: 0; /* Start hidden */
    transition: opacity 0.5s ease; 
    pointer-events: none;
    display: none; 
    z-index: 5;
}
/* IMPORTANT: Do NOT set opacity: 1 on hover via CSS. Let JS handle it when 'playing' fires. */
.media-card:hover .preview-video { display: block; }

/* Info Drawer - POP DOWN STYLE (Amazon Prime) */
.info-drawer {
    position: absolute; 
    top: 98%; /* Attach to bottom of card */
    left: -2px; right: -2px; /* Slight overlap to cover borders */
    padding: 15px; 
    background: #ffffff; /* Solid White Background */
    color: #1a202c; 
    opacity: 0; 
    visibility: hidden;
    transform: translateY(-10px); 
    transition: all 0.3s ease 0.1s; /* Slight delay */
    
    /* Style the pop-down */
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
    border: 2px solid #5b9bd5;
    border-top: none; /* Merge with card */
    box-shadow: 0 10px 20px rgba(0,0,0,0.15), 0 0 0 2px #d4afb9; /* Match outer ring */
    
    display: flex; flex-direction: column; gap: 8px;
    z-index: 101;
}

/* Flip drawer above card for bottom rows */
.info-drawer.flip-above {
    bottom: 100%;
    top: auto;
    border-top: 2px solid #5b9bd5;
    border-bottom: none;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

/* Show drawer to right of card */
.info-drawer.flip-right {
    left: 100%;
    top: 0;
    bottom: auto;
    width: 300px;
    margin-left: 10px;
    border-left: 2px solid #5b9bd5;
    border-top-right-radius: 12px;
    border-bottom-right-radius: 12px;
}

/* Show drawer to left of card */
.info-drawer.flip-left {
    right: 100%;
    left: auto;
    top: 0;
    bottom: auto;
    width: 300px;
    margin-right: 10px;
    border-right: 2px solid #5b9bd5;
    border-top-left-radius: 12px;
    border-bottom-left-radius: 12px;
}

.media-card:hover .info-drawer { 
    opacity: 1; 
    visibility: visible;
    transform: translateY(0); 
}

/* Ensure hovered card appears above others */
.media-card:hover {
    z-index: 1000;
    position: relative;
}

/* Floating Tooltip - DISABLED (using original info-drawer instead) */
.video-tooltip {
    display: none !important;
}

.tooltip-content {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border: 2px solid #5b9bd5;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2), 0 0 0 2px #d4afb9;
    min-width: 280px;
    max-width: 320px;
    color: #1a202c;
}

.tooltip-content .star-rating {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    color: #f59e0b;
    font-size: 14px;
    font-weight: 600;
}

.tooltip-content .info-title {
    font-size: 16px;
    font-weight: 700;
    color: #1a202c;
    margin-bottom: 8px;
    line-height: 1.3;
}

.tooltip-content .info-meta {
    display: flex;
    gap: 10px;
    font-size: 13px;
    color: #4a5568;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.tooltip-content .quality-badge {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
}

.tooltip-content .director-info {
    font-size: 13px;
    font-weight: 600;
    color: #5b9bd5;
    margin-bottom: 8px;
}

.tooltip-content .video-description {
    font-size: 13px;
    line-height: 1.5;
    color: #374151;
}

.info-header { display: flex; justify-content: space-between; font-size: 0.8rem; color: #238636; font-weight: 700; }
.info-title { font-size: 1rem; font-weight: 700; color: #1a202c; line-height: 1.2; margin-bottom: 6px; }

/* Star Rating */
.star-rating {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
    color: #f5a623; /* Golden color for stars */
    margin: 4px 0;
}
.star-rating i {
    font-size: 0.9rem;
}
.rating-number {
    margin-left: 4px;
    color: #1a202c;
    font-weight: 600;
    font-size: 0.85rem;
}

/* Meta Information */
.info-meta { 
    font-size: 0.75rem; 
    color: #4a5568; 
    display: flex; 
    flex-wrap: wrap;
    gap: 8px; 
    margin-top: 4px; 
    align-items: center;
}
.info-meta i {
    font-size: 0.7rem;
    margin-right: 2px;
}
.quality-badge {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 0.7rem;
}

/* Director Info */
.director-info {
    font-size: 0.75rem;
    color: #2d3748;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    font-style: italic;
}
.director-info i {
    color: #5b9bd5;
    font-size: 0.7rem;
}

/* Video Description */
.video-description {
    font-size: 0.75rem;
    color: #4a5568;
    line-height: 1.3;
    margin: 6px 0 0 0;
    opacity: 0.9;
}

/* Arrows (Visible on sides) - LIGHT THEME */
.section-arrow {
    position: absolute; top: 50%; transform: translateY(-50%);
    width: 44px; height: 44px; 
    background: rgba(255,255,255,0.9); /* White bubble */
    color: #1a202c; /* Dark Icon */
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    cursor: pointer; z-index: 20; 
    border: 1px solid rgba(0,0,0,0.1); 
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    backdrop-filter: blur(4px); transition: all 0.2s;
}
.section-arrow:hover { 
    background: #1f6feb; /* Accent Color */
    color: #fff; 
    transform: translateY(-50%) scale(1.1); 
    box-shadow: 0 6px 15px rgba(31, 111, 235, 0.3);
}
.section-arrow.prev { left: 5px; }
.section-arrow.next { right: 5px; }
.section-arrow.disabled { opacity: 0; pointer-events: none; } /* Hide if no more slides */

/* Pagination (Modern Floating Island) - Matching Auction Page */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 60px auto 30px;
    gap: 8px;
    padding: 12px 24px;
    background: rgba(255,255,255,0.95);
    border-radius: 50px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    width: fit-content;
    border: 1px solid rgba(0,0,0,0.03);
    backdrop-filter: blur(10px);
}
.pagination button {
    min-width: 40px;
    height: 40px;
    padding: 0 14px;
    border: none;
    background: transparent;
    color: #555;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 20px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
}
.pagination button:hover:not(.disabled):not(.active) {
    background: #f5f7fa;
    color: #007bff;
    transform: translateY(-2px);
}
.pagination button.active {
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: #fff;
    box-shadow: 0 4px 12px rgba(0,123,255,0.3);
}
.pagination button.disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}
.pagination .page-jump {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 12px;
    padding: 4px 10px;
    background: rgba(248,248,248,0.8);
    border-radius: 20px;
    border: 1px solid rgba(0,0,0,0.05);
}
.pagination .page-jump label {
    font-size: 13px;
    color: #666;
    font-weight: 500;
    margin: 0;
}
.pagination .page-jump input {
    width: 50px;
    padding: 4px 8px;
    border: 1px solid #ddd;
    border-radius: 6px;
    text-align: center;
    font-size: 13px;
    outline: none;
    background: white;
}
.pagination .page-jump input:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0,123,255,0.1);
}
.pagination .page-jump button {
    padding: 4px 12px;
    background: #007bff;
    color: #fff;
    font-size: 12px;
    min-width: auto;
    height: 28px;
    border-radius: 14px;
}
.pagination .page-jump button:hover {
    background: #0056b3;
    transform: translateY(-1px);
}

/* ===== MOBILE & TABLET RESPONSIVE STYLES ===== */

/* Tablet (768px - 1024px) */
@media (max-width: 1024px) {
    .gallery-container {
        padding: 15px 0 60px 0;
    }
    
    .section-topic {
        font-size: 1.3rem;
        padding: 0 30px;
    }
    
    /* Grid becomes 2 columns */
    .prime-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: auto;
        gap: 15px;
        padding: 0 30px;
    }
    
    /* Featured item still spans 2 columns but only 1 row on tablet */
    .media-card.featured {
        grid-column: span 2;
        grid-row: span 1;
    }
    
    .carousel-viewport {
        padding: 15px 0 250px 0;
    }
    
    .section-arrow {
        width: 38px;
        height: 38px;
        font-size: 16px;
    }
    
    .pagination {
        padding: 10px 18px;
        gap: 6px;
    }
    
    .pagination button {
        min-width: 36px;
        height: 36px;
        font-size: 13px;
    }
}

/* Mobile (max-width: 768px) */
@media (max-width: 768px) {
    .gallery-header {
        padding: 15px 20px;
    }
    
    .gallery-title {
        font-size: 1.5rem;
    }
    
    .section-topic {
        font-size: 1.1rem;
        padding: 0 20px;
        gap: 8px;
    }
    
    /* Grid becomes 2 columns on mobile for more content */
    .prime-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: auto;
        gap: 10px;
        padding: 0 15px;
    }
    
    /* Featured item takes 2 columns */
    .media-card.featured {
        grid-column: span 2;
        grid-row: span 1;
    }
    
    /* Reduce card height on mobile */
    .media-card {
        min-height: 160px;
    }
    
    .carousel-viewport {
        padding: 10px 0 280px 0;
    }
    
    /* Hide carousel arrows on mobile, rely on touch scrolling */
    .section-arrow {
        display: none;
    }
    
    /* Info drawer adjustments for mobile */
    .info-drawer {
        padding: 12px;
        font-size: 0.85rem;
    }
    
    .info-drawer.flip-right,
    .info-drawer.flip-left {
        /* On mobile, always show below or above, never to the side */
        position: absolute;
        left: -2px !important;
        right: -2px !important;
        width: auto !important;
        margin: 0 !important;
    }
    
    .info-title {
        font-size: 0.9rem;
    }
    
    .info-meta,
    .director-info,
    .video-description {
        font-size: 0.7rem;
    }
    
    /* Pagination mobile adjustments - COMPACT */
    .pagination {
        padding: 4px 8px;
        gap: 3px;
        flex-wrap: wrap;
        margin: 20px auto 15px;
    }
    
    .pagination button {
        min-width: 26px;
        height: 26px;
        font-size: 10px;
        padding: 0 6px;
    }
    
    .pagination .page-jump {
        display: none; /* Hide on mobile to keep pagination on one row */
    }
    
    /* Video modal responsive */
    .modal-wrapper {
        width: 95vw !important;
        max-width: 95vw !important;
    }
    
    .modal-header {
        height: 40px;
        padding: 0 12px;
    }
    
    .modal-title {
        font-size: 14px;
    }
    
    .control-btn {
        width: 12px;
        height: 12px;
    }
}

/* Small Mobile (max-width: 480px) */
@media (max-width: 480px) {
    .gallery-title {
        font-size: 1.3rem;
    }
    
    .section-topic {
        font-size: 1rem;
    }
    
    .prime-grid {
        gap: 12px;
        padding: 0 15px;
    }
    
    .info-drawer {
        padding: 10px;
    }
    
    .pagination button {
        min-width: 28px;
        height: 28px;
        padding: 0 8px;
    }
}

/* Touch-friendly enhancements */
@media (hover: none) and (pointer: coarse) {
    /* On touch devices, convert hover to tap */
    .media-card {
        -webkit-tap-highlight-color: transparent;
    }
    
    /* Ensure drawer appears on tap */
    .media-card.tapped .info-drawer {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }
    
    .media-card.tapped .preview-video {
        display: block;
        opacity: 1;
    }
    
    .media-card.tapped .video-poster {
        opacity: 0;
    }
}

/* Video Modal - Clean Implementation */
.video-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    pointer-events: none; /* Clicks pass through background */
}

.video-modal.active {
    display: flex !important; /* Force visibility */
    visibility: visible !important;
    opacity: 1 !important;
}

.modal-wrapper {
    pointer-events: auto; /* Block clicks on player */
    width: 800px;
    max-width: 90vw;
    background: #000;
    border: 1px solid #30363d;
    border-radius: 8px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Force wrapper visibility when modal is active */
.video-modal.active .modal-wrapper {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
}

.modal-header {
    height: 32px;
    background: #161b22;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    cursor: move;
    border-bottom: 1px solid #30363d;
}

.modal-title { font-size: 12px; font-weight: 600; color: #8b949e; }
.window-controls { display: flex; gap: 6px; }
.control-btn { width: 10px; height: 10px; border-radius: 50%; border: none; cursor: pointer; }
.btn-minimize { background: #d29922; }
.btn-maximize { background: #238636; }
.btn-close { background: #da3633; }
.modal-content { flex-grow: 1; position: relative; background: #000; }

.video-modal.minimized {
    align-items: flex-end;
    justify-content: flex-end;
    padding: 20px;
}
.video-modal.minimized .modal-wrapper { width: 300px; }

