/* Equal image widths are relative to the full archive canvas, including rail gutters. */
.works {
  --large-photo: 22.8cqw;
  --small-photo: 15.6cqw;
  container-type: inline-size;
  position: relative;
  z-index: 30;
  padding-block: clamp(42px, 5.3vw, 82px) clamp(42px, 4vw, 65px);
}

.editorial-project {
  --page-gutter: max(32px, 4vw);
  --row-start: clamp(var(--page-gutter), calc(var(--start) * 1cqw), 620px);
  --row-gap: clamp(24px, calc(var(--gap) * .32vw), 80px);
  margin-block-end: clamp(32px, calc(var(--after) * .52vw), 105px);
  min-inline-size: 0;
  scroll-margin-top: 52px;
}

.editorial-track {
  display: flex;
  align-items: flex-start;
  gap: var(--row-gap);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  padding: 8px var(--page-gutter) 14px var(--row-start);
  scrollbar-width: none;
}

.editorial-track::-webkit-scrollbar { display: none; }

.editorial-track:focus-visible { outline-offset: -2px; }

.editorial-photo {
  flex: none;
  inline-size: var(--small-photo);
  margin: calc(var(--offset) * 1px) 0 0 calc(var(--space) * 1px);
}

.editorial-photo[data-size="large"] { inline-size: var(--large-photo); }

/* Landscape frames share the height of a 3:4 large portrait. D1 retains its width. */
.editorial-photo[data-sizing="landscape-height"] {
  inline-size: calc(var(--large-photo) / .75 * var(--ratio));
}

.editorial-photo img {
  display: block;
  inline-size: 100%;
  block-size: auto;
  /* Average colour of each photo, shown while it loads. Set per figure by build_editorial.py. */
  background-color: var(--ph, #151515);
}

.editorial-caption {
  margin: 10px 0 0 calc(var(--label) * 1px);
  color: #f0f0ea;
  font-family: "Novarese", var(--serif);
  font-size: clamp(13px, .95vw, 18px);
  font-weight: 400;
  line-height: 1.2;
  /* Same shadow as #intro, so the light caption stays legible over the lime part of the backdrop. */
  text-shadow: 0 1px 4px rgba(0, 0, 0, .88), 0 0 16px rgba(0, 0, 0, .7);
}

.editorial-heading {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin: 0;
  font: inherit;
  white-space: nowrap;
}

.editorial-number {
  font-family: "Helvetica Now", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: .8em;
  font-variant-numeric: tabular-nums;
}

.editorial-caption p { margin: 4px 0 0; }

.editorial-placeholder {
  display: grid;
  aspect-ratio: var(--ratio);
  place-items: center;
  padding: 1em;
  border: 1px dashed currentColor;
  color: var(--paper);
  font-size: 12px;
  text-align: center;
}

/* Tablet: 800px → 1200px goes linearly from 36% / 26% to the desktop 22.8% / 15.6%.
   Keep these numbers in sync with PHOTO_SIZE_RULES in build_editorial.py. */
@media (max-width: 1200px) {
  .works {
    --large-photo: calc(316.8px - 3.6cqw);
    --small-photo: calc(249.6px - 5.2cqw);
  }
}

/* Phone: 76% / 56% up to 420px, then linear to 36% / 26% at 800px. */
@media (max-width: 800px) {
  .works {
    --large-photo: min(76cqw, calc(353.684px - 8.2105cqw));
    --small-photo: min(56cqw, calc(265.263px - 7.1579cqw));
  }

  .editorial-project {
    --page-gutter: 20px;
    --row-start: max(var(--page-gutter), calc(var(--start) * .48vw));
    --row-gap: clamp(26px, calc(var(--gap) * .56vw), 52px);
    margin-block-end: clamp(40px, calc(var(--after) * .75vw), 140px);
  }

  .editorial-caption { margin-inline-start: calc(var(--label) * .35px); }
  .editorial-project { scroll-margin-top: 24px; }
}

@media (max-width: 600px) {
  .editorial-caption { margin-top: 8px; }
  .editorial-photo {
    margin-block-start: calc(var(--offset) * .85px);
    margin-inline-start: calc(var(--space) * .4px);
  }
}

.editorial-project:last-child { margin-block-end: 0; }
