@font-face {
  font-family: 'ABC Areal';
  src: url('fonts/ABCArealSuperfamilyVariable.woff2') format('woff2');
  font-weight: 400 700;
  font-display: swap;
}

:root {
  --pad: 12px;
  --gap: 4px;
  --header: 44px;
  --dim: #8a8a8a;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-move: cubic-bezier(0.32, 0.72, 0, 1);
}

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

html {
  background: #000;
  color: #fff;
  font: 14px/1.35 'ABC Areal', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

:focus-visible {
  outline: 1px solid #fff;
  outline-offset: 2px;
}

img,
video {
  display: block;
  width: 100%;
  height: auto;
  background: #111;
}

video {
  aspect-ratio: var(--ratio);
}

.mono {
  filter: grayscale(1);
}

[hidden] {
  display: none !important;
}

header,
.bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: var(--header);
  padding: 0 var(--pad);
}

/* No bar. Difference blending keeps the links readable over any image. */
header {
  position: sticky;
  top: 0;
  z-index: 2;
  mix-blend-mode: difference;
  pointer-events: none;
}

header a {
  pointer-events: auto;
}

/* Padding and negative margin give these a 44px hit area. */
header a,
.close {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  margin: 0 -12px;
  transition: color 0.15s ease;
}

header a:active,
.close:active {
  color: var(--dim);
}

/* Home */

.home {
  display: flex;
  flex-direction: column;
  touch-action: none;
  height: calc(100dvh - var(--header));
  padding: 0 var(--pad) var(--pad);
}

.row {
  flex: 1 1 0;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  column-gap: 16px;
  align-items: center;
  padding: calc(var(--gap) / 2) 0;
  text-wrap: balance;
  animation: rise 0.5s var(--ease-out) backwards;
  animation-delay: calc(var(--i) * 40ms);
}

.row > :first-child {
  text-align: right;
}

.row span {
  display: block;
}

.thumb {
  position: relative;
  height: 100%;
  min-height: 0;
  max-width: 40vw;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  background: #111;
}

.thumb img,
.thumb video {
  position: absolute;
  inset: 0;
  height: 100%;
  object-fit: cover;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* Project */

.project {
  padding: 0 var(--pad) var(--pad);
}

.text {
  max-width: 44ch;
  padding: 24px 0 32px;
}

h1,
h2 {
  font: inherit;
}

.dim {
  color: var(--dim);
}

.text p + p {
  margin-top: 1em;
}

.text .dim + .dim {
  margin-top: 0;
}

.text .links {
  margin-top: 12px;
}

.text .related {
  margin-top: 24px;
}

.text .related + .links {
  margin-top: 0;
}

.links {
  display: flex;
  flex-wrap: wrap;
  column-gap: 16px;
}

.text .links {
  flex-direction: column;
  align-items: start;
}

.nowrap {
  white-space: nowrap;
}

.links a {
  padding: 4px 0;
  color: var(--dim);
  transition: color 0.15s ease;
}

.links svg,
.linked svg {
  width: 14px;
  height: 14px;
}

h2.linked {
  display: flex;
  flex-wrap: wrap;
  column-gap: 14px;
}

/* Inline, so a long place wraps as text and the arrow stays on its last word. */
p.linked a {
  display: inline;
}

p.linked svg,
.links svg {
  display: inline;
  margin-left: 3px;
  vertical-align: -2px;
}

.linked a {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  transition: color 0.15s ease;
}

.linked svg {
  color: var(--dim);
}

.head {
  display: grid;
  gap: 2px;
  max-width: 60ch;
  margin-bottom: 14px;
}

.head p:not(.links) {
  color: var(--dim);
}

.head p:empty {
  display: none;
}

/* Rows of equal height that fill the width. Each item grows in proportion to
   its shape, so nothing is cropped and no holes are left. */
.media {
  --line: 110px;
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
}

.media button {
  flex: var(--ratio) 1 calc(var(--ratio) * var(--line));
  display: block;
  cursor: zoom-in;
}

/* Soaks up the spare width so a short last row is not stretched. */
.media::after {
  content: '';
  flex-grow: 1000;
}

/* The first row always spans the full width. */
.lead {
  flex-wrap: nowrap;
  margin-bottom: var(--gap);
}

.lead::after {
  display: none;
}

.lead button {
  flex-basis: 0;
}

.lead button:only-child img,
.lead button:only-child video {
  max-height: calc(100dvh - var(--header) - var(--pad));
  object-fit: cover;
}

.wordmark video {
  width: auto;
  height: 44px;
  margin-bottom: 8px;
  background: none;
  mix-blend-mode: screen;
}

section {
  margin-top: 64px;
}

.gallery > section:first-child {
  margin-top: 0;
}

/* Viewer */

#viewer {
  position: fixed;
  inset: 0;
  z-index: 3;
  background: #000;
}

