/**
 * Gallery Section Block Styles
 *
 * Full-width white section with a category filter bar and a responsive
 * four-column image grid. The active filter is shown as a rounded blue pill,
 * inactive filters appear as plain text labels.
 *
 * @package ACF Child Theme
 */

:root {
    --color-primary: #3a9bf7;
    --color-grey: #f3f3f3;
    --color-text: #252525;
    --color-white: #ffffff;
    --font-primary: 'Montserrat', sans-serif;
}

/* Section wrapper - full-width white background
   ========================================================================== */
.gallery-section {
    width: 100%;
    margin: 0;
    padding: 80px 0;
    background-color: var(--color-white, #ffffff);
}

.gallery-section__container {
    max-width: var(--theme-normal-container-max-width, 1290px);
    width: var(--theme-container-width, 100%);
    margin: 0 auto;
    padding: 0;
}

/* Category filters
   ========================================================================== */
.gallery-section__filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 0 0 40px 0;
}

.gallery-section__filter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 22px;
    background: transparent;
    border: 0;
    border-radius: 999px;
    font-family: var(--font-primary), 'Montserrat', sans-serif;
    font-size: 18px;
    font-weight: 600;
    line-height: 1;
    color: var(--color-text, #252525);
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.gallery-section__filter:hover,
.gallery-section__filter:focus-visible {
    color: var(--color-primary, #3a9bf7);
    outline: none;
}

.gallery-section__filter.is-active {
    background-color: var(--color-primary, #3a9bf7);
    color: var(--color-white, #ffffff);
}

.gallery-section__filter.is-active:hover,
.gallery-section__filter.is-active:focus-visible {
    background-color: var(--color-primary, #3a9bf7);
    color: var(--color-white, #ffffff);
}

/* Image grid
   ========================================================================== */
.gallery-section__grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

.gallery-section__item {
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: var(--color-grey, #f3f3f3);
    aspect-ratio: 4 / 3;
}

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

.gallery-section__item-trigger {
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    margin: 0;
    border: 0;
    background: transparent;
    cursor: zoom-in;
    overflow: hidden;
    border-radius: inherit;
}

.gallery-section__item-trigger:focus-visible {
    outline: 3px solid var(--color-primary, #3a9bf7);
    outline-offset: 2px;
}

.gallery-section__item img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.gallery-section__item:hover img {
    transform: scale(1.04);
}

/* Lightbox
   ========================================================================== */
.gallery-section__lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 80px;
}

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

.gallery-section__lightbox-overlay {
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.88);
    cursor: zoom-out;
}

.gallery-section__lightbox-figure {
    position: relative;
    z-index: 1;
    margin: 0;
    max-width: 100%;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
}

.gallery-section__lightbox-image {
    display: block;
    max-width: 100%;
    max-height: 80vh;
    width: auto;
    height: auto;
    object-fit: contain;
    background-color: #111;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.gallery-section__lightbox-caption {
    color: var(--color-white, #ffffff);
    font-family: var(--font-primary), 'Montserrat', sans-serif;
    font-size: 15px;
    line-height: 1.5;
    text-align: center;
    max-width: 720px;
    margin: 0;
}

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

.gallery-section__lightbox-close,
.gallery-section__lightbox-nav {
    position: absolute;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background-color: rgba(255, 255, 255, 0.12);
    color: var(--color-white, #ffffff);
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.gallery-section__lightbox-close:hover,
.gallery-section__lightbox-close:focus-visible,
.gallery-section__lightbox-nav:hover,
.gallery-section__lightbox-nav:focus-visible {
    background-color: var(--color-primary, #3a9bf7);
    outline: none;
}

.gallery-section__lightbox-close svg,
.gallery-section__lightbox-nav svg {
    width: 24px;
    height: 24px;
    display: block;
}

.gallery-section__lightbox-close {
    top: 20px;
    right: 20px;
}

.gallery-section__lightbox-nav--prev {
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
}

.gallery-section__lightbox-nav--next {
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
}

.gallery-section__lightbox-nav--prev:hover,
.gallery-section__lightbox-nav--prev:focus-visible,
.gallery-section__lightbox-nav--next:hover,
.gallery-section__lightbox-nav--next:focus-visible {
    transform: translateY(-50%);
}

.gallery-section__lightbox-nav[disabled] {
    opacity: 0.35;
    cursor: default;
    pointer-events: none;
}

/* Lock body scroll while the lightbox is open. */
body.gallery-section-lightbox-open {
    overflow: hidden;
}

/* Responsive - Tablet
   ========================================================================== */
@media (min-width: 769px) and (max-width: 1023px) {
    .gallery-section {
        padding: 60px 0;
    }

    .gallery-section__filters {
        gap: 6px;
        margin-bottom: 32px;
    }

    .gallery-section__filter {
        padding: 9px 18px;
        font-size: 16px;
    }

    .gallery-section__grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }

    .gallery-section__lightbox {
        padding: 50px 70px;
    }

    .gallery-section__lightbox-image {
        max-height: 78vh;
    }
}

/* Responsive - Mobile
   ========================================================================== */
@media (max-width: 768px) {
    .gallery-section {
        padding: 50px 0;
    }

    .gallery-section__filters {
        gap: 4px;
        margin-bottom: 24px;
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .gallery-section__filters::-webkit-scrollbar {
        display: none;
    }

    .gallery-section__filter {
        flex: 0 0 auto;
        padding: 8px 16px;
        font-size: 15px;
    }

    .gallery-section__grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .gallery-section__lightbox {
        padding: 16px;
    }

    .gallery-section__lightbox-image {
        max-height: 70vh;
    }

    .gallery-section__lightbox-close {
        top: 12px;
        right: 12px;
        width: 40px;
        height: 40px;
    }

    .gallery-section__lightbox-close svg,
    .gallery-section__lightbox-nav svg {
        width: 20px;
        height: 20px;
    }

    .gallery-section__lightbox-nav {
        width: 40px;
        height: 40px;
    }

    .gallery-section__lightbox-nav--prev {
        left: 10px;
    }

    .gallery-section__lightbox-nav--next {
        right: 10px;
    }

    .gallery-section__lightbox-caption {
        font-size: 14px;
    }
}
