*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: none;
    text-size-adjust: none;
}

@font-face {
    font-family: 'Mona Sans Mono';
    src: url('/fonts/mona-sans-mono.woff2') format('woff2');
    font-weight: 200 900;
    font-display: swap;
}

:root {
    --color-background: oklch(98.5% 0 0);
    --color-display: oklch(30.1% 0 0);
    --color-accent: oklch(17.8% 0 0);

    --color-display-50: oklch(from var(--color-display) l c h / 50%);
    --color-display-70: oklch(from var(--color-display) l c h / 70%);

    --font-mono: 'Mona Sans Mono', ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;

    --page-max-width: 76rem;
    --page-padding: 1.5rem;

    --enter-duration: 800ms;
    --enter-ease: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

body {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    font-weight: 400;
    line-height: 1.6;
    letter-spacing: 0;
}

body {
    padding: var(--page-padding);
    background-color: var(--color-background);
    color: var(--color-display);
    -webkit-font-smoothing: antialiased;
}

img {
    display: block;
    max-inline-size: 100%;
}

a {
    color: inherit;
    text-decoration: none;
}

.top-bar {
    width: 100%;
    max-width: var(--page-max-width);
    margin-inline: auto;

    & a:hover { color: var(--color-accent); }

    & p a {
        text-decoration: underline;
        text-underline-offset: 0.2em;
    }
}

.photo-grid {
    max-width: var(--page-max-width);
    margin-inline: auto;
    margin-block: 4rem 0;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 3rem 2rem;
}

.photo-item {
    display: block;
    container-type: inline-size;
}

.photo {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    object-fit: cover;
}

.photo-stack-images {
    display: grid;
    grid-template: 2fr 1fr / 1fr 1fr;
    gap: 0.25rem;
    aspect-ratio: 1;

    & .photo {
        height: 100%;
        min-height: 0;
        aspect-ratio: auto;
    }

    & .photo:last-child { grid-area: 1 / 1 / 2 / -1; }
}

.photo-caption {
    display: block;
    margin-block-start: 0.75rem;
}

.photo-title,
.photo-meta {
    display: block;
}

.photo-title {
    transition: color 120ms ease-in-out;
}

.photo-item:hover .photo-title { color: var(--color-accent); }

.photo-meta { color: var(--color-display-70); }

body:has(.viewer) {
    --strip-height: 3rem;
    --band-height: 2.5rem;
    --thumbs-gap: 3rem;

    position: relative;
    min-height: 100svh;
    display: grid;
    grid-template-rows: var(--strip-height) 1fr auto;
}

.viewer {
    display: grid;
}

body:has(.viewer) .top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.photo-count { color: var(--color-display-70); }

.slide figcaption {
    position: absolute;
    inset-block-start: var(--page-padding);
    inset-inline-start: 50%;
    translate: -50% 0;
    height: var(--strip-height);
    max-width: calc(100% - 2 * var(--page-padding) - 8rem);
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;

    & span {
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }
}

.slide { display: none; }

.slide:target,
.viewer:not(:has(.slide:target)) .slide:first-of-type {
    display: grid;
    grid-template-columns: auto auto;
    grid-template-rows: var(--band-height) auto var(--band-height);
    place-content: center;
}

.slide img {
    grid-area: 2 / 1 / 3 / -1;
    width: auto;
    height: auto;
    max-width: 80vw;
    max-height: min(80svh, 100svh - 2 * (var(--page-padding) + var(--strip-height) + var(--band-height)) - var(--thumbs-gap));
}

.slide-prev,
.slide-next {
    grid-row: 3;
    padding-block-start: 1rem;
    color: var(--color-display-70);
    transition: color 120ms ease-in-out;

    &:hover { color: var(--color-accent); }
}

.slide-prev {
    grid-column: 1;
    justify-self: start;
}

.slide-next {
    grid-column: 2;
    justify-self: end;
}

.thumbs {
    margin-block-start: var(--thumbs-gap);
    display: flex;
    justify-content: safe center;
    gap: 0.25rem;
    overflow-x: auto;
    scrollbar-width: none;

    & a { flex: none; }

    & img {
        width: var(--strip-height);
        height: var(--strip-height);
        object-fit: cover;
        transition: opacity 120ms ease-in-out;
    }

    &:has([aria-current]) a:not([aria-current], :hover) img { opacity: 0.4; }
}

@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }

    body:not(:has(.viewer)) :is(.top-bar, main) {
        animation: slideUpBlur var(--enter-duration) var(--enter-ease) both;
    }

    body:not(:has(.viewer)) main { animation-delay: 80ms; }
}

@keyframes slideUpBlur {
    from {
        opacity: 0;
        translate: 0 1rem;
        filter: blur(5px);
    }
    to {
        opacity: 1;
        translate: 0;
        filter: blur(0);
    }
}

@media screen and (max-width: 1080px) {
    .photo-grid { grid-template-columns: repeat(3, 1fr); }
}

@media screen and (max-width: 744px) {
    .photo-grid { grid-template-columns: repeat(2, 1fr); }

    .slide img { max-width: calc(100vw - 2 * var(--page-padding)); }
}

@media screen and (max-width: 440px) {
    .photo-grid { grid-template-columns: 1fr; }
}