.count {
  font-variant-numeric: tabular-nums;
}

.stage {
  position: absolute;
  inset: var(--header) var(--pad) var(--pad);
  display: grid;
  place-items: center;
}

.stage img,
.stage video {
  width: min(100%, (100dvh - var(--header) - var(--pad)) * var(--ratio));
  aspect-ratio: var(--ratio);
  background: none;
}

.prev,
.next {
  position: absolute;
  top: var(--header);
  bottom: 0;
  width: 50%;
  display: flex;
  align-items: center;
  padding: 0 var(--pad);
  color: var(--dim);
  transition: color 0.15s ease;
}

.prev {
  left: 0;
}

.next {
  right: 0;
  justify-content: end;
}

/* Each button covers half the screen, so the focus ring goes on its arrow. */
.prev:focus-visible,
.next:focus-visible {
  outline: none;
}

.prev:focus-visible svg,
.next:focus-visible svg {
  outline: 1px solid #fff;
  outline-offset: 6px;
}

.single .prev,
.single .next {
  display: none;
}

@media (max-width: 699px) {
  .prev svg,
  .next svg {
    display: none;
  }
}

/* Page transitions */

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.2s;
}

::view-transition-group(cover),
::view-transition-group(zoom) {
  animation-duration: 0.35s;
  animation-timing-function: var(--ease-move);
}

/* Lets a cropped thumbnail and the uncropped file morph without squashing. */
::view-transition-old(cover),
::view-transition-new(cover),
::view-transition-old(zoom),
::view-transition-new(zoom) {
  height: 100%;
  object-fit: cover;
}

/* Phones: the list has three narrow columns, so its text is set smaller. */
@media (max-width: 699px) {
  .row {
    font-size: 12px;
    line-height: 1.3;
    column-gap: 12px;
  }

  /* Narrow enough that longer titles break into two lines. */
  .row > :first-child {
    justify-self: end;
    max-width: 7em;
  }

  .text,
  .head {
    font-size: 13px;
  }
}

@media (min-width: 700px) {
  :root {
    --pad: 20px;
    --gap: 8px;
    --header: 56px;
  }

  .row {
    column-gap: 24px;
  }

  .stage {
    inset-inline: 60px;
  }

  .media {
    --line: 240px;
  }
}

@media (min-width: 1000px) {
  .project {
    display: grid;
    grid-template-columns: 1fr 4fr;
    column-gap: var(--gap);
    align-items: start;
  }

  .text {
    position: sticky;
    top: var(--header);
    padding: 0 24px 0 0;
  }
}

@media (hover: hover) and (pointer: fine) {
  header a:hover,
  .close:hover,
  h2.linked a:hover {
    color: var(--dim);
  }

  p.linked a:hover {
    color: #fff;
  }

  .links a:hover,
  .prev:hover,
  .next:hover {
    color: #fff;
  }
}

@media (prefers-reduced-motion: reduce) {
  .row {
    animation: none;
    transition: opacity 0.2s ease;
  }

  .home:hover .row:not(:hover) {
    opacity: 0.35;
  }
}
