
.carousel {
    display: grid;
    gap: 0.75rem;
}

.carousel .stage {
    display: grid;
    position: relative;
}

/* every slide occupies the same grid cell, so the frame does not jump */
.carousel .stage > .slide {
    grid-area: 1 / 1;
    width: 100%;
    max-height: 70vh;
    object-fit: contain;
}

.carousel .stage > .slide[hidden] {
    display: none;
}

.carousel-status {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    min-height: 2.5em; /* reserved so captions of different lengths don't shift the rail */
}

.carousel-status .counter {
    flex: none;
    font-variant-numeric: tabular-nums;
    opacity: 0.6;
}

.carousel-caption {
    margin: 0;
    max-width: 68ch;
}

.carousel-label {
    margin: 0;
}

.carousel-nav {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.carousel .rail {
    display: flex;
    flex: 0 1 auto;
    flex-wrap: nowrap;
    gap: 0.25rem;
    overflow-x: auto;
    scrollbar-width: thin;
}

/* ---- buttons ---- */

.carousel button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    background: none;
    color: inherit;
    border: 1px solid currentColor;
    border-radius: 2px;
    cursor: pointer;
    font: inherit;
    line-height: 1;
    padding: 0;
    opacity: 0.45;
    transition: opacity 120ms, box-shadow 120ms;
}

.carousel button:hover:not(:disabled) {
    opacity: 0.8;
}

.carousel button:disabled {
    opacity: 0.2;
    cursor: default;
}

.carousel .rail-dot,
.carousel .carousel-step {
    flex: 0 0 auto;          /* keep their size instead of squeezing */
    width: 2.25rem;
    height: 2.25rem;
    font-variant-numeric: tabular-nums;
}

/* the lit-up current step — only ONE rule for this, or it gets overwritten */
.carousel .rail-dot[aria-current] {
    opacity: 1;
    font-weight: 600;
    box-shadow: 0 0 0 1px currentColor, 0 0 12px -2px currentColor;
}

.carousel :focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/* ---- edge navigation over the media (needs the JS from earlier) ---- */

.carousel .edge {
    position: absolute;
    top: 0;
    bottom: 3rem;            /* clears the native video control bar */
    width: 18%;
    max-width: 5rem;
    height: auto;
    border: 0;
    border-radius: 0;
    font-size: 2rem;
    opacity: 0;
    background: linear-gradient(to right, rgba(0, 0, 0, 0.45), transparent);
}

.carousel .edge-prev { left: 0; }

.carousel .edge-next {
    right: 0;
    left: auto;
    background: linear-gradient(to left, rgba(0, 0, 0, 0.45), transparent);
}

.carousel .stage:hover .edge { opacity: 0.75; }
.carousel .edge:hover { opacity: 1; }
.carousel .edge[hidden] { display: none; }

.empty {
    opacity: 0.5;
}