/* Gallery template (gallery.php) */

.gallery-page__title {
    font-weight: 700;
    color: #6d676a;
}

.gallery-page__empty {
    margin: 0 0 3rem;
    color: #6d676a;
}

.gallery-container {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.25rem;
    width: 100%;
    padding: 0 0 3rem;
    box-sizing: border-box;
    align-items: start;
}

.gallery-item {
    display: flex;
    flex-direction: column;
    min-width: 0;
    width: 100%;
    background: #fff;
}

.gallery-item__trigger {
    display: block;
    width: 100%;
    padding: 0;
    margin: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    text-align: left;
}

.gallery-image {
    display: block;
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    border-radius: 12px;
    background: #f3f3f3;
}

.gallery-item__img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: transform 0.35s ease;
    will-change: transform;
}

.gallery-item__trigger:hover .gallery-item__img,
.gallery-item__trigger:focus-visible .gallery-item__img {
    transform: scale(1.08);
}

.gallery-item__trigger:focus-visible {
    outline: 2px solid #6d676a;
    outline-offset: 3px;
    border-radius: 12px;
}

.gallery-caption {
    flex: 0 0 auto;
    margin-top: 0.5rem;
    font-size: 0.9rem;
    line-height: 1.35;
    color: #333;
    background: var(--mmn-caption-bg, #f7f7f7);
    padding: 0.65rem 1rem;
    box-sizing: border-box;
    overflow-wrap: anywhere;
    word-wrap: break-word;
    hyphens: auto;
}

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

.gallery-lightbox {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    box-sizing: border-box;
}

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

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

.gallery-lightbox__dialog {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: min(92vw, 1200px);
    max-height: 92vh;
    pointer-events: none;
}

.gallery-lightbox__content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-height: 92vh;
    pointer-events: auto;
}

.gallery-lightbox__figure {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    max-width: 100%;
    margin: 0;
    border-radius: 12px;
    overflow: hidden;
    background: rgba(20, 20, 20, 0.92);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.gallery-lightbox__image {
    display: block;
    width: auto;
    max-width: 100%;
    max-height: calc(92vh - 7rem);
    height: auto;
    margin: 0 auto;
    object-fit: contain;
}

.gallery-lightbox__caption {
    margin: 0;
    padding: 0.85rem 1.25rem 1rem;
    max-width: 100%;
    color: #fff;
    font-size: 0.95rem;
    line-height: 1.45;
    text-align: center;
    background: rgba(0, 0, 0, 0.72);
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    box-sizing: border-box;
    overflow-wrap: anywhere;
    word-wrap: break-word;
}

.gallery-lightbox__caption[hidden] {
    display: none !important;
}

.gallery-lightbox__nav,
.gallery-lightbox__close {
    pointer-events: auto;
    border: 0;
    cursor: pointer;
    color: #fff;
    background: rgba(0, 0, 0, 0.55);
    transition: background-color 0.25s ease, transform 0.25s ease;
}

.gallery-lightbox__nav:hover,
.gallery-lightbox__nav:focus-visible,
.gallery-lightbox__close:hover,
.gallery-lightbox__close:focus-visible {
    background: rgba(0, 0, 0, 0.8);
}

.gallery-lightbox__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 50%;
    font-size: 1.5rem;
    line-height: 1;
    z-index: 2;
}

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

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

.gallery-lightbox__close {
    position: absolute;
    top: -0.5rem;
    right: -0.5rem;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    font-size: 1.75rem;
    line-height: 1;
    z-index: 3;
}

@media (max-width: 1024px) {
    .gallery-container {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    .gallery-container {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .gallery-lightbox {
        padding: 0.5rem;
    }

    .gallery-lightbox__dialog {
        width: 100%;
    }

    .gallery-lightbox__nav {
        width: 2.25rem;
        height: 2.25rem;
        font-size: 1.25rem;
    }

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

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

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

    .gallery-lightbox__image {
        max-height: calc(92vh - 8rem);
    }

    .gallery-lightbox__caption {
        font-size: 0.875rem;
        padding: 0.75rem 1rem 0.9rem;
    }
}
