/* ------------------------------------------------------------------
   Hannah Liebig — portfolio
   Rebuilt 1:1 from the InDesign mockup (1440 x design canvas).
   Every size and gap below is expressed in "design pixels" of that
   canvas and scaled through --u, so the page is pixel-identical to the
   mockup at 1440px and proportional at any smaller width.
   ------------------------------------------------------------------ */

:root {
    /* White frame left and right at every width, always relative to the
       viewport (24vw) rather than a fixed pixel value. The canvas inside it
       keeps growing with the screen up to 1800, so the page never sits there
       small on a large monitor. */
    --frame: clamp(24px, 24vw, 600px);
    --canvas: clamp(680px, calc(100vw - 2 * var(--frame)), 1800px);
    /* One design pixel: everything in the layout stays proportional to the
       canvas, exactly as in the mockup. Readability is handled on the type
       sizes below, so the two never drift apart. */
    --u: calc(var(--canvas) / 1440);
    --gs: 1;                            /* gap scale */

    --fs-nav: calc(36 * var(--u));
    --fs-body: max(calc(30 * var(--u)), 17px);
    --fs-cap: max(calc(24 * var(--u)), 13.5px);

    --margin: calc(36 * var(--u));      /* page gutter */
    --header-h: calc(118.5 * var(--u));
    --art-h: calc(var(--canvas) * 0.7748);   /* 98.78% of canvas / 1.2749 aspect */
    --ink: #000;
}

* { box-sizing: border-box; }

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    scroll-padding-top: calc(150 * var(--u));
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
}

body {
    margin: 0;
    background: #fff;
    color: var(--ink);
    font-family: 'Work Sans', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
    font-weight: 400;
    font-synthesis-weight: none;
    text-rendering: optimizeLegibility;
}

.page {
    width: var(--canvas);
    margin: 0 auto;
    padding-bottom: calc(240 * var(--u));
    overflow-x: clip;   /* clip, not hidden: `hidden` would break position:sticky */
}

/* Every flow block carries its mockup offset as --mt (design px).
   --mt is reset here so it never leaks into nested blocks by inheritance. */
.b { margin-top: calc(var(--mt, 0) * var(--u) * var(--gs)); }
.b > * { --mt: 0; }

.pad { margin-left: var(--margin); margin-right: var(--margin); }
/* replaced elements resolve width:100% against the container, not the margin box */
img.pad { width: calc(100% - 2 * var(--margin)); }

img { display: block; width: 100%; height: auto; }

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 0.18em; }

/* ------------------------------------------------------- header ---- */

/* One header for the whole page. It only ever says, in bold, which section
   you are currently in. */
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: #fff;
    padding-top: calc(55.1 * var(--u));
    padding-bottom: calc(27.4 * var(--u));
}

.nav {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    font-size: var(--fs-nav);
    line-height: 1;
}
.nav a { white-space: nowrap; }
.nav a:nth-child(1) { justify-self: start; }
.nav a:nth-child(2) { justify-self: center; }
.nav a:nth-child(3) { justify-self: end; }
.nav a[aria-current] { font-weight: 600; }

/* ----------------------------------------------------- wordmark ---- */

.wordmark { margin-bottom: 0; }
.wordmark svg { display: block; width: 100%; height: auto; }
.wordmark text {
    font-family: 'Work Sans', system-ui, sans-serif;
    font-weight: 800;
    font-size: 175px;
    fill: var(--ink);
}

/* The red line drawing is a pinned background layer: it holds its place in
   the viewport, centred in the space under the header, while the Artist
   Statement and CV/Contact scroll over it. .pinned ends where Selected Works
   begins, so that is where it unpins and travels up and out (position: sticky). */
.pinned { position: relative; }

.drawing {
    position: sticky;
    /* centred in the space under the header, but never pushed below the
       position the mockup gives it on tall screens */
    top: min(calc(146 * var(--u)),
             calc(var(--header-h) + (100svh - var(--header-h) - var(--art-h)) / 2));
    z-index: 0;
    width: 98.78%;
}

/* Everything in .pinned reads on top of the artwork, as in the mockup: the
   drawing starts at y146, the opening paragraph at y892 on the canvas. */
.pinned > * { position: relative; z-index: 1; }
.pinned > .drawing { position: sticky; z-index: 0; }

/* ------------------------------------------------------- copy ------ */

.lede, .note, .prose {
    font-size: var(--fs-body);
    font-weight: 400;
}
.lede { line-height: 1.267; }
.lede p { margin: 0; }

.prose { line-height: 1.167; }
.prose p { margin: 0; }
.prose .spacer { height: 1.167em; }

.note { line-height: 1.2; }
.note p { margin: 0; }

.measure-885 { width: calc(884.8 / 1368 * 100%); }

/* --------------------------------------------------------- cv ------ */

.cv { font-size: var(--fs-body); line-height: 1; }
.cv .row {
    --mt: 0;
    display: grid;
    grid-template-columns: 23.68% 1fr;   /* tab stop at x324 of 1368 */
    margin-top: calc(var(--mt) * var(--u) * var(--gs));
}

