:root {
  --bg: #fff;
  --ink: #1f1f1f;
  --pad: 15px;
  --gap: 18px;
  --side: 25.8vw;
  --text: clamp(15px, 0.92vw, 19px);
  --small: clamp(12px, 0.7vw, 14.5px);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-weight: 500;
  font-size: var(--text);
  line-height: 1.22;
  letter-spacing: -0.012em;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img, video { display: block; width: 100%; height: auto; }
.small { font-size: var(--small); line-height: 1.3; letter-spacing: -0.005em; }

/* ───── Left column (fixed) ───── */

.side {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--side);
  padding: var(--pad);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow-y: auto;
}

.site-title { display: block; }
.nav { margin-top: 1.22em; display: flex; flex-direction: column; align-items: flex-start; }
.nav a { transition: opacity .15s; }
.nav.sections { margin-top: 0; }
.nav[hidden] { display: none; }

/* dim the other names while one is hovered or open */
.nav:hover a:not(:hover),
.nav.has-active a:not(.active),
.nav.has-peer a:not(.peer) { opacity: .3; }
.nav.has-active:hover a:hover { opacity: 1; }
/* the previewed name wins over the open one */
.nav.has-peer a.peer { opacity: 1; }
.nav.has-peer a.active:not(.peer) { opacity: .3; }

/* ───── Right column (scrolls) ───── */

main {
  margin-left: var(--side);
  padding: 10px 12px var(--pad) 0;
  min-height: 100vh;
}

/* Index grid */
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
}
.tile { display: block; aspect-ratio: 3 / 2; overflow: hidden; }
/* whole work is shown inside the tile, never cropped */
.tile img, .tile video { width: 100%; height: 100%; object-fit: contain; object-position: center; }
.tile { animation: appear .2s ease-out; }
@keyframes appear { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .tile { animation: none; } }

/* Project page */
.project { display: flex; flex-direction: column; min-height: calc(100vh - 25px); }

.project-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: var(--gap);
  padding: 15px 0 calc(var(--gap) - 2px);
  margin-top: -10px;
  background: var(--bg);
}
.project-head .right { display: flex; justify-content: space-between; gap: 1em; }

