/* Responsive grid gallery */
.media-gallery {
  display: grid;
  gap: var(--gap, 1rem);
  /* Auto-fit mode: use when --cols is 0 or not set */
  grid-template-columns: repeat(auto-fit, minmax(var(--min, 260px), 1fr));
}

/* If you prefer a fixed column count on some pages, set cols="2" or "3" */
.media-gallery[style*="--cols: 0"] { /* auto-fit already set above */ }
.media-gallery[style*="--cols: 1"] { grid-template-columns: 1fr; }
.media-gallery[style*="--cols: 2"] { grid-template-columns: repeat(2, 1fr); }
.media-gallery[style*="--cols: 3"] { grid-template-columns: repeat(3, 1fr); }
.media-gallery[style*="--cols: 4"] { grid-template-columns: repeat(4, 1fr); }

.media-gallery__item { 
  margin: 0; 
  max-width: none; 
}

.media-gallery__item img {
  width: 100%;
  height: auto;
  display: block;
}

.media-gallery__link { 
  text-decoration: none; 
  display: block; 
}

.media-gallery figcaption {
  text-align: center;
  font-size: 0.9em;
  opacity: 0.85;
  margin-top: 0.35rem;
}

/* If your theme forces figures full-width or floats, neutralize inside the gallery */
.media-gallery > figure { float: none; }
