/* ==========================================================================
   Nutan's Art — warm editorial, press-clipping collage
   Tokens live in :root. Change those first; everything follows.
   ========================================================================== */

/* --- Typefaces: self-hosted, no Google, no CDN, no tracking --------------- */

@font-face {
  font-family: 'EB Garamond';
  src: url('../fonts/eb-garamond-latin-400-normal.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'EB Garamond';
  src: url('../fonts/eb-garamond-latin-400-italic.woff2') format('woff2');
  font-weight: 400; font-style: italic; font-display: swap;
}
@font-face {
  font-family: 'EB Garamond';
  src: url('../fonts/eb-garamond-latin-500-normal.woff2') format('woff2');
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Fraunces';
  src: url('../fonts/fraunces-latin-wght-normal.woff2') format('woff2-variations');
  font-weight: 100 900; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Fraunces';
  src: url('../fonts/fraunces-latin-wght-italic.woff2') format('woff2-variations');
  font-weight: 100 900; font-style: italic; font-display: swap;
}

@font-face {
  font-family: 'Inter';
  src: url('../fonts/inter-latin-wght-normal.woff2') format('woff2-variations');
  font-weight: 100 900; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('../fonts/inter-latin-wght-italic.woff2') format('woff2-variations');
  font-weight: 100 900; font-style: italic; font-display: swap;
}

@font-face {
  font-family: 'Cormorant Garamond';
  src: url('../fonts/cormorant-garamond-latin-400-normal.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Cormorant Garamond';
  src: url('../fonts/cormorant-garamond-latin-500-normal.woff2') format('woff2');
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Cormorant Garamond';
  src: url('../fonts/cormorant-garamond-latin-400-italic.woff2') format('woff2');
  font-weight: 400; font-style: italic; font-display: swap;
}
@font-face {
  font-family: 'Lora';
  src: url('../fonts/lora-latin-400-normal.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Lora';
  src: url('../fonts/lora-latin-500-normal.woff2') format('woff2');
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Lora';
  src: url('../fonts/lora-latin-400-italic.woff2') format('woff2');
  font-weight: 400; font-style: italic; font-display: swap;
}
/* Three slots for fonts you add yourself, installed with tools/add-font.py.
   Each lists woff2 first and falls back to an unconverted .otf or .ttf, so a
   file that could not be converted still works — just as a larger download. */
@font-face {
  font-family: 'Custom1';
  src: url('../fonts/custom1.woff2') format('woff2'),
       url('../fonts/custom1.otf')   format('opentype'),
       url('../fonts/custom1.ttf')   format('truetype');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Custom2';
  src: url('../fonts/custom2.woff2') format('woff2'),
       url('../fonts/custom2.otf')   format('opentype'),
       url('../fonts/custom2.ttf')   format('truetype');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Custom3';
  src: url('../fonts/custom3.woff2') format('woff2'),
       url('../fonts/custom3.otf')   format('opentype'),
       url('../fonts/custom3.ttf')   format('truetype');
  font-weight: 400; font-style: normal; font-display: swap;
}

/* Declaring a family costs nothing. The browser only downloads the files a
   page actually uses, so the unselected faces are never fetched. */

/* --- Tokens --------------------------------------------------------------- */

:root {
  /* Fallbacks only. snippets/theme.php overrides all of these from the
     Panel, and derives every intermediate tone with color-mix(). */
  --paper:      #f7f3ec;
  --ink:        #241e18;
  --accent:     #aa451f;
  --ink-soft:   color-mix(in oklab, var(--ink) 80%, var(--paper));
  --ink-muted:  color-mix(in oklab, var(--ink) 54%, var(--paper));
  --ink-faint:  color-mix(in oklab, var(--ink) 32%, var(--paper));
  --rule:       color-mix(in oklab, var(--ink) 17%, var(--paper));
  --mount:      color-mix(in oklab, var(--ink)  7%, var(--paper));
  --wash:       color-mix(in oklab, var(--accent) 9%, var(--paper));

  --display: 'Fraunces', Georgia, serif;
  --serif:   'EB Garamond', 'Iowan Old Style', Georgia, serif;

  --step--2: clamp(0.72rem, 0.70rem + 0.10vw, 0.80rem);
  --step--1: clamp(0.95rem, 0.92rem + 0.15vw, 1.04rem);
  --step-0:  clamp(1.13rem, 1.08rem + 0.25vw, 1.28rem);
  --step-1:  clamp(1.35rem, 1.22rem + 0.55vw, 1.72rem);
  --step-2:  clamp(1.80rem, 1.55rem + 1.05vw, 2.60rem);
  --step-3:  clamp(2.30rem, 1.80rem + 2.10vw, 3.90rem);

  --sp-xs: 0.4rem;
  --sp-s:  0.9rem;
  --sp-m:  1.6rem;
  --sp-l:  3rem;
  --sp-xl: clamp(4rem, 9vw, 7rem);

  --measure:  62ch;
  --gutter:   clamp(1.25rem, 6vw, 5rem);
  --grid-min: 280px;

  --tilt: 1;   /* set to 0 in one place to straighten the whole site */
}

/* --- Base ----------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: var(--step-0);
  line-height: 1.6;
  font-variant-numeric: oldstyle-num;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-underline-offset: 0.18em; }
p { margin: 0 0 var(--sp-s); }
::selection { background: var(--accent); color: var(--paper); }

h1, h2, h3 {
  font-family: var(--display);
  font-weight: 500;
  line-height: 1.14;
  margin: 0;
  letter-spacing: -0.012em;
}

/* Every small label on the site — the menu, tombstones, captions, the
   footer. All of it driven by the label slot in the Panel, which sets the
   casing and tracking as well as the face: a handwriting font needs the
   opposite treatment to letterspaced capitals. */
/* --- 1. Menu: the navigation only ----------------------------------------- */

.masthead nav {
  font-family: var(--menu-font, var(--serif));
  font-size: calc(var(--step--2) * var(--menu-scale, 1));
  font-weight: var(--menu-weight, 500);
  font-style: var(--menu-style, normal);
  letter-spacing: var(--menu-track, 0.15em);
  text-transform: var(--menu-case, uppercase);
  font-variant-caps: var(--menu-variant, normal);
  color: var(--ink-muted);
}

/* --- 2. Captions: everything that sits beside a picture ------------------- */

.tombstone, .range, .count, .crumbs, .tags, .pager, .kicker,
.thumb .d, .aside figcaption, body > footer, .aside .enlarge::after {
  font-family: var(--caption-font, var(--serif));
  font-size: calc(var(--step--2) * var(--caption-scale, 1));
  font-weight: var(--caption-weight, 500);
  font-style: var(--caption-style, normal);
  letter-spacing: var(--caption-track, 0.15em);
  text-transform: var(--caption-case, uppercase);
  font-variant-caps: var(--caption-variant, normal);
  font-variant-numeric: lining-num;
  color: var(--ink-muted);
}

/* --- 3. Records: the CV, press entries, the archive year index ------------
   Dense structured data. A handwriting face is unreadable across forty-two
   rows of exhibition history, so this is deliberately separate and defaults
   to capitals whatever the other two are set to. */

.press-meta, .year-jump, .clip-meta, .prose dt {
  font-family: var(--record-font, var(--serif));
  font-size: calc(var(--step--2) * var(--record-scale, 1));
  font-weight: var(--record-weight, 500);
  font-style: var(--record-style, normal);
  letter-spacing: var(--record-track, 0.15em);
  text-transform: var(--record-case, uppercase);
  font-variant-caps: var(--record-variant, normal);
  font-variant-numeric: lining-num;
  color: var(--ink-muted);
}

/* the CV year column is set at reading size, not label size */
.prose dt {
  font-size: calc(var(--step--1) * min(var(--record-scale, 1), 1.1));
  text-transform: none;
  letter-spacing: 0.02em;
}

.kicker { color: var(--accent); display: block; margin-bottom: var(--sp-m); }

/* --- Masthead ------------------------------------------------------------- */

.masthead { padding: var(--sp-l) var(--gutter) 0; }

.wordmark { display: inline-block; text-decoration: none; line-height: 1; }

.wordmark img { max-height: var(--wordmark-h, 92px); width: auto; }

.wordmark span {
  font-family: var(--display);
  font-style: italic;
  font-size: var(--step-2);
  font-weight: 500;
  letter-spacing: -0.02em;
}

.masthead .rules {
  border-top: 1.5px solid var(--ink);
  border-bottom: 1px solid var(--rule);
  height: 3px;
  margin: var(--sp-m) 0 var(--sp-s);
}

.masthead .bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-s) var(--sp-m);
  justify-content: space-between;
  align-items: baseline;
}

/* The gap used to be derived from the menu's font size, so a bigger menu
   automatically got wider gaps and wrapped onto two lines on a phone. It is
   now its own value, and the fallback shrinks with the viewport. */
.masthead nav {
  display: flex;
  flex-wrap: wrap;
  row-gap: 0.4em;
  column-gap: var(--menu-gap, clamp(0.9rem, 3.2vw, 1.7rem));
}

/* On a phone the gap is capped whatever the setting says, because a setting
   chosen on a laptop is the thing that pushes one menu item onto a second
   line at 390px wide. Below the cap the setting still applies. */
@media (max-width: 560px) {
  .masthead nav {
    column-gap: min(var(--menu-gap, 1.1rem), 4.5vw);
  }
}

.masthead nav a {
  text-decoration: none;
  padding-bottom: calc(2px * var(--menu-scale, 1));
  border-bottom: 1px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

.masthead nav a:hover { color: var(--ink); border-bottom-color: var(--accent); }

.masthead .tagline {
  font-family: var(--display);
  font-style: italic;
  font-size: var(--step--1);
  color: var(--accent);
  text-transform: none;
  letter-spacing: 0;
}

main { padding: var(--sp-l) var(--gutter) var(--sp-xl); }

body > footer {
  padding: var(--sp-l) var(--gutter);
  border-top: 1px solid var(--rule);
  color: var(--ink-muted);
}


/* --- Artwork gallery -----------------------------------------------------
   Justified rows. Every painting is scaled to the same visual height whatever
   its shape, so framed, unframed, portrait and landscape all read as one hang
   line. flex-basis and flex-grow come from each image's real aspect ratio,
   emitted by PHP — no JavaScript, no cropping, no borders.
   -------------------------------------------------------------------------- */

.grid {
  display: flex;
  flex-wrap: wrap;   /* never remove: without it every work crams onto one line */
  gap: var(--sp-xl) var(--sp-m);
}

/* soaks up the slack so a short last row doesn't stretch to giant */
.grid::after {
  content: '';
  flex-grow: 1000000;
  flex-basis: 0;
}

.thumb {
  display: block;
  text-decoration: none;
  color: inherit;
  min-width: 120px;   /* a work can never collapse to a sliver of overlapping text */
  max-width: 100%;
}

.grid--stacked .thumb,
.grid--staggered .thumb,
.grid--duo .thumb { min-width: 0; }

.thumb .frame { display: block; width: 100%; }

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: bottom;
  transition: opacity 0.25s ease;
}


.thumb .meta { display: block; margin-top: var(--sp-s); }

.thumb .t {
  display: block;
  font-family: var(--serif);
  font-size: var(--step-0);
  line-height: 1.3;
}

.thumb .d {
  display: block;
  margin-top: 0.25rem;
  color: var(--ink-muted);
}

.empty-note {
  font-family: var(--display);
  font-style: italic;
  color: var(--ink-muted);
  max-width: 40ch;
}

/* dense archive index — a contact sheet, not a display */
.grid--dense {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--sp-l) var(--sp-m);
  align-items: end;
}

