/**
 * STComponents carousel. Slides hold any markup; image_carousel() fills them with .st-lightbox images.
 * Everything is :where()-wrapped (zero specificity). Custom properties:
 *
 *   --st-carousel-slide-size    slide width; 50% = two per view. Default 100%.
 *   --st-carousel-gap           space between slides. Default 16px.
 *   --st-carousel-btn-size / -btn-color / -btn-bg / -btn-inset / -btn-top
 *
 * Units are px/em, never rem: some sites shrink the root font size.
 */

:where(.st-carousel) {
    position: relative;
    min-width: 0;
}

:where(.st-carousel__stage) {
    position: relative;
}

:where(.st-carousel__viewport) {
    overflow: hidden;
    touch-action: pan-y pinch-zoom;
    cursor: grab;
}

:where(.st-carousel__viewport:active) {
    cursor: grabbing;
}

/* Embla's loop math ignores flex `gap`, which leaves no space at the wrap point.
   Slide padding plus a negative track margin spaces them evenly instead. */
:where(.st-image-carousel) {
    --st-carousel-align-items: center;
}

:where(.st-carousel__track) {
    display: flex;
    align-items: var(--st-carousel-align-items, stretch);
    margin-left: calc(var(--st-carousel-gap, 16px) * -1);
}

:where(.st-carousel__slide) {
    flex: 0 0 var(--st-carousel-slide-size, 100%);
    min-width: 0;
    box-sizing: border-box;
    padding-left: var(--st-carousel-gap, 16px);
}

:where(.st-carousel__button) {
    position: absolute;
    z-index: 2;
    top: var(--st-carousel-btn-top, 50%);
    display: grid;
    place-items: center;
    width: var(--st-carousel-btn-size, 48px);
    height: var(--st-carousel-btn-size, 48px);
    padding: 0;
    border: 0;
    border-radius: 50%;
    color: var(--st-carousel-btn-color, #111);
    background: var(--st-carousel-btn-bg, rgb(255 255 255 / 92%));
    box-shadow: 0 4px 20px rgb(0 0 0 / 18%);
    cursor: pointer;
    transform: translateY(-50%);
    transition:
        opacity 150ms ease,
        background-color 150ms ease;
}

:where(.st-carousel__button:hover) {
    background: var(--st-carousel-btn-bg-hover, #fff);
}

:where(.st-carousel__button:focus-visible) {
    outline: 3px solid currentColor;
    outline-offset: 3px;
}

:where(.st-carousel__button:disabled) {
    opacity: 0;
    pointer-events: none;
}

:where(.st-carousel__button svg) {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
}

:where(.st-carousel__button--prev) {
    left: var(--st-carousel-btn-inset, clamp(8px, 2vw, 16px));
}

:where(.st-carousel__button--next) {
    right: var(--st-carousel-btn-inset, clamp(8px, 2vw, 16px));
}

:where(.st-carousel__counter) {
    margin: 12px 0 0;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

:where(.st-carousel__sr-only) {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

@media (prefers-reduced-motion: reduce) {
    :where(.st-carousel__button) {
        transition: none;
    }
}

/* ── Pill pagination ──────────────────────────────────────────────────── */

:where(.st-carousel__dots) {
    position: relative;
    display: flex;
    justify-content: center;
    margin: 12px 0 0;
}

:where(.st-carousel__dots[hidden]) {
    display: none;
}

:where(.st-carousel__dot) {
    display: block;
    margin: 0;
    padding: 8px calc(var(--st-carousel-dot-gap, 8px) / 2);
    border: 0;
    background: none;
    cursor: pointer;
}

:where(.st-carousel__dot > span) {
    display: block;
    width: var(--st-carousel-dot-size, 10px);
    height: var(--st-carousel-dot-size, 10px);
    border-radius: 999px;
    background: var(--st-carousel-dot-color, #c9ccd6);
    transition: background-color 250ms ease;
}

:where(.st-carousel__dot:hover > span) {
    background: var(--st-carousel-dot-color-hover, #9aa0b2);
}

:where(.st-carousel__dot:focus-visible) {
    outline: 2px solid var(--st-carousel-pill-color, #111);
    outline-offset: 0;
    border-radius: 999px;
}

/* Positioned per frame by JS from the scroll position — no transitions, it rides the scroll. */
:where(.st-carousel__pill) {
    position: absolute;
    top: 0;
    left: 0;
    border-radius: 999px;
    background: var(--st-carousel-pill-color, #111);
    pointer-events: none;
    will-change: transform, width;
}
