/* Archivo (SIL Open Font License, see fonts/OFL.txt): variable font, Latin subset. */
@font-face {
    font-family: "Archivo";
    src: url("fonts/archivo-variable.woff") format("woff");
    font-weight: 100 900;
    font-stretch: 62% 125%;
    font-style: normal;
    font-display: swap;
}

:root {
    --paper: #fbfaf8;
    --ink: #111;
    --muted: #6a6862;
    --placeholder: #ecebe6;
    --side: 264px;
    --gap: 16px;
    --row: 290px; /* target row height of the photo grid (bigger on large screens, below) */
    --font: "Archivo", system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font);
    font-size: 13px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

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

a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 3px;
}

/* Layout: sidebar + photos. On narrow screens the sidebar parts stack
   (wordmark, albums, photos, contact). */
.layout {
    display: flex;
    flex-wrap: wrap;
    min-height: 100vh;
}

.side {
    flex: 0 0 var(--side);
    align-self: flex-start;
    position: sticky;
    top: 0;
    max-height: 100vh;
    overflow-y: auto;
    padding: 48px 36px;
    display: flex;
    flex-direction: column;
    gap: 56px;
}

main {
    flex: 999 1 560px;
    min-width: 0;
    padding: 48px 48px 72px 12px;
}

.wordmark {
    margin: 0;
    font-weight: 600;
    font-stretch: 112%;
    font-size: 15px;
    line-height: 1.25;
    letter-spacing: -0.015em;
    text-wrap: balance;
}

.album-nav[hidden] {
    display: none;
}

.album-nav ul {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.album-nav a {
    color: var(--muted);
    transition: color 120ms ease;
}

.album-nav a:hover {
    color: var(--ink);
}

.album-nav .is-active {
    color: var(--ink);
    font-weight: 500;
}

.contact {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 12px;
    color: var(--muted);
}

.contact a:hover {
    color: var(--ink);
}

.status {
    margin: 0 0 1rem;
    color: var(--muted);
}

.status[hidden] {
    display: none;
}

/* Photo grid: rows that keep every photo's real proportions.
   Each tile grows in proportion to its aspect ratio (--ar), so portraits and
   landscapes share a row at the same height. The spacer keeps the last row
   from stretching. */
.gallery {
    display: flex;
    flex-wrap: wrap;
    gap: var(--gap);
}

.gallery::after {
    content: "";
    flex: 1000000 1 0;
    height: 0;
}

.tile {
    display: block;
    min-width: 0;
    flex: calc(var(--ar) * 100) 1 calc(var(--ar) * var(--row));
    background: var(--placeholder);
}

.tile img {
    display: block;
    width: 100%;
    height: auto;
    transition: opacity 600ms ease;
}

/* An album's note (from the studio), above its photos. Fades in like the photos. */
.album-note {
    max-width: 34em;
    margin: 0 0 40px;
    opacity: 0;
    transition: opacity 600ms ease;
}

.album-note.is-loaded {
    opacity: 1;
}

.album-note[hidden] {
    display: none;
}

.album-note p {
    margin: 0;
}

.album-note p + p {
    margin-top: 0.8em;
}

.album-note a {
    text-decoration: underline;
    text-decoration-color: rgba(17, 17, 17, 0.3);
    text-underline-offset: 3px;
}

.album-note a:hover {
    text-decoration-color: currentColor;
}

/* fade each photo in as it finishes loading (class added by app.js) */
img.fade {
    opacity: 0;
}

img.fade.is-loaded {
    opacity: 1;
}

.tile:hover img.is-loaded,
.tile:hover img:not(.fade) {
    opacity: 0.9;
    transition-duration: 150ms;
}

/* Landing page: one cover photo where the grid would be, hung like a print.
   Photo + caption fit in the window with the same 48px margin above and below
   (136px = 48 top + ~40 caption + 48 bottom; --ar is its aspect ratio), and it's
   centred in the column so spare width becomes even margins on both sides. */
.cover {
    margin: 0 auto;
    width: min(100%, calc((100vh - 136px) * var(--ar, 1.5)));
}

.cover[hidden] {
    display: none;
}

.cover-link {
    display: block;
    background: var(--placeholder) center / cover no-repeat; /* app.js puts the small grid copy here while the full one loads */
}

.cover-link picture {
    display: block;
}

.cover-link img {
    display: block;
    width: 100%;
    height: auto;
    transition: opacity 600ms ease;
}

.cover-meta {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    padding-top: 16px;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: 11px;
}

.cover-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0 18px;
}

