/* ==========================================================================
   Gallery – masonry layout (Pinterest-style) + scroll-in animation
   ========================================================================== */

.aptly-gallery {
  padding: 0 0 5rem;
  background: var(--bg-body);
}

.aptly-gallery__hero {
  padding: calc(var(--header-height, 80px) + 4rem) 0 4rem;
  margin-bottom: 3rem;
}

.aptly-gallery__hero-inner {
  max-width: 48rem;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

.aptly-gallery__header {
  margin: 0;
}

.aptly-gallery__label {
  font-size: var(--font-sm);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-secondary);
  margin: 0 0 0.75rem;
}

.aptly-gallery__title {
  font-size: var(--font-4xl);
  font-weight: 600;
  line-height: 1.3;
  margin: 0 0 1.25rem;
}

.aptly-gallery__subtitle {
  font-size: var(--font-lg);
  line-height: 1.6;
  color: var(--color-text-soft);
  margin: 0;
  max-width: 36rem;
  margin-left: auto;
  margin-right: auto;
}

/* Masonry container (CSS multi-column)
   ---------------------------------------- */
.aptly-gallery__main {
  padding-bottom: 2rem;
}

.aptly-gallery__masonry {
  columns: 1;
  column-gap: 1.25rem;
}

@media (min-width: 640px) {
  .aptly-gallery__masonry {
    columns: 2;
    column-gap: 1.5rem;
  }
}

@media (min-width: 1024px) {
  .aptly-gallery__masonry {
    columns: 3;
    column-gap: 1.5rem;
  }
}

/* Masonry item – keeps natural aspect ratio, no fixed grid
   ---------------------------------------- */
.aptly-gallery__item {
  position: relative;
  margin: 0 0 1.25rem;
  break-inside: avoid;
  page-break-inside: avoid;
  border-radius: var(--radius-2xl);
  overflow: hidden;
  background: var(--bg-muted);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  transition:
    transform 0.35s ease,
    box-shadow 0.35s ease;

  /* Scroll-in: fade + slight lift (respect reduced motion) */
  animation: aptly-gallery-in 0.6s ease both;
  animation-delay: calc(0.04s * var(--i, 0));
}

@media (prefers-reduced-motion: reduce) {
  .aptly-gallery__item {
    animation: none;
  }
}

@keyframes aptly-gallery-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.aptly-gallery__item:hover {
  transform: translateY(-6px);
  box-shadow: 0 16px 40px rgba(0, 7, 119, 0.14);
}

.aptly-gallery__link {
  display: block;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  position: relative;
  z-index: 1;
}

.aptly-gallery__img-wrap {
  position: relative;
  display: block;
  overflow: hidden;
}

.aptly-gallery__img-wrap img {
  width: 100%;
  height: auto;
  display: block;
  vertical-align: middle;
  transition: transform 0.5s ease;
}

.aptly-gallery__item:hover .aptly-gallery__img-wrap img {
  transform: scale(1.05);
}

.aptly-gallery__overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 40%, rgba(0, 7, 119, 0.2) 100%);
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
}

.aptly-gallery__item:hover .aptly-gallery__overlay {
  opacity: 1;
}

/* Responsive hero
   ---------------------------------------- */
@media (max-width: 767px) {
  .aptly-gallery__hero {
    padding: calc(var(--header-height, 80px) + 2.5rem) 0 2.5rem;
    margin-bottom: 2rem;
  }
}
