@font-face {
  font-family: Archivo;
  src: url("../fonts/archivo-latin.woff2") format("woff2");
  font-weight: 400 600;
  font-stretch: 75% 90%;
  font-display: swap;
}

:root {
  --ink: #fff;
  --ink-soft: #c9c9c9;
  --paper: #000;
  --gap: 3px;
  --edge: 20px;
  --caption-height: 64px;
  --map-height: 44px;
}

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

body {
  /* Never taller than the caption band, the viewport frame's 3px above and below included. */
  --map-size: min(var(--map-height), var(--caption-height) - 6px);
  --map-width: min(var(--sum) * var(--map-size), 60vw);
  --map-room: calc(var(--map-width) + var(--edge)); /* What the map and its margin take from a caption. */

  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: Archivo, "Arial Narrow", sans-serif;
}

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

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ─── Strip: every photo has the same height, its width follows its own ratio ───────── */
.strip {
  position: relative;
  container-type: size;
  display: flex;
  gap: var(--gap);
  overflow: auto hidden;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  cursor: grab;
}

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

.strip:active {
  cursor: grabbing;
}

.frame {
  position: relative;
  flex: none;
}

/* The inline background is the map thumbnail, so a photo shows a preview while it loads. */
.photo {
  position: relative;
  height: calc(100cqh - var(--caption-height));
  aspect-ratio: var(--ratio);
  background-position: center;
  background-size: cover;
}

/* Anti-download: this layer takes the right click and the long press instead of the image. */
.photo::after {
  content: "";
  position: absolute;
  inset: 0;
}

.photo img,
.map img {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
}

/* ─── Caption: sticks to the screen edge and leaves with its photo ──────────────────── */

/* Zero width, then stretched: a long caption can never widen the frame it belongs to. */
.caption {
  display: flex;
  align-items: center;
  width: 0;
  min-width: 100%;
  height: var(--caption-height);
  overflow: clip;
}

.caption-text {
  position: sticky;
  left: var(--edge);
  min-width: 0;

  /* Stays clear of the map, including when a photo narrower than the screen sits in the middle. */
  max-width: min(100% - 2 * var(--edge), 100cqw - 2 * var(--edge) - var(--map-room) - max(0px, (100cqw - 100%) / 2));
  margin-inline: var(--edge);
}

.caption h2,
.caption p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.caption h2 {
  font-size: 1.75rem;
  font-weight: 600;
  font-stretch: 75%;
  line-height: 1.1;
}

.caption p {
  color: var(--ink-soft);
  font-size: 0.9375rem;
  font-stretch: 88%;
  line-height: 1.3;
}

/* ─── Map: the whole collection at true proportions, and what the screen leaves out ─── */

/* It sits inside the caption band and never rises above it. */
.map {
  position: fixed;
  right: var(--edge);
  bottom: calc((var(--caption-height) - var(--map-size)) / 2);
  display: flex;
  width: var(--map-width);
  height: var(--map-size);
  background: var(--paper);
}

/* Hides the captions that scroll in under the map, over exactly the height of the band. */
.map::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: calc((var(--map-size) - var(--caption-height)) / 2) calc(-1 * var(--edge));
  background: var(--paper);
  pointer-events: none;
}

.map a {
  flex: var(--ratio) 1 0;
  min-width: 0;
}

.map img {
  object-fit: cover;
}

.map:has([aria-current]) a:not([aria-current]) {
  opacity: 0.55;
}

.map-viewport {
  position: absolute;
  inset-block: -3px;
  border: 2px solid var(--ink);
  pointer-events: none;
}

/* ─── Tall screens: a little less room for the caption ──────────────────────────────── */
@media (aspect-ratio <= 1/1) {
  :root {
    --edge: 16px;
    --caption-height: 62px;
  }

  .caption h2 {
    font-size: 1.5rem;
  }
}

/* ─── Phones, held either way: the map leaves the screen, the captions get its room ─── */
@media (width <= 600px), (height <= 500px) {
  body {
    --map-room: 0px;
  }

  /* Hidden from sight only: screen readers keep the list of photographs and its links. */
  .map {
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  /* Held sideways: every pixel of height goes to the photo. */
  @media (aspect-ratio > 1/1) {
    :root {
      --edge: 12px;
      --caption-height: 30px;
    }

    .caption-text {
      display: flex;
      align-items: baseline;
      gap: 10px;
    }

    /* A title gives way only once its details are entirely gone. */
    .caption h2 {
      min-width: 0;
      font-size: 1.0625rem;
    }

    .caption p {
      flex-shrink: 1000;
      min-width: 0;
      font-size: 0.8125rem;
    }
  }
}
