/*
 * SF.2 / BR.5 — Shop the Range: the BR.3B R3 landscape brand tile on the
 * homepage.
 *
 * Human authority: BR.3B BRAND SYSTEM HUMAN LOCK (2026-09-25,
 * ~/Documents/PouchPick-Labs/brand-experience-lab/br3-unified-brand-system/
 * BR3B-BRAND-SYSTEM-HUMAN-LOCK.md) — LOCK 3 (homepage discovery shelf),
 * LOCK 4 (≈2.05:1, bought at the minimum track), LOCK 5 (bleeding rail),
 * LOCK 8 (R3 lockup), LOCK 9 (packshot cue at 49–55% of card height), LOCK 10
 * + ruling C1 (SOFT, resting only), C2 (count-only foot, TT-1), C3 (up to
 * four slots — a DATA cap in inc/homepage.php, never a column count here),
 * C5 (registry mark model); the BR.4 amendment (§2.3) for the minimum tracks.
 * Visual authority: captures 45 (1440 shelf) and 40 (390 rail). Human ruling
 * D3 as amended by SF.2 Human Ruling 1 (2026-10-05): GRID at ≥1248px,
 * horizontal snapping RAIL below 1248px. 1248px is the first width at which
 * the four locked tiles fit one row with valid wordmark clearance; the 3 + 1
 * wrap a 1024px handover produced is not a design state.
 * Supersedes the BR.1.2J "Controlled Crop" card this file used to carry.
 *
 * ONE CARD FAMILY, TWO SURFACES (LOCK 1). This is the same R3 tile /brands/
 * renders (assets/css/brands-directory.css), at the homepage's density and
 * with the homepage's foot. Per-BRAND values — tone, field, logo_scale, cue
 * ratios — arrive inline from the shared resolver pp_brand_presentation()
 * under its own property names (--pp-bdx-tone / -field / -ls, --k-*); this
 * sheet owns per-SURFACE density only, so one media query can move the whole
 * family at once.
 *
 * The section chrome — head, "See all brands", the quick-link chips and the
 * section's external rhythm (`range_row` role, HOMEPAGE-VERTICAL-RHYTHM-
 * LOCK.md) — is unchanged and stays in home-page.css. CSS only: the rail is
 * native scroll, no script.
 */

.pp-range-shelf,
.pp-range-shelf *,
.pp-range-shelf *::before,
.pp-range-shelf *::after { box-sizing: border-box; } /* R3-D1 */

/* --------------------------------------------------------------------------
   SURFACE DENSITY — the homepage row of the density table (BR.3B §2.1–2.3).
   Declared once on the shelf so a single media query moves every card.

   THE MINIMUM TRACK IS 284, NOT THE LAB'S 268.
   Ruling C5 made the registry mark model production authority, under which
   VELO binds: its mark is 30 × 1.0 × 1.03 × 1.25 × 640/163 = 151.66px, and
   the identity column is track − 2 (borders) − pad − (canz + 8). BR.4
   re-derived the tracks that clear it (+6.34px at the minimum track) and the
   homepage shelf uses the same tile, padding, product zone and mark density
   at these widths, so the same derivation — and the same number — holds. (The
   lock's ≤1100 grid row, track 274, has no homepage state: below 1248px the
   shelf is the rail.)
   -------------------------------------------------------------------------- */
.pp-range-shelf {
	--pp-range-ar: 2.05;
	--pp-range-min: 284px;
	--pp-range-gap: 16px;
	--pp-range-pad: 20px;
	--pp-range-canz: 96px;          /* the zone the product owns on the right */
	--pp-range-radius: 18px;
	--pp-range-faceD: 66px;
	--pp-range-crop: -14px;
	--pp-range-mark-base: 30px;
	--pp-range-mark-k: 1.25;
	--pp-range-markband: 46px;

	/* GRID (≥1248, D3 as amended by SF.2 Ruling 1): auto-fill over the minimum
	   track — the column count is a consequence, never a decision (R3-F2; X15
	   rejects a fixed four-up). The grid starts exactly where four tracks fit,
	   so the four curated slots always share one row and a slot never wraps;
	   a valid three-brand state keeps its tiles on the same tracks. */
	display: grid;
	gap: var(--pp-range-gap);
	grid-template-columns: repeat(auto-fill, minmax(var(--pp-range-min), 1fr));
	margin-bottom: var(--pp-space-4); /* the existing head → shelf → quick-links rhythm */
}

.pp-range-shelf > * { min-width: 0; }

/* --------------------------------------------------------------------------
   THE CARD
   -------------------------------------------------------------------------- */
