/* Modern Masonry Gallery Styles */

/* Gallery Container */
.gallery-masonry-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px;
    display: flex;
    justify-content: center;
    opacity: 0; /* Initially hide the container */
    transition: opacity 0.5s ease-in-out; /* Smooth fade-in */
}

/* Gallery Grid */
.gallery-grid {
    width: 100%;
    margin: 0 auto;
}

/* Gallery Items */
.gallery-item {
    display: block;
    width: 100%;
    margin-bottom: 20px;
    position: relative;
    cursor: pointer;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    opacity: 1 !important; /* Force opacity to be 1 */
    transform: none !important; /* Force no transform */
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* Heights set dynamically via JavaScript for true masonry effect */

/* Animation for gallery items - simplified */
.gallery-item.animated {
    opacity: 1 !important;
    transform: none !important;
}

/* Hover effects */
.gallery-item:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.15);
    z-index: 2;
}

/* Gallery inner wrapper */
.gallery-item-inner {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: 12px;
    padding-bottom: 100%; /* Default ratio */
}

/* Gallery item ratios */
.gallery-item-ratio-1 { padding-bottom: 125%; }
.gallery-item-ratio-2 { padding-bottom: 85%; }
.gallery-item-ratio-3 { padding-bottom: 110%; }
.gallery-item-ratio-4 { padding-bottom: 75%; }
.gallery-item-ratio-5 { padding-bottom: 100%; }
.gallery-item-ratio-6 { padding-bottom: 90%; }
.gallery-item-ratio-7 { padding-bottom: 120%; }
.gallery-item-ratio-8 { padding-bottom: 80%; }
.gallery-item-ratio-9 { padding-bottom: 105%; }
.gallery-item-ratio-10 { padding-bottom: 95%; }
.gallery-item-ratio-11 { padding-bottom: 115%; }

/* Gallery image */
.gallery-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    transition: transform 0.5s ease;
    border-radius: 12px;
}

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

/* Caption styling */
.gallery-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.9), rgba(0,0,0,0.5) 60%, rgba(0,0,0,0) 100%);
    padding: 30px 16px 16px;
    color: white;
    font-size: 0.875rem;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.4s ease, transform 0.4s ease;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.gallery-item:hover .gallery-caption {
    opacity: 1;
    transform: translateY(0);
}

/* Animation delay for staggered effect */
.gallery-item:nth-child(1) { transition-delay: 0ms; }
.gallery-item:nth-child(2) { transition-delay: 100ms; }
.gallery-item:nth-child(3) { transition-delay: 200ms; }
.gallery-item:nth-child(4) { transition-delay: 300ms; }
.gallery-item:nth-child(5) { transition-delay: 400ms; }
.gallery-item:nth-child(6) { transition-delay: 500ms; }
.gallery-item:nth-child(7) { transition-delay: 600ms; }
.gallery-item:nth-child(8) { transition-delay: 700ms; }
.gallery-item:nth-child(9) { transition-delay: 800ms; }
.gallery-item:nth-child(10) { transition-delay: 900ms; }
.gallery-item:nth-child(11) { transition-delay: 1000ms; }
.gallery-item:nth-child(12) { transition-delay: 1100ms; }

/* Responsive layouts */
@media (min-width: 640px) {
    .gallery-item {
        width: calc(50% - 10px);
    }
}

@media (min-width: 1024px) {
    .gallery-item {
        width: calc(33.333% - 16px);
    }
}

/* All items should be visible by default */
.gallery-item.hidden {
    display: block; /* Changed from none to block to ensure all items are visible */
}

/* Load More Button */
#load-more-btn {
    background-color: #8B5D33;
    color: white;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(139, 93, 51, 0.3);
}

#load-more-btn:hover {
    background-color: #6D4A29;
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(139, 93, 51, 0.4);
}

/* Generic animation class - simplified */
.animate-on-scroll {
    opacity: 1 !important;
    transform: none !important;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.animate-on-scroll.animated {
    opacity: 1 !important;
    transform: none !important;
}

/* Lightbox Styles */
.gallery-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.gallery-lightbox.active {
    opacity: 1;
    pointer-events: auto;
}

.lightbox-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-image-container {
    position: relative;
    max-width: 100%;
    max-height: 90vh;
}

#lightbox-image {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.lightbox-caption {
    position: absolute;
    bottom: -40px;
    left: 0;
    right: 0;
    text-align: center;
    color: white;
    font-size: 1rem;
    padding: 10px;
}

.lightbox-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: transparent;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    z-index: 10;
    transition: color 0.2s ease;
}

.lightbox-close:hover {
    color: #f8b400;
}

.lightbox-prev,
.lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease;
}

.lightbox-prev {
    left: -70px;
}

.lightbox-next {
    right: -70px;
}

.lightbox-prev:hover,
.lightbox-next:hover {
    background: rgba(0, 0, 0, 0.8);
}

.lightbox-prev svg,
.lightbox-next svg {
    width: 24px;
    height: 24px;
}

/* Responsive adjustments for the lightbox */
@media (max-width: 640px) {
    .lightbox-prev {
        left: 10px;
    }
    
    .lightbox-next {
        right: 10px;
    }
    
    .lightbox-prev,
    .lightbox-next {
        width: 40px;
        height: 40px;
    }
    
    .lightbox-prev svg,
    .lightbox-next svg {
        width: 20px;
        height: 20px;
    }
}

/* Fix for IE and Edge */
@supports (-ms-ime-align: auto) {
    .gallery-masonry-container {
        display: flex;
        flex-wrap: wrap;
    }
    
    .gallery-item {
        width: 100%;
    }
    
    @media (min-width: 640px) {
        .gallery-item {
            width: calc(50% - 10px);
            margin: 10px;
        }
    }
    
    @media (min-width: 1024px) {
        .gallery-item {
            width: calc(33.333% - 16px);
            margin: 8px;
        }
    }
}