.grid--dense::after { content: none; }

.grid--dense a { display: block; text-decoration: none; color: var(--ink-muted); }
.grid--dense a:hover span { color: var(--ink); }
.grid--dense img { transition: opacity 0.25s ease; }
.grid--dense a:hover img { opacity: 0.78; }

.grid--dense span {
  display: block;
  margin-top: var(--sp-xs);
  font-size: var(--step--2);
  line-height: 1.35;
  font-variant-numeric: lining-num;
}

/* --- Home ----------------------------------------------------------------- */

.intro {
  font-family: var(--display);
  font-style: italic;
  font-weight: 400;
  max-width: 26ch;
  font-size: var(--step-2);
  line-height: 1.22;
  margin: 0 0 var(--sp-xl);
  color: var(--ink-soft);
  text-wrap: balance;
}

.more { margin-top: var(--sp-xl); font-family: var(--display); font-size: var(--step-1); }
.more a { text-decoration: none; border-bottom: 1px solid var(--rule); }
.more a:hover { border-bottom-color: var(--accent); color: var(--accent); }

/* --- Series index: numbered, pinned up ------------------------------------ */

.series-index {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: series;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  gap: var(--sp-xl) var(--sp-l);
}

.series-index li { counter-increment: series; transition: transform 0.3s ease; }
.series-index li:nth-child(3n+1) { transform: rotate(calc(-0.7deg * var(--tilt))); }
.series-index li:nth-child(3n+2) { transform: rotate(calc( 0.5deg * var(--tilt))); }
.series-index li:nth-child(3n+3) { transform: rotate(calc(-0.3deg * var(--tilt))); }
.series-index li:hover { transform: rotate(0deg); }

