.projects-gallery {
    padding: var(--section-block-start) var(--page-gutter) var(--section-block-end);
    background: #fff;
}

.projects-gallery__container {
    width: min(100%, var(--container-width));
    margin-inline: auto;
}

.projects-gallery__header {
    display: grid;
    gap: 8px;
    margin-block-end: var(--section-title-gap);
    text-align: center;
}

.projects-gallery__header > div {
    display: grid;
    gap: 5px;
}

.projects-gallery__eyebrow,
.projects-gallery__description,
.projects-gallery__title {
    margin: 0;
}

.projects-gallery__eyebrow {
    color: var(--color-accent-text);
    font-size: .75rem;
    font-weight: 700;
    line-height: 1.7;
}

.projects-gallery__title {
    color: var(--color-primary);
    font-size: clamp(1.25rem, 2vw, 1.5rem);
    font-weight: 700;
    line-height: 1.7;
}

.projects-gallery__description {
    max-width: 540px;
    margin-inline: auto;
    color: #666b7f;
    font-size: .8rem;
    line-height: 1.9;
}

.projects-gallery__more {
    justify-self: center;
    border-block-end: 1px solid currentColor;
    padding-block-end: 2px;
    color: var(--color-accent-text);
    font-size: .76rem;
    font-weight: 700;
    line-height: 1.8;
    text-underline-offset: 4px;
    transition: color 160ms ease;
}

.projects-gallery__more:hover,
.projects-gallery__more:focus-visible {
    color: var(--color-primary);
}

.projects-gallery__grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.projects-gallery__grid > li {
    min-width: 0;
}

.projects-gallery__grid > li:first-child {
    grid-column: 1 / -1;
}

@media (max-width: 1023.98px) {
    .projects-gallery__grid--even > li:last-child {
        grid-column: 1 / -1;
    }
}

.projects-gallery__card {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    min-height: 190px;
    overflow: hidden;
    border: 0;
    border-radius: 12px;
    padding: 0;
    color: #fff;
    background: var(--color-primary-dark);
    font: inherit;
    text-align: start;
    cursor: zoom-in;
    isolation: isolate;
}

.projects-gallery__grid > li:first-child .projects-gallery__card {
    min-height: 280px;
}

.projects-gallery__thumbnail {
    position: absolute;
    inset: 0;
    z-index: -2;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 240ms ease, filter 240ms ease;
}

.projects-gallery__overlay {
    position: absolute;
    inset: 0;
    z-index: -1;
    background: linear-gradient(0deg, rgba(23, 29, 111, .9), rgba(23, 29, 111, .08) 68%);
    transition: background-color 180ms ease;
}

.projects-gallery__card-content {
    position: absolute;
    inset-inline: 15px;
    inset-block-end: 14px;
    display: grid;
    gap: 3px;
}

.projects-gallery__card-content small {
    color: var(--color-accent-on-dark);
    font-size: .75rem;
    font-weight: 700;
    line-height: 1.6;
}

.projects-gallery__card-content strong {
    color: #fff;
    font-size: .82rem;
    font-weight: 700;
    line-height: 1.7;
}

.projects-gallery__card:hover .projects-gallery__thumbnail,
.projects-gallery__card:focus-visible .projects-gallery__thumbnail {
    filter: brightness(.88);
    transform: scale(1.035);
}

.projects-gallery__card:focus-visible {
    outline: 3px solid var(--color-cta);
    outline-offset: 3px;
}

body.projects-gallery-is-open {
    overflow: hidden;
}

.projects-gallery-dialog {
    width: min(1100px, calc(100% - 32px));
    max-width: none;
    max-height: calc(100dvh - 32px);
    overflow: visible;
    border: 0;
    padding: 0;
    color: #fff;
    background: transparent;
}

.projects-gallery-dialog::backdrop {
    background: rgba(23, 29, 111, .86);
    backdrop-filter: blur(4px);
}

.projects-gallery-dialog__surface {
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 16px;
    background: var(--color-primary);
    box-shadow: 0 24px 70px rgba(0, 0, 0, .45);
}

.projects-gallery-dialog__figure {
    display: grid;
    margin: 0;
}

.projects-gallery-dialog__media {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 420px;
    background: var(--color-primary);
}

.projects-gallery-dialog__image {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: calc(100dvh - 180px);
    object-fit: contain;
}

.projects-gallery-dialog__caption {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 8px 16px;
    min-height: 80px;
    padding: 15px 72px 16px;
}

