/*
 * Results grid.
 *
 * Two columns on a phone, three from 640px, four beside the filter column from
 * 1024px. The page asks for 24 products, which fills whole rows at all three
 * counts.
 *
 * The track, not the card, decides how wide a card is — see product-card.css.
 * minmax(0, 1fr) rather than 1fr so a long product name cannot widen its track.
 */

.product-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--shop-space-4) var(--shop-gap-tight);
    margin: 0;
    padding: 0;
    list-style: none;
}

/* The grid stretches the <li>, but a block child of one does not inherit that
   height — so without this the card stops at its content and the availability
   badge has no slack to push the price down with, which is what aligns prices
   across a row. */
.product-grid > li {
    display: grid;
}

/* An old /webshop/accessoires#<id> link lands here without JavaScript: the card
   is framed in the accent (a frame, not an outline, so it doesn't read as focus). */
.product-grid > li:target {
    scroll-margin-block-start: var(--shop-space-4);
}

.product-grid > li:target > .product-card {
    border-color: var(--shop-accent);
    box-shadow: 0 0 0 1px var(--shop-accent), var(--shop-shadow-card);
}

/* Forced colours drop the shadow and repaint the border, which would leave the
   arrival card like every other: an inset outline in the system highlight,
   still clear of the focus ring outside the card. */
@media (forced-colors: active) {
    .product-grid > li:target > .product-card {
        outline: 2px solid Highlight;
        outline-offset: -3px;
    }
}

@media (min-width: 640px) {
    .product-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: var(--shop-space-5) var(--shop-space-4);
    }
}

@media (min-width: 1024px) {
    .product-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    /* Across the full container rather than beside a filter column: as many
       columns as fit at the catalogue's card width (five in the 1000px
       container), so cards, and the stock line on them, read as they do on
       the homepage; a short list keeps that width instead of stretching. */
    .product-grid--fill {
        grid-template-columns: repeat(auto-fill, minmax(176px, 1fr));
    }
}
