/* Photo gallery — responsive grid + lightbox */

.gallery-intro {
  margin-bottom: 2rem;
  color: #444;
  line-height: 1.7;
}

.photo-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
  margin-bottom: 3rem;
  padding: 0;
  list-style: none;
}

@media (max-width: 480px) {
  .photo-gallery {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
  }
}

.gallery-card {
  margin: 0;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 2px 12px rgba(55, 116, 104, 0.12);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.gallery-card:hover,
.gallery-card:focus-within {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(55, 116, 104, 0.2);
}

.gallery-card__link {
  display: block;
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  background: #edf2da;
}

.gallery-card__link:focus {
  outline: 2px solid #377468;
  outline-offset: 2px;
}

.gallery-card__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s ease;
}

.gallery-card:hover .gallery-card__img,
.gallery-card:focus-within .gallery-card__img {
  transform: scale(1.04);
}

.gallery-card__overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  padding: 0.75rem 1rem;
  background: linear-gradient(transparent 40%, rgba(0, 0, 0, 0.65));
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.gallery-card:hover .gallery-card__overlay,
.gallery-card:focus-within .gallery-card__overlay {
  opacity: 1;
}

@media (max-width: 767px) {
  .gallery-card__overlay {
    opacity: 1;
    background: linear-gradient(transparent 55%, rgba(0, 0, 0, 0.55));
    padding: 0.5rem 0.65rem;
  }
}

.gallery-card__title {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
  line-height: 1.3;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.gallery-card__caption-below {
  display: none;
  margin: 0;
  padding: 0.6rem 0.75rem;
  font-size: 0.85rem;
  color: #377468;
  font-weight: 600;
  line-height: 1.3;
}

@media (max-width: 767px) {
  .gallery-card__caption-below {
    display: block;
  }
}

/* Lightbox */
.gallery-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.92);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.gallery-lightbox.is-open {
  opacity: 1;
  visibility: visible;
}

.gallery-lightbox__dialog {
  position: relative;
  max-width: min(1100px, 100%);
  max-height: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0;
}

.gallery-lightbox__figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-height: calc(100vh - 6rem);
}

.gallery-lightbox__img {
  max-width: 100%;
  max-height: calc(100vh - 8rem);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

.gallery-lightbox__caption {
  margin: 0.85rem 0 0;
  color: #edf2da;
  font-size: 1rem;
  text-align: center;
  max-width: 40rem;
  line-height: 1.5;
}

.gallery-lightbox__counter {
  margin-top: 0.5rem;
  color: rgba(237, 242, 218, 0.7);
  font-size: 0.85rem;
}

.gallery-lightbox__close,
.gallery-lightbox__nav {
  position: absolute;
  border: none;
  background: rgba(237, 242, 218, 0.12);
  color: #edf2da;
  cursor: pointer;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  transition: background 0.2s ease, transform 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.gallery-lightbox__close:hover,
.gallery-lightbox__nav:hover,
.gallery-lightbox__close:focus,
.gallery-lightbox__nav:focus {
  background: rgba(237, 242, 218, 0.25);
  outline: none;
}

.gallery-lightbox__close:active,
.gallery-lightbox__nav:active {
  transform: scale(0.94);
}

.gallery-lightbox__close {
  top: -0.25rem;
  right: 0;
}

@media (min-width: 768px) {
  .gallery-lightbox__close {
    top: -2.5rem;
    right: 0;
  }
}

.gallery-lightbox__nav {
  top: 50%;
  transform: translateY(-50%);
}

.gallery-lightbox__nav:active {
  transform: translateY(-50%) scale(0.94);
}

.gallery-lightbox__nav--prev {
  left: -0.5rem;
}

.gallery-lightbox__nav--next {
  right: -0.5rem;
}

@media (max-width: 767px) {
  .gallery-lightbox {
    padding: 0.5rem;
  }

  .gallery-lightbox__nav {
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.45);
  }

  .gallery-lightbox__nav--prev {
    left: 0.25rem;
  }

  .gallery-lightbox__nav--next {
    right: 0.25rem;
  }

  .gallery-lightbox__close {
    top: 0.25rem;
    right: 0.25rem;
    z-index: 2;
    background: rgba(0, 0, 0, 0.45);
  }

  .gallery-lightbox__img {
    max-height: calc(100vh - 7rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  .gallery-card,
  .gallery-card__img,
  .gallery-card__overlay,
  .gallery-lightbox,
  .gallery-lightbox__close,
  .gallery-lightbox__nav {
    transition: none;
  }
}
