/* ==========================================================================
   Galerie.

   Not part of the cloned page — this is a route of its own — but it is built
   out of the same tokens, type scale and grid variables, so it belongs to the
   same site rather than looking like a second one.
   ========================================================================== */

.gallery-page {
  background-color: var(--primitive-black);
  min-height: 100vh;
  padding: calc(var(--global-nav-height) + 72px) var(--grid-gutter-width) 120px;
}
@media (width >= 1280px) {
  .gallery-page {
    padding-top: calc(var(--global-nav-height) + 112px);
  }
}

.gallery__intro {
  max-width: calc((var(--grid-column-width) * 8) + (var(--grid-gutter-width) * 7));
  margin-bottom: 48px;
}
.gallery__eyebrow {
  margin: 0 0 16px;
}
.gallery__title {
  margin: 0 0 24px;
}
.gallery__lede {
  margin: 0;
  color: color-mix(in srgb, var(--primitive-white) 72%, transparent);
}

/* ---------- filters ---------- */

.gallery__filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.gallery__chip {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 9px 16px;
  border: 1px solid color-mix(in srgb, var(--primitive-white) 22%, transparent);
  border-radius: 999px;
  background: 0 0;
  color: var(--primitive-white);
  cursor: pointer;
  transition:
    background-color 0.2s var(--anim-ease),
    border-color 0.2s var(--anim-ease);
}
.gallery__chip:hover {
  border-color: color-mix(in srgb, var(--primitive-white) 55%, transparent);
}
.gallery__chip[data-active="true"] {
  background-color: var(--primitive-white);
  border-color: var(--primitive-white);
  color: var(--primitive-black);
}

/* The chip already carries the right colour for its state — white while
   inactive, black against the white background of the active one. The label
   is a `.text` span, and that class sets `color: var(--primitive-black)`
   explicitly, which beats inheritance: every inactive label was black on a
   black ground, so only the active chip could be read. The count span has no
   `.text` class, which is why the numbers were visible and the words were not.

   Inheriting is the fix, not `text--light` — that would paint the label white
   and hide it on the active chip instead. */
.gallery__chip .text {
  color: inherit;
}

.gallery__chip-count {
  font-size: 12px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  opacity: 0.6;
}

.gallery__count {
  margin: 0 0 28px;
  font-size: 13px;
  line-height: 1.4;
  color: color-mix(in srgb, var(--primitive-white) 50%, transparent);
}

/* ---------- grid ----------
   Columns rather than grid: the frames run from 0.56 to 2.9 in aspect, and a
   row-based grid would either crop them all to one shape or leave ragged gaps
   under the short ones. Columns let every picture keep its own proportions.

   The trade-off is reading order — columns fill top-to-bottom, so the visual
   order is not the DOM order. That is why the list is not numbered and each
   tile is reachable and labelled on its own. */
.gallery__grid {
  columns: 2;
  column-gap: var(--grid-gutter-width);
  margin: 0;
  padding: 0;
  list-style: none;
}
@media (width >= 744px) {
  .gallery__grid {
    columns: 3;
  }
}
@media (width >= 1280px) {
  .gallery__grid {
    columns: 4;
  }
}
@media (width >= 1920px) {
  .gallery__grid {
    columns: 5;
  }
}

.gallery__cell {
  break-inside: avoid;
  /* `break-inside` is not honoured by every engine for the box itself, so the
     bottom spacing is padding on an unbreakable child rather than a margin
     that could be split across a column boundary. */
  padding-bottom: var(--grid-gutter-width);
}

.gallery__tile {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: none;
  border-radius: 4px;
  overflow: hidden;
  background-color: #111;
  cursor: zoom-in;
  color: var(--primitive-white);
}
.gallery__tile:focus-visible {
  outline: 2px solid var(--primitive-white);
  outline-offset: 3px;
}

.gallery__image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* The placeholder is set as a background on the image itself, so it is
     covered the moment the real pixels decode — no second element to fade. */
  background-size: cover;
  background-position: center;
  transition: transform 0.5s var(--anim-ease);
}
.gallery__tile:hover .gallery__image {
  transform: scale(1.03);
}

/* The discipline, shown on hover so the grid itself stays quiet. */
.gallery__tile-group {
  position: absolute;
  left: 10px;
  bottom: 10px;
  padding: 4px 8px;
  border-radius: 3px;
  background-color: rgb(0 0 0 / 62%);
  backdrop-filter: blur(6px);
  font-size: 11px;
  line-height: 1;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0;
  transform: translateY(4px);
  transition:
    opacity 0.25s var(--anim-ease),
    transform 0.25s var(--anim-ease);
}
.gallery__tile:hover .gallery__tile-group,
.gallery__tile:focus-visible .gallery__tile-group {
  opacity: 1;
  transform: translateY(0);
}

/* A film has to say so while it is still a still. */
.gallery__badge {
  position: absolute;
  top: 10px;
  right: 10px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 999px;
  background-color: rgb(0 0 0 / 62%);
  backdrop-filter: blur(6px);
  font-size: 11px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

/* ---------- lightbox ---------- */

.gallery__lightbox {
  position: fixed;
  inset: 0;
  z-index: 2100; /* above the header (900) and the About panel (1000) */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 72px 16px;
  background-color: rgb(0 0 0 / 92%);
  animation: galleryFade 0.2s linear;
}
@media (width >= 744px) {
  .gallery__lightbox {
    padding: 80px 88px;
  }
}

.gallery__lightbox-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
}

.gallery__lightbox-meta {
  display: inline-flex;
  align-items: baseline;
  gap: 12px;
  font-size: 13px;
}
.gallery__lightbox-index {
  font-variant-numeric: tabular-nums;
  opacity: 0.55;
}

.gallery__lightbox-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background-color: rgb(255 255 255 / 8%);
  color: var(--primitive-white);
  cursor: pointer;
  transition: background-color 0.2s var(--anim-ease);
}
.gallery__lightbox-button:hover {
  background-color: rgb(255 255 255 / 18%);
}
.gallery__lightbox-button:focus-visible {
  outline: 2px solid var(--primitive-white);
  outline-offset: 2px;
}

.gallery__lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}
.gallery__lightbox-nav--prev {
  left: 12px;
}
.gallery__lightbox-nav--next {
  right: 12px;
}
.gallery__lightbox-nav--next svg {
  transform: scaleX(-1);
}

.gallery__lightbox-figure {
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: 100%;
}

.gallery__lightbox-media {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 160px);
  width: auto;
  height: auto;
  object-fit: contain;
  animation: galleryFade 0.25s var(--anim-ease);
}

@keyframes galleryFade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .gallery__lightbox,
  .gallery__lightbox-media {
    animation: none;
  }
  .gallery__image,
  .gallery__tile-group {
    transition: none;
  }
  .gallery__tile:hover .gallery__image {
    transform: none;
  }
}