.cover-tags a,
.cover-date {
    color: var(--muted);
}

.cover-tags a {
    transition: color 120ms ease;
}

.cover-tags a:hover {
    color: var(--ink);
}

.cover-date {
    white-space: nowrap;
}

.gallery[hidden] {
    display: none;
}

/* Viewer */
.no-scroll {
    overflow: hidden;
}

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: flex;
    flex-direction: column;
    padding: 28px 40px 40px;
    background: var(--paper);
}

.lightbox[hidden] {
    display: none;
}

.lb-bar {
    flex: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: 11px;
}

.lb-bar button {
    padding: 0.5rem 0;
    border: none;
    background: none;
    font: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
    color: var(--ink);
    cursor: pointer;
    transition: color 120ms ease;
}

.lb-bar button:hover {
    color: var(--muted);
}

.lb-bar button:disabled {
    color: #b8b6af;
    cursor: default;
}

.lb-steps {
    display: flex;
    gap: 28px;
}

.lb-meta {
    display: flex;
    align-items: baseline;
    gap: 28px;
    min-width: 0;
}

.lb-count {
    color: var(--muted);
}

/* albums the open photo is in: links back to each album (and its note) */
.lb-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0 18px;
}

.lb-tags[hidden] {
    display: none;
}

.lb-tags a {
    color: var(--muted);
    transition: color 120ms ease;
}

.lb-tags a:hover {
    color: var(--ink);
}

.lb-tags [aria-current] {
    color: var(--ink);
}

.lb-stage {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
}

.lb-img {
    flex: 1 1 0;
    width: 100%;
    min-width: 0;
    min-height: 0;
    object-fit: contain;
    transition: opacity 120ms ease;
}

.lb-img.is-loading {
    opacity: 0.35;
}

/* Desktop viewer full screen: clicking the photo hides the controls, puts it on black and asks the
   browser for real fullscreen; clicking again brings them back (app.js toggles .is-immersive).
   Phones use the phone viewer (.pv) below instead. */
.lightbox:focus {
    outline: none;
}

.lb-img {
    cursor: zoom-in;
}

.lightbox.is-immersive {
    padding: 0;
    background: #000;
}

.lightbox.is-immersive .lb-bar {
    display: none;
}

.lightbox.is-immersive .lb-img {
    cursor: zoom-out;
}

/* Phone viewer (#pv; app.js opens it instead of the lightbox at <=860px): full screen on black,
   swipe sideways between photos (the track snaps), tap to hide the controls, double-tap or pinch to
   zoom, swipe down to close. The photo fits whichever way the phone is held. */
.pv {
    position: fixed;
    inset: 0;
    z-index: 30;
    background: #000;
    color: #fff;
}

.pv[hidden] {
    display: none;
}

.pv:focus {
    outline: none;
}

/* black behind Safari's toolbar and status bar too while it's open */
html.pv-open,
html.pv-open body {
    background: #000;
}

.pv-track {
    position: absolute;
    inset: 0;
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    overscroll-behavior: contain;
    touch-action: pan-x; /* pinch and double-tap are handled in app.js */
}

.pv-track::-webkit-scrollbar {
    display: none;
}

/* zoomed in: dragging moves around the photo instead of changing photos */
.pv.is-zoomed .pv-track {
    overflow-x: hidden;
    touch-action: none;
}

.pv-slide {
    flex: 0 0 100%;
    height: 100%;
    overflow: hidden;
    scroll-snap-align: center;
    scroll-snap-stop: always;
}

.pv-slide img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.pv-top,
.pv-tags {
    position: absolute;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    padding-left: 16px;
    padding-right: 16px;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: 11px;
    transition: opacity 200ms ease;
}

.pv-top {
    top: 0;
    justify-content: space-between;
    padding-top: env(safe-area-inset-top);
    background: linear-gradient(rgba(0, 0, 0, 0.5), transparent);
}