.pp-range-card {
	/* per-brand values arrive inline; these are the fallbacks for a card that
	   carries none (Navy-safe tone: only VERIFIED accents are ever emitted). */
	--pp-bdx-tone: var(--pp-navy);
	--pp-bdx-field: 1;
	--pp-bdx-ls: 1;

	position: relative;
	display: block;
	overflow: hidden;
	isolation: isolate;
	text-decoration: none;
	color: var(--pp-ink);
	border-radius: var(--pp-range-radius);
	aspect-ratio: var(--pp-range-ar);

	/* GROUND (LOCK 10) — R1-D2: `field` DIVIDES the tint, so the strongest
	   tone never collects the most of it; the glow is aimed at the corner the
	   product occupies, light falling on the can rather than a wash. */
	background:
		radial-gradient(132% 148% at 88% 116%,
			color-mix(in srgb, var(--pp-bdx-tone) calc(13% / var(--pp-bdx-field)), transparent),
			transparent 62%),
		linear-gradient(168deg, #FFFFFF 0%, #FBFCFE 56%, #F3F6FA 100%);

	/* EDGE: SOFT, RESTING ONLY (LOCK 10 + ruling C1) — "PRODUCT may move, CARD
	   remains stable": no hover shadow, no border shift, no lift, no press
	   scale. The lab's `.r3-e-soft:hover` rule is deliberately not ported. */
	--pp-range-elevation:
		0 1px 2px rgba(16, 32, 56, 0.045),
		0 10px 22px -14px rgba(16, 32, 56, 0.20);
	border: 1px solid #EFF3F8;
	box-shadow: var(--pp-range-elevation);
}

/* The design system's `a:focus-visible` box-shadow ring would REPLACE the
   resting elevation while focused — an interaction-driven change C1 rules
   out (the BR.4 trap). Focus is therefore an OUTLINE, painted outside the
   border box, with the elevation re-asserted. */
.pp-range-card:focus-visible {
	outline: 2px solid var(--pp-navy);
	outline-offset: 2px;
	box-shadow: var(--pp-range-elevation);
}

/* --------------------------------------------------------------------------
   THE IDENTITY COLUMN (LOCK 8) — laid out against the product's zone, not
   sharing a bottom edge with it, so the cue and the count are never on the
   same axis.
   -------------------------------------------------------------------------- */
.pp-range-id {
	position: absolute;
	z-index: 4;
	left: var(--pp-range-pad);
	right: calc(var(--pp-range-canz) + 8px);
	top: var(--pp-range-pad);
	bottom: var(--pp-range-pad);
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	justify-content: space-between;
	pointer-events: none;
}

/* R1-D3 — every mark centred on ONE optical line, never hung from a shared
   top edge. */
.pp-range-markband {
	display: flex;
	align-items: center;
	justify-content: flex-start;
	height: var(--pp-range-markband);
	flex: 0 0 auto;
}

/* C5 — base × logo_scale × 1.03 × surface density; no per-brand CSS. */
.pp-range-mark {
	display: block;
	width: auto;
	height: calc(var(--pp-range-mark-base) * var(--pp-bdx-ls, 1) * 1.03 * var(--pp-range-mark-k));
	object-fit: contain;
	object-position: left center;
}

/* THE FOOT — TT-1, count only (ruling C2): the wordmark carries the name, so
   the name is not repeated and the count sits alone, left, with no dot.
   Longhand declarations only (R1-D1). */
.pp-range-foot {
	display: flex;
	align-items: baseline;
	flex: 0 0 auto;
	max-width: 100%;
}

.pp-range-count {
	flex: 0 0 auto;
	font-family: var(--pp-font-body);
	font-size: 12.5px;
	font-weight: 500;
	line-height: 1.3;
	color: var(--pp-secondary-text);
	font-variant-numeric: tabular-nums;   /* R1-H1 */
	white-space: nowrap;
}

/* --------------------------------------------------------------------------
   THE PRODUCT LAYER (LOCK 9) — the one R3 geometry path, resolved in CSS from
   the brand's own measured cue ratios (pp_brand_cue_ratios()):
     visW = faceD × k-vis     boxW = faceD × k-box
   The BR.1.2J / BR.1.3A packshot contract is untouched — every brand delivers
   the same branded-face diameter and the frame takes the same bite out of
   every face; only the SURFACE's faceD and crop move. Anchor: MID.
   -------------------------------------------------------------------------- */
.pp-range-vp {
	position: absolute;
	inset: 0;
	overflow: hidden;
	border-radius: calc(var(--pp-range-radius) - 1px);
	pointer-events: none;
}

.pp-range-shot {
	--visW: calc(var(--pp-range-faceD) * var(--k-vis));
	--boxW: calc(var(--pp-range-faceD) * var(--k-box));
	position: absolute;
	display: block;
	width: var(--boxW);
	right: calc(-1 * (var(--pp-range-crop) + var(--boxW) * var(--k-r) + var(--visW) * var(--k-rim)));
	bottom: calc(50% - var(--visW) / 2 - var(--boxW) * var(--k-b));
}

.pp-range-shot img {
	display: block;
	width: 100%;
	height: auto;
}

/* The contact pool is sized against the VISIBLE product, not the image box. */
.pp-range-seat {
	position: absolute;
	z-index: -1;
	width: var(--visW);
	height: calc(var(--visW) * 0.155);
	left: calc(var(--boxW) * var(--k-l) + var(--visW) * 0.02);
	bottom: calc(var(--boxW) * var(--k-b) - var(--visW) * 0.0527);
	border-radius: 50%;
	background: radial-gradient(closest-side,
		rgba(11, 29, 56, 0.30) 0%, rgba(11, 29, 56, 0.16) 52%, transparent 100%);
}

/* Logo-led fallback: a brand whose approved feature packshot does not
   resolve renders the SAME card without a cue — never a placeholder, never an
   invented can. The identity column takes the whole width. */
.pp-range-card--logo-led { --pp-range-canz: 0px; }

/* --------------------------------------------------------------------------
   MOTION (ruling C1) — PRODUCT may move, CARD remains stable: the product
   rises and its contact pool counter-moves, the existing production
   convention. Nothing on the card itself.
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
	.pp-range-shot,
	.pp-range-seat { transition: transform 180ms var(--pp-ease-out); }

	.pp-range-card:hover .pp-range-shot,
	.pp-range-card:focus-visible .pp-range-shot { transform: translateY(-4px); }

	.pp-range-card:hover .pp-range-seat,
	.pp-range-card:focus-visible .pp-range-seat { transform: translateY(4px) scaleX(1.035); }
}

/* --------------------------------------------------------------------------
   THE BLEEDING RAIL (<1248 — LOCK 5, ruling D3 as amended by SF.2 Ruling 1:
   1247, 1024, 1023, 768, 390 and 360 are all rail states). Production's native rail
   mechanism (full-bleed scroll area on the gutter grid; the RAIL, never the
   document, owns horizontal overflow) carrying the locked R3 rail tile:
   250px at 1.86:1, the rail density row. R1-D5: `scroll-padding-inline`
   insets the snapport, so mandatory snapping never scrolls the first card
   flush to the screen edge under an indented heading. Block padding gives the
   focus outline and the resting elevation room inside the scroll clip; the
   compensating negative margins keep the section's external rhythm exactly
   the grid's. Where the viewport is wider than the four rail tiles need, the
   rail simply has nothing to scroll; its tiles keep the locked rail size
   (never stretched toward the grid).
   -------------------------------------------------------------------------- */
@media (max-width: 1247px) {
	.pp-range-shelf {
		--pp-range-ar: 1.86;
		--pp-range-gap: 10px;
		--pp-range-pad: 16px;
		--pp-range-canz: 66px;
		--pp-range-faceD: 50px;
		--pp-range-crop: -12px;
		--pp-range-mark-k: 1.15;
		--pp-range-markband: 42px;

		display: flex;
		overflow-x: auto;
		overscroll-behavior-x: contain;
		scroll-snap-type: x mandatory;
		scroll-padding-inline: var(--pp-gutter);
		-webkit-overflow-scrolling: touch;
		scrollbar-width: none;
		margin-inline: calc(var(--pp-gutter) * -1);
		padding-inline: var(--pp-gutter);
		padding-block: 4px 12px;
		margin-block: -4px calc(var(--pp-space-4) - 12px);
	}
	.pp-range-shelf::-webkit-scrollbar { display: none; }
	.pp-range-shelf > * {
		flex: 0 0 auto;
		width: 250px;
		scroll-snap-align: start;
	}
	.pp-range-count { font-size: 12px; }
}

/* The homepage's true-mobile container gutter (home-page.css, lock §17). */
@media (max-width: 767px) {
	.pp-range-shelf {
		scroll-padding-inline: var(--pp-gutter-mobile);
		margin-inline: calc(var(--pp-gutter-mobile) * -1);
		padding-inline: var(--pp-gutter-mobile);
	}
}
