/* Square thumbnail grid for listagem cards (no diamond / clip-path) */

.listing-gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  max-width: none;
  flex: 1 1 auto;
  align-self: stretch;
  box-sizing: border-box;
}

.listing-gallery__cell {
  display: flex;
  align-items: stretch;
  min-width: 0;
}

.listing-gallery__open {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: rgba(20, 48, 58, 0.06);
  box-shadow: inset 0 0 0 1px rgba(20, 48, 58, 0.08);
  line-height: 0;
  padding: 0;
  margin: 0;
  border: none;
  font: inherit;
  color: inherit;
  cursor: zoom-in;
  text-align: left;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.listing-gallery__open:hover {
  box-shadow:
    inset 0 0 0 1px rgba(58, 114, 111, 0.35),
    0 4px 14px rgba(20, 48, 58, 0.08);
}

.listing-gallery__open:focus {
  outline: none;
}

.listing-gallery__open:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.listing-gallery__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  display: block;
  vertical-align: middle;
}

/* Single image: full width of media column */
.listing-gallery--1 {
  grid-template-columns: 1fr;
  max-width: none;
}

/* Three images: third centered on second row */
.listing-gallery--3 .listing-gallery__cell:last-child {
  grid-column: 1 / -1;
  max-width: calc(50% - 4px);
  justify-self: center;
}

.listing-gallery--3 .listing-gallery__cell:last-child .listing-gallery__open {
  width: 100%;
}

/* Listagem cards: one visible thumb on narrow viewports (lightbox still has all images). */
@media (max-width: 640px) {
  .listing-gallery {
    grid-template-columns: 1fr;
    gap: 0;
    flex: 0 0 auto;
    align-self: stretch;
    width: 100%;
  }

  .listing-gallery .listing-gallery__cell:nth-child(n + 2) {
    display: none;
  }

  .listing-gallery--3 .listing-gallery__cell:last-child {
    grid-column: auto;
    max-width: none;
    justify-self: stretch;
  }

  /* Full-bleed strip: card rounds the top; 16:9 reads better than a full-width square. */
  .listing-gallery__open {
    border-radius: 0;
    aspect-ratio: 16 / 9;
  }
}
