.photo-lead-link {
    display: block;
    position: relative;
}

[data-photo-open] { cursor: zoom-in; }
.photo-expand {
    position: absolute;
    inset: auto 12px 12px auto;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #242321e8;
    color: var(--paper);
    pointer-events: none;
    z-index: 1;
}
.photo-expand svg { width: 17px; height: 17px; }
.photo-expand[hidden] { display: none; }

html.photo-viewing { overflow: hidden; scrollbar-gutter: auto; overscroll-behavior: none; }
.photo-viewer {
    --night: #242321;
    --warm-white: #f5f2eb;
    --hairline: #5d5954;
    --brass: #e1c9a9;
    --viewer-ease: cubic-bezier(.2,.72,.24,1);
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    overflow: hidden;
    overscroll-behavior: contain;
    background: var(--night);
    color: var(--warm-white);
    color-scheme: dark;
}
.photo-viewer::backdrop { background: var(--night, #242321); }
.photo-viewer:not([open]) { display: none; }
.photo-viewer[open] { animation: viewer-arrive 290ms var(--viewer-ease) both; }
.photo-viewer[open]::backdrop { animation: viewer-arrive 235ms ease-out both; }
.photo-viewer::selection { color: var(--night); background: var(--brass); }
.viewer-shell {
    --edge: clamp(1.2rem, 3.4vw, 4rem);
    display: grid;
    grid-template-rows: auto minmax(0,1fr);
    gap: clamp(.75rem, 1.8vh, 1.35rem);
    width: min(100%, 1800px);
    height: 100%;
    margin-inline: auto;
    padding: max(.8rem, env(safe-area-inset-top)) max(var(--edge), env(safe-area-inset-right))
             max(.85rem, env(safe-area-inset-bottom)) max(var(--edge), env(safe-area-inset-left));
}
.viewer-browse {
    min-height: 0;
    min-width: 0;
    display: grid;
    grid-template-rows: minmax(0,1fr) auto;
    gap: clamp(.75rem, 1.8vh, 1.35rem);
}
.viewer-status {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}
.viewer-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    border-bottom: 1px solid var(--hairline);
    padding-bottom: clamp(.55rem, 1.3vh, 1rem);
}
.viewer-top h2 {
    margin: 0;
    color: var(--warm-white);
    font: 500 clamp(1.75rem, 2.95vw, 2.8rem)/1.05 var(--display);
    letter-spacing: -.025em;
    text-wrap: initial;
}
.viewer-top h2 i { font-weight: 500; }
.viewer-divider { margin-inline: .12em; font-style: italic; color: var(--brass); }
.photo-viewer button {
    color: inherit;
    font-family: var(--sans);
    background: transparent;
}
.viewer-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    gap: .65rem;
    min-height: 44px;
    margin-right: -.45rem;
    padding: .42rem .5rem;
    border: 0;
    font-size: .88rem;
    font-weight: 700;
}
.viewer-close svg { width: 22px; height: 22px; }
.viewer-close:hover { color: var(--brass); }
.photo-viewer button:focus-visible {
    outline: 2px solid var(--brass);
    outline-offset: 2px;
}
.viewer-content {
    min-width: 0;
    min-height: 0;
    display: grid;
    grid-template:
        "prev image next" minmax(0, 1fr)
        ".    note  ." auto
        / 3rem minmax(0, 1fr) 3rem;
    align-items: center;
    gap: .6rem clamp(.6rem, 1.8vw, 1.8rem);
}
.viewer-mount {
    position: relative;
    grid-area: image;
    align-self: stretch;
    min-width: 0;
    min-height: 0;
    isolation: isolate;
}
.viewer-stage { position: absolute; inset: 0; touch-action: pan-y pinch-zoom; user-select: none; }
.viewer-image {
    position: absolute;
    inset: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background-color: var(--night);
    pointer-events: none;
}
.viewer-image.is-outgoing { z-index: 0; }
.viewer-notice {
    position: absolute;
    inset: 50% auto auto 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
    width: max-content;
    max-width: 90%;
    padding: .55rem .85rem;
    margin: 0;
    color: var(--warm-white);
    background: var(--night);
    font-size: .9rem;
    text-align: center;
    pointer-events: none;
}
.viewer-step {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    padding: 0;
    border: 1px solid var(--hairline);
    border-radius: 50%;
    justify-self: center;
    transition: border-color 150ms, background-color 150ms;
}
.viewer-step svg { width: 22px; height: 22px; }
.viewer-prev { grid-area: prev; }
.viewer-next { grid-area: next; }
.viewer-step:hover { border-color: var(--brass); background: #353330; }
.viewer-legend {
    grid-area: note;
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: .8rem;
    min-width: 0;
    min-height: 1.65rem;
}
.viewer-count {
    flex: none;
    color: var(--brass);
    font: 700 .76rem/1.4 var(--sans);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.viewer-caption { margin: 0; color: var(--warm-white); font: 400 clamp(.88rem, 1.05vw, 1.06rem)/1.45 var(--sans); }
.viewer-strip { min-width: 0; border-top: 1px solid var(--hairline); padding-top: .6rem; }
.viewer-thumbs {
    display: flex;
    gap: .45rem;
    width: max-content;
    max-width: 100%;
    margin-inline: auto;
    padding: 3px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    touch-action: pan-x pinch-zoom;
}
.viewer-thumbs::-webkit-scrollbar { display: none; }
.viewer-thumb {
    position: relative;
    display: block;
    flex: 0 0 auto;
    width: clamp(52px, 5.5vw, 76px);
    min-height: 44px;
    padding: 0 0 5px;
    border: 0;
}
.viewer-thumb img {
    width: 100%;
    aspect-ratio: 3 / 2;
    height: auto;
    object-fit: cover;
    opacity: .62;
    transition: opacity 180ms;
}
.viewer-thumb:hover img, .viewer-thumb:focus-visible img, .viewer-thumb[aria-current=true] img { opacity: 1; }
.viewer-thumb[aria-current=true]::after {
    position: absolute;
    content: "";
    inset: auto 0 0;
    height: 2px;
    background: var(--brass);
}
.photo-viewer[open] .viewer-stage { animation: viewer-aperture 440ms var(--viewer-ease) both; }
.photo-viewer[open] .viewer-strip { animation: viewer-controls 320ms var(--viewer-ease) both; }
.photo-viewer[open][data-closing], .photo-viewer[open][data-closing]::backdrop {
    animation: viewer-depart 170ms ease-in both;
}
@keyframes viewer-arrive { from { opacity: 0; } to { opacity: 1; } }
@keyframes viewer-aperture {
    from { clip-path: inset(0 27%); }
    to { clip-path: inset(0); }
}
@keyframes viewer-controls {
    from { opacity: .3; transform: translateY(5px); }
    to { opacity: 1; transform: none; }
}
@keyframes viewer-depart { from { opacity: 1; } to { opacity: 0; } }

@media (max-width: 700px) and (orientation: portrait) {
    .viewer-shell {
        --edge: clamp(.8rem, 4vw, 1.5rem);
        gap: .7rem;
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
    .viewer-top h2 { font-size: clamp(1.37rem, 6.6vw, 2rem); }
    .viewer-top { gap: .45rem; }
    .viewer-close { gap: .25rem; font-size: .8rem; }
    .viewer-close svg { width: 19px; }
    .viewer-browse {
        align-content: center;
        grid-template-rows: minmax(0, min(calc(100% - 5.5rem), calc(100vw / min(var(--viewer-ratio,1.5),1.5) + 4.5rem))) auto;
        gap: 1.2rem;
    }
    .viewer-content {
        grid-template:
            "image image image" minmax(0, 1fr)
            "note prev next" auto
            / minmax(0,1fr) 44px 44px;
        gap: .9rem .45rem;
    }
    .viewer-mount { margin-inline: calc(-1 * var(--edge)); }
    .viewer-step { width: 44px; height: 44px; }
    .viewer-legend { flex-direction: column; align-items: flex-start; gap: .2rem; }
    .viewer-caption { font-size: .95rem; }
    .viewer-thumbs { justify-content: start; }
    .viewer-thumb { width: 56px; }
}
@media (max-height: 500px) and (orientation: landscape) {
    .viewer-shell { --edge: 1rem; gap: .25rem; padding-block: .2rem; }
    .viewer-browse { gap: .25rem; }
    .viewer-top { padding: 0; }
    .viewer-top h2 { font-size: 1.52rem; }
    .viewer-content { row-gap: .12rem; }
    .viewer-legend { min-height: 1.15rem; }
    .viewer-caption { font-size: 1rem; }
    .viewer-strip { padding-top: .15rem; }
    .viewer-thumb { width: 52px; }
}
:root[data-preview-motion=reduced] .photo-viewer,
:root[data-preview-motion=reduced] .photo-viewer *,
:root[data-preview-motion=reduced] .photo-viewer::backdrop { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) {
    :root:not([data-preview-motion=full]) .photo-viewer,
    :root:not([data-preview-motion=full]) .photo-viewer *,
    :root:not([data-preview-motion=full]) .photo-viewer::backdrop { animation: none !important; transition: none !important; }
}
