/* Preserve every photograph's full aspect ratio in the gallery and lightbox. */
.gallery-grid {
  display: block;
  columns: 3;
  column-gap: 0.65rem;
}

.gallery-grid button {
  display: block;
  width: 100%;
  height: auto;
  min-height: 0;
  margin: 0 0 0.65rem;
  break-inside: avoid;
  background: #0b0c0f;
}

.gallery-grid img {
  position: static;
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
  transform: none;
}

.gallery-grid button:hover img { transform: none; }

.lightbox {
  overflow: hidden;
  grid-template-rows: minmax(0, 1fr) 40px;
}

.lightbox img {
  display: block;
  grid-column: 2;
  grid-row: 1;
  width: auto;
  height: auto;
  max-width: calc(100vw - 160px);
  max-height: calc(100vh - 80px);
  max-height: calc(100dvh - 80px);
  object-fit: contain;
  align-self: center;
  justify-self: center;
}

.lightbox .prev { grid-column: 1; grid-row: 1; }
.lightbox .next { grid-column: 3; grid-row: 1; }

@media (max-width: 720px) {
  .gallery-grid {
    columns: 2;
    column-gap: 0.4rem;
  }

  .gallery-grid button,
  .gallery-grid button:nth-child(n) {
    width: 100%;
    height: auto;
    min-height: 0;
    margin-bottom: 0.4rem;
  }

  .lightbox img {
    max-width: calc(100vw - 104px);
    max-height: calc(100vh - 64px);
    max-height: calc(100dvh - 64px);
  }
}

@media (max-width: 440px) {
  .gallery-grid { columns: 1; }
}
