/* ---------- Tokens ---------- */
:root {
    --bg: #f8f8f8;
    --ink: #1a1a1a;
    --muted: #898989;       /* = #1a1a1a at 50% opacity over --bg: every non-black text uses this */
    --line: var(--muted);   /* lines and borders share the one grey */
    --pad-x: 1.5rem;
    /* Typefaces. Helvetica Neue is built into Mac/iPhone; other devices fall back to Inter (Google Fonts) */
    --font: 'Helvetica Neue', Helvetica, 'Inter', Arial, sans-serif;   /* Nav, Label and everything else */
    --font-text: var(--font);                                          /* Body */
    --font-display: 'Space Grotesk', sans-serif;                       /* Display */
    --fade: 0.65s;   /* never transition `visibility` (or `all`) inside a .page: the element would stay visible for a moment after its page hides */

    /* Type scale: 4 styles only */
    --fs-display: clamp(1.5rem, 2.6vw, 2.75rem);
    --lh-display: 1.3;
    --fs-body: 1rem;
    --lh-body: 1.625;
    --fs-label: 0.75rem;
    --lh-label: 1rem;

    /* Nav bar: same space above and below the buttons; content starts right under it */
    --nav-pad: 32px;
    --pad-top: calc(2 * var(--nav-pad) + var(--fs-body) * var(--lh-body));
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
/* Phones: no dark flash over whatever is tapped */
* { -webkit-tap-highlight-color: transparent; }
ul { list-style: none; }
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button, input { font: inherit; color: inherit; background: transparent; border: 0; }
button { cursor: pointer; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }

/* Hide scrollbars, as in the Variant preview */
* { scrollbar-width: none; }
*::-webkit-scrollbar { display: none; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--ink);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    height: 100vh;
    overflow: hidden;
}

/* ---------- Type styles ---------- */
/* Display: lede, Works titles, big search field */
.lede,
.work-title,
.search-big-input {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: var(--fs-display);
    line-height: var(--lh-display);
}

/* Body: all running text and form text */
.intro, .small, .entry-title, .entry-text, .list-items, .search-input, .field input, .field textarea, .result-item .r-title {
    font-family: var(--font-text);
    font-weight: 400;
    font-size: var(--fs-body);
    line-height: var(--lh-body);
}

/* Label: small grey caps (labels, dates, captions, copyright) */
.label, .micro, .entry-meta, .entry-date, .mini-tag {
    font-size: var(--fs-label);
    line-height: var(--lh-label);
    color: var(--muted);
    text-transform: uppercase;
}
.label { display: block; margin-bottom: 1rem; }
/* Buttons use the Label size and caps but keep ink color so they read as clickable */
.tag-btn, .send-btn {
    font-size: var(--fs-label);
    line-height: var(--lh-label);
    text-transform: uppercase;
}
.muted { color: var(--muted); }

/* Copyright: bottom right on every page */
.copyright { margin: auto 0 0; text-align: right; }

/* ---------- Nav bar ---------- */
/* The nav itself is only the buttons (no background, on every page).
   On section pages the "bar" is a cover that belongs to each page, so it dissolves with that page. */
.top-nav {
    position: fixed;
    inset: 0 0 auto 0;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    padding-top: var(--nav-pad);
    z-index: 40;
    pointer-events: none;
}
.top-nav .nav-cell { padding: 0 var(--pad-x); }
.top-nav a { pointer-events: auto; }

/* Nav: Body size, all caps, bold; the open section is underlined */
.nav-link {
    font-size: var(--fs-body);
    line-height: var(--lh-body);
    text-transform: uppercase;
    font-weight: 600;
    /* Underline is always there but transparent: grey 1px on hover, ink 2px while pressed / when its section is open */
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.3em;
    text-decoration-color: transparent;
    transition: text-decoration-color 0.2s ease, opacity var(--fade) ease, visibility var(--fade) ease;
}
.nav-link:hover { text-decoration-color: var(--muted); }
.nav-link:active { text-decoration-color: var(--ink); text-decoration-thickness: 2px; }

