/* Afiltro Shop Grid — Brand Category v1.9
   Scope: body.afiltro-brand-grid (product_cat = filters-by-hood-brand and descendants)
   Desktop/Tablet: 3 columns (=> 4 rows when per-page=12)
   Mobile: 2 columns
   Neutralize theme float/nth-child layout quirks.
*/
body.afiltro-brand-grid ul.products {
  box-sizing: border-box;
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 20px;
  padding: 0;
  margin: 0;
}
@media (max-width: 767.98px) {
  body.afiltro-brand-grid ul.products {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 12px;
  }
}

/* Make product cards equal height so last row is even */
body.afiltro-brand-grid ul.products li.product {
  display: flex;
  flex-direction: column;
  height: 100%;
}
body.afiltro-brand-grid ul.products li.product .woocommerce-LoopProduct-link {
  display: flex;
  flex-direction: column;
  height: 100%;
}
body.afiltro-brand-grid ul.products li.product .button { margin-top: auto; }

/* Neutralize theme's nth-child clearing and fixed widths */
body.afiltro-brand-grid ul.products li.product:nth-child(n) { clear: none !important; }
body.afiltro-brand-grid .columns-4 ul.products li.product { width: auto !important; }


/* Fix legacy float/margins from theme so CSS Grid controls gaps */
body.afiltro-brand-grid ul.products::before,
body.afiltro-brand-grid ul.products::after { display: none !important; }

body.afiltro-brand-grid ul.products li.product {
  float: none !important;
  margin: 0 !important;
  width: auto !important;
  align-self: stretch;
}

body.afiltro-brand-grid ul.products {
  align-items: stretch;
  justify-items: stretch;
  grid-auto-rows: auto;
}

/* Make card fill available height but avoid forcing extra blank space */
body.afiltro-brand-grid ul.products li.product {
  display: flex;
  flex-direction: column;
}
body.afiltro-brand-grid ul.products li.product .woocommerce-LoopProduct-link {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
}
body.afiltro-brand-grid ul.products li.product .button {
  margin-top: auto;
}
