/* Theme kit: sliders and timelines in imported page content, served at /_theme/_kit/sliders.css.

   Pages imported from another site keep the markup of the slider library that site ran (Swiper,
   Slick, Owl, Bootstrap's carousel, Splide, Glide), but never its script: block HTML is sanitised
   and the CSP allows no inline script. Without the library that markup is a tall stack of slides
   or a row wider than the page. Here each one becomes a horizontal row that scrolls and snaps to a
   slide - by touch, trackpad, Shift+wheel or its scrollbar - with no script at all. sliders.js then
   adds Previous/Next buttons, arrow keys and labels for screen readers.

   Only the library's own pre-start markup is matched, and a container its library has started
   (swiper-initialized, slick-initialized, owl-loaded, is-initialized...) is left alone, so a theme
   that loads the real library keeps it. Colours come from the theme (--k-*) when there is one,
   else from the default layout's --primary-color. */

:root {
    --k-slider-gap: 1rem;
}

/* --- the track: one row of slides that scrolls sideways and snaps ---------------------- */
.timeline-slider:not(.slick-initialized),
.slick-carousel:not(.slick-initialized),
.owl-carousel:not(.owl-loaded),
.swiper:not(.swiper-initialized):not(.swiper-container-initialized) > .swiper-wrapper,
.swiper-container:not(.swiper-initialized):not(.swiper-container-initialized) > .swiper-wrapper,
.carousel:not([data-bs-ride]):not([data-ride]) > .carousel-inner,
.splide:not(.is-initialized) .splide__list,
.glide:not(.glide--slider):not(.glide--carousel) .glide__slides {
    display: flex;
    flex-wrap: nowrap;
    gap: var(--k-slider-gap);
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
    position: relative;
    width: auto;
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
    padding: 0 0 0.75rem;
    list-style: none;
    transform: none;
}

/* --- a slide: a whole one per view; card sliders show two at a time on a wide screen ---- */
.timeline-slider:not(.slick-initialized) > *,
.slick-carousel:not(.slick-initialized) > *,
.owl-carousel:not(.owl-loaded) > *,
.swiper:not(.swiper-initialized):not(.swiper-container-initialized) > .swiper-wrapper > *,
.swiper-container:not(.swiper-initialized):not(.swiper-container-initialized) > .swiper-wrapper > *,
.carousel:not([data-bs-ride]):not([data-ride]) > .carousel-inner > *,
.splide:not(.is-initialized) .splide__list > *,
.glide:not(.glide--slider):not(.glide--carousel) .glide__slides > * {
    /* flex-basis wins over a width the library wrote inline when the page was saved */
    flex: 0 0 100%;
    min-width: 0;
    max-width: 100%;
    margin: 0;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    /* Bootstrap hides every carousel item but the active one; here they all stay in the row */
    display: block;
    float: none;
    transform: none;
}
@media (min-width: 62em) {
    .owl-carousel:not(.owl-loaded) > *,
    .swiper:not(.swiper-initialized):not(.swiper-container-initialized) > .swiper-wrapper > *,
    .swiper-container:not(.swiper-initialized):not(.swiper-container-initialized) > .swiper-wrapper > *,
    .splide:not(.is-initialized) .splide__list > *,
    .glide:not(.glide--slider):not(.glide--carousel) .glide__slides > * {
        flex-basis: calc((100% - var(--k-slider-gap)) / 2);
    }
}
:is(.timeline-slider, .slick-carousel, .owl-carousel, .swiper-wrapper, .carousel-inner, .splide__list, .glide__slides) img {
    display: block;
    max-width: 100%;
    height: auto;
    margin-left: auto;
    margin-right: auto;
}

/* Copies a library made for its endless loop, and its own controls: inert without its script.
   Only where the library has not started - a started one needs its loop copies. */
:is(.timeline-slider:not(.slick-initialized), .slick-carousel:not(.slick-initialized), .owl-carousel:not(.owl-loaded),
    .swiper:not(.swiper-initialized):not(.swiper-container-initialized) > .swiper-wrapper,
    .swiper-container:not(.swiper-initialized):not(.swiper-container-initialized) > .swiper-wrapper,
    .carousel:not([data-bs-ride]):not([data-ride]) > .carousel-inner,
    .splide:not(.is-initialized) .splide__list,
    .glide:not(.glide--slider):not(.glide--carousel) .glide__slides)
    > :is(.slick-cloned, .swiper-slide-duplicate, .cloned, .glide__slide--clone),
.swiper:not(.swiper-initialized):not(.swiper-container-initialized) > :is(.swiper-pagination, .swiper-button-prev, .swiper-button-next, .swiper-scrollbar),
.swiper-container:not(.swiper-initialized):not(.swiper-container-initialized) > :is(.swiper-pagination, .swiper-button-prev, .swiper-button-next, .swiper-scrollbar),
.carousel:not([data-bs-ride]):not([data-ride]) > :is(.carousel-indicators, .carousel-control-prev, .carousel-control-next),
.splide:not(.is-initialized) :is(.splide__arrows, .splide__pagination),
.glide:not(.glide--slider):not(.glide--carousel) :is(.glide__arrows, .glide__bullets) {
    display: none !important;
}

/* --- with sliders.js: the controls, and no scrollbar now there are buttons ------------- */
.k-slider { position: relative; max-width: 100%; }
.k-slider [data-k-slider-track] { scrollbar-width: none; }
.k-slider [data-k-slider-track]::-webkit-scrollbar { display: none; }
.k-slider__controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 0.75rem;
}
.k-slider__controls[hidden] { display: none; }
.k-slider__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: 0 0.75rem;
    border: 2px solid var(--k-primary, var(--primary-color, #333333));
    border-radius: var(--k-radius, 6px);
    background-color: var(--k-primary, var(--primary-color, #333333));
    color: var(--k-on-primary, #ffffff);
    font: inherit;
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
}
.k-slider__button:hover { background-color: var(--k-text, #1f2328); border-color: var(--k-text, #1f2328); }
.k-slider__button:focus-visible { outline: 3px solid var(--k-accent, var(--primary-color, #333333)); outline-offset: 2px; }
.k-slider__button[aria-disabled="true"] {
    background-color: transparent;
    color: var(--k-primary, var(--primary-color, #333333));
    opacity: 0.45;
    cursor: default;
}
.k-slider__status { min-width: 4.5em; text-align: center; font-variant-numeric: tabular-nums; color: var(--k-muted, inherit); }
.k-slider [data-k-slider-track]:focus-visible { outline: 3px solid var(--k-accent, var(--primary-color, #333333)); outline-offset: 2px; }

/* Smooth only when the visitor has not asked for less motion (sliders.js asks the same). */
@media (prefers-reduced-motion: no-preference) {
    .k-slider [data-k-slider-track] { scroll-behavior: smooth; }
}

/* --- print: every slide, one below the other, and no buttons --------------------------- */
@media print {
    .timeline-slider, .slick-carousel, .owl-carousel, .swiper-wrapper, .carousel-inner, .splide__list, .glide__slides {
        display: block !important;
        overflow: visible !important;
    }
    :is(.timeline-slider, .slick-carousel, .owl-carousel, .swiper-wrapper, .carousel-inner, .splide__list, .glide__slides) > * {
        display: block !important;
        width: auto !important;
        margin: 0 0 1rem !important;
        break-inside: avoid;
    }
    .k-slider__controls { display: none !important; }
}
