/* ==========================================================================
   products-gallery — default collection view: asymmetric editorial grid.
   A card rhythm repeats (6 cards on desktop, 5 on small screens: a wide card,
   offsets), so it still looks composed
   after "Load more" appends cards. Every image is cropped to the cell
   (object-fit: cover), so mixed source ratios never break the grid.
   Mobile / tablet: 2 columns. Desktop: 12 columns.
   Hidden cards (filtered out) get [hidden].
   ========================================================================== */
.products-gallery {
  padding-block: var(--space-xl) var(--space-2xl);
}

.products-gallery__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-xl) var(--grid-gutter);
  align-items: start;
  padding: 0;
}

.products-gallery__item {
  min-width: 0;
}

.products-gallery__item[hidden] {
  display: none;
}

.products-gallery__item .product-card__media {
  --image-ratio: var(--card-ratio, 4 / 5);
}

/* Small screens (2 columns): a wide card every 5th, starting with the 3rd, so
   cards always pair up in between: [1 2] [3 wide] [4 5] [6 7] [8 wide] ... */
@media (max-width: 63.99em) {
  .products-gallery__item:nth-child(5n + 3) {
    --card-ratio: 3 / 2;

    grid-column: 1 / -1;
  }

  .products-gallery__item:nth-child(5n + 3) .product-card__title {
    font-size: var(--text-xl);
  }

  .products-gallery__item:nth-child(5n + 3) .product-card__media {
    border-radius: var(--radius-lg);
  }
}

@media (min-width: 64em) {
  .products-gallery__grid {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    row-gap: var(--space-2xl);
  }

  .products-gallery__item:nth-child(6n + 1),
  .products-gallery__item:nth-child(6n + 2),
  .products-gallery__item:nth-child(6n + 3) {
    grid-column: span 4;
  }

  .products-gallery__item:nth-child(6n + 4) {
    --card-ratio: 3 / 2;

    grid-column: span 6;
  }

  .products-gallery__item:nth-child(6n + 4) .product-card__title {
    font-size: var(--text-xl);
  }

  .products-gallery__item:nth-child(6n + 4) .product-card__media {
    border-radius: var(--radius-lg);
  }

  .products-gallery__item:nth-child(6n + 5),
  .products-gallery__item:nth-child(6n + 6) {
    grid-column: span 3;
  }

  /* small drops give the rows a hand-laid, photo-shoot feel */
  .products-gallery__item:nth-child(6n + 2) {
    margin-top: var(--space-xl);
  }

  .products-gallery__item:nth-child(6n + 5) {
    margin-top: var(--space-lg);
  }

  .products-gallery__item:nth-child(6n + 6) {
    margin-top: var(--space-2xl);
  }
}
