/* =============================================================
   barrio_npm_prototype — image gallery grid + lightbox (shared component)

   Content-type-neutral. Any content type with field_image renders the grid
   via templates/content/_image-grid.html.twig (data from Media\GalleryBuilder)
   inside its own <section> + heading, and emits the shared #np-gallery-modal
   (_gallery-modal.html.twig + barrioNpmGalleryModal JS). The section wrapper +
   heading are owned per-content-type; the grid + items + lightbox live here.

   `data-count` on the grid keeps small-N layouts from stretching awkwardly:
     · 1 image  → full width + 16:9 poster (4:3 at phone)
     · 2 images → forced 2 columns
     · 3+ images → auto-fit grid
   ============================================================= */

.np-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.np-gallery-item {
  margin: 0;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 8px;
  background: #f1ece1;
  /* Each cell is a <button> for keyboard/screen-reader affordance.
     Strip UA chrome and use the Pātai hue for focus ring. */
  appearance: none;
  border: 0;
  padding: 0;
  cursor: zoom-in;
}
.np-gallery-item:focus-visible {
  outline: 3px solid var(--hue);
  outline-offset: 2px;
}
.np-gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Count-based sizing — on the grid, so every content type inherits it.
   A lone image is a full-width 16:9 hero (4:3 at phone); 2 images force
   2-col; 3+ use the auto-fit grid above. */
.np-gallery-grid[data-count="1"] {
  grid-template-columns: 1fr;
}
.np-gallery-grid[data-count="1"] .np-gallery-item {
  aspect-ratio: 16 / 9;
}
.np-gallery-grid[data-count="2"] {
  grid-template-columns: 1fr 1fr;
}
@media (max-width: 560px) {
  /* Match the hero — a single gallery image at phone width works better
     as a square-ish 4:3 than a wide 16:9 strip. */
  .np-gallery-grid[data-count="1"] .np-gallery-item {
    aspect-ratio: 4 / 3;
  }
}

/* ---------- Lightbox modal ----------
   Dark, chromeless modal showing the wide image at up to 85vh. */
.np-gallery-modal .modal-content {
  background: transparent;
  border: 0;
  position: relative;
  box-shadow: none;
}
.np-gallery-modal-img {
  width: 100%;
  height: auto;
  max-height: 85vh;
  object-fit: contain;
  display: block;
  border-radius: 8px;
  background: #000;
}
.np-gallery-modal-caption {
  color: #fff;
  font-size: 13px;
  margin: 10px 0 0;
  text-align: center;
}
.np-gallery-modal .np-gallery-close {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  background-color: rgba(255, 255, 255, .9);
  border-radius: 50%;
  padding: 8px;
  width: 32px;
  height: 32px;
  opacity: 1;
}