/* ------------------------------------------------- works index ----- */

.index { font-size: var(--fs-body); line-height: 2.4; }
.index div { font-weight: 400; }
.index .year { font-weight: 500; }

/* ---------------------------------------------------- captions ----- */

.cap { font-size: var(--fs-cap); line-height: 1.2; }
.cap--lg { font-size: var(--fs-body); line-height: 1.2; }
.cap--lead { line-height: 1.5; }
.cap .title { font-weight: 700; font-style: italic; }
.cap div { font-weight: 400; }

/* Two-column caption rows (title | exhibition) */
.cap.split { display: grid; }
.cap.split.at-32 { grid-template-columns: 32.3% 1fr; }
.cap.split.at-46 { grid-template-columns: 46.1% 1fr; }

.label {
    font-size: var(--fs-cap);
    line-height: 1.2;
    text-align: right;
}

/* Copyright line closing the page */
.colophon {
    font-size: var(--fs-cap);
    line-height: 1.2;
}

/* ------------------------------------------------------ figures ---- */

.pair { display: grid; grid-template-columns: 1fr 1fr; }
.pair--808 { grid-template-columns: 808fr 632fr; }
.pair--808 > div { overflow: hidden; }
.pair--808 > div img { width: 102.72%; }   /* 830 of 808 */

/* Studio shot that bleeds off the left edge, with its caption column */
.horse { display: flex; align-items: stretch; }
.horse .shot { width: 73.167%; overflow: hidden; }
.horse .shot img { width: 105.56%; margin-left: -5.56%; }
.horse .side {
    width: 23.875%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* 60 ceramic tiles, laid out column by column as in the mockup.
   Each one opens in the detail view. */
.tiles .tile {
    display: block;
    padding: 0;
    border: 0;
    background: none;
    cursor: zoom-in;
    -webkit-appearance: none;
    appearance: none;
}
.tiles .tile:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.tiles {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    grid-template-rows: repeat(6, auto);
    grid-auto-flow: column;
    column-gap: calc(13.9 * var(--u));
    row-gap: calc(5.3 * var(--u));
}

/* ----------------------------------------------------- lightbox ---- */

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(8px, 3vw, 48px);
    padding: clamp(12px, 4vw, 48px);
    background: #fff;
}
.lightbox[hidden] { display: none; }
.lightbox:focus { outline: none; }

.lb-stage { margin: 0; text-align: center; }

.lb-img {
    width: min(70vw, 480px);
    max-height: 72svh;
    object-fit: contain;
}

.lb-count {
    margin-top: 1em;
    font-size: clamp(12px, 1.1vw, 16px);
}

.lb-btn {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(8px, 1vw, 16px);
    border: 0;
    background: none;
    color: var(--ink);
    cursor: pointer;
    transition: opacity 0.15s ease;
}
.lb-btn:hover { opacity: 0.4; }
.lb-btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.lb-btn svg {
    display: block;
    height: auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.lb-prev svg,
.lb-next svg { width: clamp(15px, 1.6vw, 24px); }

.lb-close {
    position: absolute;
    top: clamp(6px, 2vw, 28px);
    right: clamp(8px, 2.5vw, 36px);
}
.lb-close svg { width: clamp(16px, 1.5vw, 22px); }

/* ------------------------------------------------------- mobile ---- */

@media (max-width: 760px) {
    :root {
        --u: calc(100vw / 900);
        --gs: 0.62;
        --fs-nav: clamp(10px, 3.2vw, 15px);
        --fs-body: 15px;
        --fs-cap: 12.5px;
        --margin: 5vw;
        --frame: 0px;
        --canvas: 100vw;
    }

    .lede { line-height: 1.32; }
    .prose { line-height: 1.32; }
    .note  { line-height: 1.32; }
    .cv    { line-height: 1.32; }
    .index { line-height: 2.2; }
    .cap   { line-height: 1.3; }
    .cap--lg, .cap--lead { font-size: var(--fs-body); line-height: 1.3; }
    .label { line-height: 1.3; }

    .nav a { white-space: nowrap; }

    /* the artwork still pins, but the opening text sits below it, not on top */
    .pinned .lede { margin-top: calc(40 * var(--u)); }

    .cv .row { grid-template-columns: 30% 1fr; }

    .pair, .pair--808 { grid-template-columns: 1fr; }
    .pair--808 > div img { width: 100%; margin-left: 0; }

    .horse { display: block; }
    .horse .shot { width: 100%; }
    .horse .shot img { width: 100%; margin-left: 0; }
    .horse .side { width: auto; margin: calc(24 * var(--u)) var(--margin) 0; }
    .horse .side .note { margin-top: calc(24 * var(--u)); }

    .measure-885 { width: 100%; }

    .cap.split.at-32, .cap.split.at-46 { grid-template-columns: 1fr; }
    .cap.split > :nth-child(2) { margin-top: 0.4em; }

    .tiles { column-gap: calc(10 * var(--u)); row-gap: calc(4 * var(--u)); }
}
