/* =================== hc-pgrid.css =================== */
/* hc-pgrid - product grid container. Wraps .pcard children. Used on catalog,
 * search results, favorites, related-product rails, etc. Adapts column count
 * to viewport with sensible breakpoints. Strictly .hc-pgrid / .hc-pgrid__*. */

.hc-pgrid {
  display: grid;
  grid-auto-rows: 1fr;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(14px, 1.4vw, 22px);
  /* Uniform row heights — cards stretch to the row baseline. The hoverband
     is an absolute float, so only the hovered card visibly extends below
     the row (siblings stay at row height). */
  align-items: stretch;
}

/* Column count = divisors of PAGE_SIZE (24): 2 / 3 / 4 — never 5 or 7,
   so the last grid row is always full (24 % 5 = 4 left an empty cell). */
@media (min-width: 600px) { .hc-pgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 992px) { .hc-pgrid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* List view toggle. Single column → rows must be content-height; the base
   `grid-auto-rows: 1fr` otherwise stretches each row to an equal slice of the
   (tall) results column, blowing every card up into a huge empty panel. */
.hc-pgrid[data-view="list"] {
  grid-template-columns: 1fr;
  grid-auto-rows: auto;
  align-content: start;
}
.hc-pgrid[data-view="compact"] {
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: var(--hc-sp-2);
}

/* List view — every catalog card is forced to variant 'a' (editorial: a media
   row + 1fr body row, 468px min-height). Flip it to a horizontal media|body row.
   We MUST reset grid-template-rows AND min-height too: overriding only the
   columns leaves the editorial `auto 1fr` rows + 468px min in place, so the card
   grows a tall empty second row under the content. (The previous rules here
   targeted .pcard-shell / .pcard-stage, which variant 'a' does not emit, so the
   override never landed and the empty panel showed.) */
#cat-results .hc-pgrid[data-view="list"] {
  grid-template-columns: 1fr;
}

#cat-results .hc-pgrid[data-view="list"] .pcard[data-pcard-variant="a"] {
  grid-template-columns: minmax(150px, 230px) minmax(0, 1fr);
  grid-template-rows: auto;
  min-height: 0;
}

/* Divider moves from under the image (vertical card) to its right edge. */
#cat-results .hc-pgrid[data-view="list"] .pcard[data-pcard-variant="a"] .pcard-a__media-wrap {
  border-bottom: 0;
  border-right: 1px solid rgba(141, 109, 71, 0.12);
}

/* Image fills the row height (dictated by the taller body column) instead of a
   fixed 16:10 ratio, so there is no gradient gap below a short image. */
#cat-results .hc-pgrid[data-view="list"] .pcard[data-pcard-variant="a"] .pcard-a__media {
  aspect-ratio: auto;
  height: 100%;
  min-height: 132px;
}

/* Body: vertically centre content; CTA reads as a button, not a full-width bar. */
#cat-results .hc-pgrid[data-view="list"] .pcard[data-pcard-variant="a"] .pcard-a__body {
  justify-content: center;
  gap: 5px;
  padding: 14px 20px;
}

/* List row stays compact: drop the long editorial caption (and its reserved
   3-line min-height) — the spec chips below carry the key info. */
#cat-results .hc-pgrid[data-view="list"] .pcard[data-pcard-variant="a"] .pcard-a__caption {
  display: none;
}

/* Grid view pins the footer to the bottom; in the centred list row that would
   fight justify-content, so let the footer sit in normal flow. */
#cat-results .hc-pgrid[data-view="list"] .pcard[data-pcard-variant="a"] .pcard-a__foot {
  margin-top: 0;
}

#cat-results .hc-pgrid[data-view="list"] .pcard[data-pcard-variant="a"] .pcard-a__cta {
  margin-top: 12px;
  width: auto;
  min-width: 220px;
  max-width: 320px;
}

/* Compact view — hide only the long caption; KEEP the spec chips
   (.pcard-a__props) so the dense 6-up grid still shows decor / size / series. */
#cat-results .hc-pgrid[data-view="compact"] .pcard-a__caption {
  display: none;
}

#cat-results .hc-pgrid[data-view="compact"] .pcard-a__body {
  padding: 10px 12px 12px;
}

/* Inline marketing banner inside the grid spans the full row */
.hc-pgrid__banner {
  grid-column: 1 / -1;
  max-height: 260px;
  overflow: hidden;
  border-radius: 14px;
}

/* Inside PDP cross-sell rails, gaps are tighter */
.pdp-commerce-sections .hc-pgrid,
.hc-pdp .hc-pgrid {
  gap: clamp(12px, 1.2vw, 18px);
}

.hc-pgrid > .pcard {
  min-width: 0;
}

/* List view: lift the editorial a card price + cart into a right rail at the
   card edge (content stays left, footer centred vertically). Wide screens only;
   compact/mobile keep the stacked footer. Matches the existing list-a selector
   specificity so this grid override wins over the flex body above. */
@media (min-width: 760px) {
  #cat-results .hc-pgrid[data-view="list"] .pcard[data-pcard-variant="a"] .pcard-a__body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(190px, 228px);
    column-gap: 24px;
    row-gap: 5px;
    align-content: center;
  }
  #cat-results .hc-pgrid[data-view="list"] .pcard[data-pcard-variant="a"] .pcard-a__body > * { grid-column: 1; min-width: 0; }
  #cat-results .hc-pgrid[data-view="list"] .pcard[data-pcard-variant="a"] .pcard-a__foot {
    grid-column: 2;
    grid-row: 1 / -1;
    align-self: center;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    gap: 10px;
    padding-left: 24px;
    border-left: 1px solid rgba(141, 109, 71, 0.14);
  }
}
