/* Bento Box Gallery Styles */
.gallery-wrapper {
    max-width: 1400px;
    margin: 3rem auto;
    padding: 0 1rem;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    grid-auto-rows: 200px;
    gap: 0.3rem;
    grid-auto-flow: dense;
}

.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.45);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border: 1.5px solid rgba(255, 255, 255, 0.35);
    box-shadow: 
        0 8px 32px rgba(44, 62, 80, 0.12),
        0 2px 0 rgba(255, 255, 255, 0.25) inset;
    transition: all 0.4s cubic-bezier(0.25, 0.72, 0.22, 1);
    cursor: zoom-in;
}

.gallery-item img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
    filter: saturate(105%) contrast(102%) brightness(99%);
    transition: all 0.6s cubic-bezier(0.25, 0.72, 0.22, 1);
}

.gallery-item figcaption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1.2em 1.5em;
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1rem;
    letter-spacing: 0.5px;
    color: #293b25;
    background: linear-gradient(
        180deg, 
        rgba(255, 255, 255, 0) 0%, 
        rgba(255, 255, 255, 0.85) 60%,
        rgba(255, 255, 255, 0.95) 100%
    );
    backdrop-filter: blur(8px) saturate(160%);
    -webkit-backdrop-filter: blur(8px) saturate(160%);
    opacity: 0;
    transform: translateY(100%);
    transition: all 0.4s cubic-bezier(0.25, 0.72, 0.22, 1);
    font-weight: 500;
    text-shadow: 0 1px 4px rgba(255, 255, 255, 0.8);
}

/* Hide empty captions */
.gallery-item figcaption:empty {
    display: none;
}

/* Bento Box Size Variants */
.gallery-item.large {
    grid-column: span 2;
    grid-row: span 2;
}

.gallery-item.wide {
    grid-column: span 2;
}

.gallery-item.tall {
    grid-row: span 2;
}

/* Hover Effects */
.gallery-item:hover {
    transform: translateY(-8px);
    box-shadow: 
        0 20px 40px -8px rgba(44, 62, 80, 0.25),
        0 4px 16px rgba(44, 62, 80, 0.12),
        0 2px 0 rgba(255, 255, 255, 0.35) inset;
    border-color: rgba(157, 212, 145, 0.4);
}

.gallery-item:hover img {
    transform: scale(1.05);
    filter: saturate(115%) contrast(108%) brightness(102%);
}

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

/* Elegant focus ring for accessibility */
.gallery-item:focus {
    outline: 3px solid rgba(157, 212, 145, 0.6);
    outline-offset: 4px;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fit, minmax(440px, 1fr));
        grid-auto-rows: 180px;
    }
    .gallery-item.large {
        grid-column: span 2;
        grid-row: span 2;
    }
}

@media (max-width: 900px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
        grid-auto-rows: 160px;
        gap: 0.15rem;
    }
    .gallery-wrapper {
        padding: 0 0.5rem;
    }
    .gallery-item.large,
    .gallery-item.wide {
        grid-column: span 1;
    }
    .gallery-item.large,
    .gallery-item.tall {
        grid-row: span 1;
    }
}

@media (max-width: 600px) {
    .gallery-wrapper {
        padding: 0 0.1rem;
    }
    .gallery-grid {
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
        grid-auto-rows: 140px;
        gap: 0.1rem;
    }
    .gallery-item figcaption {
        font-size: 0.9rem;
        padding: 1em 1.2em;
    }
}

/* Lightbox Styles with Liquid Glass Theme */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    display: none;
    animation: lightboxFadeIn 0.4s cubic-bezier(0.25, 0.72, 0.22, 1);
}

.lightbox.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(44, 62, 80, 0.85);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    cursor: pointer;
}

.lightbox-container {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(25px) saturate(180%);
    -webkit-backdrop-filter: blur(25px) saturate(180%);
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-radius: 24px;
    box-shadow: 
        0 20px 60px -12px rgba(44, 62, 80, 0.35),
        0 8px 32px rgba(44, 62, 80, 0.15),
        0 2px 0 rgba(255, 255, 255, 0.3) inset;
    overflow: hidden;
    animation: lightboxZoomIn 0.5s cubic-bezier(0.25, 0.72, 0.22, 1);
    margin: 0 auto;
}

.lightbox-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 4rem;
    box-sizing: border-box;
}

#lightbox-image {
    max-width: calc(100% - 4rem);
    max-height: calc(90vh - 160px);
    object-fit: contain;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(44, 62, 80, 0.2);
    background: rgba(255, 255, 255, 0.1);
    display: block;
    margin: 0 auto;
}

.lightbox-caption {
    margin-top: 1.5rem;
    padding: 0.8rem 1.5rem;
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.2rem;
    font-weight: 500;
    color: #293b25;
    text-align: center;
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(12px) saturate(160%);
    -webkit-backdrop-filter: blur(12px) saturate(160%);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    letter-spacing: 0.5px;
    text-shadow: 0 1px 3px rgba(255, 255, 255, 0.8);
}

.lightbox-counter {
    margin-top: 1rem;
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 0.9rem;
    color: rgba(41, 59, 37, 0.8);
    text-align: center;
}

/* Navigation Buttons */
.lightbox-close,
.lightbox-prev,
.lightbox-next {
    position: absolute;
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border: 1.5px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.72, 0.22, 1);
    z-index: 10001;
    color: #293b25;
    box-shadow: 
        0 4px 16px rgba(44, 62, 80, 0.15),
        0 1px 0 rgba(255, 255, 255, 0.4) inset;
}

.lightbox-close {
    top: 1rem;
    right: 1rem;
}

.lightbox-prev {
    top: 50%;
    left: 1rem;
    transform: translateY(-50%);
}

.lightbox-next {
    top: 50%;
    right: 1rem;
    transform: translateY(-50%);
}

.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover {
    background: rgba(255, 255, 255, 0.4);
    border-color: rgba(157, 212, 145, 0.5);
    transform: translateY(-50%) scale(1.1);
    box-shadow: 
        0 8px 24px rgba(44, 62, 80, 0.2),
        0 2px 0 rgba(255, 255, 255, 0.5) inset;
}

.lightbox-close:hover {
    transform: scale(1.1);
}

.lightbox-close .material-icons,
.lightbox-prev .material-icons,
.lightbox-next .material-icons {
    font-size: 24px;
}

/* Animations */
@keyframes lightboxFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes lightboxZoomIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .lightbox-container {
        max-width: 95vw;
        max-height: 95vh;
    }

    .lightbox-content {
        padding: 1.5rem 3rem;
    }

    #lightbox-image {
        max-width: calc(100% - 2rem);
        max-height: calc(95vh - 120px);
    }

    .lightbox-caption {
        font-size: 1rem;
        padding: 0.6rem 1rem;
    }

    .lightbox-close,
    .lightbox-prev,
    .lightbox-next {
        width: 40px;
        height: 40px;
    }

    .lightbox-close .material-icons,
    .lightbox-prev .material-icons,
    .lightbox-next .material-icons {
        font-size: 20px;
    }
}