/**
 * Gallery block slider ("slidegallery").
 *
 * nav-panel.js converts a core Gallery block into the same fade slider the
 * navigation panels use. The slider rules are scoped to "is-slider-ready",
 * which is only added after the markup has been converted, so a gallery
 * without JavaScript keeps the normal WordPress grid. A small pre-ready
 * block keeps the first image in the slider box while the script loads.
 *
 * The slider fills whatever box it is placed in (100% x 100%). Give the
 * block or its parent a width/height/aspect-ratio if you want a fixed size.
 */

/*
 * Before the slider script runs, keep the gallery in the same 1-up box and
 * show only the first image. Without this the core gallery stacks every
 * image vertically, which can briefly paint a later (portrait) image over
 * the hero area. The scripting media query preserves the normal gallery
 * fallback when JavaScript is disabled.
 */
@media (scripting: enabled) {
    .wp-block-gallery.slidegallery:not(.is-slider-ready) {
        position: relative;
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 0 !important;
        width: 100%;
        height: 100%;
        margin: 0;
        padding: 0;
        overflow: hidden;
        background: none;
        border: 0;
        border-radius: 0;
    }

    .wp-block-gallery.slidegallery:not(.is-slider-ready) > figure.wp-block-image {
        grid-area: 1 / 1;
        width: 100%;
        min-width: 0;
        margin: 0 !important;
        padding: 0;
        overflow: hidden;
    }

    .wp-block-gallery.slidegallery:not(.is-slider-ready) > figure.wp-block-image:not(:first-child) {
        opacity: 0;
        visibility: hidden;
        z-index: 0;
    }

    .wp-block-gallery.slidegallery:not(.is-slider-ready) > figure.wp-block-image:first-child {
        opacity: 1;
        visibility: visible;
        z-index: 1;
    }

    .wp-block-gallery.slidegallery:not(.is-slider-ready) > figure.wp-block-image img {
        display: block;
        width: 100% !important;
        height: 100% !important;
        max-width: none !important;
        margin: 0;
        object-fit: cover;
        object-position: center;
        border: 0;
        border-radius: 0;
        pointer-events: none;
    }
}

/* Softer first paint for the homepage hero gallery. */
@keyframes sf-slidegallery-fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.wp-block-gallery.slidegallery {
    animation: sf-slidegallery-fade-in 1s ease both;
}

.wp-block-gallery.slidegallery.is-slider-ready {
    position: relative;
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 0 !important;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: none;
    border: 0;
    border-radius: 0;
}

.wp-block-gallery.slidegallery.is-slider-ready > figure.wp-block-image {
    grid-area: 1 / 1;
    width: 100%;
    min-width: 0;
    margin: 0 !important;
    padding: 0;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    z-index: 0;
    transition: opacity .65s ease, visibility 0s linear .65s;
}

.wp-block-gallery.slidegallery.is-slider-ready > figure.wp-block-image.is-active {
    opacity: 1;
    visibility: visible;
    z-index: 1;
    transition: opacity .65s ease, visibility 0s;
}

.wp-block-gallery.slidegallery.is-slider-ready > figure.wp-block-image img {
    display: block;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    margin: 0;
    object-fit: cover;
    object-position: center;
    border: 0;
    border-radius: 0;
    pointer-events: none;
}

/* Click-to-zoom is not used inside a slider. */
.wp-block-gallery.slidegallery.is-slider-ready .lightbox-trigger,
.wp-block-gallery.slidegallery.is-slider-ready .wp-lightbox-container button {
    display: none !important;
}

/* Arrows --------------------------------------------------------------- */

.wp-block-gallery.slidegallery.is-slider-ready .sf-nav-slider__arrow {
    position: absolute;
    top: 38px;
    z-index: 4;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    padding: 0;
    margin: 0;
    line-height: 0;
    color: #ffffff;
    background: #053daa;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    cursor: pointer;
    transform: unset !important;
    transition: background .2s ease, color .2s ease, transform .2s ease;
}

.wp-block-gallery.slidegallery.is-slider-ready .sf-nav-slider__arrow--prev {
    right: 90px;
}

.wp-block-gallery.slidegallery.is-slider-ready .sf-nav-slider__arrow--next {
    right: 33px;
}

.wp-block-gallery.slidegallery.is-slider-ready .sf-nav-slider__arrow:hover,
.wp-block-gallery.slidegallery.is-slider-ready .sf-nav-slider__arrow:focus {
    color: #ffffff;
    background: #ff5500;
    transform: translateY(-50%) scale(1.08);
}

.wp-block-gallery.slidegallery.is-slider-ready .sf-nav-slider__arrow svg {
    display: block;
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    stroke: currentColor;
}

.wp-block-gallery.slidegallery.is-slider-ready .sf-nav-slider__arrow:focus-visible,
.wp-block-gallery.slidegallery.is-slider-ready .sf-nav-slider__dot:focus-visible {
    outline: 2px solid #ff5500;
    outline-offset: 3px;
}

/* Dots ---------------------------------------------------------------- */

.wp-block-gallery.slidegallery.is-slider-ready .sf-nav-slider__dots {
    position: absolute;
    left: 33px;
    bottom: 28px;
    z-index: 4;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 9px;
    max-width: calc(100% - 32px);
    padding: 0;
    background: none;
}

.wp-block-gallery.slidegallery.is-slider-ready .sf-nav-slider__dot {
    width: 16px;
    height: 16px;
    padding: 0;
    margin: 0;
    background: #053daa;
    border: 0;
    border-radius: 0;
    cursor: pointer;
    opacity: 1;
    transition: background .25s ease, opacity .25s ease, width .35s ease;
}

.wp-block-gallery.slidegallery.is-slider-ready .sf-nav-slider__dot:hover {
    background: #ff5500;
    opacity: 1;
}

.wp-block-gallery.slidegallery.is-slider-ready .sf-nav-slider__dot.is-active {
    width: 38px;
    background: #ff5500;
    opacity: 1;
}

/* Single image: no slider chrome. */
.wp-block-gallery.slidegallery.is-slider-ready.is-single .sf-nav-slider__arrow,
.wp-block-gallery.slidegallery.is-slider-ready.is-single .sf-nav-slider__dots {
    display: none;
}

@media (max-width: 767px) {
    .wp-block-gallery.slidegallery.is-slider-ready .sf-nav-slider__arrow {
        width: 36px;
        height: 36px;
    }

    .wp-block-gallery.slidegallery.is-slider-ready .sf-nav-slider__arrow svg {
        width: 18px;
        height: 18px;
    }

    .wp-block-gallery.slidegallery.is-slider-ready .sf-nav-slider__arrow--prev {
        left: 12px;
    }

    .wp-block-gallery.slidegallery.is-slider-ready .sf-nav-slider__arrow--next {
        right: 12px;
    }

    .wp-block-gallery.slidegallery.is-slider-ready .sf-nav-slider__dots {
        bottom: 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .wp-block-gallery.slidegallery {
        animation: none;
    }

    .wp-block-gallery.slidegallery.is-slider-ready > figure.wp-block-image,
    .wp-block-gallery.slidegallery.is-slider-ready > figure.wp-block-image.is-active {
        transition: none;
    }
}
