/* =============================================
   gallery.css — Galeria masonry + Lightbox
   S3-1 (masonry) · S3-7 (lightbox)
   ============================================= */

/* ── Seção ─────────────────────────────────── */
#galeria {
  padding: var(--section-pad-v) var(--section-pad-h);
  background: var(--color-primary);
}

.gallery__header {
  text-align: center;
  margin-bottom: 2rem;
}

.gallery__header h2 {
  font-size: clamp(1.75rem, 5vw, 2.75rem);
  font-weight: var(--fw-black);
  margin-bottom: .5rem;
}

.gallery__header p {
  color: var(--color-text-muted);
  font-size: 1rem;
}

/* ── Grid masonry (CSS grid + span calculado em JS) ─ */
.gallery__grid {
  display: grid;
  grid-template-columns: 1fr;
  grid-auto-rows: 10px;
  gap: 6px;
}

@media (min-width: 768px) {
  .gallery__grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .gallery__grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }
}

/* ── Item da galeria ─────────────────────────── */
[data-gallery-item] {
  break-inside: avoid;
  margin: 0;
  overflow: hidden;
  border-radius: 8px;
  cursor: pointer;
}

[data-gallery-item] img {
  width: 100%;
  display: block;
  border-radius: 8px;
  cursor: pointer;
  transition: transform var(--transition-slow);
}

@media (hover: hover) {
  [data-gallery-item]:hover img {
    transform: scale(1.04);
  }
}

/* ── Lightbox (<dialog> nativo) ─────────────── */
#lightbox {
  border: none;
  background: transparent;
  width: fit-content;
  height: fit-content;
  max-width: 90vw;
  max-height: 90vh;
  padding: 0;
  outline: none;
  position: fixed;
  inset: 0;
  margin: auto;
}

#lightbox::backdrop {
  background: rgba(0, 0, 0, .85);
}

.lightbox__inner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

#lightbox img {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 8px;
  display: block;
}

/* ── Botões do lightbox ──────────────────────── */
.lightbox__controls {
  position: fixed;
  inset: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
}

.lightbox__btn {
  pointer-events: all;
  background: rgba(0, 0, 0, .55);
  border: 1px solid rgba(255, 255, 255, .2);
  color: #fff;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-base);
  line-height: 1;
}

.lightbox__btn:hover {
  background: rgba(0, 0, 0, .8);
}

.lightbox__btn--close {
  position: fixed;
  top: 1rem;
  right: 1rem;
  font-size: 1rem;
}

.lightbox__btn--prev,
.lightbox__btn--next {
  font-size: 1.5rem;
}

