/* Category and brand archive intro - the section board.
 * See functions/sd-category-intro.php for the shape and the reasoning.
 *
 * The block gets the whole 1,680px of .catalog_top and is built as the opening
 * spread of a catalogue section: a reading rail across the top, then the section
 * heading and its standfirst side by side. Boldness is spent in one place - the
 * red tick that starts the rail - and the rest is hairlines and type.
 *
 * Colours are the house tokens the home page and the clearance archive already
 * use, so this belongs to the same site. The accent is the brand red, not the
 * AIMS green the first version borrowed: red is what the header, the search
 * button and the deals nav all use, and green on this store means AIMS.
 *
 * SPECIFICITY. The theme prints an inline <style> carrying
 * `h2, .woocommerce h2, .woocommerce-page h2 { font-size: 44.425px }` - 0,1,1,
 * which beats a lone `.sd-cat-intro__heading`. Anything the theme also styles by
 * element is written here as `.sd-cat-intro .sd-cat-intro__x` to get above it. */

.sd-cat-intro, .sd-cat-intro *, .sd-cat-intro *::before, .sd-cat-intro *::after { box-sizing: border-box; }

.sd-cat-intro {
	--ink: #201e1d;
	--ink-soft: #4a4746;
	--muted: #6f6c6a;
	--chalk: #f7f5ef;
	--rule: #ded9cf;         /* one step darker than --sd-rule: this one sits on chalk, not white */
	--red: #ec3013;
	--red-text: #b8240c;     /* the brand red, contrast-corrected for text */
	--red-deep: #8f1b09;
	--font-head: 'Archivo', Arial, Helvetica, sans-serif;
	--font-body: 'Montserrat', -apple-system, 'system-ui', Arial, sans-serif;

	background: var(--chalk);
	padding: clamp(20px, 1.9vw, 30px) clamp(18px, 2.1vw, 38px) clamp(24px, 2.2vw, 34px);
	margin: 0 0 clamp(24px, 2.2vw, 34px);
	text-align: left;
	font-family: var(--font-body);
	color: var(--ink-soft);
}

/* ------------------------------------------------------------------ */
/* The reading rail                                                     */
/*                                                                      */
/* Every part of it is information: the tick marks where the section     */
/* starts, the reading is counted from the catalogue at render time, and */
/* the hairline runs out to the way back up. Nothing here is ornament.   */
/* ------------------------------------------------------------------ */

.sd-cat-intro__rail {
	display: flex;
	align-items: center;
	gap: clamp(14px, 1.5vw, 24px);
	margin: 0 0 clamp(20px, 1.9vw, 30px);
	min-width: 0;
}

.sd-cat-intro__tick {
	flex: none;
	width: clamp(38px, 3.6vw, 58px);
	height: 7px;
	background: var(--red);
}

.sd-cat-intro .sd-cat-intro__reading {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	align-items: baseline;
	flex-wrap: wrap;
	gap: 4px clamp(16px, 1.9vw, 32px);
	min-width: 0;
}

.sd-cat-intro .sd-cat-intro__reading li {
	margin: 0;
	padding: 0;
	list-style: none;
	font-family: var(--font-head);
	font-weight: 700;
	font-size: 12px;
	line-height: 1;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--muted);
	white-space: nowrap;
}
.sd-cat-intro .sd-cat-intro__reading li::before { content: none; }

.sd-cat-intro .sd-cat-intro__reading b {
	font-family: var(--font-head);
	font-weight: 800;
	font-size: clamp(19px, 1.5vw, 26px);
	line-height: 1;
	letter-spacing: -0.01em;
	color: var(--ink);
	font-variant-numeric: tabular-nums;
	margin-right: 7px;
}

.sd-cat-intro__line {
	flex: 1 1 40px;
	min-width: 20px;
	height: 1px;
	background: var(--rule);
}

/* Back up to the parent section. The breadcrumb below says the same thing in
   10px grey; this is the one a thumb can hit. */
.sd-cat-intro .sd-cat-intro__up {
	flex: none;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-family: var(--font-head);
	font-weight: 700;
	font-size: 12px;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--red-text);
	text-decoration: none;
	padding-bottom: 3px;
	border-bottom: 2px solid transparent;
	transition: color 0.18s ease, border-color 0.18s ease;
}
/* The parent theme fades every link to opacity .7 on hover; this block opts out. */
.sd-cat-intro a:hover,
.sd-cat-intro a:focus { opacity: 1 !important; }
.sd-cat-intro .sd-cat-intro__up:hover,
.sd-cat-intro .sd-cat-intro__up:focus-visible {
	color: var(--red-deep);
	border-bottom-color: var(--red);
}
.sd-cat-intro .sd-cat-intro__up:focus-visible { outline: 2px solid var(--red); outline-offset: 4px; }
.sd-cat-intro .sd-cat-intro__up span { font-size: 14px; letter-spacing: 0; }

/* Brand archives put the brand's own mark where a category puts its way back
   up - the one place the two archive types are allowed to differ. */
.sd-cat-intro__logo { flex: none; display: block; line-height: 0; }
.sd-cat-intro .sd-cat-intro__logo img {
	display: block;
	width: auto;
	max-width: 168px;
	max-height: 46px;
	height: auto;
	object-fit: contain;
}

/* ------------------------------------------------------------------ */
/* Heading and standfirst                                               */
/* ------------------------------------------------------------------ */

.sd-cat-intro__grid {
	display: grid;
	gap: clamp(16px, 1.6vw, 26px);
	align-items: start;
}

