body.gallery-page {
    background: #242424;
    color: #fffefd;
}

.project-gallery {
    width: min(100%, 1600px);
    margin: 0 auto;
    padding: 170px 6% 100px;
}

.project-gallery__intro {
    max-width: 650px;
    margin-bottom: 48px;
}

.project-gallery__intro h1 {
    margin-bottom: 18px;
    font-size: clamp(2.25rem, 4vw, 3.5rem);
    letter-spacing: -0.035em;
}

.project-gallery__intro > p:last-child {
    color: #c4c4bf;
    line-height: 1.7;
}

.project-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: stretch;
    grid-auto-rows: 1fr;
    gap: 44px 26px;
    list-style: none;
}

.project-card {
    border: 1px solid #545450;
    background: #191919;
}

.project-card__link {
    display: block;
    height: 100%;
    padding: 12px;
    color: inherit;
    text-decoration: none;
}

.project-card__image {
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: #191919;
}

.project-card img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 220ms ease;
}

.project-card figcaption {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 16px;
    padding-top: 16px;
    border-top: 1px solid #545450;
    margin-top: 16px;
    font-size: 0.93rem;
    line-height: 1.5;
}

.project-card__title {
    overflow-wrap: anywhere;
}

.project-card__arrow {
    color: #c4c4bf;
    transition: transform 220ms ease, color 220ms ease;
}

@media (hover: hover) {
    .project-card__link:hover img {
        opacity: 0.85;
    }

    .project-card__link:hover .project-card__arrow {
        transform: translate(2px, -2px);
        color: var(--accent-hover);
    }
}

.project-card__link:focus-visible,
.gallery-lightbox button:focus-visible {
    outline: 2px solid var(--accent-hover);
    outline-offset: 5px;
}

.gallery-lightbox {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: clamp(12px, 3vw, 40px);
    border: 0;
    background: transparent;
    color: #fffefd;
    overscroll-behavior: contain;
}

.gallery-lightbox[open] {
    display: grid;
    place-items: center;
}

.gallery-lightbox::backdrop {
    background: rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(4px);
}

.gallery-lightbox__panel {
    width: min(1080px, 100%);
    max-height: 100%;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: #191919;
    border: 1px solid #3a3a38;
}

.gallery-lightbox__toolbar {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 16px;
    background: #191919;
}

.gallery-lightbox__position {
    color: #c4c4bf;
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    font-variant-numeric: tabular-nums;
}

.gallery-lightbox__controls {
    display: flex;
    gap: 8px;
}

.gallery-lightbox button {
    width: 44px;
    height: 44px;
    border: 1px solid #50504c;
    background: transparent;
    color: inherit;
    font-size: 1.5rem;
    cursor: pointer;
    transition: background 180ms ease;
}

.gallery-lightbox button:hover {
    background: #343430;
}

.gallery-lightbox button[hidden] {
    display: none;
}

.gallery-lightbox__image {
    display: grid;
    place-items: center;
    height: clamp(180px, 60vh, 650px);
    height: clamp(180px, 60dvh, 650px);
    background: #101010;
}

.gallery-lightbox__image img {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 0;
    object-fit: contain;
}

.gallery-lightbox__caption {
    padding: 22px 26px 26px;
    overflow-wrap: anywhere;
}

.gallery-lightbox__caption h2 {
    margin-bottom: 10px;
    font-size: 1.15rem;
    line-height: 1.4;
}

.gallery-lightbox__caption p {
    max-width: 800px;
    color: #c4c4bf;
    font-size: 0.9rem;
    line-height: 1.65;
}

.gallery-lightbox__materials {
    margin-top: 10px;
}

.gallery-lightbox__details {
    margin-bottom: 10px;
}

.gallery-lightbox__thumbnails {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 0 26px 26px;
}

.gallery-lightbox__thumbnails[hidden] {
    display: none;
}

.gallery-lightbox__thumbnails button {
    width: 64px;
    height: 64px;
    padding: 3px;
}

.gallery-lightbox__thumbnails button[aria-pressed="true"] {
    border-color: var(--accent-hover);
}

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

.gallery-notice a {
    color: inherit;
}

@media (max-width: 1100px) {
    .project-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 600px) {
    .project-gallery {
        padding: 145px 24px 64px;
    }

    .project-gallery__intro {
        margin-bottom: 32px;
    }

    .project-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 36px;
    }

    .gallery-lightbox__image {
        height: 48vh;
        height: 48dvh;
    }

    .gallery-lightbox__caption {
        padding: 18px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .project-card img,
    .project-card__arrow,
    .gallery-lightbox button {
        transition: none;
    }
}
