/* ===== Premium Phase 7 — gallery image consistency ====================
   WordPress [gallery] shortcode outputs images at their native aspect
   ratio, so a single portrait image in a row of landscapes throws the
   row out of alignment (visible on /secondary-school-programme/, where
   the first tile is 225×300 portrait, the other five are 300×225
   landscape). Force every gallery tile to a uniform 4:3 frame with a
   cover crop and a gentle hover zoom. Scoped strictly to
   .elementor-image-gallery so no other layouts are touched.
   ====================================================================== */

.elementor-image-gallery .gallery .gallery-item {
  margin: 0 0 12px !important;
  padding: 0 6px !important;
}

.elementor-image-gallery .gallery .gallery-icon,
.elementor-image-gallery .gallery .gallery-icon.portrait,
.elementor-image-gallery .gallery .gallery-icon.landscape {
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 14px;
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  background: #f1f5f9;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05),
              0 6px 18px -10px rgba(15, 23, 42, 0.10);
  transition: box-shadow 280ms ease, transform 280ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* Force the figure / item itself to fill the grid cell — WP core
   defines `.gallery-item { display: inline-block; max-width: 100% }`
   AND `.gallery-columns-3 .gallery-item { max-width: 33.33% }` which
   caps each item to 1/3 of the parent regardless of grid layout.
   Override BOTH width and max-width so the item stretches with the
   grid cell. */
.elementor-image-gallery .gallery .gallery-item {
  display: flex !important;
  flex-direction: column;
  align-items: stretch;
  width: 100% !important;
  max-width: 100% !important;
  text-align: center;
}

.elementor-image-gallery .gallery .gallery-icon:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.06),
              0 20px 38px -16px rgba(11, 68, 193, 0.18);
}

.elementor-image-gallery .gallery .gallery-icon a {
  display: block;
  width: 100%;
  height: 100%;
}

.elementor-image-gallery .gallery .gallery-icon img {
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  object-fit: cover !important;
  display: block;
  transition: transform 480ms cubic-bezier(0.22, 1, 0.36, 1);
}

.elementor-image-gallery .gallery .gallery-icon:hover img {
  transform: scale(1.05);
}

/* Make sure the gallery row uses a clean grid with even gaps even if
   WordPress' default float layout was active before. Force 4 per row
   on the wide breakpoint (was 3) — used by /school-facilities/ and
   /pre-school-facilities/ where the gallery has 12-15 cards and wants
   bigger images filling the container width. */
.elementor-image-gallery .gallery.gallery-columns-3 {
  display: grid !important;
  grid-template-columns: repeat(4, 1fr) !important;
  gap: 20px !important;
  /* nuke the per-widget Elementor "gallery spacing" negative margin —
     it indents items into the parent and shrinks the visible row. */
  margin: 0 !important;
}
.elementor-image-gallery .gallery.gallery-columns-3 .gallery-item {
  width: auto !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* Caption ("Cafeteria", "Library" etc.) styling so it doesn't look
   like a random text node below the thumb */
.elementor-image-gallery .gallery .gallery-caption,
.elementor-image-gallery .gallery .wp-caption-text {
  margin-top: 10px !important;
  text-align: center !important;
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.92rem;
  font-weight: 500;
  color: #1f2937;
}

/* Tablet: drop to 3 cols, then 2 on small */
@media (max-width: 1024px) {
  .elementor-image-gallery .gallery.gallery-columns-3 {
    grid-template-columns: repeat(3, 1fr) !important;
  }
}
@media (max-width: 640px) {
  .elementor-image-gallery .gallery.gallery-columns-3 {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}