/* Inside a section, only the pressed button stays */
body[data-section] .top-nav a[data-target] { visibility: hidden; opacity: 0; }
body[data-section="about"]  .top-nav a[data-target="about"],
body[data-section="works"]  .top-nav a[data-target="works"],
body[data-section="discover"] .top-nav a[data-target="discover"] {
    visibility: visible;
    opacity: 1;
    text-decoration-color: var(--ink);
    text-decoration-thickness: 2px;
}

/* ---------- Pages + dissolve ---------- */
.page {
    position: fixed;
    inset: 0;
    background: var(--bg);
    visibility: hidden;
    z-index: 10;
}
.page.current { visibility: visible; }
.page.leaving  { visibility: visible; z-index: 20; animation: pageOut var(--fade) ease forwards; }
.page.entering { visibility: visible; z-index: 30; animation: pageIn  var(--fade) ease forwards; }
.page-scroll { overflow-y: auto; }
/* Cover under the nav buttons: content scrolls beneath it, and it fades with its own page */
.page-scroll::before {
    content: '';
    display: block;
    position: sticky;
    top: 0;
    z-index: 1;
    height: var(--pad-top);
    margin-bottom: calc(-1 * var(--pad-top));
    background: var(--bg);
}
.page-inner {
    padding: var(--pad-top) var(--pad-x) 2rem;
    min-height: 100%;
    display: flex;
    flex-direction: column;
}
.page-inner > .copyright { padding-top: 4rem; }

