/*
 * Justified rows: each thumbnail grows in proportion to its own width/height
 * (--r, set per photo), so a row shares one height and no photo is cropped.
 * The ::after filler keeps the last, half-full row at the normal height.
 */
.photo-grid {
    --photo-grid-row: 8.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

.photo-grid::after {
    content: '';
    flex-grow: 999;
}

.photo-grid-item {
    flex: var(--r) 1 calc(var(--r) * var(--photo-grid-row));
    display: block;
    overflow: hidden;
    border-radius: .6rem;
    background: rgba(127, 160, 190, .18);
    cursor: zoom-in;
}

.photo-grid-item img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: var(--r);
    object-fit: contain; /* the box already has the photo's own proportions — never crop, even if they're off */
    transition: transform .25s ease, opacity .25s ease;
}

.photo-grid-item:hover img,
.photo-grid-item:focus-visible img {
    transform: scale(1.03);
    opacity: .92;
}

@media (max-width: 575.98px) {
    .photo-grid { --photo-grid-row: 6rem; gap: .35rem; }
}

/* ---------- lightbox ---------- */
.lightbox {
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: rgba(4, 18, 32, .94);
    color: #fff;
}

.lightbox[open] {
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox::backdrop {
    background: rgba(4, 18, 32, .94);
}

.lightbox-figure {
    margin: 0;
    max-width: calc(100vw - 7rem);
    text-align: center;
}

.lightbox-figure img {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 6rem);
    margin: 0 auto;
    object-fit: contain;
    border-radius: .5rem;
}

.lightbox-figure figcaption {
    margin-top: .6rem;
    font-size: .9rem;
    opacity: .8;
}

.lightbox-figure figcaption:empty {
    display: none;
}

.lightbox button {
    position: absolute;
    border: 0;
    background: rgba(255, 255, 255, .12);
    color: #fff;
    line-height: 1;
    border-radius: 50%;
    width: 3rem;
    height: 3rem;
    font-size: 2rem;
    cursor: pointer;
}

.lightbox button:hover,
.lightbox button:focus-visible {
    background: rgba(255, 255, 255, .28);
}

.lightbox-close { top: 1rem; right: 1rem; }
.lightbox-prev { left: 1rem; top: 50%; transform: translateY(-50%); }
.lightbox-next { right: 1rem; top: 50%; transform: translateY(-50%); }

@media (max-width: 575.98px) {
    .lightbox-figure { max-width: 100vw; }
    .lightbox-prev, .lightbox-next { top: auto; bottom: 1rem; transform: none; }
}