.projects-gallery-dialog__location {
    color: var(--color-accent-on-dark);
    font-size: .78rem;
    font-weight: 700;
    line-height: 1.6;
}

.projects-gallery-dialog__title {
    color: #fff;
    font-size: .92rem;
    line-height: 1.8;
}

.projects-gallery-dialog__close,
.projects-gallery-dialog__control {
    position: absolute;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, .42);
    border-radius: 50%;
    padding: 0;
    color: #fff;
    background: rgba(23, 29, 111, .8);
    font: inherit;
    line-height: 1;
    cursor: pointer;
    transition: border-color 160ms ease, background-color 160ms ease;
}

.projects-gallery-dialog__close:hover,
.projects-gallery-dialog__close:focus-visible,
.projects-gallery-dialog__control:hover,
.projects-gallery-dialog__control:focus-visible {
    border-color: var(--color-cta);
    background: var(--color-cta);
}

.projects-gallery-dialog__close {
    inset-block-start: 14px;
    inset-inline-end: 14px;
    width: 42px;
    height: 42px;
    font-size: 1.55rem;
}

.projects-gallery-dialog__control {
    top: 46%;
    width: 48px;
    height: 48px;
    font-size: 1.2rem;
    transform: translateY(-50%);
}

.projects-gallery-dialog__control--previous {
    inset-inline-start: 16px;
}

.projects-gallery-dialog__control--next {
    inset-inline-end: 16px;
}

.projects-gallery-dialog__status {
    position: absolute;
    inset-block-end: 22px;
    left: 50%;
    color: rgba(255, 255, 255, .72);
    font-size: .75rem;
    line-height: 1.5;
    transform: translateX(-50%);
}

@media (min-width: 640px) {
    .projects-gallery__grid {
        gap: 14px;
    }

    .projects-gallery__card {
        min-height: 230px;
    }

    .projects-gallery__grid > li:first-child .projects-gallery__card {
        min-height: 350px;
    }

    .projects-gallery__card-content strong {
        font-size: .9rem;
    }
}

@media (min-width: 1024px) {
    .projects-gallery__header {
        grid-template-columns: minmax(0, 1fr) minmax(320px, 470px);
        align-items: end;
        gap: 56px;
        text-align: start;
    }

    .projects-gallery__description {
        margin-inline: 0;
        text-align: start;
    }

    .projects-gallery__grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        grid-auto-rows: 220px;
        gap: 16px;
    }

    .projects-gallery__grid > li:first-child {
        grid-column: span 2;
        grid-row: span 2;
    }

    .projects-gallery__grid > li:nth-child(2) {
        grid-column: span 2;
    }

    .projects-gallery__grid--desktop-tail-1 > li:last-child {
        grid-column: span 4;
    }

    .projects-gallery__grid--desktop-tail-2 > li:nth-last-child(-n + 2),
    .projects-gallery__grid--desktop-tail-3 > li:nth-last-child(3) {
        grid-column: span 2;
    }

    .projects-gallery__card,
    .projects-gallery__grid > li:first-child .projects-gallery__card {
        min-height: 0;
    }
}

@media (max-width: 639.98px) {
    .projects-gallery {
        padding-inline: 16px;
    }

    .projects-gallery__title {
        font-size: 1.2rem;
    }

    .projects-gallery__description {
        font-size: .78rem;
    }

    .projects-gallery-dialog {
        width: calc(100% - 20px);
        max-height: calc(100dvh - 20px);
    }

    .projects-gallery-dialog__surface {
        border-radius: 12px;
    }

    .projects-gallery-dialog__media {
        min-height: 240px;
    }

    .projects-gallery-dialog__image {
        max-height: calc(100dvh - 220px);
    }

    .projects-gallery-dialog__caption {
        grid-template-columns: minmax(0, 1fr);
        gap: 4px 10px;
        min-height: 106px;
        padding: 12px 18px 38px;
    }

    .projects-gallery-dialog__location,
    .projects-gallery-dialog__title {
        grid-column: 1;
    }

    .projects-gallery-dialog__close {
        inset-block-start: 10px;
        inset-inline-end: 10px;
        width: 38px;
        height: 38px;
    }

    .projects-gallery-dialog__control {
        top: 40%;
        width: 40px;
        height: 40px;
    }

    .projects-gallery-dialog__control--previous {
        inset-inline-start: 8px;
    }

    .projects-gallery-dialog__control--next {
        inset-inline-end: 8px;
    }

    .projects-gallery-dialog__status {
        inset-block-end: 14px;
    }
}