.series-index a { text-decoration: none; color: inherit; display: block; }
.series-index img { transition: opacity 0.25s ease; }
.series-index a:hover img { opacity: 0.78; }

.series-body { display: flex; gap: var(--sp-s); margin-top: var(--sp-m); }

.series-body::before {
  content: counter(series, decimal-leading-zero);
  font-family: var(--display);
  font-size: var(--step--1);
  font-variant-numeric: lining-num;
  color: var(--ink-faint);
  padding-top: 0.45em;
  flex: 0 0 auto;
}

.series-index h2 { font-size: var(--step-1); margin-bottom: var(--sp-xs); }
.series-index .range { display: block; margin-bottom: var(--sp-xs); }

.series-index .blurb {
  margin: 0;
  max-width: 40ch;
  color: var(--ink-soft);
  font-size: var(--step--1);
  line-height: 1.55;
}

/* --- Series page ---------------------------------------------------------- */

.series-header {
  max-width: var(--measure);
  margin-bottom: var(--sp-xl);
  padding-bottom: var(--sp-l);
  border-bottom: 1px solid var(--rule);
}

.series-header h1 { font-size: var(--step-3); margin-bottom: var(--sp-s); }
.series-header .range { display: block; margin-bottom: var(--sp-m); }
.series-header p { color: var(--ink-soft); }

