.gallery {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: clamp(44px, 5vw, 56px);  /* room for the pin above each photo */
    padding: clamp(40px, 5vw, 56px) clamp(16px, 11vw, 160px) clamp(24px, 4vw, 40px);
    box-sizing: border-box;
}

.photo {
    position: relative;  /* the pin is placed on the photo's top edge */
    width: fit-content;
    max-width: 100%;
    margin: 0;
    padding: clamp(10px, 1.5vw, 16px);
    box-sizing: border-box;
    background-color: #FFFFFF;
    box-shadow: var(--shadow-soft);
}

.photo:nth-child(odd) {
    align-self: flex-start;
}

/* Pinboard: each photo hangs from its pin and is a little crooked, every one a bit differently.
   It turns around the pin (top centre), so the pin stays where it is stuck in. */
.photo {
    transform-origin: 50% 0;
}

.photo:nth-child(3n + 1) {
    rotate: -1.5deg;
}

.photo:nth-child(3n + 2) {
    rotate: 1.2deg;
}

.photo:nth-child(3n) {
    rotate: -0.7deg;
}

/* Pixel pushpin seen from the side (head, collar and needle; 11 x 13 px drawn at 4px per pixel = 44 x 52px).
   Its needle tip ends 2px above the picture (the frame's padding is 10-16px), so it never covers the picture;
   the head sticks out above the photo onto the board. The shadow makes it stand off the board a little. */
.photo .pin {
    position: absolute;
    top: calc(clamp(10px, 1.5vw, 16px) - 54px);
    left: 50%;
    width: 44px;
    height: 52px;
    translate: -50% 0;
    image-rendering: pixelated;
    filter: drop-shadow(3px 3px 0 rgba(0, 0, 0, 0.35));  /* hard pixel shadow on the board */
}

.photo:nth-child(even) {
    align-self: flex-end;
}

/* Photos are 512px tall on large screens and shrink to fit small ones (keeping their proportions) */
.photo img {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: min(640px, 70vh);
}

.photo figcaption {
    margin-top: 8px;
    color: #000000;
    font-family: var(--font-primary);
    font-size: 20px;
    font-weight: bold;
    text-align: center;
}

/* Phones: every photo centred and as wide as the screen allows */
@media screen and (max-width: 600px) {
    .photo,
    .photo:nth-child(odd),
    .photo:nth-child(even) {
        align-self: center;
    }
}
