/*
 * Gallery block: masonry_grid / carousel / albums / classic_grid + lightbox.
 *
 * Plain CSS (matches hero.css/documents.css) - no build step in this
 * project, Tailwind is loaded via the CDN Play script.
 */

.gallery-item {
    display: block;
    position: relative;
    width: 100%;
    padding: 0;
    border: none;
    background: none;
    cursor: zoom-in;
    text-align: left;
}

.gallery-item__img {
    display: block;
    width: 100%;
    border-radius: 0.75rem;
}

.gallery-item__caption {
    position: absolute;
    inset: auto 0 0 0;
    padding: 0.6rem 0.75rem;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.65), transparent);
    color: #fff;
    font-size: 0.825rem;
    border-radius: 0 0 0.75rem 0.75rem;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.gallery-item:hover .gallery-item__caption,
.gallery-item:focus-visible .gallery-item__caption {
    opacity: 1;
}

/* ---- classic_grid ------------------------------------------------------ */

.gallery-grid--classic {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

@media (min-width: 640px) {
    .gallery-grid--classic {
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
    }
}

@media (min-width: 1024px) {
    .gallery-grid--classic {
        grid-template-columns: repeat(4, 1fr);
    }
}

.gallery-item--classic {
    aspect-ratio: 4 / 3;
    overflow: hidden;
    border-radius: 0.75rem;
}

.gallery-item--classic .gallery-item__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ---- masonry_grid: CSS multi-column layout keeps each image's natural
   aspect ratio instead of cropping it into a uniform cell. ------------- */

.gallery-grid--masonry {
    column-count: 2;
    column-gap: 0.75rem;
}

@media (min-width: 640px) {
    .gallery-grid--masonry {
        column-count: 3;
        column-gap: 1rem;
    }
}

@media (min-width: 1024px) {
    .gallery-grid--masonry {
        column-count: 4;
    }
}

.gallery-item--masonry {
    break-inside: avoid;
    margin-bottom: 0.75rem;
}

@media (min-width: 640px) {
    .gallery-item--masonry {
        margin-bottom: 1rem;
    }
}

/* ---- carousel ----------------------------------------------------------- */

.gallery-carousel {
    position: relative;
}

.gallery-carousel__viewport {
    overflow: hidden;
    border-radius: 0.75rem;
    touch-action: pan-y;
}

.gallery-carousel__track {
    display: flex;
    transition: transform 0.35s ease;
}

.gallery-carousel__slide {
    flex: 0 0 100%;
    min-width: 0;
}

.gallery-carousel__slide-btn {
    display: block;
    width: 100%;
    padding: 0;
    border: none;
    background: none;
    cursor: zoom-in;
}

.gallery-carousel__img {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 10;
    object-fit: cover;
}

.gallery-carousel__caption {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: #6b7280;
    text-align: center;
}

.gallery-carousel__nav {
    position: absolute;
    top: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    border: none;
    background: rgba(17, 24, 39, 0.35);
    color: #fff;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.gallery-carousel__nav:hover {
    background: rgba(17, 24, 39, 0.6);
}

.gallery-carousel__nav svg {
    width: 1.5rem;
    height: 1.5rem;
}

.gallery-carousel__nav--prev {
    left: 0;
    border-radius: 0.75rem 0 0 0.75rem;
}

.gallery-carousel__nav--next {
    right: 0;
    border-radius: 0 0.75rem 0.75rem 0;
}

.gallery-carousel__thumbs {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-top: 0.75rem;
    padding-bottom: 0.25rem;
}

.gallery-carousel__thumb {
    flex: 0 0 auto;
    width: 4.5rem;
    height: 3.375rem;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 0.5rem;
    overflow: hidden;
    opacity: 0.6;
    cursor: pointer;
    transition: opacity 0.15s ease, border-color 0.15s ease;
}

.gallery-carousel__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.gallery-carousel__thumb:hover {
    opacity: 0.85;
}

.gallery-carousel__thumb.is-active {
    opacity: 1;
    border-color: var(--color-primary, #2563eb);
}

/* ---- albums --------------------------------------------------------------- */

.gallery-albums {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
}

@media (min-width: 640px) {
    .gallery-albums {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .gallery-albums {
        grid-template-columns: repeat(3, 1fr);
    }
}

.gallery-album__trigger {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    padding: 0;
    border: none;
    border-radius: 0.75rem;
    overflow: hidden;
    cursor: pointer;
}

.gallery-album__cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.25s ease;
}

.gallery-album__trigger:hover .gallery-album__cover {
    transform: scale(1.04);
}

.gallery-album__overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 1rem;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0) 55%);
    color: #fff;
    text-align: left;
}

.gallery-album__name {
    font-weight: 700;
    font-size: 1.05rem;
}

.gallery-album__count {
    margin-top: 0.15rem;
    font-size: 0.8rem;
    opacity: 0.9;
}

/* ---- lightbox --------------------------------------------------------- */

.gallery-lightbox {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-lightbox[hidden] {
    display: none;
}

.gallery-lightbox__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
}

body.gallery-lightbox-open {
    overflow: hidden;
}

.gallery-lightbox__figure {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: min(92vw, 1200px);
    max-height: 90vh;
    margin: 0;
    padding: 0 3.5rem;
}

.gallery-lightbox__img {
    display: block;
    max-width: 100%;
    max-height: 80vh;
    border-radius: 0.5rem;
    object-fit: contain;
}

.gallery-lightbox__caption {
    margin-top: 0.75rem;
    color: #f3f4f6;
    font-size: 0.9rem;
    text-align: center;
}

.gallery-lightbox__close,
.gallery-lightbox__nav {
    position: absolute;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 2.75rem;
    min-height: 2.75rem;
    border: none;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.gallery-lightbox__close:hover,
.gallery-lightbox__nav:hover {
    background: rgba(255, 255, 255, 0.25);
}

.gallery-lightbox__close {
    top: 1rem;
    right: 1rem;
}

.gallery-lightbox__nav {
    top: 50%;
    transform: translateY(-50%);
    font-size: 2rem;
}

.gallery-lightbox__nav--prev {
    left: 0.5rem;
}

.gallery-lightbox__nav--next {
    right: 0.5rem;
}

.gallery-lightbox__counter {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    color: #f3f4f6;
    font-size: 0.8rem;
    letter-spacing: 0.03em;
}

@media (max-width: 640px) {
    .gallery-lightbox__figure {
        padding: 0 2.75rem;
    }

    .gallery-lightbox__nav {
        min-width: 2.5rem;
        min-height: 2.5rem;
    }

    .gallery-carousel__nav {
        width: 2.25rem;
    }
}