/* --- Single artwork ------------------------------------------------------- */

.crumbs { margin-bottom: var(--sp-l); }
.crumbs a { text-decoration: none; }
.crumbs a:hover { color: var(--accent); }

.artwork { display: grid; gap: var(--sp-l); justify-items: center; }
.artwork figure { margin: 0; }
.artwork figure img { margin: 0 auto; max-height: 76vh; width: auto; }
.artwork .caption { text-align: center; max-width: 52ch; }
.artwork h1 { font-size: var(--step-2); margin-bottom: var(--sp-s); }
.artwork .tombstone { display: block; margin-bottom: var(--sp-m); }

.artwork .note {
  font-family: var(--display);
  font-style: italic;
  font-size: var(--step--1);
  color: var(--ink-soft);
}

.tags { margin-top: var(--sp-m); }
.tags a { text-decoration: none; margin: 0 var(--sp-xs); }
.tags a:hover { color: var(--accent); }

.pager {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-m);
  width: 100%;
  max-width: 52ch;
  margin-top: var(--sp-m);
  padding-top: var(--sp-m);
  border-top: 1px solid var(--rule);
}

.pager a { text-decoration: none; }
.pager a:hover { color: var(--accent); }
.pager .spacer { visibility: hidden; }

/* --- About: prose with a column of side images ---------------------------- */

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
  gap: var(--sp-xl) var(--sp-l);
  align-items: start;
}

.split--solo { grid-template-columns: minmax(0, 1fr); }

.aside { display: grid; gap: var(--sp-l); }
.aside figure { margin: 0; }

