/* PCOM category listings: 3/4/6/8 columns, with the native mobile layout. */
@media (min-width: 768px) {
  /* Leave every populated sidebar to the theme and to its filter modules. */
  body#category #wrapper > .columns-container:has(> .row > #center-column):not(:has(> .row > #left-column > *, > .row > #right-column)) {
    --pcom-category-grid-columns: 3;
    /* Reserve the right gutter for the fixed support controls. */
    --pcom-category-grid-start: max(3%, calc((100% - 3100px) / 2 - 24px));
    width: min(3100px, calc(100% - var(--pcom-category-grid-start) - 194px)) !important;
    max-width: none;
    margin-inline: var(--pcom-category-grid-start) 0 !important;
  }

  body#category #wrapper > .columns-container > .row:has(> #center-column):not(:has(> #left-column > *, > #right-column)) > #left-column {
    /* Whitespace contributes zero width; any bare text can still render. */
    flex: 0 0 auto;
    width: auto;
    min-width: 0;
    max-width: min(25vw, 280px);
    padding-inline: 0;
  }

  body#category #wrapper > .columns-container > .row:has(> #center-column):not(:has(> #left-column > *, > #right-column)) > #center-column {
    flex: 1 1 0%;
    width: auto;
    max-width: 100%;
  }

  body#category #wrapper > .columns-container > .row:not(:has(> #left-column > *, > #right-column)) > #center-column #js-product-list > .products {
    grid-template-columns: repeat(var(--pcom-category-grid-columns), minmax(0, 1fr)) !important;
    gap: clamp(12px, 0.54vw, 20px) !important;
  }

  body#category #wrapper > .columns-container > .row:not(:has(> #left-column > *, > #right-column)) > #center-column #js-product-list > .products > .product-miniature .product-miniature__image {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    object-fit: contain;
  }

  /* Keep the full discount text visible alongside the wishlist button. */
  body#category #wrapper > .columns-container > .row:not(:has(> #left-column > *, > #right-column)) > #center-column #js-product-list > .products > .product-miniature .product-flags {
    padding-inline-end: clamp(54px, 3.5vw, 64px);
  }

  body#category #wrapper > .columns-container > .row:not(:has(> #left-column > *, > #right-column)) > #center-column #js-product-list > .products > .product-miniature .product-flags .pcomsf-discount-badge {
    min-width: 0;
    padding-inline: clamp(6px, 0.47vw, 9px) !important;
    font-size: clamp(10px, 0.7vw, 12px) !important;
    white-space: normal;
    overflow-wrap: anywhere;
  }
}

@media (min-width: 1100px) {
  body#category #wrapper > .columns-container:has(> .row > #center-column):not(:has(> .row > #left-column > *, > .row > #right-column)) {
    --pcom-category-grid-columns: 4;
  }
}

@media (min-width: 1440px) {
  body#category #wrapper > .columns-container:has(> .row > #center-column):not(:has(> .row > #left-column > *, > .row > #right-column)) {
    --pcom-category-grid-columns: 6;
  }
}

@media (min-width: 3000px) {
  body#category #wrapper > .columns-container:has(> .row > #center-column):not(:has(> .row > #left-column > *, > .row > #right-column)) {
    --pcom-category-grid-columns: 8;
  }
}
