/* Masonry Gallery - Beautiful & Functional */
.masonry_gallery {
    display: flex;
    gap: 20px;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    box-sizing: border-box;
}

.masonry_column {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 20px;
    min-width: 0; /* Critical for flexbox */
}

.masonry_item {
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
    position: relative;
}

.masonry_item:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.masonry_item:hover::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, rgba(0,0,0,0.1), rgba(0,0,0,0.3));
    z-index: 1;
}

.masonry_image {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.5s ease;
    cursor: pointer;
}

.masonry_item:hover .masonry_image {
    transform: scale(1.05);
}

/* Lightbox Styles - IMPROVED */
.masonry_lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease;
    padding: 20px;
    box-sizing: border-box;
}

.masonry_lightbox.active {
    display: flex;
    opacity: 1;
    animation: lightboxFadeIn 0.3s ease;
}

@keyframes lightboxFadeIn {
    from {
        opacity: 0;
        backdrop-filter: blur(0px);
    }
    to {
        opacity: 1;
        backdrop-filter: blur(10px);
    }
}

.masonry_lightbox_image {
    max-width: 90%;
    max-height: 85%;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    transition: transform 0.4s ease;
    cursor: default;
}

.masonry_lightbox.active .masonry_lightbox_image {
    transform: scale(1);
    animation: imageZoomIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes imageZoomIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.masonry_lightbox_close {
    position: absolute;
    top: 25px;
    right: 25px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    font-size: 32px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 10001;
}

.masonry_lightbox_close:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: rotate(90deg) scale(1.1);
}

.masonry_lightbox_caption {
    position: absolute;
    bottom: 30px;
    left: 0;
    width: 100%;
    text-align: center;
    color: white;
    font-size: 18px;
    font-weight: 500;
    padding: 15px 30px;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
}

/* Loading animation */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.masonry_item {
    animation: fadeIn 0.5s ease forwards;
}

.masonry_item:nth-child(odd) {
    animation-delay: 0.1s;
}

.masonry_item:nth-child(even) {
    animation-delay: 0.2s;
}

/* Responsive */
@media (max-width: 768px) {
    .masonry_gallery {
        flex-direction: column;
        padding: 15px;
        gap: 15px;
    }
    
    .masonry_column {
        gap: 15px;
    }
    
    .masonry_item {
        border-radius: 10px;
    }
    
    .masonry_lightbox_close {
        top: 15px;
        right: 15px;
        width: 45px;
        height: 45px;
    }
    
    .masonry_lightbox_caption {
        bottom: 20px;
        font-size: 16px;
        padding: 12px 20px;
    }
}