.aside figure:nth-child(2n+1) { transform: rotate(calc(-0.8deg * var(--tilt))); }
.aside figure:nth-child(2n+2) { transform: rotate(calc( 0.6deg * var(--tilt))); }
.aside figure { transition: transform 0.3s ease; }
.aside figure:hover { transform: rotate(0deg); }

.aside figcaption {
  margin-top: var(--sp-xs);
  color: var(--ink-muted);
}

/* --- Text pages ----------------------------------------------------------- */

.prose { max-width: var(--measure); }
.prose h1 { font-size: var(--step-3); margin-bottom: var(--sp-l); }

.prose h2 {
  font-size: var(--step-1);
  margin: var(--sp-xl) 0 var(--sp-m);
  padding-bottom: var(--sp-xs);
  border-bottom: 1px solid var(--rule);
}

.prose p { color: var(--ink-soft); }
.prose a { color: var(--accent); }

.prose dl {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: var(--sp-xs) var(--sp-m);
  margin: 0;
}

.prose dt {
  font-variant-numeric: lining-num;
  font-size: var(--step--1);
  color: var(--ink-muted);
  padding-top: 0.15em;
}

.prose dd { margin: 0; font-size: var(--step--1); }

/* --- Archive -------------------------------------------------------------- */

.year-jump { margin-bottom: var(--sp-xl); line-height: 2.4; }
.year-jump a { text-decoration: none; margin-right: var(--sp-s); border-bottom: 1px solid transparent; }
.year-jump a:hover { color: var(--accent); border-bottom-color: var(--accent); }

.archive-year { margin-bottom: var(--sp-xl); scroll-margin-top: var(--sp-m); }

.archive-year h2 {
  font-size: var(--step-1);
  font-variant-numeric: lining-num;
  padding-bottom: var(--sp-s);
  margin-bottom: var(--sp-l);
  border-bottom: 1px solid var(--rule);
}

/* --- Small screens -------------------------------------------------------- */

