*, *::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';
    src: url('/fonts/mona-sans.woff2') format('woff2');
    font-weight: 200 900;
    font-display: swap;
}

:root {
    --color-background: oklch(100% 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-sans: 'Mona Sans', ui-sans-serif, system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;

    --page-padding: 1.5rem;

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

body {
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 400;
    line-height: 1.5;
    letter-spacing: 0;
    font-feature-settings: "ss01", "ss05", "ss07", "ss09", "rlig" 0;
    font-variant-ligatures: none;
    text-wrap: pretty;
}

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%;

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

    & p:has(a) {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        color: var(--color-display-50);
    }

    & .logo {
        height: 20px;
        width: auto;
        flex: none;
        color: var(--color-display);
        opacity: 0.7;
    }

    & p a { color: var(--color-display); }
}

.photo-grid {
    margin-block: 2rem 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(16rem, 100%), 1fr));
    gap: 2rem var(--page-padding);
}

.photo-item {
    display: block;
}

.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: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    margin-block-start: 0.75rem;
}

.photo-title {
    min-width: 0;
    overflow-wrap: anywhere;
    transition: color 120ms ease-in-out;
}

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

.photo-meta {
    flex: none;
    color: var(--color-display-50);
}

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

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

body:has(.not-found) {
    min-height: 100svh;
    display: grid;
    grid-template-rows: auto 1fr;
}

.not-found {
    display: grid;
    grid-template-columns: auto 28rem;
    justify-content: center;
    align-items: center;
    gap: 2rem 4rem;

    & .photo-item {
        justify-self: start;
        width: fit-content;
    }

    & .photo-item img {
        width: auto;
        height: auto;
        max-width: min(28rem, 100vw - 2 * var(--page-padding));
        max-height: 50svh;
    }

    & h1 {
        font: inherit;

        & span { color: var(--color-display-70); }
    }

    & .not-found-text p {
        margin-block-start: 1rem;
        color: var(--color-display-70);

        & a {
            color: var(--color-display);
            transition: color 120ms ease-in-out;

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

.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;
    width: max-content;
    max-width: calc(100% - 2 * var(--page-padding) - 8rem);
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
}

.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 {
    --max-width: 80vw;
    --max-height: min(80svh, 100svh - 2 * (var(--page-padding) + var(--band-height)) - 1lh - var(--thumb-size) - var(--thumbs-gap));

    grid-area: 2 / 1 / 3 / -1;
    width: min(var(--max-width), var(--max-height) * var(--ratio));
    height: auto;
    max-width: var(--max-width);
    max-height: var(--max-height);
}

.slide-prev,
.slide-next,
.slide-edge {
    grid-row: 3;
    padding-block-start: 1rem;
}

.slide-prev,
.slide-next {
    color: var(--color-display-70);
    transition: color 120ms ease-in-out;

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

.slide-edge { color: var(--color-display-50); }

.slide-prev + .slide-edge { justify-self: end; }

.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(--thumb-size);
        height: var(--thumb-size);
        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: fadeInBlur var(--enter-duration) var(--enter-ease) both;
    }

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

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

@media screen and (max-width: 744px) {
    .not-found {
        grid-template-columns: 1fr;
        align-content: center;
    }

    .slide figcaption {
        inset-block-start: calc(var(--page-padding) + 1lh + 0.75rem);
        inset-inline: var(--page-padding);
        translate: none;
        width: auto;
        max-width: none;
        justify-content: space-between;
    }

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