@keyframes pageOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes pageIn  { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Home grid ---------- */
.grid-container {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 100vh auto;   /* the kiosk screen fills the window; the bottom bar sits below it */
    width: 100%;
}
/* Home shows only the buttons and the kiosk; intro and Discover columns stay in the HTML, hidden */
#page-home .grid-column:not(.works-column) { display: none; }
.grid-column {
    padding: var(--pad-top) var(--pad-x) 2rem;
    min-width: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Photo under the home intro: 3:4, but shrinks (cropping top/bottom) on short screens so it never runs past the bottom margin */
.home-photo {
    display: block;
    width: 100%;
    flex: 0 1 auto;
    min-height: 0;
    aspect-ratio: 3 / 4;
    object-fit: cover;
    margin-top: 2rem;
}

/* Bottom bar: below the first screen; same height and columns as the top bar; everything right-aligned */
.home-footer {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    min-height: var(--pad-top);
}
.footer-cell {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-width: 0;
    padding: 0 var(--pad-x);
    text-align: right;
}
.footer-cell .label { margin: 0; }
.footer-cell .comms { margin: 0; }

/* Kiosk: full width, from under the button bar down to the bottom of the first screen */
.works-column { padding: var(--pad-top) 0 0; }
.kiosk-thumb {
    position: relative;
    display: block;
    flex: 1;
    overflow: hidden;
    background: var(--ink);
}
.kiosk-stack { position: absolute; inset: 0; }
.kiosk-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: translateX(100%);   /* waits to the right of the frame */
}
/* Push: the next slide comes in from the right and pushes the current one out the left */
.kiosk-img.active, .kiosk-img.leaving { transition: transform 1.2s cubic-bezier(0.65, 0, 0.35, 1); }
.kiosk-img.active { transform: translateX(0); }
.kiosk-img.leaving { transform: translateX(-100%); }

/* Discover column */
.search-input {
    width: 100%;
    border-bottom: 1px solid var(--ink);
    padding: 0.25rem 0;
    outline: none;
}
.mini-tags { margin-top: 1rem; }
.tag-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.mini-tag {
    border: 1px solid var(--line);
    padding: 0 0.25rem;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
/* Same hover as the Discover page tags */
.mini-tag:hover { background: var(--ink); border-color: var(--ink); color: var(--bg); }

/* Contact logos (home + Discover) */
.comms { display: flex; align-items: center; gap: 1.25rem; margin-top: 3rem; }
.icon-link { display: block; transition: opacity 0.2s ease; }
.icon-link:hover { opacity: 0.5; }
.icon { width: 20px; height: 20px; max-width: none; }   /* max-width: none lets a larger "size" icon overflow its 20px slot */

/* ---------- About ---------- */
/* Every row uses the home guides: 3 equal columns, gap = both column paddings */
.about-top, .about-section, .about-entry, .about-lists {
    display: grid;
    column-gap: calc(2 * var(--pad-x));
}
.about-top, .about-section { grid-template-columns: repeat(3, 1fr); }
.about .label:not(.copyright) { margin-bottom: 1.5rem; }

/* Top: photo | intro */
.portrait {
    width: 100%;
    aspect-ratio: 3 / 4;
    object-fit: cover;
}
.about-intro { grid-column: 2 / 4; }
.about .muted.small { margin-top: 1.5rem; }

/* Résumé: section title | content | dates. Separated by space only, no dividers */
.about-section { margin-top: 6rem; }
.about-section > .label { grid-column: 1; }
.about-section .about-body { grid-column: 2 / 4; }
.about-entry { grid-template-columns: 1fr 1fr; }
.about-entry + .about-entry { margin-top: 2rem; }
.entry-meta { display: block; margin-top: 0.25rem; }
.entry-text { margin-top: 0.5rem; color: var(--muted); }
.entry-date { padding-top: 0.25rem; }   /* sits on the title's first line */
.about-lists { grid-template-columns: 1fr 1fr; }
.about-lists .label { margin-bottom: 0.75rem; }
.about-tags { display: grid; grid-template-columns: repeat(3, 1fr); column-gap: calc(2 * var(--pad-x)); margin-top: 6rem; }
.about-tags .tag-row { grid-column: 2 / 4; }

/* Narrow screens: stack everything in one column */
@media (max-width: 760px) {
    .home-footer { grid-template-columns: 1fr; row-gap: 0.75rem; padding: 1rem 0; }
    .about-top, .about-section, .about-entry, .about-lists { grid-template-columns: 1fr; row-gap: 1rem; }
    .about-tags { grid-template-columns: 1fr; }
    .about-intro, .about-section .about-body, .about-tags .tag-row { grid-column: auto; }
    .about-lists { row-gap: 2rem; }
}

/* ---------- Works ---------- */
/* Filter tags: one row from the left margin, right under the bar (same gap as the bar's); they stay while the page scrolls */
.works-filters {
    position: sticky;
    top: var(--pad-top);
    z-index: 2;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin: 0 calc(-1 * var(--pad-x));
    padding: 0 var(--pad-x) calc(var(--nav-pad) - 1rem);
    background: var(--bg);
}
/* Same big box as the Discover tags (.tag-btn); the pressed one stays filled */
.filter-tag {
    font-size: var(--fs-label);
    line-height: var(--lh-label);
    text-transform: uppercase;
    border: 1px solid var(--ink);
    padding: 0.4rem 1rem;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.filter-tag:hover, .filter-tag.on { background: var(--ink); color: var(--bg); }

/* The 1rem above the covers is open page (not under the bar), so a lifted cover is not clipped */
.works-body { position: relative; padding-top: 1rem; }
/* Opening / closing a project: everything under the tags fades out, swaps, fades in */
#page-works .page-inner > .works-body,
#page-works .page-inner > .copyright { transition: opacity 0.3s ease; }
#page-works .page-inner.fading > .works-body,
#page-works .page-inner.fading > .copyright { opacity: 0; }
/* A jump (back/forward button, a link): the new state shows at once, no fades */
#page-works.instant, #page-works.instant * { transition: none !important; }

/* Covers: 3 columns on the home guides, in order (1 2 3 / 4 5 6 …); the grid is only for layout */
.works-grid {
    position: relative;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: calc(2 * var(--pad-x));
    align-items: start;
}
/* Left-out covers (and the covers while a project is open) stay drawn but collapsed and invisible, not display: none —
   Safari throws away the decoded images of display: none content and decodes them again when they come back */
.gone {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 0;
    overflow: hidden;
    visibility: hidden;
}
.work-cover { display: block; width: 100%; }
.work-cover img, .cover-blank {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 5;
    object-fit: cover;
    /* Steep ease-out: the card lifts almost at once, then settles */
    transition: transform 0.5s cubic-bezier(0.05, 0.9, 0.1, 1), box-shadow 0.5s cubic-bezier(0.05, 0.9, 0.1, 1);
}
.cover-blank { background: var(--ink); }
/* Hover: the cover lifts a little off the page, tilting as if picked up by a corner */
@media (hover: hover) {
    .work-cover:hover img,
    .work-cover:hover .cover-blank {
        transform: translateY(-0.5rem) rotate(-1.2deg);
        box-shadow: 0 1rem 2rem rgba(26, 26, 26, 0.18);
    }
}
/* Narrow screens: one cover per row at full width */
@media (max-width: 760px) {
    .works-grid { grid-template-columns: 1fr; }
}

/* Project page: year, title, tags, then the work at full width */
.work-head { margin-bottom: 3rem; }
.work-head .label { margin-bottom: 0.5rem; }
/* Title: underlined on hover; clicking it goes back to the covers */
.work-title-link { text-align: left; }
.work-title-link:hover {
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 0.12em;
}
.fold-tags { margin-top: 1rem; }
/* Work media: images keep their own proportions; PDF pages are drawn as images (PDF.js) */
.fold-media + .fold-media { margin-top: 1.5rem; }
.fold-img { width: 100%; height: auto; }
.fold-pdf-page { display: block; width: 100%; height: auto; }
.fold-video { display: block; width: 100%; aspect-ratio: 16 / 9; border: 0; background: var(--ink); }
.fold-pdf-page + .fold-pdf-page { margin-top: 1.5rem; }
/* columns: 2 in content.js: pages side by side, one column again on narrow screens */
.fold-pdf[data-columns="2"] { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.fold-pdf[data-columns="2"] .fold-pdf-page { margin-top: 0; }
.fold-pdf-link { display: inline-block; margin-top: 0.5rem; color: var(--ink); }
.fold-pdf-link:hover { text-decoration: underline; }
.fold-caption { margin-top: 0.5rem; }
.fold-button { display: inline-block; }
.fold-img.zoomable { cursor: zoom-in; }

/* ---------- Full screen photo viewer ---------- */
/* script.js places, turns and scales the photo (tap zoom, pinch, drag, wheel all share it).
   touch-action: none hands every finger movement to script.js, so the page itself never zooms or scrolls */
.viewer {
    --viewer-x: max(var(--pad-x), 4vw);
    position: fixed;
    inset: 0;
    z-index: 100;
    overflow: hidden;
    background: var(--bg);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;   /* no "save image" menu on a long press */
}
.viewer[hidden] { display: none; }
.viewer:focus { outline: none; }
/* The margins an un-zoomed photo fits inside (measured by script.js, never seen) */
.viewer-frame {
    position: absolute;
    top: var(--pad-top);
    bottom: var(--pad-top);
    left: var(--viewer-x);
    right: var(--viewer-x);
    pointer-events: none;
}
.viewer-img {
    position: absolute;
    top: 0;
    left: 0;
    max-width: none;
    transform-origin: 0 0;
    will-change: transform;
}
/* Only when springing back after a gesture; taps and drags move it at once */
.viewer-img.animate { transition: transform 0.25s ease; }
/* A finished swipe: the next photo glides into the middle (ease-out, so it follows on from the finger) */
.viewer-img.slide { transition: transform 0.3s cubic-bezier(0.2, 0.7, 0.3, 1); }
/* The photos waiting before / after, off screen: never clicked */
.viewer-side { pointer-events: none; }
/* Zoomed (tap zoom or pinch): count and Close step aside */
.viewer.zoomed .viewer-count, .viewer.zoomed .viewer-close { display: none; }
/* Two click layers: the photo zooms, the background around it changes photo (left half back, right half forward) */
.viewer { cursor: e-resize; }
.viewer.left-half { cursor: w-resize; }
.viewer-img { cursor: zoom-in; }
.viewer.zoomed, .viewer.zoomed .viewer-img { cursor: zoom-out; }
.viewer-count, .viewer-close {
    position: absolute;
    top: var(--nav-pad);
    z-index: 1;
    font-size: var(--fs-label);
    line-height: var(--lh-label);
    text-transform: uppercase;
}
.viewer-count { left: var(--viewer-x); color: var(--muted); }
/* X icon; padding makes the click area larger without moving the icon */
.viewer-close {
    top: calc(var(--nav-pad) - 1rem);
    right: calc(var(--viewer-x) - 1rem);
    padding: 1rem;
    color: var(--ink);
    transition: opacity 0.2s ease;
    /* Drawn on its own layer from the start: it sits at a fractional pixel (4vw margin), and switching
       layers when the hover fade starts would round it to a whole pixel and make it wobble */
    will-change: opacity;
}
.viewer-close svg { display: block; }
.viewer-close:hover { opacity: 0.5; }

/* ---------- Discover ---------- */
#page-discover .label:not(.copyright) { margin-bottom: 2rem; }
.search-big-input {
    width: 100%;
    border-bottom: 2px solid var(--ink);
    padding: 0.75rem 0;
    outline: none;
}
.tag-row-big { gap: 0.75rem; margin-top: 2rem; }
.tag-btn {
    border: 1px solid var(--ink);
    padding: 0.4rem 1rem;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.tag-btn:hover, .tag-btn.on { background: var(--ink); color: var(--bg); }

#search-results { margin-top: 3rem; }
#search-results .micro { display: block; margin-bottom: 0.5rem; }
.result-item {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 1.1rem 0;
    border-bottom: 1px solid var(--line);
    cursor: pointer;
}
.result-item:hover .r-title { text-decoration: underline; }

/* Contact (bottom of Discover) */
.contact {
    /* Separated from the search by space only, no divider */
    margin-top: 10rem;
    /* Same 3 columns as the home guides: form spans to the 2nd line, links start at the 3rd column */
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3rem calc(2 * var(--pad-x));
}
.contact-form { grid-column: 1 / 3; display: flex; flex-direction: column; gap: 1.75rem; }
.field { display: flex; flex-direction: column; gap: 0.5rem; }
.field input,
.field textarea {
    color: inherit;
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--ink);
    padding: 0.4rem 0;
    outline: none;
    resize: vertical;
}
.send-btn {
    align-self: flex-start;
    border: 1px solid var(--ink);
    padding: 0.9rem 2.5rem;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.send-btn:hover { background: var(--ink); color: var(--bg); }
.contact-links { grid-column: 3; margin-top: 0; align-self: start; }
/* Narrow screens: the form takes the full width, links move below it */
@media (max-width: 760px) {
    .contact { grid-template-columns: 1fr; }
    .fold-pdf[data-columns="2"] { grid-template-columns: 1fr; }
    .contact-form, .contact-links { grid-column: 1; }
}

/* ---------- Photo stroke ---------- */
/* 1px inside stroke on every photo; drawn over the image so sizes and positions don't shift */
.portrait, .home-photo, .fold-img, .fold-pdf-page, .work-cover img {
    outline: 1px solid var(--ink);
    outline-offset: -1px;
}