.pv-top button {
    min-height: 44px;
    padding: 0;
    border: 0;
    background: none;
    color: #fff;
    font: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
    cursor: pointer;
}

.pv-count {
    color: rgba(255, 255, 255, 0.7);
}

.pv-tags {
    bottom: 0;
    justify-content: center;
    gap: 0 22px;
    padding-bottom: env(safe-area-inset-bottom);
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.5));
}

.pv-tags[hidden] {
    display: none;
}

.pv-tags a,
.pv-tags [aria-current] {
    display: inline-block;
    padding: 14px 0;
}

.pv-tags a {
    color: rgba(255, 255, 255, 0.7);
}

.pv-tags [aria-current] {
    color: #fff;
}

/* controls out of the way: tapped away, zoomed in, or mid swipe-down */
.pv.is-bare .pv-top,
.pv.is-bare .pv-tags,
.pv.is-zoomed .pv-top,
.pv.is-zoomed .pv-tags,
.pv.is-dragging .pv-top,
.pv.is-dragging .pv-tags {
    opacity: 0;
    pointer-events: none;
}

/* phone-only header parts */
.nav-toggle,
.album-head {
    display: none;
}

/* Large screens: taller grid rows so photos aren't postage stamps on a wide monitor */
@media (min-width: 1600px) {
    :root {
        --row: 380px;
    }
}

@media (min-width: 2200px) {
    :root {
        --row: 460px;
    }
}

/* Narrow screens (phones): one-line header (wordmark + "albums" menu), the album's name above
   its photos, a 2-column grid (app.js puts each photo in the shorter column), contact below.
   Photos open in the phone viewer above. */
@media (max-width: 860px) {
    :root {
        --gap: 6px;
    }

    /* short pages (the cover) stay packed at the top instead of spreading out */
    .layout {
        align-content: flex-start;
        align-items: baseline;
    }

    .side {
        display: contents;
    }

    .wordmark {
        order: 1;
        flex: 1 1 auto;
        min-width: 0;
        padding: 18px 0 10px 16px;
    }

    .nav-toggle {
        display: block;
        order: 2;
        flex: none;
        min-height: 44px;
        padding: 18px 16px 10px;
        border: 0;
        background: none;
        font: inherit;
        color: var(--muted);
        cursor: pointer;
    }

    .nav-toggle[aria-expanded="true"] {
        color: var(--ink);
    }

    /* the album list opens under the header when "albums" is tapped */
    .album-nav {
        order: 3;
        flex: 1 1 100%;
        padding: 0 16px 10px;
    }

    .layout:not(.nav-open) .album-nav {
        display: none;
    }

    .album-nav ul {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0 22px;
    }

    /* comfortable touch targets (~44px tall) */
    .album-nav a,
    .album-nav .is-active {
        display: inline-block;
        padding: 12px 0;
    }

    main {
        order: 4;
        flex: 1 1 100%;
        padding: 0 16px;
    }

    .album-head {
        display: flex;
        padding: 6px 0 14px;
        text-transform: uppercase;
        letter-spacing: 0.16em;
        font-size: 11px;
    }

    .album-head[hidden] {
        display: none;
    }

    .album-note {
        margin-bottom: 24px;
    }

    .gallery.is-cols {
        flex-wrap: nowrap;
        align-items: flex-start;
    }

    .gallery.is-cols::after {
        display: none;
    }

    .gallery .col {
        flex: 1 1 0;
        min-width: 0;
        display: flex;
        flex-direction: column;
        gap: var(--gap);
    }

    .gallery .col .tile {
        flex: none;
    }

    .cover {
        width: 100%;
    }

    .cover-link {
        cursor: pointer; /* phones tap it to open the viewer */
    }

    .cover-meta {
        padding-top: 4px;
    }

    .cover-tags {
        gap: 0 22px;
    }

    .cover-tags a {
        display: inline-block;
        padding: 12px 0;
    }

    /* name, email, site: evenly spaced, set apart from the photos by a hairline */
    .contact {
        order: 5;
        flex: 1 1 100%;
        gap: 0;
        margin: 40px 16px 0;
        padding: 12px 0 32px;
        border-top: 1px solid var(--placeholder);
    }

    .contact span,
    .contact a {
        display: block;
        padding: 6px 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
    }
}
