:root {
  color-scheme: light;
  --bg: #ffffff;
  --fg: rgb(0 0 0 / .5);
  --muted: rgb(0 0 0 / .5);
  --hover: #000000;
  --line: #ececec;
  --tile: #f4f4f4;
  --accent: #000000;
  --gutter: clamp(16px, 4vw, 40px);
  --gap: 8px;
  --max: 1280px;
  --max-wide: 1760px;
  --column: 960px;
  --head: "Chivo", "Helvetica Neue", Arial, sans-serif;
  --body: "Nunito", "Helvetica Neue", Arial, sans-serif;
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 17px/1.7 var(--body);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }

img, iframe { display: block; max-width: 100%; }

a { color: inherit; }

figure { margin: 0; }

.wrap {
  width: 100%;
  max-width: var(--max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

.skip {
  position: absolute; left: 8px; top: -100px;
  background: var(--fg); color: var(--bg);
  padding: 6px 12px; z-index: 10; text-decoration: none;
}
.skip:focus { top: 8px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* Header ---------------------------------------------------------------- */

.site-header, .site-footer { max-width: var(--max-wide); }

/* Project pages: one centered column. Titles, text and full-width videos all
   share its edges; a row of two vertical videos fills it exactly. */
.project { max-width: calc(var(--column) + 2 * var(--gutter)); }

.site-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding-top: clamp(24px, 5vw, 48px);
  padding-bottom: clamp(24px, 4vw, 44px);
}

.brand {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  column-gap: 16px;
  text-decoration: none;
}
.brand:hover .brand-name { color: var(--hover); }

.brand-name {
  font: 700 clamp(20px, 2.4vw, 24px)/1.2 var(--head);
  letter-spacing: -0.01em;
}

.brand-tag {
  font: 600 13px/1.2 var(--body);
  color: var(--muted);
}

.site-nav { display: flex; gap: 22px; }

.site-nav a {
  font: 600 14px/1 var(--body);
  color: var(--muted);
  text-decoration: none;
  padding-block: 6px;
  border-bottom: 1px solid transparent;
  transition: color .2s;
}
.site-nav a:hover { color: var(--hover); }
.site-nav a[aria-current="page"] { border-bottom-color: currentColor; }

/* Work grid -------------------------------------------------------------- */

.grid-wrap {
  width: 100%;
  max-width: var(--max-wide);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.work-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gap);
}

.card {
  position: relative;
  display: block;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--tile);
  text-decoration: none;
}

.card img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform .6s cubic-bezier(.2, .7, .2, 1), filter .4s;
}

.card-title {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  text-align: center;
  font: 700 clamp(16px, 1.6vw, 22px)/1.2 var(--head);
  color: #fff;
  background: rgba(0, 0, 0, .45);
  opacity: 0;
  transition: opacity .3s;
}

.card:hover img, .card:focus-visible img { transform: scale(1.04); }
.card:hover .card-title, .card:focus-visible .card-title { opacity: 1; }

@media (hover: none) {
  .card { aspect-ratio: auto; background: none; }
  .card img { aspect-ratio: 16 / 10; background: var(--tile); }
  .card-title {
    position: static; opacity: 1; background: none; color: var(--fg);
    font-family: var(--body); font-weight: 600;
    justify-content: flex-start; padding: 8px 0 14px; font-size: 15px;
  }
}

/* On a project page, the grid marks the project you're on. */
.card[aria-current="page"] .card-title { opacity: 1; }

@media (max-width: 900px) { .work-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .work-grid { grid-template-columns: 1fr; } }

/* Project pages ---------------------------------------------------------- */

.project-head { margin-bottom: clamp(24px, 4vw, 40px); }

.project-head h1 {
  margin: 0;
  font: 900 clamp(34px, 6vw, 64px)/1.02 var(--head);
  letter-spacing: -0.02em;
}

.kicker, .subtitle { margin: 0; color: var(--muted); }
.kicker { font: 700 13px/1.4 var(--body); letter-spacing: .08em; text-transform: uppercase; margin-bottom: 10px; }
.subtitle { font: 400 clamp(18px, 2.2vw, 24px)/1.3 var(--head); margin-top: 10px; }

.project-body {
  display: flex;
  flex-direction: column;
  gap: clamp(20px, 3vw, 32px);
}

.prose { max-width: 70ch; }
.prose p { margin: 0 0 1em; }
/* Avoid single words stranded on the last line. */
p, dd, li { text-wrap: pretty; }
h1, h2 { text-wrap: balance; }
.prose p:last-child { margin-bottom: 0; }
.prose a { text-underline-offset: 3px; }
.prose a:hover { color: var(--hover); }

.project-body > .prose { margin-block: clamp(8px, 2vw, 20px); max-width: none; }

.media { background: var(--tile); }
.media.video { width: 100%; }
.media.video iframe { width: 100%; height: 100%; border: 0; }
.media.image { background: none; }
.media.image img { width: 100%; height: auto; }

/* Single tall videos shouldn't fill the whole column. */
.project-body > .media.is-tall { max-width: 460px; margin-inline: auto; }

.row {
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  gap: clamp(12px, 2vw, 24px);
  align-items: start;
}
.row-center { align-items: center; }
.row > .prose { padding: clamp(0px, 2vw, 24px); }

