.opus-page #logo {
    height: auto;
}

.opus-page footer .view-switch {
    position: fixed;
    left: 4%;
    bottom: 4%;
}

.view-switch a:hover {
    animation: rainbow 1.74s linear infinite normal;
}

#titlegrid .thumbs a.planar-preview img {
    aspect-ratio: 4 / 3;
    object-fit: cover;
}

/* Horizontal navigation for larger screens; the mobile image list follows below. */
@media (min-width: 501px) {
    body.opus-page {
        --opus-rail-top: max(18rem, 56vh);
        position: relative;
        min-height: calc(var(--opus-rail-top) + 22rem);
        min-height: max(100svh, calc(var(--opus-rail-top) + 22rem));
        overflow-y: auto;
    }

    #titlegrid {
        position: absolute;
        top: var(--opus-rail-top);
        right: 0;
        bottom: auto;
        left: 0;
        width: min(64rem, calc(100% - 2rem));
        margin: 0 auto;
        padding: 0;
        display: flex;
        flex-direction: row-reverse;
        align-items: flex-start;
        transform: none;
    }

    #titlegrid .both {
        /* Every preview shares the rail as its positioning parent. */
        position: static;
        display: block;
        flex: 1 1 0;
        min-width: 0;
        height: auto;
        margin: 0;
    }

    #titlegrid .circles {
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 100%;
        height: auto;
    }

    #titlegrid .icons {
        display: block;
        flex: none;
        width: min(25px, 100%);
        height: auto;
        aspect-ratio: 1;
    }

    #titlegrid .titles {
        display: block;
        box-sizing: content-box;
        width: 1.6rem;
        max-width: none;
        max-height: 0;
        margin: 0;
        padding: 0;
        /* The transparent border connects the icon and label hit areas. */
        border-top: 11px solid transparent;
        overflow: hidden;
        writing-mode: vertical-rl;
        text-orientation: sideways;
        white-space: nowrap;
        font-size: 1rem;
        line-height: 1.6rem;
        pointer-events: auto;
    }

    #titlegrid .circles:hover .titles,
    #titlegrid .both:focus-within .titles {
        max-width: none;
        max-height: 18rem;
        transition: max-height 1.47s;
    }

    #titlegrid .circles:hover .icons,
    #titlegrid .both:focus-within .icons {
        animation: rotate .74s linear infinite normal;
    }

    #titlegrid .circles:focus-visible {
        outline: 1px solid currentColor;
        outline-offset: 3px;
    }

    #titlegrid .thumbs {
        position: absolute;
        top: auto;
        right: auto;
        bottom: calc(100% + 2rem);
        left: 50%;
        width: min(333px, calc(100vw - 2rem));
        margin: 0;
        transform: translateX(-50%);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
    }

    #titlegrid .thumbs img {
        display: block;
        width: 100%;
        height: auto;
        max-height: calc(var(--opus-rail-top) - 9rem);
        object-fit: contain;
    }

    #titlegrid .thumbs a.planar-preview img {
        /* Scale both dimensions together when the space above the rail is short. */
        width: min(100%, calc((var(--opus-rail-top) - 9rem) * 4 / 3));
        max-height: none;
        margin-inline: auto;
    }

    #titlegrid .circles:hover + .thumbs,
    #titlegrid .both:focus-within .thumbs {
        opacity: 1;
        visibility: visible;
        transition: opacity 1.47s;
    }

    .opus-page footer .view-switch,
    .opus-page footer .temp,
    .opus-page footer .oporto {
        position: absolute;
        bottom: 2rem;
    }
}

/* Unsupported viewport units must not replace the custom property's fallback. */
@supports (height: 1svh) {
    body.opus-page { --opus-rail-top: max(18rem, 56svh); }
}

/* Use the image-only list on phones and tablets without a hover input. */
@media (max-width: 500px), (hover: none) and (pointer: coarse) {
    body.opus-page {
        min-height: 100vh;
        min-height: 100svh;
        overflow-x: hidden;
        overflow-y: auto;
    }

    #titlegrid {
        position: relative;
        inset: auto;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: .5rem;
        width: min(222px, calc(100% - 2rem));
        margin: max(12rem, 33vh) auto 0;
        margin: max(12rem, 33svh) auto 0;
        padding: 0 0 7rem;
        transform: none;
    }

    #titlegrid .both {
        position: static;
        display: block;
        flex: none;
        width: 100%;
        height: auto;
        margin: 0;
    }

    #titlegrid .circles,
    #titlegrid .icons,
    #titlegrid .titles {
        display: none;
    }

    #titlegrid .thumbs,
    #titlegrid .both:focus-within .thumbs {
        position: static;
        inset: auto;
        width: 100%;
        margin: 0;
        transform: none;
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transition: none;
    }

    #titlegrid .thumbs a {
        display: block;
        width: 100%;
        touch-action: manipulation;
    }

    #titlegrid .thumbs img {
        display: block;
        width: 100%;
        height: auto;
        max-height: none;
    }

    #titlegrid .thumbs a.planar-preview img {
        width: 100%;
    }

    .opus-page footer .view-switch,
    .opus-page footer .temp,
    .opus-page footer .oporto {
        position: fixed;
        bottom: 4%;
    }
}
