/**
 * core/post-template rules, each scoped to the unit that owns it.
 *
 * This file is shared by construction, like every other file in this directory: any unit that
 * places a query loop lands here. Nothing in it may be written unscoped -- a rule with no unit
 * hook class repaints every post template on the site, which is a theme decision and belongs to
 * wp-theme-scaffold.
 */

/*
 * `products-listing` -- THE 2-UP BAND, WHICH `columnCount` CANNOT EXPRESS AND CORE DOES NOT COVER.
 *
 * The contract asserts `layout: {type: grid, columnCount: 3}` on core/post-template and records
 * the consequence as a limitation: "`columnCount: 3` fixes the widest step only, the same
 * limitation recorded on `units/news-listing.yml` and `units/related-products.yml`." The
 * attribute is written exactly as asserted in templates/archive-product.html and is NOT changed
 * here; this rule is a second mechanism over the top of it, scoped to this unit.
 *
 * WHAT THE SOURCE DOES, from the contract's own reading of the stored markup: every one of the 24
 * card columns carries `columns small-12 medium-6 large-4` -- Foundation 6's 3-up at large
 * (>= 1024px), 2-up at medium (640-1023px), 1-up below 640px.
 *
 * WHAT THE BUILD DID BEFORE THIS RULE, measured on this install with seven throwaway products at
 * five viewports (`probe.js --select='.wm-products-listing__grid > li' --all`):
 *
 *   1440   3-up, 390x500 @x=135   correct -- and 1170/3 = 390 is the same column
 *                                 `units/related-products.yml` measures for the same card
 *   1024   3-up, 315x500          correct
 *    768   3-up, 229x500          WRONG -- the source is 2-up here
 *    640   3-up, 187x500          WRONG -- the source is 2-up here
 *    390   1-up, 310x500          correct, and core did this by itself
 *
 * SO THE RECORDED LIMITATION IS REAL BUT NARROWER THAN IT WAS WRITTEN, and that is worth saying
 * because it changes what the fix costs. `columnCount: 3` is right at both ends: core's grid
 * layout collapses to a single column somewhere between 391 and 640 on its own, which is what
 * Foundation's `small-12` asks for anyway. The band that is actually wrong is 600-1023, and one
 * media query closes it. The 639.98 rule below is belt-and-braces over core's own collapse --
 * without it the 600-639 sliver stays 3-up, since 640 measured 3-up above.
 *
 * THE SAME BAND IS OPEN ON `news-listing` AND `related-products`, whose contracts record the same
 * limitation in the same words. It is NOT closed from here: three units sharing one limitation
 * want one decision, taken once, rather than three units drifting apart because whichever one was
 * built last happened to measure it. Named in the build hand-back.
 */
@media (max-width: 1023.98px) {
	.wm-products-listing__grid.is-layout-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (max-width: 639.98px) {
	.wm-products-listing__grid.is-layout-grid {
		grid-template-columns: minmax(0, 1fr);
	}
}

/*
 * `related-products` -- THE 15px GUTTER INSIDE EACH COLUMN, WHICH IS THE CONSUMER'S TO DRAW.
 *
 * The contract measures three things that only fit together this way: the post-template row is
 * three columns "at 390px each, butting with no gap" (1170/3), the card in this band is
 * `article.view-mode__teaser_card.products` at 360x500 AT x=150 while the row starts at x=135,
 * and the card's own `div.top-content` is 300x220. 390 - 360 = 30, split either side of a card
 * that starts 15px into its column; and 360 - 300 = 60, which is the card's own
 * `var:preset|spacing|40` padding (30px) on both sides and is already written as a block
 * attribute in patterns/product-teaser-card.php.
 *
 * IT IS NOT THE CARD'S TO WRITE, and that pattern says so itself: "THE ROOT'S WIDTH ... No
 * attribute on this card produces any of them -- they are the widths a three-up, two-up and
 * one-up consumer row gives it. This pattern writes no width at all, which is why it can sit in
 * that row." So the gutter is written by the unit that places the row, scoped to that unit's own
 * grid.
 *
 * NOT `blockGap`, WHICH THE CONTRACT PINS AT "0" AND WHICH WOULD MEASURE DIFFERENTLY. A 30px
 * grid gap would take the columns to 370 each and leave the outer two cards flush with the row's
 * own edges at x=135 and x=1305; the source has 390px columns with the card inset on BOTH sides,
 * including the outer ones. Padding on the grid item reproduces that; a gap cannot.
 */
.wm-related-products__grid > li {
	/* Was 15px (the card's own measured half-gutter, distinct from the shared root-padding
	   token -- see the note above). Snapped to spacing|25 (16px), 2026-09-25
	   (spacing-standard.md §1 item 3). */
	padding-inline: var( --wp--preset--spacing--25 );
}

/*
 * ROW GAP, 2026-09-21: the source's product rows are 530px apart (500px cards, 30px between -- measured, 1440),
 * and this grid's row gap was 0, so rows abutted. The 30px is also what gives a hovered card's scale (1.05 ->
 * 12.5px of vertical growth) room to stay out of the row above and below.
 */
.wm-related-products__grid.is-layout-grid {
	row-gap: var( --wp--preset--spacing--40 );
}

/*
 * COLUMN STEPS, 2026-09-21: MEASURED on the live source, /products/alumina-zirconia -- 3-up at 1440 and 1124
 * (337px cards), 2-up at 1024 and 768, 1-up at 390 (370px). This grid had no steps, so at 768 its cards were 206px
 * wide and their (now fixed 500px) tile clipped the wrapped copy. The edges are the theme's own viewport tokens.
 */
@media (max-width: 1123.98px) {
	.wm-related-products__grid.is-layout-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (max-width: 639.98px) {
	.wm-related-products__grid.is-layout-grid {
		grid-template-columns: minmax(0, 1fr);
	}
}

/*
 * `tall-image-nav-row` -- REMOVED 2026-09-26, ai/card-grids-plan.md Option B (plan §2: "Every
 * row, cell, width, gutter and centring rule is deleted"). The row is no longer a
 * `core/post-template` over a placed `core/pattern washington-mills/navigation-card` --
 * blocks/tall-image-nav-row/render.php now builds a flex `core/group` (wrap, centred,
 * `blockGap`) with each card a `core/cover` carrying its own `flexSize`/`selfStretch` style
 * attributes, verified by test on this install (that file's own plan §2 test) to produce the
 * three responsive steps this rule used to hand-write. What replaced this rule and the hover
 * zoom it no longer needs (the row places no `.wm-navigation-card` any more) is
 * assets/css/blocks/cover.css, scoped to `.wm-tall-image-nav-row`.
 *
 * `.wm-navigation-card .wp-block-post-title a:hover`, immediately below this comment before the
 * rewrite, is NOT removed: it is the `navigation-card` pattern's own hover-colour fix, unrelated
 * to how the pattern gets PLACED, and the pattern is left registered and unused
 * (ai/inventory.yml, this unit's approval: "navigation-card is left as it is; retiring it is not
 * part of this work").
 */
.wm-navigation-card .wp-block-post-title a:hover {
	color: inherit;
	text-decoration: none;
}
