.ps-carousel {
    position: relative;
    max-width: 900px;
    margin: 2rem 0;
    border-radius: var(--ps-border-radius);
    overflow: hidden;
    outline: none;
}

.ps-carousel-track {
    position: relative;
    aspect-ratio: 3 / 2;
    /* background: var(--color-background-tertiary); */
    border-radius: var(--ps-border-radius);
    overflow: hidden;
}

/* Slides come from the directive as ``figure`` nodes, and Sphinx's HTML writer
   tags every figure ``align-default``. Furo then styles ``article .align-default``
   with ``display: block; margin: auto`` -- which outranks a lone
   ``.ps-carousel-slide`` and breaks the flex layout below. Scoping under
   ``.ps-carousel`` raises specificity above that rule so the slide stays a
   flex column that letterboxes the image into the 3/2 track. */
.ps-carousel .ps-carousel-slide {
    position: absolute;
    inset: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transition:
        opacity 0.6s ease,
        visibility 0s linear 0.6s;
}

.ps-carousel-slide.is-active {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.6s ease;
}

.ps-carousel-slide img {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    object-fit: contain;
    display: block;
    transform: scale(1.06);
    transition: transform 0.9s ease;
    background: var(--color-background-image);
    border-radius: var(--ps-border-radius);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    padding: var(--ps-padding-tile);
}

.ps-carousel-slide.is-active img {
    transform: scale(1);
}

.ps-carousel-slide figcaption {
    /* display: flex;
    align-items: center;
    justify-content: center; */
    padding: var(--ps-padding-tile);
    /* margin-top: 0.5rem; */
    background: var(--color-background-secondary);
    border-radius: var(--ps-border-radius);
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    color: var(--color-foreground-secondary);
    font-size: 1rem;
    /* white-space: nowrap; */
    /* overflow: hidden; */
    /* text-overflow: ellipsis; */
    text-align: center;
    opacity: 0;
    transform: translateY(10px);
    transition:
        opacity 0.4s ease,
        transform 0.4s ease;
}

.ps-carousel-slide.is-active figcaption {
    opacity: 1;
    transform: translateY(0);
    transition:
        opacity 0.4s ease 0.2s,
        transform 0.4s ease 0.2s;
}

.ps-carousel-slide figcaption p {
    margin: 0;
    width: auto;
}

.ps-carousel-slide figcaption .headerlink {
    display: none;
}

/* Shared image credit (copyright / license), shown as a muted sub-line
   beneath the caption text within the same caption bar. */
.ps-carousel-slide figcaption .ps-carousel-credit {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.8rem;
    opacity: 0.7;
}

.ps-carousel-slide figcaption .ps-carousel-credit a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.ps-carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: var(--ps-border-radius);
    background: var(--color-background-secondary);
    box-shadow: var(--ps-shadow-clickable);
    border: 1px solid transparent;
    color: var(--color-brand-primary);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition:
        border-color 0.2s ease,
        transform 0.2s ease;
}

.ps-carousel-btn:hover,
.ps-carousel-btn:focus-visible {
    border-color: var(--color-brand-primary);
    transform: translateY(-50%) scale(1.08);
}

.ps-carousel-prev {
    left: 0.75rem;
}

.ps-carousel-next {
    right: 0.75rem;
}

.ps-carousel-dots {
    display: flex;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.75rem 0;
}

.ps-carousel-dot {
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 50%;
    border: none;
    background: var(--color-foreground-secondary);
    opacity: 0.4;
    cursor: pointer;
    padding: 0;
    transition:
        opacity 0.2s ease,
        background 0.2s ease;
}

.ps-carousel-dot.is-active {
    opacity: 1;
    background: var(--color-brand-primary);
}
