/* gallery items more gap between them */
/*-----------------------------*/

/* WordPress Gallery Spacing and Centering - Universal Solution */
.gallery {
    display: flex;
    flex-wrap: wrap;
    justify-content: center; /* Center gallery horizontally */
    margin: 30px auto !important; /* Center gallery with vertical spacing */
    max-width: 1400px; /* Optional: limit maximum width */
}

/* gallery items shadow */
/*-----------------------------*/

.gallery-item img {
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
    display: block;
    width: 100%;
    height: auto;
}

.gallery-item {
    margin: 6px !important; /* Balanced spacing between items */
    padding: 0 !important;
    position: relative;
    overflow: hidden;
}

.gallery-icon {
    margin-bottom: 0 !important;
}

/* Universal column solution using attribute selector */
.gallery[class*="gallery-columns-"] .gallery-item {
    /* Width will be calculated based on the number of columns */
}

/* Specific column calculations */
.gallery.gallery-columns-1 .gallery-item { width: calc(100% - 20px) !important; }
.gallery.gallery-columns-2 .gallery-item { width: calc(50% - 20px) !important; }
.gallery.gallery-columns-3 .gallery-item { width: calc(33.333% - 30px) !important; }
.gallery.gallery-columns-4 .gallery-item { width: calc(25% - 20px) !important; }
.gallery.gallery-columns-5 .gallery-item { width: calc(20% - 20px) !important; }
.gallery.gallery-columns-6 .gallery-item { width: calc(16.666% - 20px) !important; }
.gallery.gallery-columns-7 .gallery-item { width: calc(14.285% - 20px) !important; }
.gallery.gallery-columns-8 .gallery-item { width: calc(12.5% - 20px) !important; }
.gallery.gallery-columns-9 .gallery-item { width: calc(11.111% - 20px) !important; }

/* Hover overlay for title and description */
.gallery-item-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--primary-color);
    color: #fff;
    padding: 15px;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    z-index: 10;
}

.gallery-item-title {
    font-family: var(--font-family-base);
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 5px;
}

.gallery-item-description {
    font-family: var(--font-family-base);
    font-size: 13px;
    text-align: center;
    line-height: 1.4;
}

/* Show overlay on hover */
.gallery-item:hover .gallery-item-overlay {
    transform: translateY(0);
}

/* Optional: Add subtle hover effect */
.gallery-item img {
    transition: transform 0.3s ease;
    width: 100%;
    height: auto;
    display: block;
}

.gallery-item:hover img {
    transform: scale(1.02);
}

/* Responsive adjustments */
@media (max-width: 1200px) {
    .gallery.gallery-columns-8 .gallery-item,
    .gallery.gallery-columns-9 .gallery-item {
        width: calc(25% - 20px) !important; /* 4 columns on large tablets */
    }
}

@media (max-width: 992px) {
    .gallery.gallery-columns-6 .gallery-item,
    .gallery.gallery-columns-7 .gallery-item {
        width: calc(33.333% - 20px) !important; /* 3 columns on tablets */
    }
}

@media (max-width: 768px) {
    .gallery.gallery-columns-4 .gallery-item,
    .gallery.gallery-columns-5 .gallery-item {
        width: calc(50% - 20px) !important; /* 2 columns on small tablets */
    }
    
    .gallery.gallery-columns-6 .gallery-item,
    .gallery.gallery-columns-7 .gallery-item,
    .gallery.gallery-columns-8 .gallery-item,
    .gallery.gallery-columns-9 .gallery-item {
        width: calc(50% - 20px) !important; /* 2 columns on small tablets */
    }
    
    .gallery-item-title {
        font-size: 14px;
    }
    
    .gallery-item-description {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .gallery[class*="gallery-columns-"] .gallery-item {
        width: calc(100% - 20px) !important; /* 1 column on mobile */
    }
}