.gallery {
  align-items: start;
}

.gallery figure,
.gallery figure.wide {
  grid-column: auto;
  margin: 0;
}

.gallery figure:nth-child(2) { transition-delay: .07s; }
.gallery figure:nth-child(3) { transition-delay: .14s; }
.gallery figure:nth-child(4) { transition-delay: .21s; }
.gallery figure:nth-child(5) { transition-delay: .28s; }
.gallery figure:nth-child(6) { transition-delay: .35s; }
.gallery figure:nth-child(7) { transition-delay: .42s; }

.gallery button {
  aspect-ratio: 4 / 5;
  box-shadow: 0 16px 36px rgba(16, 35, 31, .12);
  animation: gallery-drift 6s ease-in-out infinite;
}

.gallery figure:nth-child(even) button {
  animation-delay: -3s;
}

.gallery img,
.gallery .wide img {
  width: 100%;
  height: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  object-position: center;
  transition: transform .45s ease, filter .45s ease;
}

.gallery button:hover img,
.gallery button:focus-visible img {
  transform: scale(1.055);
  filter: saturate(1.06) contrast(1.03);
}

@keyframes gallery-drift {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@media (prefers-reduced-motion: reduce) {
  .gallery button { animation: none; }
  .gallery figure { transition-delay: 0s !important; }
  .gallery img { transition: none; }
}
