/*
 * Masonry Grid Layout CSS - Inspired by Rexiew Tube
 * Modern CSS Grid-based masonry layout for thumbnails
 */

/* Main gallery container - CSS Column Masonry Layout (Rexiew Style) */
#gallery-wrap {
    column-count: 4;
    margin: auto;
    column-gap: 0;
}

/* Individual gallery items */
.gallery-item {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    z-index: 1000;
}

/* Gallery images */
/* .gallery-image {
} */

.gallery-image:hover {
    transform: scale(1.02);
}

/* Overlay elements styling improvements */
.time-since-upload {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    z-index: 20;
    pointer-events: none;
    backdrop-filter: blur(2px);
    transition: opacity 0.3s ease;
}

.view-count {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(139, 69, 19, 0.9);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    z-index: 20;
    pointer-events: none;
    backdrop-filter: blur(2px);
    transition: opacity 0.3s ease;
}

.video-duration {
    position: absolute;
    bottom: 0px;
    right: 8px;
    color: white;
    text-shadow: 1px 1px 0 black;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    z-index: 20;
    pointer-events: none;
    font-family: monospace;
    transition: opacity 0.3s ease;
}

/* Hide overlays on hover for cleaner look */
.gallery-item:hover .time-since-upload,
.gallery-item:hover .view-count,
.gallery-item:hover .video-duration {
    opacity: 0.7;
}

/* Advertisement styling */
.gallery-ad .ad-link {
    display: block;
    text-decoration: none;
    color: inherit;
    position: relative;
}

.gallery-ad .ad-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255, 165, 0, 0.9);
    color: #000;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
    z-index: 20;
    pointer-events: none;
    backdrop-filter: blur(2px);
    border: 1px solid rgba(255, 165, 0, 0.5);
}

.gallery-ad:hover .ad-badge {
    background: rgba(255, 165, 0, 1);
    transform: scale(1.05);
}

.loaded .gallery-ad .ad-image {
    transition: scale 0.25s ease;
}

.gallery-ad:hover .ad-image {
    transform: scale(1.02);
}

/* Responsive column adjustments - Rexiew Style */
@media (min-width: 1250px) {
    #gallery-wrap {
        column-count: 5;
    }
}

@media (max-width: 1000px) {
    #gallery-wrap {
        column-count: 3;
        /* padding: 0 15px; */
    }
}

@media (max-width: 750px) {
    #gallery-wrap {
        column-count: 2;
        /* padding: 0 10px; */
        /* column-gap: 15px; */
    }
    
    .gallery-item[data-media-type="video"]::before {
        font-size: 20px;
        width: 40px;
        height: 40px;
    }
}

@media (max-width: 500px) {
    #gallery-wrap {
        column-count: 1;
        /* padding: 0 5px; */
    }
}

/* Remove the old column-based layout */
.gallery-column {
    display: none !important;
}

/* Enhanced hover effects */
.gallery-item {
    position: relative;
}

/* Grid animation on load */
@keyframes galleryFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.gallery-item {
    animation: galleryFadeIn 0.6s ease forwards;
    animation-delay: calc(var(--item-index, 0) * 0.1s);
}

/* Improved focus states for accessibility */
.gallery-item:focus-within {
    outline: 2px solid #4CAF50;
    outline-offset: 2px;
}