.gallery {
  padding: 40px;
  text-align: center;
}

.gallery h2 {
  font-size: 2rem;
  margin-bottom: 20px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 15px;
}

.gallery-grid img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.3s ease;
}

.gallery-grid img:hover {
  transform: scale(1.05);
}

:root {
  --stagger-ms: 90ms; /* change to speed up/slow down the cascade */
}

/* start hidden */
.gallery-grid > a {
  opacity: 0;
  transform: translateY(10px) scale(0.98);
}

/* when revealed, animate in with a per-item delay */
.gallery-grid > a.in {
  animation: pop-in 500ms ease-out both;
  animation-delay: calc(var(--i) * var(--stagger-ms));
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* respect users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  .gallery-grid > a,
  .gallery-grid > a.in {
    opacity: 1 !important;
    transform: none !important;
    animation: none !important;
  }
}