@media (max-width: 720px) {
  .row { grid-template-columns: repeat(min(var(--cols), 2), minmax(0, 1fr)); }
  .row > .prose { grid-column: 1 / -1; padding: 0; }
}
@media (max-width: 460px) {
  .row:has(> .is-tall) { grid-template-columns: 1fr; }
  .row > .is-tall { max-width: 360px; margin-inline: auto; width: 100%; }
}

.meta-list {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}
.meta-list h2 {
  margin: 0 0 10px;
  font: 700 12px/1.4 var(--body);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}
.meta-list dl { margin: 0; display: grid; gap: 8px; }
.meta-list dl > div { display: grid; grid-template-columns: minmax(120px, 13em) 1fr; gap: 16px; }
.meta-list dt { font-weight: 700; }
.meta-list dd { margin: 0; }
@media (max-width: 560px) {
  .meta-list dl > div { grid-template-columns: 1fr; gap: 0; }
}

.gallery {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--gap);
}
.gallery-item { display: block; aspect-ratio: 4 / 3; overflow: hidden; background: var(--tile); cursor: zoom-in; }
.gallery-item img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s; }
.gallery-item:hover img { transform: scale(1.03); }
@media (max-width: 560px) { .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* All work, under each project ------------------------------------------ */

.more-work {
  margin-top: clamp(56px, 8vw, 96px);
  padding-top: clamp(24px, 3vw, 36px);
  border-top: 1px solid var(--line);
}

/* A footer strip: all nine in one row of small tiles, greyed out until hovered. */
.more-work .work-grid { grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 4px; }

.more-work .card img {
  filter: grayscale(1);
  opacity: .45;
  transition: filter .3s, opacity .3s, transform .6s cubic-bezier(.2, .7, .2, 1);
}
.more-work .card:hover img,
.more-work .card:focus-visible img { filter: none; opacity: 1; }

/* Title sits on a bottom fade so the colour still shows through on hover. */
.more-work .card-title {
  font-size: 12px;
  padding: 6px;
  align-items: flex-end;
  background: linear-gradient(transparent 35%, rgba(0, 0, 0, .65));
}

/* The project you're on: title centred on an even shade. */
@media (hover: hover) {
  .more-work .card[aria-current="page"] .card-title { align-items: center; background: rgba(0, 0, 0, .45); }
}

@media (max-width: 900px) {
  .more-work .work-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: 480px; }
}

@media (hover: none) {
  .more-work .card-title { font-size: 11px; padding: 4px 0 8px; line-height: 1.25; background: none; text-align: left; }
}

/* About ------------------------------------------------------------------ */

.about {
  max-width: var(--max-wide);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: clamp(32px, 6vw, 80px);
  align-items: start;
}
.about .lead { font-size: clamp(18px, 1.8vw, 21px); line-height: 1.6; }
.about .lead p:first-child { font: 900 clamp(34px, 5vw, 56px)/1 var(--head); margin-bottom: .5em; letter-spacing: -0.02em; }
.facts { margin: 36px 0 0; display: grid; gap: 18px; }
.facts dt {
  font: 700 12px/1.4 var(--body);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}
.facts dd { margin: 2px 0 0; }
.about-text { max-width: 640px; }
/* The portrait is sized by the window height so it always fits on screen. */
.about-photo img {
  width: auto;
  height: clamp(420px, calc(100vh - 200px), 900px);
  max-width: 100%;
  object-fit: cover;
  background: var(--tile);
}
@media (max-width: 820px) {
  .about { grid-template-columns: 1fr; }
  .about-photo { max-width: 520px; }
  .about-photo img { width: 100%; height: auto; }
}

.notfound { padding-block: 40px; }
.notfound h1 { font: 900 clamp(34px, 6vw, 56px)/1.05 var(--head); margin: 0 0 12px; }

/* Footer ----------------------------------------------------------------- */

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-top: clamp(48px, 8vw, 88px);
  padding-bottom: 32px;
  font: 600 13px/1.4 var(--body);
  color: var(--muted);
}
.site-footer a { text-decoration: none; }
.site-footer a:hover { color: var(--hover); }

/* Lightbox --------------------------------------------------------------- */

.lightbox {
  border: 0;
  padding: 0;
  max-width: 100vw;
  max-height: 100vh;
  width: 100vw;
  height: 100vh;
  background: rgba(10, 10, 10, .94);
  color: #fff;
}
.lightbox::backdrop { background: transparent; }
.lightbox[open] { display: flex; align-items: center; justify-content: center; }
.lightbox img { max-width: calc(100vw - 32px); max-height: calc(100vh - 120px); width: auto; height: auto; }
.lightbox button {
  position: absolute;
  background: none; border: 0; color: #fff;
  font: 400 30px/1 var(--head);
  padding: 16px; cursor: pointer; opacity: .8;
}
.lightbox button:hover { opacity: 1; }
.lb-close { top: 8px; right: 8px; }
.lb-prev { left: 4px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 4px; top: 50%; transform: translateY(-50%); }
.lb-count { position: absolute; bottom: 20px; left: 0; right: 0; text-align: center; font: 600 13px/1 var(--body); opacity: .7; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
}