.project-images { display: flex; flex-direction: column; gap: var(--gap); }
.project-images img, .project-images video { background: #eee; }
.project-images .row { display: grid; grid-template-columns: repeat(var(--cols), 1fr); gap: var(--gap); align-items: start; }
.project-images .row.centered {
  grid-template-columns: repeat(var(--fill), calc((100% - (var(--cols) - 1) * var(--gap)) / var(--cols)));
  justify-content: center;
}

.project-text {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: var(--gap);
  padding: 30px 0 90px;
}
.project-text h2 { font: inherit; margin-bottom: 1.3em; }
.project-text p { max-width: 46em; }
.details p + p { margin-top: 1.3em; }
.details p { white-space: pre-line; }
.body p + p { margin-top: 1.3em; }
/* description under a hover preview spans both grid columns */
.grid > .project-text { grid-column: 1 / -1; padding-top: 12px; }

.project-foot {
  margin-top: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: var(--gap);
}
.project-foot a span { text-decoration: underline; text-underline-offset: 2px; }
a:hover .u, .project-foot a:hover span { text-decoration: none; }

/* Editorial spreads (photography) — see renderSpreads in app.js
   Every spread shares one book grid, so photos, captions and page numbers
   always land on the same lines from spread to spread:

     | outer | 6 columns (left page) | inner | 6 columns (right page) | outer |
     top margin / 6 rows / bottom margin

   Column lines are named l1…l6, lx (end of left page), r1…r6, rx;
   row lines t1…t6, tx (end); bleed-l / bleed-r and edge-t / edge-b are the paper's edges.
   Photos fill their grid cell exactly (cropped to it; a `pos` per image moves the crop). */
.spreads {
  container-type: inline-size;            /* cqw = 1% of a spread's width */
  display: flex;
  flex-direction: column;
  gap: clamp(60px, 12cqw, 200px);
  padding: 4cqw 0 2cqw;
}
.spreads + .project-text { margin-top: clamp(50px, 7vw, 130px); }

.spread {
  --g: 1.5cqw;                            /* gutter, both directions */
  position: relative;
  display: grid;
  aspect-ratio: 1.414;                    /* two A4 pages side by side */
  min-height: 0;                          /* keep that shape exactly, never grow to fit a photo */
  column-gap: var(--g);
  row-gap: var(--g);
  /* minmax(0, 1fr): tracks keep their size whatever the photo inside, so the grid never shifts */
  grid-template-columns:
    [bleed-l] 5cqw
    [l1] minmax(0, 1fr) [l2] minmax(0, 1fr) [l3] minmax(0, 1fr) [l4] minmax(0, 1fr) [l5] minmax(0, 1fr) [l6] minmax(0, 1fr) [lx] 6cqw
    [r1] minmax(0, 1fr) [r2] minmax(0, 1fr) [r3] minmax(0, 1fr) [r4] minmax(0, 1fr) [r5] minmax(0, 1fr) [r6] minmax(0, 1fr) [rx] 5cqw [bleed-r];
  grid-template-rows:
    [edge-t] 4.5cqw [t1] minmax(0, 1fr) [t2] minmax(0, 1fr) [t3] minmax(0, 1fr) [t4] minmax(0, 1fr) [t5] minmax(0, 1fr) [t6] minmax(0, 1fr) [tx] 5.5cqw [edge-b];
}
.spread::before {                         /* the fold */
  content: "";
  position: absolute;
  inset: 0 auto 0 50%;
  border-left: 1px solid #efefef;
}
.spread figure { display: contents; }     /* photo and caption sit on the grid themselves */
.spread .ph { position: relative; z-index: 1; width: 100%; height: 100%; min-height: 0; object-fit: cover; }
.spread figcaption { align-self: start; white-space: pre-line; }

.folio { opacity: .45; align-self: center; }
.folio.tl { grid-area: edge-t / l1 / t1 / lx; }
.folio.tr { grid-area: edge-t / r1 / t1 / rx; justify-self: end; }
.folio.bl { grid-area: tx / l1 / edge-b / lx; }
.folio.br { grid-area: tx / r1 / edge-b / rx; justify-self: end; }

/* single: one photo across the fold, caption on the right page below it */
.spread--single figure:nth-of-type(1) .ph         { grid-area: t1 / l3 / t6 / r5; }
.spread--single figure:nth-of-type(1) figcaption  { grid-area: t6 / r1 / tx / r5; }

/* pair: one photo per page, the right one a row lower */
.spread--pair figure:nth-of-type(1) .ph           { grid-area: t1 / l2 / t5 / l6; }
.spread--pair figure:nth-of-type(1) figcaption    { grid-area: t5 / l2 / t6 / l6; }
.spread--pair figure:nth-of-type(2) .ph           { grid-area: t2 / r2 / t6 / r6; }
.spread--pair figure:nth-of-type(2) figcaption    { grid-area: t6 / r2 / tx / r6; }

/* tall-pair: the whole left page, two photos stacked right with captions beside */
.spread--tall-pair figure:nth-of-type(1) .ph        { grid-area: t1 / l1 / tx / lx; }
.spread--tall-pair figure:nth-of-type(1) figcaption { grid-area: tx / l1 / edge-b / lx; align-self: center; padding-left: 4em; }

/* full-pair: the left page bleeds off top, bottom and outer edge */
.spread--full-pair figure:nth-of-type(1) .ph        { grid-area: edge-t / bleed-l / edge-b / lx; }
.spread--full-pair figure:nth-of-type(1) figcaption { grid-area: tx / r1 / edge-b / r4; align-self: center; }
.spread--full-pair .folio.tl, .spread--full-pair .folio.bl { display: none; }

/* the right page of tall-pair and full-pair: two photos, captions in the outer columns */
:is(.spread--tall-pair, .spread--full-pair) figure:nth-of-type(2) .ph        { grid-area: t1 / r1 / t4 / r5; }
:is(.spread--tall-pair, .spread--full-pair) figure:nth-of-type(2) figcaption { grid-area: t1 / r5 / t2 / rx; }
:is(.spread--tall-pair, .spread--full-pair) figure:nth-of-type(3) .ph        { grid-area: t4 / r1 / tx / r5; }
:is(.spread--tall-pair, .spread--full-pair) figure:nth-of-type(3) figcaption { grid-area: t6 / r5 / tx / rx; align-self: end; }

/* full: one wide photo across both pages */
.spread--full figure:nth-of-type(1) .ph         { grid-area: t1 / l1 / t5 / rx; }
.spread--full figure:nth-of-type(1) figcaption  { grid-area: t5 / r1 / t6 / r5; }

/* duo: each page filled by one photo, margin to margin */
.spread--duo figure:nth-of-type(1) .ph { grid-area: t1 / l1 / tx / lx; }
.spread--duo figure:nth-of-type(2) .ph { grid-area: t1 / r1 / tx / rx; }

/* large: one photo across both pages and all six rows (fits a 3:2 photo almost uncropped) */
.spread--large figure:nth-of-type(1) .ph        { grid-area: t1 / l1 / tx / rx; }

/* Information page */
.info { display: flex; align-items: flex-start; gap: var(--gap); padding-top: 5px; }
.info-text { max-width: 34em; }
.info p + p { margin-top: 1.22em; }
.info .portrait { flex: none; width: 6em; height: auto; } /* 4:5, lightly cropped */
.info p { white-space: pre-line; } /* \n in the text = line break */
.info a { text-decoration: underline; text-underline-offset: 2px; }

/* ───── Phones: stack ───── */

@media (max-width: 800px) {
  :root { --gap: 10px; --text: 16px; --small: 13px; }

  .side { position: static; width: auto; display: block; overflow: visible; }
  .side-foot { display: none; }

  main { margin-left: 0; padding: 10px var(--pad) var(--pad); min-height: 0; }

  .grid { grid-template-columns: 1fr; }

  /* on a project page the project list is hidden — (Index) brings it back */
  body.is-project #project-nav,
  body.is-project #meta-nav { display: none; }

  .project { min-height: 0; }
  .project-head { grid-template-columns: 1fr; }
  .project-images .row, .project-images .row.centered { grid-template-columns: 1fr; }
  .project-head .right { margin-top: 0; }
  .project-text { grid-template-columns: 1fr; row-gap: 2.5em; padding: 22px 0 60px; }
  .project-foot { grid-template-columns: 1fr; row-gap: .4em; }

  /* spreads become a single airy column: photos uncropped, alternating sides */
  .spreads { gap: 18cqw; padding-top: 8cqw; }
  .spread { display: flex; flex-direction: column; gap: 14cqw; aspect-ratio: auto; }
  .spread::before, .folio { display: none; }
  .spread figure { display: block; width: 78%; align-self: flex-start; }
  .spread figure:nth-of-type(even) { align-self: flex-end; }
  .spread--single figure, .spread--full figure, .spread--large figure, .spread--duo figure,
  .spread--tall-pair figure:nth-of-type(1), .spread--full-pair figure:nth-of-type(1) { width: 100%; }
  .spread .ph { height: auto; object-fit: initial; }
  .spread figcaption { margin-top: .8em; padding-left: 0; }
}