.sd-cat-intro .sd-cat-intro__heading {
	font-family: var(--font-head);
	font-weight: 800;
	font-size: clamp(21px, 2.15vw, 43px);
	line-height: 1.08;
	letter-spacing: -0.02em;
	color: var(--ink);
	margin: 0;
	padding: 0;
	text-transform: none;
	text-wrap: balance;
}

.sd-cat-intro__prose { min-width: 0; }

.sd-cat-intro .sd-cat-intro__body p {
	font-family: var(--font-body);
	font-size: clamp(14.5px, 0.86vw, 16px);
	line-height: 1.72;
	margin: 0 0 15px;
	color: var(--ink-soft);
}
.sd-cat-intro .sd-cat-intro__body p:last-child { margin-bottom: 0; }
.sd-cat-intro .sd-cat-intro__body strong { color: var(--ink); font-weight: 600; }
.sd-cat-intro .sd-cat-intro__body a { color: var(--red-text); text-decoration: underline; text-underline-offset: 2px; }

/* The clamp control: hidden entirely at widths where the whole intro fits. */
.sd-cat-intro__more { position: absolute; opacity: 0; pointer-events: none; width: 0; height: 0; }
.sd-cat-intro__toggle { display: none; }

/* ------------------------------------------------------------------ */
/* Two tracks from 1024px, two prose columns from 1400px                */
/*                                                                      */
/* The width is the whole point of this layout, and the second prose     */
/* column is what pays for it: the same hundred words that ran five      */
/* lines deep run three, so the products below move UP the page rather   */
/* than down it. Below 1400px one column is already the right measure.   */
/* ------------------------------------------------------------------ */

@media screen and (min-width: 1024px) {
	.sd-cat-intro__grid {
		grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
		gap: clamp(24px, 2vw, 34px);
	}

	.sd-cat-intro__prose {
		border-left: 1px solid var(--rule);
		padding-left: clamp(24px, 2vw, 34px);
	}

	/* No heading to sit beside, so the standfirst takes the width on its own. */
	.sd-cat-intro--no-heading .sd-cat-intro__grid { grid-template-columns: minmax(0, 1fr); }
	.sd-cat-intro--no-heading .sd-cat-intro__prose { border-left: 0; padding-left: 0; }
}

@media screen and (min-width: 1400px) {
	.sd-cat-intro__body--split {
		columns: 2;
		column-gap: clamp(26px, 2.2vw, 44px);
	}
	.sd-cat-intro__body--split p { break-inside: avoid; }
	.sd-cat-intro__body--split p:first-child { margin-top: 0; }

	/* Without a heading beside it the standfirst has the whole 1,680px, and two
	   columns of it would run 100 characters wide. Cap the track instead. */
	.sd-cat-intro--no-heading .sd-cat-intro__prose { max-width: 1120px; }
}

/* ------------------------------------------------------------------ */
/* Narrow                                                               */
/* ------------------------------------------------------------------ */

@media screen and (max-width: 900px) {
	.sd-cat-intro__rail { flex-wrap: wrap; gap: 12px 18px; }
	.sd-cat-intro__line { display: none; }
	.sd-cat-intro .sd-cat-intro__reading b { font-size: 20px; }
}

@media screen and (max-width: 640px) {
	.sd-cat-intro { padding: 16px 16px 20px; margin-bottom: 20px; }
	.sd-cat-intro__rail { margin-bottom: 16px; }
	.sd-cat-intro__grid { gap: 14px; }
	.sd-cat-intro__tick { height: 6px; }
	.sd-cat-intro .sd-cat-intro__reading li { font-size: 11px; letter-spacing: 0.1em; }
	.sd-cat-intro .sd-cat-intro__reading b { font-size: 18px; margin-right: 5px; }

	.sd-cat-intro__body {
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 4;
		overflow: hidden;
	}

	.sd-cat-intro__more:checked ~ .sd-cat-intro__body {
		display: block;
		overflow: visible;
	}

	.sd-cat-intro__toggle {
		display: inline-block;
		margin-top: 12px;
		font-family: var(--font-head);
		font-weight: 700;
		font-size: 12px;
		letter-spacing: 0.1em;
		text-transform: uppercase;
		color: var(--red-text);
		cursor: pointer;
		border-bottom: 2px solid currentColor;
		padding-bottom: 2px;
	}
	.sd-cat-intro__toggle::after { content: "Read more"; }
	.sd-cat-intro__more:checked ~ .sd-cat-intro__toggle::after { content: "Read less"; }
	.sd-cat-intro__more:focus-visible ~ .sd-cat-intro__toggle { outline: 2px solid var(--red); outline-offset: 3px; }
}

/* ------------------------------------------------------------------ */
/* Motion                                                               */
/*                                                                      */
/* One gesture, on page load: the rail draws itself left to right - the  */
/* tick, then the hairline chasing it out to the edge. Both are          */
/* aria-hidden decoration, so nothing readable is ever parked at zero,   */
/* and nothing here needs JavaScript (WP Rocket delays all of it).       */
/* ------------------------------------------------------------------ */

@keyframes sd-cat-intro-draw {
	from { transform: scaleX(0); }
	to   { transform: scaleX(1); }
}

.sd-cat-intro__tick,
.sd-cat-intro__line { transform-origin: left center; will-change: transform; }

.sd-cat-intro__tick { animation: sd-cat-intro-draw 360ms cubic-bezier(0.2, 0.75, 0.25, 1) 60ms both; }
.sd-cat-intro__line { animation: sd-cat-intro-draw 620ms cubic-bezier(0.2, 0.75, 0.25, 1) 220ms both; }

@media (prefers-reduced-motion: reduce) {
	.sd-cat-intro__tick,
	.sd-cat-intro__line { animation: none; transform: none; will-change: auto; }
	.sd-cat-intro .sd-cat-intro__up { transition: none; }
}
