/* Gallery surfaces (homepage + full gallery page) */
.home-gallery-grid,
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.05rem;
  margin-top: 1.25rem;
  align-items: stretch;
}

.home-gallery-grid .home-gallery-item:first-child {
  grid-column: span 2;
}

.home-gallery-grid .home-gallery-item:first-child img {
  height: 300px;
}

.gallery-grid {
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  grid-auto-flow: dense;
  margin-top: 1.35rem;
}

.home-gallery-item,
.gallery-item {
  position: relative;
  border: 0;
  padding: 0;
  width: 100%;
  background: var(--card-surface);
  border-radius: var(--card-radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--card-border);
  cursor: pointer;
  transition:
    transform var(--anim-duration) ease,
    box-shadow var(--anim-duration) ease,
    border-color var(--anim-duration) ease;
}

.home-gallery-item.missing,
.gallery-item.missing {
  display: grid;
  place-items: center;
  min-height: 220px;
  cursor: default;
  border-style: dashed;
  border-color: rgba(123, 91, 46, 0.3);
  background: linear-gradient(160deg, #fbf7ef 0%, #f3e8d7 100%);
}

.gallery-missing-inner {
  display: grid;
  gap: 0.35rem;
  padding: 1rem;
  text-align: center;
}

.gallery-missing-inner strong {
  color: var(--primary-dark);
}

.gallery-missing-inner span {
  color: var(--gray-700);
  font-size: 0.9rem;
}

.home-gallery-item::after,
.gallery-item::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(255, 253, 248, 0.3);
}

.home-gallery-item:hover,
.gallery-item:hover {
  transform: translateY(-3px);
  border-color: var(--card-border-strong);
  box-shadow: var(--shadow-md);
}

.home-gallery-item img,
.gallery-item img {
  width: 100%;
  height: 228px;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  transition: transform var(--anim-duration) ease;
}

.home-gallery-item:hover img,
.gallery-item:hover img {
  transform: scale(1.03);
}

.gallery-grid .gallery-item:nth-child(4n + 1) img {
  height: 300px;
}

.gallery-grid .gallery-item:nth-child(5n + 2) img {
  height: 260px;
}

.home-gallery-caption,
.gallery-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0.78rem 0.85rem;
  font-size: 0.84rem;
  letter-spacing: 0.01em;
  color: var(--white);
  background: linear-gradient(
    180deg,
    rgba(60, 48, 18, 0.06),
    rgba(60, 48, 18, 0.84)
  );
  text-align: left;
  line-height: 1.45;
  font-weight: 550;
}

.home-gallery-empty {
  text-align: center;
  margin-top: 1.1rem;
  padding: 1.25rem 1rem;
  border-radius: var(--card-radius);
  border: 1px dashed var(--card-border);
  background: linear-gradient(180deg, #fdf9f1 0%, #f6edde 100%);
}

.home-gallery-empty p {
  margin-bottom: 0.75rem;
  color: var(--gray-600);
}

.home-gallery-cta {
  margin-top: 1.3rem;
  display: flex;
  justify-content: center;
}

.home-gallery-more-btn {
  min-width: 196px;
  border-color: rgba(80, 64, 24, 0.3);
  background: linear-gradient(140deg, #fffaf0 0%, #f6e9d3 100%);
  color: var(--primary-dark);
  box-shadow: 0 10px 22px rgba(55, 45, 19, 0.14);
}

.home-gallery-more-btn:hover {
  background: linear-gradient(140deg, #fdf2df 0%, #efdebf 100%);
}

.gallery-page-shell {
  padding: clamp(2.5rem, 4.5vw, 3.7rem) 0 clamp(2.8rem, 5.2vw, 4.2rem);
  background: linear-gradient(180deg, #faf7f2 0%, #f4ecdf 100%);
  border-top: 1px solid rgba(123, 91, 46, 0.08);
  border-bottom: 1px solid rgba(123, 91, 46, 0.08);
}

.gallery-page-head {
  max-width: 760px;
  display: grid;
  gap: 0.7rem;
}

.gallery-page-head h1 {
  margin: 0;
}

.gallery-page-head .lead-text {
  text-align: left;
  margin: 0;
}

.gallery-bottom-actions {
  margin-top: 2rem;
}

.home-gallery-item.skeleton,
.gallery-item.skeleton {
  min-height: 220px;
  background: linear-gradient(
    90deg,
    var(--gray-200),
    var(--gray-300),
    var(--gray-200)
  );
  background-size: 200% 100%;
  animation: gallery-shimmer 1.4s infinite;
}

@keyframes gallery-shimmer {
  0% {
    background-position: 0% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

@media (max-width: 700px) {
  .home-gallery-grid,
  .gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.7rem;
  }

  .home-gallery-grid .home-gallery-item:first-child {
    grid-column: auto;
  }

  .home-gallery-cta {
    margin-top: 0.9rem;
  }

  .home-gallery-more-btn {
    width: 100%;
    max-width: 320px;
  }

  .home-gallery-item img,
  .home-gallery-grid .home-gallery-item:first-child img,
  .gallery-item img,
  .gallery-grid .gallery-item:nth-child(4n + 1) img,
  .gallery-grid .gallery-item:nth-child(5n + 2) img {
    height: 186px;
  }
}
