Gallery 2020 - MK I

Note: This work has been a journey. I went from this model, to a model less reliant on magic numbers, to a change using srcset then back to two images, but lazy loading for bandwidth preservation. Phew.

I've removed comments from my blog as they weren't getting used and it was one more external JS I could remove. There are other ways for people to interact with my posts now, and slowly I'll get better at it. The reduce-JS bug bit me in an awkward place as I thought my JS-powered gallery is a bit naff, so why not CSS it?

I was inspired by a post I have unfortunely lost where someone used :focus to link thumbnails to following images and show/ hide the following image based on that. I toyed with that and rememberd some other work using radio inputs, settled on using radios. The following is the CSS, with an HTML snippet. Gimme all the pointers.

/** 2020-05-04: New gallery */
:root {
    --gallery-height: 700px;
    --gallery-thumbnail-height: 100px;
}
.gallery-2020 {
    position: relative;
    width: 100%;
    text-align: center;
}
.gallery-2020 label {
    margin-right: -2ex;
}
.gallery-2020 input {
    visibility: hidden;
    transform: scaleX(0.00001);
    font-size: 0.1px;
    margin: 0;
}
.gallery-2020 input:checked {
    margin-bottom: calc(var(--gallery-height) - var(--gallery-thumbnail-height));
}
.gallery-2020 img.thumbnail {
    max-width: var(--gallery-thumbnail-height);
    max-height: var(--gallery-thumbnail-height);
}
.gallery-2020 a.gallery-image {
    display: none;
    padding: 0 auto;
}
.gallery-2020 .thumbnail-radio:checked + a.gallery-image {
    display: flex;
    position: absolute;
    top: var(--gallery-thumbnail-height);
    left: 0;
    clear:both;
    align-items: center;
    flex-direction: column;
    height: calc(var(--gallery-height) - var(--gallery-thumbnail-height) - 1.5em);
}
.gallery-2020 a {
    text-align:center;
    width: 100%;
}
.gallery-2020 a em {
    display: block;
    text-align: center;
}
.gallery-2020 * a img {
    object-fit: contain;
    width: 100%;
    height: calc(100% - 2em);
    margin-top: 1px;
    display: block;
}
.gallery-2020 * a img + em {
    position: absolute;
    bottom: 0;
    width: 100%;
    text-align: center;
}
<div class="gallery-2020">
    <label>
        <img class="thumbnail" src="[thumbnail]"
            alt="[caption]" />
        <input
            type="radio"
            name="gallery-2020-[gallery#]"
            value="Y"
            class="thumbnail-radio"/>
        <a class="gallery-image" href="[full image]">
            <img src="[big image]"
                alt="[caption]" /> <em>[caption]</em>
        </a>
    </label>
    <label>
        <img class="thumbnail" src="[thumbnail]"
            alt="[caption]" />
        <input
            type="radio"
            name="gallery-2020-[gallery#]"
            value="Y"
            class="thumbnail-radio" />
        <a class="gallery-image" href="[full image]">
            <img src="[big image]"
                alt="[caption]" /> <em>[caption]</em>
        </a>
    </label>
    ...
</div>

Example: