/* tool-tiles.css — minimal, self-contained */

/* Centered white container */
#gallery.gallery-container {
  max-width: 1100px;
  margin: 0 auto;
  /* background: #fff; */
  border-radius: 16px;
  padding: 24px;
}

/* 3-tile grid, centered as a block */
#gallery .bg-card-grid {
  display: grid;
  /* grid-template-columns: repeat(3, minmax(220px, 1fr)); */
  /* gap: 18px; */
  /* max-width: 980px; */
  grid-template-columns: repeat(3, minmax(260px, 1fr)); /* was 220px */
  max-width: 1120px;                                    /* was 980px */
  gap: 24px;                                            /* slightly more breathing room */
  margin: 0 auto 14px;
  align-items: stretch;            /* ensures row height follows tiles */
  justify-content: center;
  justify-items: center;
}

/* Tile (borderless). Width:100% is critical so aspect-ratio works */
#gallery .bg-card {
  width: 100%;
  display: block;
  text-decoration: none;
  color: inherit;
  border-radius: 12px;
  overflow: visible;               /* was hidden; allow PNG drop-shadow to render */
  /* background: #fff; */
  transition: transform .3s ease;
}
#gallery .bg-card:hover {
  transform: translateY(-2px);
}
#gallery .bg-card:focus-visible {
  outline: 2px solid var(--link-color, #1e90ff);
  outline-offset: 2px;
}

/* Image stage must span full width for the aspect-ratio to compute */
#gallery .bg-card__image-wrap {
  width: 100%;
  /* background: #fff; */
  display: grid;
  place-items: center;
  /* aspect-ratio: 4 / 3; */

  aspect-ratio: auto;
  /* fluid height: tall on desktop, still reasonable on phones */
  height: clamp(260px, 36vw, 540px);
}

/* Defeat global img { width:100% } rules ONLY for these images */
#gallery .bg-card__image-wrap > img.bg-card__img {
  max-width: 100% ;
  max-height: 100% ;
  width: auto ;
  height: auto ;
  display: block;
  transition: transform .3s ease;

  filter: drop-shadow(0 3px 10px rgba(0,0,0,.12));
  will-change: transform, filter;
}
#gallery .bg-card:hover .bg-card__image-wrap > img.bg-card__img,
#gallery .bg-card:focus-visible .bg-card__image-wrap > img.bg-card__img {
  transform: scale(1.06);
}

#gallery .bg-card__image-wrap > img.bg-card__img {
  filter: drop-shadow(0 3px 10px rgba(0,0,0,.12));
}
#gallery .bg-card:hover .bg-card__image-wrap > img.bg-card__img,
#gallery .bg-card:focus-visible .bg-card__image-wrap > img.bg-card__img {
  filter: drop-shadow(0 6px 18px rgba(0,0,0,.16));
}

/* Shared metadata under the grid */
#gallery .gallery-meta {
  max-width: 980px;
  margin: 14px auto 0;
  padding: 8px 4px 0;
  border-top: 1px solid #eee;
}
#gallery .gallery-meta .g-title   { margin: 0 0 4px; font-size: 1.05rem; font-weight: 650; }
#gallery .gallery-meta .g-excerpt { margin: 0; color: #666; }

/* Motion preference */
@media (prefers-reduced-motion: reduce) {
  #gallery .bg-card,
  #gallery .bg-card__image-wrap > img.bg-card__img { transition: none; }
}

/* ===== Additions: prevent mobile overflow + center meta ===== */
#gallery .bg-card-grid { max-width: 100%; }
#gallery .gallery-meta { text-align: center; }

@media (max-width: 1100px) {
  #gallery .bg-card-grid {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
    max-width: min(760px, 100%);
    gap: 20px;
  }
}

@media (max-width: 700px) {
  #gallery .bg-card-grid {
    grid-template-columns: 1fr;
    max-width: 100%;
    gap: 16px;
  }
  #gallery.gallery-container { padding: 16px; }
}
