/**
 * Cool Bear — Sibling-cohort card grid.
 *
 * Used at the bottom of every coilover/brake/wheel/part PDP and inside the
 * cb_family type-selector landing. Renders sister products for the same
 * fitment as cards (image, type pill, price-from, CTA).
 *
 * Markup is server-rendered by either:
 *   (a) plan 08-03 importer writing into post_content / post meta, OR
 *   (b) plan 08-06 configurator JS hydrating into the .cb-cohort__list slot.
 * This file styles whichever layer fills the slot.
 */

.cb-cohort {
	margin-top: var(--wp--preset--spacing--60);
	padding-top: var(--wp--preset--spacing--50);
	border-top: 1px solid var(--wp--preset--color--border);
}

.cb-cohort__heading {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: var(--wp--preset--spacing--30);
	margin: 0 0 var(--wp--preset--spacing--40);
}

.cb-cohort__title {
	font-family: var(--wp--preset--font-family--sans);
	font-size: var(--wp--preset--font-size--xl);
	font-weight: 600;
	letter-spacing: -0.015em;
	margin: 0;
	color: var(--wp--preset--color--text);
}

.cb-cohort__sub {
	font-size: var(--wp--preset--font-size--small);
	color: var(--wp--preset--color--text-muted);
	margin: 0;
}

.cb-cohort__list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	grid-template-columns: 1fr;
	gap: var(--wp--preset--spacing--30);
}

