:root {
    --marker-border: black;
    --marker-foreground: black;
    --overlay-background: white;
    --button-background-color: rgba(0, 0, 0, 0.3);
}

.carousel-wrapper {
    position: relative;
    margin: 24px;
}

.carousel {
    list-style: none;
    margin: 0;
    padding: 0;
    border: 0;

    display: grid;
    gap: 2rem;
    grid-auto-flow: column;
    grid-auto-columns: 100%;

    width: 100%;

    overflow-x: auto;

    scroll-snap-type: x mandatory;

    scrollbar-width: none;

    >li {
        width: 100%;
        scroll-snap-align: center;
    }

    >li img {
        width: 100%;
        aspect-ratio: calc(16/9);
        object-fit: scale-down;
    }

    anchor-name: --carousel;
}

.carousel-btn {
    position-anchor: --carousel;
    z-index: 2;

    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
}

.carousel-btn img {
    width: 36px;
    height: 36px;
    display: block;
}

.carousel-btn.prev {
    position: fixed;
    position-area: bottom left;
}

.carousel-btn.next {
    position: fixed;
    position-area: bottom right;
}

.carousel-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

.carousel-markers {
    display: flex;

    gap: 8px;
    justify-content: center;
    margin-top: 12px;
}

.carousel-markers button {
    appearance: none;
    -webkit-appearance: none;

    width: 8px;
    height: 8px;

    padding: 0;
    border: 0.07rem solid var(--marker-border);
    border-radius: 50%;

    background: none;
    cursor: pointer;
}

.carousel-markers button.active {
    background: var(--marker-foreground);
}

.carousel-markers button:hover {
    border: 0.07rem solid var(--marker-border);
}

.carousel-expand {
    position: absolute;
    top: 8px;
    right: 24px;

    width: 30px;
    height: 30px;

    padding: 8px;

    appearance: none;
    background: none;
    border: 0.1rem solid var(--button-background-color);
    border-radius: 50%;

    cursor: pointer;
    z-index: 3;

    cursor: pointer;

    &:hover {
        background: var(--button-background-color);
    }

    & img {
        display: block;
        content: url(/Resources/svg/viewfinder-light.svg);
    }

    @media (prefers-color-scheme: dark) {
        & img {
            content: url(/Resources/svg/viewfinder-dark.svg);
        }
    }

    @media (width < 640px) {
        top: 0;
        right: 0;
    }
}

.carousel-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay-background);

    display: none;
    place-items: center;
    z-index: 999;

    & p {
        opacity: 0.5;
    }
}

.carousel-overlay.open {
    display: grid;
}

.carousel-overlay img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
}

@media (prefers-color-scheme: dark) {
    :root {
        --marker-border: white;
        --marker-foreground: white;
        --overlay-background: black;
        --button-background-color: rgba(255, 255, 255, 0.4);
    }
}