/* ==========================================================================
   ACF Gallery Block
   Layout: 2 full squares + half of 3rd visible → arrows → lightbox
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS Custom Properties
   -------------------------------------------------------------------------- */
.acf-gallery-block {
    --gallery-gap: 32px;
    --gallery-arrow-size: 44px;
    --gallery-arrow-offset: -82px;  /* half of arrow size to sit on edge */
    --gallery-radius: 8px;
    --gallery-transition: transform 0.42s cubic-bezier(0.4, 0, 0.2, 1);
    --gallery-accent: #4F2C1D;

    position: relative;
    width: 100%;
}

/* --------------------------------------------------------------------------
   Wrapper – creates the clipping context
   -------------------------------------------------------------------------- */
.acf-gallery__wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

/* --------------------------------------------------------------------------
   Track outer – clips overflow so only 2.5 images are visible
   -------------------------------------------------------------------------- */
.acf-gallery__track-outer {
    overflow: hidden;
    width: 100%;
    /* Small padding on right so the half-image has a visible edge */
}

/* --------------------------------------------------------------------------
   Track – the moving strip of slides
   -------------------------------------------------------------------------- */
.acf-gallery__track {
    display: flex;
    gap: var(--gallery-gap);
    transition: var(--gallery-transition);
    /* will-change for GPU acceleration */
    will-change: transform;
}

/* --------------------------------------------------------------------------
   Slide – each image cell
   Show exactly 2.5 slides:
   width = (100% - 2 * gap) / 2.5
   We use calc with the outer width minus gaps between 2.5 items (= 1.5 gaps)
   -------------------------------------------------------------------------- */
.acf-gallery__slide {
    flex: 0 0 calc((100% - 2 * var(--gallery-gap)) / 3);
    min-width: 0;
}

/* --------------------------------------------------------------------------
   Thumbnail button – makes the image square via aspect-ratio
   -------------------------------------------------------------------------- */
.acf-gallery__thumb-btn {
    display: block;
    width: 100%;
    padding: 0;
    border: none;
    border-radius: var(--gallery-radius);
    background: #f0f0f0;
    overflow: hidden;
    cursor: pointer;
    aspect-ratio: 1 / 1;
    position: relative;
    transition: opacity 0.2s, transform 0.2s;
}

.acf-gallery__thumb-btn:hover {
    opacity: 0.88;
    transform: scale(0.985);
}

.acf-gallery__thumb-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
    transition: transform 0.35s ease;
}

.acf-gallery__thumb-btn:hover img {
    transform: scale(1.04);
}

/* --------------------------------------------------------------------------
   Navigation Arrows (slider)
   -------------------------------------------------------------------------- */
.acf-gallery__arrow {
    position: absolute;
    z-index: 10;
    top: 50%;
    transform: translateY(-50%);
    width: var(--gallery-arrow-size);
    height: var(--gallery-arrow-size);
    border-radius: 50%;
    border: none;
    background: #F6F4F3;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, box-shadow 0.2s, opacity 0.2s;
    padding: 0;
}

.acf-gallery__arrow svg {
    width: 20px;
    height: 20px;
    color: var(--gallery-accent);
    display: block;
}

.acf-gallery__arrow--prev {
    left: var(--gallery-arrow-offset);
}

.acf-gallery__arrow--next {
    right: var(--gallery-arrow-offset);
}

.acf-gallery__arrow:hover {
    background: var(--gallery-accent);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
}

.acf-gallery__arrow:hover svg {
    color: #fff;
}

/* Arrows never disabled in loop mode */

/* --------------------------------------------------------------------------
   LIGHTBOX
   -------------------------------------------------------------------------- */
.acf-gallery__lightbox {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.acf-gallery__lightbox[hidden] {
    display: none;
}

/* Backdrop */
.acf-gallery__lb-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    cursor: pointer;
}

/* Inner container */
.acf-gallery__lb-inner {
    position: relative;
    z-index: 1;
    width: 90vw;
    max-width: 1100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 20px 0;
}

/* Close button */
.acf-gallery__lb-close {
    position: fixed;
    top: 16px;
    right: 20px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.25);
    background: rgba(0,0,0,0.5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, border-color 0.2s;
    padding: 0;
}

.acf-gallery__lb-close svg {
    width: 20px;
    height: 20px;
    color: #fff;
}

.acf-gallery__lb-close:hover {
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.6);
}

/* Stage (image + side arrows) */
.acf-gallery__lb-stage {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.acf-gallery__lb-img-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-height: 70vh;
}

.acf-gallery__lb-img {
    display: block;
    max-width: 100%;
    max-height: 70vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 6px;
    transition: opacity 0.25s ease;
}

.acf-gallery__lb-img.is-loading {
    opacity: 0.25;
}

/* Lightbox arrows */
.acf-gallery__lb-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.3);
    background: rgba(0,0,0,0.5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, border-color 0.2s;
    padding: 0;
}

.acf-gallery__lb-arrow svg {
    width: 22px;
    height: 22px;
    color: #fff;
}

.acf-gallery__lb-arrow--prev { left: -60px; }
.acf-gallery__lb-arrow--next { right: -60px; }

.acf-gallery__lb-arrow:hover {
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.7);
}

.acf-gallery__lb-arrow:disabled {
    opacity: 0.3;
}

/* Counter */
.acf-gallery__lb-counter {
    color: rgba(255,255,255,0.7);
    font-size: 14px;
    font-family: sans-serif;
    letter-spacing: 0.04em;
}

/* Thumbnail strip in lightbox */
.acf-gallery__lb-thumbs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    max-width: 100%;
    padding: 4px 2px 8px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.2) transparent;
}

.acf-gallery__lb-thumbs::-webkit-scrollbar {
    height: 4px;
}
.acf-gallery__lb-thumbs::-webkit-scrollbar-track {
    background: transparent;
}
.acf-gallery__lb-thumbs::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
}

.acf-gallery__lb-thumb {
    flex: 0 0 64px;
    width: 64px;
    height: 64px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 5px;
    background: rgba(255,255,255,0.1);
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.2s;
    opacity: 0.6;
}

.acf-gallery__lb-thumb.is-active {
    border-color: #fff;
    opacity: 1;
    transform: scale(1.07);
}

.acf-gallery__lb-thumb:hover {
    opacity: 0.9;
}

.acf-gallery__lb-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

/* --------------------------------------------------------------------------
   Responsive — on small screens show 1.3 images
   -------------------------------------------------------------------------- */
@media (max-width: 600px) {
    .acf-gallery-block {
        --gallery-gap: 8px;
        --gallery-arrow-size: 36px;
        --gallery-arrow-offset: -4px;
    }

    /* Show 1.3 images on mobile */
    .acf-gallery__slide {
        flex: 0 0 100%;
    }

    .acf-gallery__lb-arrow--prev { left: -4px; }
    .acf-gallery__lb-arrow--next { right: -4px; }

    .acf-gallery__lb-arrow {
        width: 38px;
        height: 38px;
        background: rgba(0,0,0,0.65);
        border-color: rgba(255,255,255,0.4);
    }

    .acf-gallery__lb-arrow svg {
        width: 18px;
        height: 18px;
    }
}

/* Body scroll lock when lightbox open */
body.acf-gallery-open {
    overflow: hidden;
}