/*
 * Coaching for Health slider (inc/c4h-slider.php, js/c4h-slider.js).
 *
 * Reproduces what Slider Revolution did here: a full-width band that keeps the
 * old 1240 x 500 proportion at every width, images cropped to fill it, a 300ms
 * cross-fade, and arrows and dots that appear on hover and hide under 600px.
 */

.c4h-slider {
    position: relative;
    z-index: 0;
    overflow: hidden;
    aspect-ratio: 1240 / 500;
    background: #e7e7e7;
}

.c4h-slider__track,
.c4h-slider__slide,
.c4h-slider__link {
    position: absolute;
    inset: 0;
}

.c4h-slider__link {
    display: block;
}

.c4h-slider__slide {
    opacity: 0;
    visibility: hidden;
    transition: opacity 300ms ease, visibility 0s linear 300ms;
}

.c4h-slider__slide.is-active {
    opacity: 1;
    visibility: visible;
    transition: opacity 300ms ease, visibility 0s;
}

/* Slide mode: the new slide pushes the old one out sideways. The script puts
   the incoming slide on the correct side first, so going back slides the
   other way. */
.c4h-slider--slide .c4h-slider__slide {
    opacity: 1;
    transform: translateX(100%);
    transition: transform 600ms ease-in-out, visibility 0s linear 600ms;
}

.c4h-slider--slide .c4h-slider__slide.is-active {
    transform: translateX(0);
    transition: transform 600ms ease-in-out, visibility 0s;
}

/* Jumping straight to a slide with a dot cross-fades instead: sliding past
   the slides in between would look like it went to the wrong one. */
.c4h-slider--slide.is-fading .c4h-slider__slide {
    opacity: 0;
    transform: none;
    transition: opacity 300ms ease, visibility 0s linear 300ms;
}

.c4h-slider--slide.is-fading .c4h-slider__slide.is-active {
    opacity: 1;
    transition: opacity 300ms ease, visibility 0s;
}

.c4h-slider .c4h-slider__img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: cover;
    object-position: center center;
}

/* Controls */

.c4h-slider__controls[hidden] {
    display: none;
}

.c4h-slider__arrow,
.c4h-slider__dot,
.c4h-slider__pause {
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
    padding: 0;
    border: 0;
    font: inherit;
    line-height: 1;
    cursor: pointer;
}

.c4h-slider__arrow,
.c4h-slider__dots {
    opacity: 0;
    transition: opacity 200ms ease;
}

.c4h-slider:hover .c4h-slider__arrow,
.c4h-slider:hover .c4h-slider__dots,
.c4h-slider:focus-within .c4h-slider__arrow,
.c4h-slider:focus-within .c4h-slider__dots {
    opacity: 1;
}

/* No hover on touch screens, so keep the controls showing there. */
@media (hover: none) {
    .c4h-slider__arrow,
    .c4h-slider__dots {
        opacity: 1;
    }
}

.c4h-slider__arrow {
    position: absolute;
    top: 50%;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin-top: -20px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
}

.c4h-slider__arrow:hover,
.c4h-slider__arrow:focus-visible {
    background: #000;
}

.c4h-slider__arrow--prev {
    left: 30px;
}

.c4h-slider__arrow--next {
    right: 30px;
}

.c4h-slider__arrow--next svg {
    transform: scaleX(-1);
}

.c4h-slider__dots {
    position: absolute;
    left: 50%;
    bottom: 30px;
    z-index: 2;
    display: flex;
    gap: 5px;
    transform: translateX(-50%);
}

.c4h-slider__dot {
    box-sizing: content-box;
    width: 12px;
    height: 12px;
    border: 3px solid rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    background: #999;
    box-shadow: 0 0 2px 1px rgba(130, 130, 130, 0.3);
}

.c4h-slider__dot:hover,
.c4h-slider__dot[aria-current="true"] {
    border-color: #000;
    background: #fff;
}

/* Pause/play: an auto-advancing slideshow must be stoppable (WCAG 2.2.2),
   so this one stays visible at every width. */
.c4h-slider__pause {
    position: absolute;
    right: 10px;
    bottom: 10px;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
}

.c4h-slider__pause:hover,
.c4h-slider__pause:focus-visible {
    background: #000;
}

.c4h-slider__icon-play,
.c4h-slider.is-paused .c4h-slider__icon-pause {
    display: none;
}

.c4h-slider.is-paused .c4h-slider__icon-play {
    display: block;
}

.c4h-slider button:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px #000;
}

@media (max-width: 599px) {
    .c4h-slider__arrow,
    .c4h-slider__dots {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .c4h-slider .c4h-slider__slide,
    .c4h-slider .c4h-slider__slide.is-active {
        transition: none !important;
    }
}