@media (min-width: 480px) { .cb-cohort__list { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 768px) { .cb-cohort__list { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1280px){ .cb-cohort__list { grid-template-columns: repeat(4, 1fr); } }

.cb-cohort__card {
	display: flex;
	flex-direction: column;
	background-color: var(--wp--preset--color--surface);
	border: 1px solid var(--wp--preset--color--border);
	border-radius: 8px;
	overflow: hidden;
	text-decoration: none;
	color: var(--wp--preset--color--text);
	transition: border-color 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}

.cb-cohort__card:hover,
.cb-cohort__card:focus-visible {
	border-color: var(--wp--preset--color--text-muted);
	transform: translateY(-2px);
	box-shadow: var(--wp--preset--shadow--raised);
	color: var(--wp--preset--color--text);
}

.cb-cohort__card[aria-current="true"] {
	border-color: var(--wp--preset--color--accent);
	box-shadow: 0 0 0 1px var(--wp--preset--color--accent);
}

/* The full-card anchor emitted by render_cohort() (x2e item 4). Without its own
   rules it inherited the default underlined link style; make it a clean column
   that fills the card, with a hover/focus accent on the product name only. */
.cb-cohort__card-link {
	display: flex;
	flex-direction: column;
	height: 100%;
	text-decoration: none;
	color: inherit;
}

.cb-cohort__card-link:hover,
.cb-cohort__card-link:focus-visible {
	text-decoration: none;
	color: inherit;
}

.cb-cohort__card-link:hover .cb-cohort__name,
.cb-cohort__card-link:focus-visible .cb-cohort__name {
	color: var(--wp--preset--color--accent);
}

.cb-cohort__image {
	width: 100%;
	/* Square well with contain (x2e item 4): XYZ renders are pre-squared product
	   shots — 4:3 cover cropped their tops/bottoms. Contain on a 1:1 surface well
	   shows the whole render uncropped. */
	aspect-ratio: 1 / 1;
	background-color: var(--wp--preset--color--surface-sunken);
	overflow: hidden;
}

.cb-cohort__image img {
	width: 100%;
	height: 100%;
	object-fit: contain;
	display: block;
}

.cb-cohort__body {
	padding: var(--wp--preset--spacing--30);
	display: flex;
	flex-direction: column;
	gap: var(--wp--preset--spacing--20);
	flex: 1;
}

.cb-cohort__pill {
	align-self: flex-start;
	padding: 2px 8px;
	background-color: var(--wp--preset--color--surface-raised);
	border-radius: 999px;
	font-family: var(--wp--preset--font-family--mono);
	font-size: 10px;
	color: var(--wp--preset--color--text-muted);
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

.cb-cohort__pill--race {
	color: var(--wp--preset--color--destructive);
	border: 1px solid color-mix(in srgb, var(--wp--preset--color--destructive) 40%, transparent);
}

.cb-cohort__name {
	font-weight: 600;
	font-size: var(--wp--preset--font-size--medium);
	color: var(--wp--preset--color--text);
	margin: 0;
	line-height: 1.2;
}

.cb-cohort__tagline {
	font-size: var(--wp--preset--font-size--small);
	color: var(--wp--preset--color--text-muted);
	margin: 0;
	line-height: 1.4;
	flex: 1;
}

.cb-cohort__price {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	align-items: baseline;
	gap: 2px 8px;
	margin-top: auto; /* pin the price row to the card bottom when the link is a column */
	padding-top: var(--wp--preset--spacing--20);
	border-top: 1px solid var(--wp--preset--color--border);
}

/* WC sometimes injects a <br> inside the price HTML (e.g. range/“From” prices);
   it pushes the amount onto its own line and throws the row "out of whack".
   Suppress it — the amount + VAT caption read on one line (x2e item 4). */
.cb-cohort__price br {
	display: none;
}

.cb-cohort__price-amount {
	font-family: var(--wp--preset--font-family--mono);
	font-size: var(--wp--preset--font-size--small);
	color: var(--wp--preset--color--text);
	font-weight: 600;
}

/* Inline price markup straight from WC get_price_html() — keep the currency,
   amount and any "From …" range on one baseline; never block-stack. */
.cb-cohort__price-amount .woocommerce-Price-amount {
	white-space: nowrap;
}

.cb-cohort__price-prefix {
	font-family: var(--wp--preset--font-family--mono);
	font-size: 10px;
	color: var(--wp--preset--color--text-muted);
	text-transform: uppercase;
	letter-spacing: 0.06em;
	margin-right: 4px;
}

/* Inc./Ex. VAT caption beside the amount. */
.cb-cohort__vat {
	font-family: var(--wp--preset--font-family--mono);
	font-size: 10px;
	color: var(--wp--preset--color--text-muted);
	letter-spacing: 0.04em;
}

.cb-cohort__cta {
	margin-left: auto; /* push "View →" to the right edge regardless of price width */
	font-size: var(--wp--preset--font-size--x-small);
	color: var(--wp--preset--color--accent);
	letter-spacing: 0.04em;
}

/* Empty-state when no siblings yet */
.cb-cohort__empty {
	padding: var(--wp--preset--spacing--40);
	background-color: var(--wp--preset--color--surface);
	border: 1px dashed var(--wp--preset--color--border);
	border-radius: 6px;
	color: var(--wp--preset--color--text-muted);
	text-align: center;
	font-size: var(--wp--preset--font-size--small);
}

/* ────────────────────────────────────────────────────────────────────────
   Plan 08-10 Task 4 — same-fitment cross-sell variant.

   Sits BENEATH the existing sibling-cohort grid on every PDP. Server-
   rendered by cool-bear/cross-fitment block (renders nothing when no
   matching products exist — the `.cb-cohort--cross` selectors below only
   fire when there's at least one card to display).

   Layout:
   - Desktop (≥1024px): 4-column grid (matches the sibling cohort).
   - Mobile (<768px): horizontal-scrolling row with snap so users can
     swipe through cross-sell cards without having to scroll the whole
     page. Edge-to-edge fade hint via the gradient overlay.
   ──────────────────────────────────────────────────────────────────── */

.cb-cohort--cross {
	margin-top: var(--wp--preset--spacing--50);
	padding-top: var(--wp--preset--spacing--40);
}

.cb-cohort__list--cross {
	/* Inherit the responsive grid from .cb-cohort__list above. */
}

@media (min-width: 1024px) {
	.cb-cohort--cross .cb-cohort__list,
	.cb-cohort__list--cross {
		grid-template-columns: repeat(4, 1fr);
	}
}

/* Mobile horizontal-scroll row. Falls back to the grid layout when
   prefers-reduced-motion is set (snap can feel disorientating). */
@media (max-width: 767px) {
	.cb-cohort__list--cross {
		display: flex;
		flex-wrap: nowrap;
		overflow-x: auto;
		scroll-snap-type: x mandatory;
		scroll-padding-inline: var(--wp--preset--spacing--30);
		gap: var(--wp--preset--spacing--30);
		padding-bottom: var(--wp--preset--spacing--20);
		-webkit-overflow-scrolling: touch;
	}

	.cb-cohort__list--cross > .cb-cohort__card {
		flex: 0 0 78%;
		max-width: 320px;
		scroll-snap-align: start;
	}
}

@media (max-width: 767px) and (prefers-reduced-motion: reduce) {
	.cb-cohort__list--cross {
		display: grid;
		flex-wrap: wrap;
		grid-template-columns: 1fr;
		overflow-x: visible;
		scroll-snap-type: none;
	}

	.cb-cohort__list--cross > .cb-cohort__card {
		flex: 1 1 auto;
		max-width: none;
	}
}

/* Cross-sell card variant — same shape as sibling cards, with a slightly
   muted top border so the section reads as "secondary" content. The
   anchor wrapper makes the entire card clickable. */
.cb-cohort__card--cross {
	background-color: var(--wp--preset--color--surface);
}

.cb-cohort__card--cross .cb-cohort__card-link {
	display: flex;
	flex-direction: column;
	flex: 1 1 auto;
	color: inherit;
	text-decoration: none;
	height: 100%;
}

.cb-cohort__card--cross .cb-cohort__card-link:hover .cb-cohort__name,
.cb-cohort__card--cross .cb-cohort__card-link:focus-visible .cb-cohort__name {
	color: var(--wp--preset--color--accent);
}

.cb-cohort__card--cross:focus-within {
	border-color: var(--wp--preset--color--accent);
	box-shadow: 0 0 0 1px var(--wp--preset--color--accent);
}

/* ---------------------------------------------------------------------------
 *  Minimal cohort cards emitted server-side by Cool_Bear_PDP_Hydrator::
 *  render_cohort() use cb-cohort-card / __link / __type / __price / __view —
 *  which the richer cb-cohort__card rules above never matched, so the cards
 *  rendered as unstyled squished text (operator feedback 2026-06). Style them.
 * ------------------------------------------------------------------------- */
.cb-cohort-card { list-style: none; }
.cb-cohort-card__link {
	display: flex;
	flex-direction: column;
	gap: 6px;
	height: 100%;
	padding: 16px;
	border: 1px solid rgba(255, 255, 255, 0.12);
	border-radius: 10px;
	background: rgba(255, 255, 255, 0.02);
	text-decoration: none;
	color: inherit;
	transition: border-color 150ms ease, background 150ms ease;
}
.cb-cohort-card__link:hover,
.cb-cohort-card__link:focus-visible {
	border-color: var(--wp--preset--color--accent, #c8102e);
	background: rgba(255, 255, 255, 0.04);
}
.cb-cohort-card__type { font-weight: 600; font-size: 0.95rem; line-height: 1.3; }
.cb-cohort-card__price {
	font-variant-numeric: tabular-nums;
	color: var(--wp--preset--color--text-subtle, #9a9aa2);
	font-size: 0.9rem;
}
.cb-cohort-card__view {
	margin-top: auto;
	font-size: 0.72rem;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--wp--preset--color--accent, #c8102e);
}
.cb-cohort-card--soon {
	grid-column: 1 / -1;
	color: var(--wp--preset--color--text-subtle, #9a9aa2);
	font-size: 0.9rem;
}

/* Full-width sub-heading inside the cohort list — labels the brake cross-sell
   row ("Brakes for this car", x2e item 11). Spans every grid column so the
   brake cards below it read as their own group, not mixed into the coilover/
   wheel cards above. */
.cb-cohort__row-label {
	grid-column: 1 / -1;
	list-style: none;
}

.cb-cohort__row-label-text {
	margin: var(--wp--preset--spacing--20) 0 0;
	font-family: var(--wp--preset--font-family--sans);
	font-size: var(--wp--preset--font-size--medium);
	font-weight: 600;
	letter-spacing: 0.01em;
	color: var(--wp--preset--color--text);
}
