/* Gallery Wrapper */
.gallery-wrapper {
    margin: 2rem 0;
    width: 100%;
    box-sizing: border-box;
}

/* Gallery Grid Heading - Match Category Grid Design */
.gallery-grid__heading {
    margin: 0 0 2rem 0;
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
    text-align: left;
}

/* Gallery Container - CSS Grid */
.gallery {
    display: grid;
    width: 100%;
    grid-auto-rows: auto; /* Allow natural image height */
    box-sizing: border-box;
}

/* Grid Column Variants */
.gallery--cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.gallery--cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.gallery--cols-4 {
    grid-template-columns: repeat(4, 1fr);
}

.gallery--cols-5 {
    grid-template-columns: repeat(5, 1fr);
}

.gallery--cols-6 {
    grid-template-columns: repeat(6, 1fr);
}

/* Gap Variants */
.gallery--gap-none {
    gap: 0;
}

.gallery--gap-small {
    gap: 0.5rem;
}

.gallery--gap-medium {
    gap: 1rem;
}

.gallery--gap-large {
    gap: 1.5rem;
}

/* Gallery Item */
.gallery__item {
    margin: 0;
    padding: 0;
    position: relative !important;
    overflow: visible !important;
    border-radius: 0;
    display: block; /* Changed from flex to allow natural height */
}

.gallery__link {
    position: relative; /* Changed from absolute to allow natural height */
    display: block;
    text-decoration: none;
    color: inherit;
    z-index: 3;
    border-radius: 0;
    width: 100%;
}

.gallery__image-wrapper {
    position: relative !important;
    width: 100% !important;
    height: auto !important; /* Changed from 100% to auto for natural height */
    min-height: 0 !important; /* Removed min-height constraint */
    overflow: visible !important;
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}

/* Gallery Image */
.gallery__img {
    width: 100%;
    height: auto; /* Changed from 100% to auto for natural height */
    object-fit: contain; /* Changed from cover to contain to preserve aspect ratio */
    display: block;
    transition: transform 0.3s ease;
}

/* Disable zoom on hover */
.gallery__link:hover .gallery__img,
.gallery__item:hover .gallery__img {
    transform: none;
}

/* New hover effect: subtle lift + shadow on container */
.gallery__item:hover .gallery__image-wrapper,
.gallery__link:hover .gallery__image-wrapper {
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.14);
    transform: translateY(-2px);
}

/* Gallery Overlay - Match Category Grid Design Exactly */
.gallery__overlay {
    position: absolute !important;
    left: 50% !important;
    right: auto !important;
    bottom: 1.5rem !important;
    transform: translateX(-50%) !important;
    padding: 0.875rem 2rem !important;
    z-index: 10 !important;
    border-radius: 50px !important;
    background-color: #ffffff !important;
    color: #000000 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
    display: inline-block !important;
    max-width: calc(100% - 3rem) !important;
    text-align: center !important;
    white-space: nowrap !important;
    transition: all 0.3s ease !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

.gallery__item:hover .gallery__overlay,
.gallery__link:hover .gallery__overlay {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transform: translateX(-50%) translateY(-2px);
}

/* Make overlay clickable when link is provided */
.gallery__link .gallery__overlay {
    pointer-events: auto;
    cursor: pointer;
}

.gallery__title {
    margin: 0 !important;
    font-size: 1rem !important;
    font-weight: 600 !important;
    line-height: 1.3 !important;
    white-space: nowrap !important;
    color: #000000 !important;
    text-align: center !important;
    visibility: visible !important;
    opacity: 1 !important;
    display: block !important;
}

/* Card class for images (matching your example) */
.card {
    border-radius: 0;
}

/* Specific item positioning (optional, for custom layouts) */
.gallery__item--1 {
    /* Can be customized for specific grid layouts */
}

.gallery__item--2 {
    /* Can be customized for specific grid layouts */
}

.gallery__item--3 {
    /* Can be customized for specific grid layouts */
}

.gallery__item--4 {
    /* Can be customized for specific grid layouts */
}

.gallery__item--5 {
    /* Can be customized for specific grid layouts */
}

.gallery__item--6 {
    /* Can be customized for specific grid layouts */
}

/* Preview Mode */
.gallery-preview {
    min-height: 300px;
    background-color: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
}

.gallery-preview__placeholder {
    text-align: center;
    color: #6c757d;
}

.gallery-preview__placeholder i {
    font-size: 3rem;
    display: block;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.gallery-preview__placeholder span {
    display: block;
    font-size: 0.875rem;
}

/* Responsive adjustments */
@media (max-width: 1200px) {
    .gallery--cols-6 {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .gallery--cols-5 {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .gallery__overlay {
        padding: 0.625rem 1.25rem;
        font-size: 0.875rem;
    }
    
    .gallery__title {
        font-size: 0.875rem;
    }
}

@media (max-width: 992px) {
    .gallery--cols-6,
    .gallery--cols-5,
    .gallery--cols-4 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .gallery-wrapper {
        margin: 1rem 0;
    }
    
    .gallery--cols-6,
    .gallery--cols-5,
    .gallery--cols-4,
    .gallery--cols-3 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .gallery--gap-small {
        gap: 0.375rem;
    }
    
    .gallery--gap-medium {
        gap: 0.75rem;
    }
    
    .gallery--gap-large {
        gap: 1rem;
    }
    
    .gallery__overlay {
        padding: 0.625rem 1.5rem;
        bottom: 1rem;
        max-width: calc(100% - 2rem);
    }
    
    .gallery__title {
        font-size: 0.875rem;
    }
}

@media (max-width: 575.98px) {
    .gallery--cols-6,
    .gallery--cols-5,
    .gallery--cols-4,
    .gallery--cols-3,
    .gallery--cols-2 {
        grid-template-columns: 1fr;
    }
    
    .gallery--gap-small {
        gap: 0.25rem;
    }
    
    .gallery--gap-medium {
        gap: 0.5rem;
    }
    
    .gallery--gap-large {
        gap: 0.75rem;
    }
    
    .gallery__overlay {
        padding: 0.625rem 1.5rem;
        bottom: 1rem;
        max-width: calc(100% - 2rem);
    }
    
    .gallery__title {
        font-size: 0.875rem;
    }
}
