/* ========================================
   MASONRY GALLERY GRID - AUTO LAYOUT
   Add this to your gallery.css or use as standalone
======================================== */

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    grid-auto-rows: 250px;
    gap: 20px;
    grid-auto-flow: dense; /* This fills gaps automatically */
}

/* Gallery Items with Auto Sizing */
.gallery-item {
    position: relative;
    border-radius: var(--r-md, 12px);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    
    /* Default: 1x1 - one column, one row */
    grid-column: span 1;
    grid-row: span 1;
}

/* Size variations - Auto applied based on image dimensions */
.gallery-item-large {
    grid-column: span 2;
    grid-row: span 2;
}

.gallery-item-wide {
    grid-column: span 2;
    grid-row: span 1;
}

.gallery-item-tall {
    grid-column: span 1;
    grid-row: span 2;
}

/* Hover Effects */
.gallery-item:hover {
    transform: translateY(-10px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    z-index: 10;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: all 0.5s ease;
}

.gallery-item:hover img {
    transform: scale(1.1);
}

/* Responsive Adjustments */
@media (max-width: 1400px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        grid-auto-rows: 220px;
    }
}

@media (max-width: 1024px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        grid-auto-rows: 200px;
    }
}

@media (max-width: 768px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        grid-auto-rows: 150px;
        gap: 15px;
    }
    
    /* On mobile, reduce size variations for better layout */
    .gallery-item-large {
        grid-column: span 2;
        grid-row: span 2;
    }
    
    .gallery-item-wide,
    .gallery-item-tall {
        grid-column: span 1;
        grid-row: span 1;
    }
}

@media (max-width: 480px) {
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-auto-rows: 150px;
    }
    
    /* Force all items to be uniform on very small screens */
    .gallery-item-large,
    .gallery-item-wide,
    .gallery-item-tall {
        grid-column: span 1;
        grid-row: span 1;
    }
}