/* Gallery thumbnails */
.gallery-thumb {
    cursor: pointer;
    overflow: hidden; /* clip the hover zoom */
    outline: none;
}
.gallery-thumb:focus-visible {
    outline: 3px solid var(--primary-mid);
    outline-offset: 3px;
    border-radius: var(--border-radius);
}
.gallery-thumb .img-cover {
    transition: transform 0.3s ease;
}
.gallery-thumb:hover .img-cover,
.gallery-thumb:focus-visible .img-cover {
    transform: scale(1.04);
}

/* Gallery Lightbox (native <dialog>) — dialog is display:none when closed, so
   all layout only applies once it is [open]. */
.gallery-lightbox {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    outline: none;
}
.gallery-lightbox[open] {
    display: grid;
    place-items: center;
}
.gallery-lightbox::backdrop {
    background: var(--primary-black-tint);
}
.gallery-lightbox-frame {
    position: relative;
    display: flex;
    flex-direction: column;
    margin: 0;
    max-width: min(94vw, 1400px);
    max-height: 90vh;
}
.gallery-lightbox-img {
    max-width: 94vw;
    max-height: 86vh;
    width: auto;
    height: auto;
    display: block;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.45);
}
.gallery-lightbox-caption {
    color: var(--primary-white-tint);
    text-align: center;
    margin-top: 14px;
    font-size: 1rem;
    max-width: 94vw;
}
.gallery-lightbox-btn {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.6rem;
    height: 2.6rem;
    border: 0;
    border-radius: 50%;
    padding: 0;
    margin: 0;
    cursor: pointer;
    z-index: 2;
    color: var(--primary-white-tint);
    background: var(--primary-mid-dark);
    appearance: none;
    -webkit-appearance: none;
}

.gallery-lightbox-btn .icon {
    top: 0;
}
.gallery-lightbox-btn:hover,
.gallery-lightbox-btn:focus-visible {
    background: var(--primary-mid);
    transition: background 0.2s ease;
}
.gallery-lightbox-close {
    background: rgba(0, 0, 0, 0.45);
    top: 3vw;
    right: 3vw;
}
.gallery-lightbox-close:hover,
.gallery-lightbox-close:focus-visible {
    background: rgba(128, 128, 128, 0.45);
}
.gallery-lightbox-nav {
    top: 50%;
    transform: translateY(-50%);
}
.gallery-lightbox-nav-prev {
    left: 3vw;
}
.gallery-lightbox-nav-next {
    right: 3vw;
}
.gallery-lightbox-counter {
    position: absolute;
    bottom: 4%;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.95rem;
    z-index: 2;
    user-select: none;
}

/* Fallback entrance / exit animation (used when the View Transitions API is unavailable) */
@keyframes galleryZoomIn {
    from { opacity: 0; transform: scale(0.92); }
    to { opacity: 1; transform: scale(1); }
}
@keyframes galleryZoomOut {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0; transform: scale(0.92); }
}
.gallery-lightbox-is-opening {
    animation: galleryZoomIn 220ms ease-out forwards;
}
.gallery-lightbox-is-closing {
    animation: galleryZoomOut 180ms ease-in forwards;
}

@media (max-width: 620px) {
    .gallery-lightbox-btn {
        width: 2.4rem;
        height: 2.4rem;
    }
    .gallery-lightbox-nav-prev {
        left: 2.5vw;
    }
    .gallery-lightbox-nav-next {
        right: 2.5vw;
    }
    .gallery-lightbox-close {
        top: 3%;
        right: 3%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .gallery-thumb:hover .img-cover,
    .gallery-thumb:focus-visible .img-cover {
        transform: none;
    }
    .gallery-lightbox-is-opening,
    .gallery-lightbox-is-closing {
        animation-duration: 0.01ms;
    }
}
