/* Isolated gallery styles; surrounding sections keep their existing layout. */
.project-gallery {
    --gallery-card-width: clamp(220px, 21vw, 320px);
    --gallery-gap: 0px;
    --gallery-surface: #fff;
    --gallery-arc-depth: 56px;
    position: relative;
    isolation: isolate;
    width: 100vw;
    margin: 20px calc(50% - 50vw) 45px;
    scroll-margin-top: 110px;
    background: var(--gallery-surface);
}

.project-gallery__viewport {
    position: relative;
    overflow: hidden;
    display: grid;
    gap: 0;
}

/* Two opaque half-ellipses cover only part of the outer image rows. */
.project-gallery__viewport::before,
.project-gallery__viewport::after {
    content: "";
    position: absolute;
    z-index: 2;
    left: -5%;
    width: 110%;
    height: var(--gallery-arc-depth);
    background: var(--gallery-surface);
    pointer-events: none;
}

.project-gallery__viewport::before {
    top: -1px;
    border-radius: 0 0 50% 50% / 0 0 100% 100%;
}

.project-gallery__viewport::after {
    bottom: -1px;
    border-radius: 50% 50% 0 0 / 100% 100% 0 0;
}

.project-gallery__row {
    display: flex;
    width: max-content;
    animation: project-gallery-drift var(--gallery-duration, 60s) linear infinite;
    will-change: transform;
}

.project-gallery__row--reverse {
    animation-direction: reverse;
}

.project-gallery__set {
    display: flex;
    flex: 0 0 auto;
    gap: var(--gallery-gap);
    padding-right: var(--gallery-gap);
}

.project-gallery__card {
    position: relative;
    flex: 0 0 var(--gallery-card-width);
    width: var(--gallery-card-width);
    aspect-ratio: 8 / 5;
    overflow: hidden;
    background: #ececeb;
    margin: 0;
}

.project-gallery__card:nth-child(3n + 2) {
    background: #e2e4e3;
}

.project-gallery__card:nth-child(3n) {
    background: #e9e5e2;
}

.project-gallery__card img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.project-gallery__placeholder {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    color: #73736f;
    font-size: 14px;
    letter-spacing: 0.14em;
}

.project-gallery:focus-visible {
    outline: 2px solid #cd0000;
    outline-offset: 6px;
}

@keyframes project-gallery-drift {
    from { transform: translateX(0); }
    to { transform: translateX(-50%); }
}

@media (max-width: 768px) {
    .project-gallery {
        --gallery-card-width: 220px;
        --gallery-arc-depth: 32px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .project-gallery__row {
        animation: none;
        will-change: auto;
    }
}
