/* Image carousel: a continuously scrolling banner of equal-height photos. */

.image-carousel-section {
    --carousel-height: 14rem;
    --carousel-gap: 1rem;
    padding-top: 4rem;
    padding-bottom: 4rem;
}

@media (min-width: 640px) {
    .image-carousel-section {
        --carousel-height: 18rem;
        padding-top: 2.5rem;
        padding-bottom: 2.5rem;
    }
}

@media (min-width: 1024px) {
    .image-carousel-section {
        --carousel-height: 22rem;
        --carousel-gap: 1.5rem;
        padding-top: 3.5rem;
        padding-bottom: 3.5rem;
    }
}

.image-carousel {
    position: relative;
    overflow: hidden;
}

/* The track holds two or more identical sets of photos. It slides left by
   exactly one set, then restarts, which looks like an endless loop. */
.image-carousel-track {
    display: flex;
    width: max-content;
    animation: image-carousel-scroll var(--carousel-duration, calc(var(--image-count) * 12s)) linear infinite;
}

.image-carousel:hover .image-carousel-track,
.image-carousel:focus-within .image-carousel-track {
    animation-play-state: paused;
}

/* Previous/next arrows, revealed while the carousel is paused. Scoped under
   .image-carousel to outrank Tailwind's reset of [type='button'] backgrounds. */
.image-carousel .image-carousel-arrow {
    position: absolute;
    top: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    border-radius: 9999px;
    background-color: rgba(255, 255, 255, 0.9);
    color: rgb(21, 24, 47);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    opacity: 0;
    transform: translateY(-50%);
    transition: opacity 200ms ease-in-out, background-color 200ms ease-in-out;
    cursor: pointer;
}

.image-carousel-arrow[hidden] {
    display: none;
}

.image-carousel-arrow-prev {
    left: 1rem;
}

.image-carousel-arrow-next {
    right: 1rem;
}

.image-carousel:hover .image-carousel-arrow,
.image-carousel:focus-within .image-carousel-arrow {
    opacity: 1;
}

.image-carousel .image-carousel-arrow:hover {
    background-color: rgb(255, 255, 255);
}

.image-carousel-arrow svg {
    width: 1.5rem;
    height: 1.5rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.image-carousel-set {
    display: flex;
    flex-shrink: 0;
}

/* Spacing is a right margin rather than a flex gap so each set's width
   includes its trailing gap, keeping the loop seamless. */
.image-carousel-photo {
    flex-shrink: 0;
    height: var(--carousel-height);
    width: auto;
    max-width: none;
    margin-right: var(--carousel-gap);
    border-radius: 0.5rem;
    user-select: none;
}

@keyframes image-carousel-scroll {
    from {
        transform: translateX(0);
    }
    to {
        transform: translateX(calc(-1 * var(--carousel-shift, 50%)));
    }
}

@media (prefers-reduced-motion: reduce) {
    .image-carousel {
        overflow-x: auto;
    }

    .image-carousel-track {
        animation: none;
    }

    .image-carousel-set[aria-hidden],
    .image-carousel .image-carousel-arrow {
        display: none;
    }
}
