/* Ministry photo gallery: album grids plus the lightbox viewer.
   Palette variables come from the :root block in layout.html. */

.gallery-section {
  padding: 1rem 0 4rem;
  background: var(--stp-warm-white);
}

.gallery-eyebrow {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--stp-wood);
  margin-bottom: 0.6rem;
}

.gallery-heading {
  font-size: 1.4rem;
  color: var(--stp-charcoal);
  margin-bottom: 2rem;
}

.gallery-album + .gallery-album {
  margin-top: 3rem;
  padding-top: 3rem;
  border-top: 1px solid rgba(139, 105, 20, 0.12);
}

.gallery-album-title {
  font-size: 1.1rem;
  color: var(--stp-charcoal);
  margin-bottom: 0.25rem;
}

.gallery-album-meta {
  font-size: 0.85rem;
  color: #888;
}

.gallery-album-count {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #a8a29e;
  margin-top: 0.35rem;
}

/* Grid: auto-fill keeps tiles a sensible size at any width without media queries. */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.gallery-tile {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  padding: 0;
  border: 0;
  overflow: hidden;
  cursor: pointer;
  background: var(--stp-stone);
}

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

.gallery-tile:hover img,
.gallery-tile:focus-visible img {
  transform: scale(1.04);
}

.gallery-tile:focus-visible {
  outline: 2px solid var(--stp-green);
  outline-offset: 2px;
}

/* Caption overlay: hidden until hover or keyboard focus, so an untouched grid
   stays quiet. Tiles without a caption never render this element at all. */
.gallery-tile-caption {
  position: absolute;
  inset: auto 0 0 0;
  padding: 1.75rem 0.7rem 0.6rem;
  font-size: 0.78rem;
  line-height: 1.35;
  color: #fff;
  text-align: left;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.78), rgba(0, 0, 0, 0));
  opacity: 0;
  transform: translateY(0.4rem);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.gallery-tile:hover .gallery-tile-caption,
.gallery-tile:focus-visible .gallery-tile-caption {
  opacity: 1;
  transform: translateY(0);
}

/* Touch devices have no hover, so show captions persistently there. */
@media (hover: none) {
  .gallery-tile-caption {
    opacity: 1;
    transform: none;
  }
}

/* --- Lightbox --- */

.gallery-lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1.5rem;
  background: rgba(20, 18, 16, 0.94);
}

.gallery-lightbox[hidden] {
  display: none;
}

.gallery-figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
  max-width: min(1100px, 100%);
  max-height: 100%;
  margin: 0;
}

.gallery-full {
  max-width: 100%;
  max-height: 78vh;
  object-fit: contain;
  display: block;
}

.gallery-figcaption {
  font-size: 0.9rem;
  line-height: 1.5;
  color: #e7e2da;
  text-align: center;
  max-width: 44rem;
}

.gallery-figcaption:empty {
  display: none;
}

.gallery-close,
.gallery-nav {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 0;
  cursor: pointer;
  line-height: 1;
  transition: background 0.2s ease;
}

.gallery-close:hover,
.gallery-nav:hover,
.gallery-close:focus-visible,
.gallery-nav:focus-visible {
  background: rgba(255, 255, 255, 0.24);
}

.gallery-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 2.5rem;
  height: 2.5rem;
  font-size: 1.6rem;
}

.gallery-nav {
  flex: 0 0 auto;
  width: 2.75rem;
  height: 3.75rem;
  font-size: 2rem;
}

.gallery-nav[hidden] {
  display: none;
}

.gallery-counter {
  position: absolute;
  bottom: 1rem;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #a8a29e;
}

@media (max-width: 640px) {
  .gallery-lightbox {
    padding: 0.75rem;
  }
  .gallery-nav {
    width: 2.25rem;
    height: 3rem;
    font-size: 1.6rem;
  }
  .gallery-full {
    max-height: 68vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gallery-tile img,
  .gallery-tile-caption {
    transition: none;
  }
  .gallery-tile:hover img,
  .gallery-tile:focus-visible img {
    transform: none;
  }
}
