.slideshow {
    position: relative;
    width: 100%;
}

.slideshow.has-nav {
    display: grid;
    grid-template-rows: 1fr auto;
}

.slideshow-slides {
    position: relative;
    width: 100%;
}

.slideshow-slide {
    display: none;
    opacity: 0;

    position: absolute;
    inset: 0;

    z-index: 1;

    transition: opacity 0.5s ease-in-out;
}

.slideshow-slide.pre-active {
    display: flex;
    opacity: 0;
    z-index: 1;
}

.slideshow-slide.active {
    display: flex;
    position: relative;
    opacity: 1;
    z-index: 2;
}

.slideshow-slide-media {
    position: relative;
    width: 100%;
    aspect-ratio: var(--slideshow-ratio, 3/2);
    overflow: hidden;
}

.slideshow-slide-picture {
    display: block;
    position: relative;
    width: 100%;
    height: 100%;
}

.slideshow-slide-picture img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.slideshow-slide-figure-caption {
    color: var(--color-text-secondary);
    width: var(--slide-picture-width, 100%);
}

.slideshow-slide-content {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    align-items: flex-end;
    width: 100%
}

.slideshow-slide-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    width: 100%;
}

.slideshow-slide-content-title {
    display: none;
}

.slideshow-slide-content-description {
    grid-column: 1/-3;
}

.slideshow-slide-content-counter {
    grid-column: -3/-1;
    text-align: right;
}

/* Desktop */
@media screen and (min-width: 768px) {
    .slideshow-slide-header {
        display: none;
    }

    .slideshow-slide-content {
        grid-template-columns: repeat(12, 1fr);
    }

    .slideshow-slide-content-title {
        display: block;
        grid-column: 1/3;
        text-wrap: balance;
    }

    .slideshow-slide-content-description {
        grid-column: 3/-2;
    }

    .slideshow-slide-content-counter {
        grid-column: -2/-1;
    }
}

/* Actions */
.slideshow-arrow {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 15%;
    opacity: 0;
    z-index: 3;
    background: transparent;
    border: 0;
}

.slideshow-arrow--next {
    right: 0;
    left: auto;
}

/* Expand button (lightbox trigger) */
.slideshow-slide-expand {
    display: block;
    width: 100%;
    height: 100%;
    background: transparent;
    border: 0;
    padding: 0;
}

.slideshow-slide-expand .slideshow-slide-picture,
.slideshow-slide-expand .slideshow-slide-picture img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Counter — sits below the slides, in flow */
.slideshow-counter {
    display: block;
    margin-top: 0.5rem;
    text-align: right;
    font-size: var(--text-smaller);
    letter-spacing: 0.08em;
    color: rgba(0, 0, 0, 0.7);
}

/* Close button (only rendered when lightbox is enabled) */
.slideshow-close {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 4;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0.5rem;
    display: none;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 0;
    color: white;
    font-size: 1.75rem;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
}

/* Caption — sits below the slide's media, in flow */
.slideshow-slide-caption {
    display: block;
    margin-top: 0.5rem;
    font-size: var(--text-smaller);
    color: rgba(0, 0, 0, 0.7);
}

/* ============================================================
   Fit: contain (counter sits below the image, in flow)
============================================================ */
.slideshow[data-fit="contain"] {
    display: flex;
    flex-direction: column;
    overflow: visible;
}

.slideshow[data-fit="contain"] .slideshow-slides {
    flex: 1;
    min-height: 0;
}

.slideshow[data-fit="contain"] .slideshow-slide {
    justify-content: flex-start;
    align-items: flex-start;
}

.slideshow[data-fit="contain"] .slideshow-slide-picture,
.slideshow[data-fit="contain"] .slideshow-slide-picture img {
    object-fit: contain;
    object-position: top right;
}

.slideshow[data-fit="contain"] .slideshow-counter {
    position: static;
    align-self: flex-end;
    padding: 0;
    margin-top: 0.5rem;
    pointer-events: auto;
}

/* ============================================================
   Fullscreen / Lightbox
============================================================ */
.slideshow.is-fullscreen,
.slideshow.is-fullscreen[data-fit="contain"] {
    position: fixed;
    inset: 0;
    z-index: 1000;
    width: 100vw;
    height: 100dvh;
    max-height: none;
    margin: 0;
    display: block;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* Reset contain-mode children inside fullscreen */
.slideshow.is-fullscreen[data-fit="contain"] .slideshow-slides {
    flex: none;
    height: 100%;
    min-height: 0;
}

.slideshow.is-fullscreen[data-fit="contain"] .slideshow-slide {
    justify-content: center;
    align-items: center;
    height: 100%;
}

.slideshow.is-fullscreen[data-fit="contain"] .slideshow-slide-picture,
.slideshow.is-fullscreen[data-fit="contain"] .slideshow-slide-picture img {
    object-position: center;
}

.slideshow.is-fullscreen .slideshow-close {
    display: flex;
    color: black;
}

.slideshow.is-fullscreen .slideshow-slide-expand {
    cursor: default;
}

.slideshow.is-fullscreen .slideshow-slide-media {
    width: 100%;
    height: 100dvh;
    aspect-ratio: auto;
    padding: 1rem 1rem 2rem;
}

.slideshow.is-fullscreen .slideshow-slide-picture,
.slideshow.is-fullscreen .slideshow-slide-picture img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.slideshow.is-fullscreen .slideshow-slide-caption {
    position: absolute;
    display: block;
    bottom: 1rem;
    left: 1rem;
    margin-top: 0;
    color: black;
}

.slideshow.is-fullscreen .slideshow-counter {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    margin-top: 0;
    color: black;
    align-self: auto;
    padding: 0;
}