@media (max-width: 640px) {
  :root { --grid-min: 100%; --tilt: 0.5; }
  .masthead .bar { flex-direction: column; align-items: flex-start; }
  .series-index { grid-template-columns: 1fr; }
  .split { grid-template-columns: 1fr; }
  .grid { gap: var(--sp-l) var(--sp-s); }
  .grid--dense { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .prose dl { grid-template-columns: 4rem 1fr; }
  .wordmark img { max-height: calc(var(--wordmark-h, 92px) * 0.62); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  :root { --tilt: 0; }
  * { transition: none !important; }
}

/* --- CV: pull quote and press ---------------------------------------------- */

/* first section heading sits under the h1 without the usual big gap above */
.cv > h2:first-of-type { margin-top: 0; }


.press { list-style: none; margin: 0; padding: 0; }

.press li {
  padding-bottom: var(--sp-m);
  margin-bottom: var(--sp-m);
  border-bottom: 1px solid var(--rule);
}

.press li:last-child { border-bottom: 0; }

.press-head {
  display: block;
  font-family: var(--display);
  font-size: var(--step-0);
  line-height: 1.25;
}

.press-meta {
  display: block;
  margin-top: 0.3rem;
  color: var(--ink-muted);
}

.press-quote {
  display: block;
  margin-top: var(--sp-s);
  font-family: var(--display);
  font-style: italic;
  font-size: var(--step--1);
  color: var(--ink);
}

.press-note {
  display: block;
  margin-top: var(--sp-xs);
  font-size: var(--step--1);
  line-height: 1.5;
  color: var(--ink-soft);
  max-width: 56ch;
}

/* --- About side images: click to view full size ---------------------------- */

.aside .enlarge { display: block; position: relative; }
.aside .enlarge img { transition: opacity 0.25s ease; }
.aside .enlarge:hover img { opacity: 0.85; }

.aside .enlarge::after {
  content: 'View larger';
  position: absolute;
  right: 0.6rem;
  bottom: 0.6rem;
  padding: 0.3rem 0.6rem;
  background: var(--paper);
  color: var(--ink-muted);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.aside .enlarge:hover::after { opacity: 1; }

/* --- Home page layouts -----------------------------------------------------
   The default is grid--justified, which is the level hang line used across the
   rest of the site. These two are alternatives, switchable in the Panel.
   -------------------------------------------------------------------------- */

/* Large, alternating: one work per row, sides swapping. Calm and gallery-like.
   Best with 8–14 works. */
.grid--stacked {
  display: block;
}

.grid--stacked::after { content: none; }

.grid--stacked .thumb {
  width: 100%;
  max-width: 64%;
  margin: 0 0 var(--sp-xl);
}

.grid--stacked .thumb:nth-child(even) { margin-left: auto; }

.grid--stacked .thumb:nth-child(even) .meta { text-align: right; }

/* Staggered columns: natural heights flowing down three columns. Editorial,
   handles very mixed shapes well. Best with 12–24 works. */
.grid--staggered {
  display: block;
  column-count: 3;
  column-gap: var(--sp-l);
}

.grid--staggered::after { content: none; }

.grid--staggered .thumb {
  display: inline-block;
  width: 100%;
  max-width: 100%;
  margin: 0 0 var(--sp-xl);
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
}

@media (max-width: 1000px) {
  .grid--staggered { column-count: 2; }
  .grid--stacked .thumb { max-width: 78%; }
}

@media (max-width: 640px) {
  .grid--staggered { column-count: 1; }
  .grid--stacked .thumb { max-width: 100%; }
  .grid--stacked .thumb:nth-child(even) .meta { text-align: left; }
}

/* ==========================================================================
   HOME PAGE — arrangement, size, spacing, hover and entrance

   IMPORTANT: tilt, hover and the scroll entrance all want to move the same
   element. If each sets `transform` directly, whichever rule comes last wins
   and the other two silently do nothing. So every one of them sets its OWN
   custom property, and a single `transform` composes them.
   ========================================================================== */

.thumb {
  --tilt-rot: 0deg;    /* resting tilt, from nth-child below */
  --enter-x: 0px;      /* entrance offsets, cleared when .in lands */
  --enter-y: 0px;
  --enter-s: 1;
  --hov-y: 0px;        /* hover lift */

  transform:
    translate(var(--enter-x), calc(var(--enter-y) + var(--hov-y)))
    rotate(var(--tilt-rot))
    scale(var(--enter-s));

  transition:
    transform 0.55s cubic-bezier(.2,.7,.3,1),
    opacity 0.4s ease;
}

/* --- Spacing: one pair of variables every arrangement reads ---------------- */

.grid, .opener {
  --gap-y: calc(var(--sp-xl) * var(--home-gap, 1));

  /* Across used to come off --sp-m, a quarter of the vertical base, so works
     standing side by side stayed tight together however far the one spacing
     setting was pushed. It has its own setting now, off a base close enough
     to the vertical one that 100 means the same thing in both. */
  --gap-x: calc(var(--sp-l)  * var(--home-gap-x, 1));
}

.grid { gap: var(--gap-y, var(--sp-xl)) var(--gap-x, var(--sp-m)); }

/* the opener's distance from the work beneath it follows the same setting */
.opener { margin-bottom: var(--gap-y, var(--sp-xl)); }

/* --- Size -----------------------------------------------------------------
   Size means something different in each arrangement — a column count here,
   a width there, a height in the strip — but it always means something.
   These used to be four classes, size--220 … size--540, which only worked
   because the Panel only offered four sizes. The setting is a free number
   now, so the template works these out and sets them on the container; the
   fallbacks below are what 320 comes to, i.e. the old Medium. ------------- */

.grid, .opener {
  --col: 3;
  --stack-w: 64%;
  --strip-h: 56vh;
}

/* --- Captions -------------------------------------------------------------- */

.cap--never .meta { display: none; }

.cap--hover .meta {
  opacity: 0;
  transition: opacity 0.3s ease;
}

.cap--hover .thumb:hover .meta,
.cap--hover .thumb:focus-visible .meta { opacity: 1; }

/* --- Tilt ------------------------------------------------------------------ */

/* The magnitudes are kept close to each other and only the direction varies.
   They used to range from 0.35deg to 0.75deg at the same setting, so at low
   values most works looked straight while one or two looked crooked — which
   reads as a mistake rather than as a choice. A fifth value stops a repeat
   every four works from becoming a visible pattern. */
.grid .thumb:nth-child(5n+1), .opener--row .thumb:nth-child(5n+1) { --tilt-rot: calc(-0.90deg * var(--home-tilt, 0)); }
.grid .thumb:nth-child(5n+2), .opener--row .thumb:nth-child(5n+2) { --tilt-rot: calc( 0.78deg * var(--home-tilt, 0)); }
.grid .thumb:nth-child(5n+3), .opener--row .thumb:nth-child(5n+3) { --tilt-rot: calc(-0.70deg * var(--home-tilt, 0)); }
.grid .thumb:nth-child(5n+4), .opener--row .thumb:nth-child(5n+4) { --tilt-rot: calc( 0.95deg * var(--home-tilt, 0)); }
.grid .thumb:nth-child(5n+5), .opener--row .thumb:nth-child(5n+5) { --tilt-rot: calc(-0.82deg * var(--home-tilt, 0)); }

/* a single centred opening work stays level — one tilted picture on its own
   reads as a hanging mistake rather than a style */

/* --- Hover ----------------------------------------------------------------- */

.thumb .frame { overflow: hidden; }
.thumb img { transition: transform 0.6s cubic-bezier(.2,.7,.3,1), opacity 0.35s ease; }
.thumb .frame { transition: background 0.35s ease; }

.hov--dim .thumb:hover img,
.hov--dim .thumb:focus-visible img { opacity: 0.78; }

.hov--lift .thumb:hover,
.hov--lift .thumb:focus-visible { --hov-y: -7px; --tilt-rot: 0deg; }
.hov--lift .thumb:hover img { opacity: 0.9; }

.hov--zoom .thumb:hover img,
.hov--zoom .thumb:focus-visible img { transform: scale(1.055); }

.hov--rise .thumb:hover,
.hov--rise .thumb:focus-visible { --hov-y: -12px; }

.hov--tint .thumb .frame { background: transparent; }
.hov--tint .thumb:hover .frame,
.hov--tint .thumb:focus-visible .frame { background: var(--wash); }
.hov--tint .thumb:hover img { opacity: 0.94; }

/* --- Entrance -------------------------------------------------------------- */

.reveal .thumb { opacity: 0; }
.reveal .thumb.in { opacity: 1; }

.reveal--fade  .thumb { --enter-y: 28px; }
.reveal--scale .thumb { --enter-s: 0.955; }
.reveal--slide .thumb:nth-child(odd)  { --enter-x: -36px; }
.reveal--slide .thumb:nth-child(even) { --enter-x:  36px; }

/* clears only the entrance offsets — tilt and hover are untouched */
.reveal .thumb.in { --enter-x: 0px; --enter-y: 0px; --enter-s: 1; }

.reveal .thumb:nth-child(2n) { transition-delay: 0.07s; }
.reveal .thumb:nth-child(3n) { transition-delay: 0.14s; }
.reveal .thumb:nth-child(4n) { transition-delay: 0.21s; }

.no-js .reveal .thumb { opacity: 1; --enter-x: 0px; --enter-y: 0px; --enter-s: 1; }

/* --- The opening works -----------------------------------------------------

   These used to be a fixed grid of equal columns, which was wrong in two
   ways that only showed up once the window was made narrower.

   Equal columns mean each work keeps its own aspect ratio inside its column,
   so a panoramic canvas came out a third the height of the portrait beside
   it, and both were measured against the column rather than against anything
   below them. And because the column count never changed until 760px, three
   works at iPad width were each a third of the page and plainly smaller than
   the justified rows underneath.

   They are a justified line now — the same algorithm as the rows below, with
   its own target height. Every work on a line shares one height, the line
   fills the width, and a work drops to the next line exactly when keeping it
   up there would push the line below the opening size. Because the works
   below use the identical algorithm against a smaller target, the opening
   works come out larger at every window width, whatever shapes they are.
   -------------------------------------------------------------------------- */

.opener--row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-y, var(--sp-xl)) var(--gap-x, var(--sp-m));
  align-items: flex-end;

  /* Opening width. The max() is what makes it ease off on a small screen:
     once a percentage of the page falls below this floor the floor wins, and
     a floor wider than the page constrains nothing — so the inset fades out
     rather than squeezing a phone. */
  max-width: max(var(--open-inset, 100%), 520px);
  margin-left: auto;
  margin-right: auto;
}

/* no slack-soaking ::after here, unlike .grid — the opening works are meant
   to fill their block, and a wrapped one filling the width is the "one large"
   look rather than an accident */

/* --- Arrangements ---------------------------------------------------------- */

/* Large, alternating. Size drives the width, spacing the rhythm. */
.grid--stacked { display: block; }
.grid--stacked::after { content: none; }

.grid--stacked .thumb {
  width: 100%;
  max-width: var(--stack-w, 64%);
  min-width: 0;
  margin: 0 0 var(--gap-y, var(--sp-xl));
}

.grid--stacked .thumb:nth-child(even) { margin-left: auto; }
.grid--stacked .thumb:nth-child(even) .meta { text-align: right; }

/* Staggered columns. Size drives the column count. */
.grid--staggered {
  display: block;
  column-count: var(--col, 3);
  column-gap: var(--gap-x, var(--sp-m));
}

.grid--staggered::after { content: none; }

.grid--staggered .thumb {
  display: inline-block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin: 0 0 var(--gap-y, var(--sp-xl));
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
}

/* Pairs, offset. Size narrows each work inside its column. */
.grid--duo {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.grid--duo::after { content: none; }

.grid--duo .thumb {
  max-width: var(--stack-w, 64%);
  min-width: 0;
  width: 100%;
}

.grid--duo .thumb:nth-child(even) { margin-left: auto; }
.grid--duo .thumb:nth-child(4n+2) { margin-top: calc(var(--gap-y, var(--sp-xl)) * 1.1); }
.grid--duo .thumb:nth-child(4n+3) { margin-top: calc(var(--gap-y, var(--sp-xl)) * 0.5); }

/* One horizontal band, scrolling sideways. Size drives the height. */
.grid--strip {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  align-items: flex-end;
  padding-bottom: var(--sp-m);
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  scrollbar-color: var(--rule) transparent;
}

.grid--strip::after { content: none; }

.grid--strip .thumb {
  flex: 0 0 auto;
  scroll-snap-align: center;
  max-width: none;
  min-width: 0;
}

.grid--strip .thumb .frame { height: var(--strip-h, 56vh); aspect-ratio: auto !important; }
.grid--strip .thumb img { height: var(--strip-h, 56vh); width: auto; }

.grid--strip::-webkit-scrollbar { height: 6px; }
.grid--strip::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 3px; }

.intro--below { margin: var(--sp-xl) 0 0; }

@media (max-width: 1000px) {
  .grid--staggered { column-count: min(var(--col, 3), 2); }
}

@media (max-width: 760px) {
  .grid--duo { grid-template-columns: 1fr; }
  .grid--duo .thumb { max-width: 100%; }
  .grid--duo .thumb:nth-child(n) { margin-top: 0; }
  .grid--stacked .thumb { max-width: 100%; }
  .grid--stacked .thumb:nth-child(even) .meta { text-align: left; }
  .grid--staggered { column-count: 1; }
  .grid--strip .thumb .frame,
  .grid--strip .thumb img { height: calc(var(--strip-h, 56vh) * 0.72); }
}

@media (prefers-reduced-motion: reduce) {
  .thumb { transition: none !important; }
  .reveal .thumb { opacity: 1 !important; }
  .thumb, .thumb:hover {
    --enter-x: 0px; --enter-y: 0px; --enter-s: 1; --hov-y: 0px;
  }
  .thumb:hover img { transform: none !important; }
}


/* --- Navigation placement (Panel: Identity → Navigation) ------------------- */

.masthead--left .bar  { justify-content: flex-start; gap: var(--sp-l); }
.masthead--right .bar { justify-content: flex-end; flex-direction: row-reverse; }
.masthead--right .bar nav { justify-content: flex-end; }

.masthead nav a[aria-current="page"] {
  color: var(--ink);
  border-bottom-color: var(--accent);
}
