/* CP419: compact, readable catalogue cards with one product per mobile row. */
html body.pg-visual-system .pg-category-items .product-grid.pg-catalogue-view-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 245px), 1fr)) !important;
  align-items: stretch;
  gap: 16px;
}

html body.pg-visual-system .pg-category-items .pg-catalogue-view-grid .pg-catalogue-card {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) !important;
  grid-template-rows: auto auto 1fr;
  align-content: start;
  align-items: start;
  gap: 12px;
  width: auto;
  min-width: 0;
  min-height: 0 !important;
  height: auto !important;
  padding: 14px !important;
}

/* Keep JS-filtered and paginated cards genuinely hidden despite the layout override. */
html body.pg-visual-system .pg-category-items .product-grid.pg-catalogue-view-grid .pg-catalogue-card[hidden] {
  display: none !important;
}

html body.pg-visual-system .pg-category-items .pg-catalogue-view-grid .pg-catalogue-card > .pg-catalogue-card-image {
  grid-column: 1;
  grid-row: 1;
  display: grid;
  place-items: center;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  border-radius: 12px;
}

html body.pg-visual-system .pg-category-items .pg-catalogue-card-image picture {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
}

html body.pg-visual-system .pg-category-items .pg-catalogue-card-image img {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  object-fit: contain;
}

html body.pg-visual-system .pg-category-items .pg-catalogue-card-copy {
  grid-column: 1;
  grid-row: 2;
  display: grid;
  align-content: start;
  gap: 6px;
  min-width: 0;
}

html body.pg-visual-system .pg-category-items .pg-catalogue-card-copy h3,
html body.pg-visual-system .pg-category-items .pg-catalogue-card-copy h3 a {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-height: 1.28;
  overflow-wrap: anywhere;
}

html body.pg-visual-system .pg-category-items .pg-catalogue-card-copy :is(.pg-catalogue-compatible, .pg-catalogue-sku, .pg-catalogue-description) {
  min-width: 0;
  margin-block: 0;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

html body.pg-visual-system .pg-category-items .pg-catalogue-card-copy .pg-catalogue-description {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

html body.pg-visual-system .pg-category-items .pg-card-actions {
  grid-column: 1;
  grid-row: 3;
  align-self: end;
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 10px;
  width: 100%;
  min-width: 0;
  margin: 0;
  padding-top: 10px;
}

html body.pg-visual-system .pg-category-items .pg-card-actions > :is(a, button) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  margin: 0;
  padding: 8px 10px;
  box-sizing: border-box;
  font-size: .9rem;
  line-height: 1.2;
  text-align: center;
  white-space: normal;
  overflow-wrap: anywhere;
}

html body.pg-visual-system .pg-category-items .pg-catalogue-view-grid .pg-catalogue-no-image {
  grid-template-columns: minmax(0, 1fr) !important;
}

@media (max-width: 900px) {
  html body.pg-visual-system .pg-category-items .product-grid.pg-catalogue-view-grid {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 12px;
  }

  html body.pg-visual-system .pg-category-items .pg-catalogue-view-grid .pg-catalogue-card {
    grid-template-columns: clamp(96px, 34vw, 148px) minmax(0, 1fr) !important;
    grid-template-rows: auto auto;
    align-items: start;
    gap: 10px 12px;
    padding: 12px !important;
  }

  html body.pg-visual-system .pg-category-items .pg-catalogue-view-grid .pg-catalogue-card > .pg-catalogue-card-image {
    grid-column: 1;
    grid-row: 1;
    width: 100%;
    aspect-ratio: 1;
  }

  html body.pg-visual-system .pg-category-items .pg-catalogue-view-grid .pg-catalogue-card-copy {
    grid-column: 2;
    grid-row: 1;
    gap: 5px;
  }

  html body.pg-visual-system .pg-category-items .pg-catalogue-card-copy h3,
  html body.pg-visual-system .pg-category-items .pg-catalogue-card-copy h3 a {
    -webkit-line-clamp: 3;
    font-size: clamp(.9rem, 2.8vw, 1.05rem);
  }

  html body.pg-visual-system .pg-category-items .pg-catalogue-card-copy .pg-catalogue-compatible,
  html body.pg-visual-system .pg-category-items .pg-catalogue-card-copy .pg-catalogue-sku {
    font-size: .78rem;
  }

  html body.pg-visual-system .pg-category-items .pg-catalogue-card-copy .pg-catalogue-sku {
    display: flex;
    align-items: baseline;
    gap: 5px;
    white-space: nowrap;
    overflow: hidden;
  }

  html body.pg-visual-system .pg-category-items .pg-catalogue-card-copy .pg-catalogue-sku code {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  html body.pg-visual-system .pg-category-items .pg-catalogue-card-copy .pg-catalogue-description {
    -webkit-line-clamp: 2;
    font-size: .8rem;
  }

  html body.pg-visual-system .pg-category-items .pg-card-actions {
    grid-column: 1 / -1;
    grid-row: 2;
    gap: 8px;
    padding-top: 8px;
  }

  html body.pg-visual-system .pg-category-items .pg-card-actions > :is(a, button) {
    min-height: 42px;
    padding: 7px 8px;
    font-size: clamp(.76rem, 2.7vw, .88rem);
  }

  html body.pg-visual-system .pg-category-items .pg-catalogue-view-grid .pg-catalogue-no-image {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  html body.pg-visual-system .pg-category-items .pg-catalogue-no-image .pg-catalogue-card-copy {
    grid-column: 1;
  }
}

@media (max-width: 359px) {
  html body.pg-visual-system .pg-category-items .pg-catalogue-view-grid .pg-catalogue-card {
    grid-template-columns: 92px minmax(0, 1fr) !important;
    gap: 8px 10px;
    padding: 10px !important;
  }
  html body.pg-visual-system .pg-category-items .pg-card-actions { gap: 7px; }
  html body.pg-visual-system .pg-category-items .pg-card-actions > :is(a, button) { padding-inline: 5px; font-size: .75rem; }
}
