/*
 * KNEAD. size guide (patterns/size-guide.php, the "Size Guide" page).
 *
 * The designer's guide was a standalone page that drew everything from a data
 * block in JavaScript. Here the same design sits on core blocks, so every word,
 * number and photo is editable in the block editor. The values below are his,
 * copied from knead-size-guide.html: where a number looks arbitrary, it is the
 * designer's, not ours. Measure with tools/fidelity before changing one.
 *
 * Three states, all styled here:
 *  1. No JavaScript: both garments show, stacked, each with its tab label
 *     standing where the tab buttons would be.
 *  2. Enhanced: the size guide script adds `.is-enhanced` to the root, shows
 *     one garment at a time and adds the tab and CM / IN buttons. The tab
 *     labels and the table caption then hide (the designer's guide has
 *     neither); the caption still names its table for screen readers.
 *  3. The block editor (stylesheet loaded by inc/size-guide.php): like 1, so
 *     the marketing team can see and edit both garments at once.
 *
 * Everything is scoped under .knead-size-guide. Most rules carry two classes on
 * purpose: core's layout rules (`:root :where(.is-layout-flow) > *` and the
 * root-padding rule for full-width blocks) would otherwise win on margin and
 * padding.
 */

/* ---------- Stand-in faces while the guide's fonts load ----------
   Archivo and Bodoni Moda are used nowhere else, so they are only fetched once
   the guide is on screen, and for that moment the text shows in a system font.
   A system font of another size reflows the guide when the real one lands (the
   guide is set at line-height `normal`, which follows each font's own
   metrics). These faces are system fonts (Arial for Archivo; Didot, or Times
   New Roman where there is no Didot, for Bodoni Moda), scaled and given the
   guide fonts' measurements, so the swap changes the letters and moves
   nothing. Measured in Chrome on the guide's own text; the settled guide is
   identical. A phone with none of these fonts swaps as before. Recompute them
   if either font is ever replaced. */

@font-face {
	font-family: "Archivo Fallback Arial";
	src: local("Arial"), local("ArialMT");
	font-weight: 100 500;
	size-adjust: 98.36%;
	ascent-override: 89.26%;
	descent-override: 21.35%;
	line-gap-override: 0%;
}
@font-face {
	font-family: "Archivo Fallback Arial";
	src: local("Arial Bold"), local("Arial-BoldMT");
	font-weight: 600 900;
	size-adjust: 99.07%;
	ascent-override: 88.62%;
	descent-override: 21.2%;
	line-gap-override: 0%;
}
@font-face {
	font-family: "Bodoni Fallback Didot";
	src: local("Didot Bold"), local("Didot-Bold");
	font-weight: 100 900;
	size-adjust: 101.08%;
	ascent-override: 111.29%;
	descent-override: 39.57%;
	line-gap-override: 0%;
}
@font-face {
	font-family: "Bodoni Fallback Times";
	src: local("Times New Roman Bold"), local("TimesNewRomanPS-BoldMT");
	font-weight: 100 900;
	size-adjust: 107.78%;
	ascent-override: 104.38%;
	descent-override: 37.11%;
	line-gap-override: 0%;
}

.knead-size-guide {
	--kn-ink: #1a2440;
	--kn-bg: #ecebe8;
	--kn-cell: #e4e2de;
	--kn-line: #d2cfca;
	--kn-muted: #4a4743;
	--kn-blue: #1150a1;  /* RP KNEAD royal blue */
	--kn-red: #eb2028;   /* KNEAD red */
	--kn-navy: #1a2440;
	--kn-sans: var(--wp--preset--font-family--archivo, Archivo, "Archivo Fallback Arial", "Helvetica Neue", Arial, sans-serif);
	/* Bodoni Moda is the designer's display face, self-hosted in theme.json.
	   Until it arrives (and if it ever fails) the title shows in Didot, which
	   every Mac has, sized to take Bodoni's room (below). */
	--kn-serif: "Bodoni Moda", "Bodoni Fallback Didot", "Bodoni Fallback Times", "Didot", "Times New Roman", serif;
}

.knead-size-guide.knead-size-guide {
	font-family: var(--kn-sans);
	/* The site's body leading is 1.6; the design was set at the browser's
	   `normal`. Every element the designer did not give a line height inherits
	   this one, which is what keeps the text blocks the height he drew. */
	line-height: normal;
	letter-spacing: 0;
	color: var(--kn-ink);
	background: var(--kn-bg);
	padding: 40px 40px 44px;
	box-sizing: border-box;
	/* The narrow layout follows the space the guide is given, not the screen,
	   so it also works inside the product-page pop-up on a wide screen. */
	container-type: inline-size;
}

.knead-size-guide *,
.knead-size-guide *::before,
.knead-size-guide *::after {
	box-sizing: inherit;
}

/* The design is 1000px wide including its 40px padding. The section itself
   runs full width so its background meets the screen edge on a phone, as the
   designer's page does; the content inside keeps his 920px measure. */
.knead-size-guide.knead-size-guide > * {
	max-width: 920px;
	margin-left: auto;
	margin-right: auto;
}

/* ---------- Eyebrow ----------
   The page's main heading (an h1, so the page has one), drawn as the designer's
   small eyebrow. The site's heading style (display face, tight leading, white)
   is put back to the guide's own here. */

.knead-size-guide.knead-size-guide > .knead-size-guide__eyebrow {
	font-family: inherit;
	line-height: inherit;
	color: inherit;
	font-size: 15px;
	font-weight: 600;
	letter-spacing: .28em;
	text-transform: uppercase;
	margin-top: 0;
	margin-bottom: 10px;
	padding: 0;
}

.knead-size-guide .knead-size-guide__rp {
	color: var(--kn-blue);
}

.knead-size-guide .knead-size-guide__knead {
	color: var(--kn-red);
}

/* ---------- One garment ----------
   A wrapping flex row in which almost everything takes a full line of its
   own. The exceptions are "Available in" and the colours, which share one
   centred line and wrap item by item, as the design's swatch row does; the
   column gap is the design's 18px between them, and touches nothing else,
   because nothing else ever shares a line.

   Each garment is also a size container. The title is sized in `cqi`, and the
   designer measured it against his 920px content box; against the full-width
   section it would come out at 88px instead of 73.6px. */

.knead-size-guide.knead-size-guide .knead-size-guide__garment {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	align-items: center;
	column-gap: 18px;
	container-type: inline-size;
	margin-top: 0;
	margin-bottom: 0;
}

/* Whatever hides the inactive garment, `hidden` must still win over flex. */
.knead-size-guide .knead-size-guide__garment[hidden] {
	display: none;
}

.knead-size-guide .knead-size-guide__garment > * {
	flex: 0 0 100%;
	min-width: 0;
}

/* The controls row is styled by size-guide-dialog.css, margins included, so it
   is left out of this reset. */
.knead-size-guide .knead-size-guide__garment > :not(.knead-size-guide__controls) {
	margin: 0;
}

/* Without JavaScript the stacked garments need a clear break between them. */
.knead-size-guide:not(.is-enhanced) .knead-size-guide__garment + .knead-size-guide__garment {
	margin-top: 56px;
	padding-top: 44px;
	border-top: 1px solid var(--kn-line);
}

/* Opened at a later garment (/size-guide/#hoodies), the page hides the others
   before it first paints (inc/size-guide.php), so the one on show starts at the
   top with no break above it, exactly where the script will keep it. */
.knead-size-guide:not(.is-enhanced) .knead-size-guide__garment[hidden] ~ .knead-size-guide__garment {
	margin-top: 0;
	padding-top: 0;
	border-top: 0;
}

/* ---------- Header ----------
   Pulled to the top with `order` so the tab label (first in the markup, where
   the script expects it) sits under the header, where the designer put the
   tabs. */

.knead-size-guide .knead-size-guide__garment > .knead-size-guide__head {
	order: -1;
	display: grid;
	grid-template-columns: 1.4fr 1fr;
	gap: 32px;
	align-items: end;
	padding: 0 0 28px;
	border-bottom: 3px solid var(--kn-red);
}

.knead-size-guide .knead-size-guide__head > * {
	min-width: 0;
	margin: 0;
}

.knead-size-guide .knead-size-guide__head > .knead-size-guide__title {
	font-family: var(--kn-serif);
	font-weight: 900;
	font-size: min(88px, 7.6vw);
	font-size: min(88px, 8cqi);
	line-height: .9;
	letter-spacing: -.02em;
	margin: 0;
	text-transform: uppercase;
	color: var(--kn-blue);
}

.knead-size-guide .knead-size-guide__head > .knead-size-guide__intro {
	font-size: 16px;
	line-height: 1.75;
	margin: 0 0 8px;
	max-width: 320px;
}

/* ---------- Tab label (no JavaScript) ----------
   Drawn as the selected tab, in the place the tabs sit. Once the script runs,
   its own tab buttons replace it; those, and the CM / IN buttons, are styled
   by size-guide-dialog.css, which belongs to the script. */

.knead-size-guide .knead-size-guide__garment > .knead-size-guide__tab {
	flex: 0 0 auto;
	margin: 22px auto 16px 0;
	padding: 11px 16px;
	font: 700 12px/1 var(--kn-sans);
	letter-spacing: .16em;
	text-transform: uppercase;
	color: #fff;
	background: var(--kn-blue);
	border: 1.5px solid var(--kn-blue);
}

.knead-size-guide.is-enhanced .knead-size-guide__garment > .knead-size-guide__tab {
	display: none;
}

/* ---------- Size table ---------- */

.knead-size-guide .knead-size-guide__garment > .knead-size-guide__table {
	margin: 0;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

/* On a screen narrow enough that the table scrolls sideways, the script puts
   its box in the Tab order so the arrow keys can scroll it. This is its focus
   ring, the same as the guide's own buttons. */
.knead-size-guide .knead-size-guide__garment > .knead-size-guide__table:focus-visible {
	outline: 2px solid #eb2028;
	outline-offset: 2px;
}

.knead-size-guide .knead-size-guide__table table {
	width: 100%;
	/* The design's 84px per column; below this the table scrolls sideways
	   with the size column pinned. */
	min-width: 336px;
	border-collapse: collapse;
	border: 0;
	font-size: inherit;
}

.knead-size-guide .knead-size-guide__table thead {
	border: 0;
}

.knead-size-guide .knead-size-guide__table thead th {
	background: var(--kn-blue);
	color: #fff;
	font-size: 13px;
	font-weight: 700;
	letter-spacing: .12em;
	text-transform: uppercase;
	padding: 18px 10px;
	line-height: 1.6;
	border: 0;
	border-right: 1px solid rgba(255, 255, 255, .22);
	text-align: center;
}

.knead-size-guide .knead-size-guide__table thead th:last-child {
	border-right: 0;
}

.knead-size-guide .knead-size-guide__table thead th:first-child {
	background: var(--kn-navy);
}

/* `tr > td`, not just `td`: style.css styles every table for the policy pages
   (pale #bbb text, a near-black stripe on odd rows) at a weight this rule
   would otherwise only tie, so the outcome would hang on load order. */
.knead-size-guide .knead-size-guide__table tbody tr > td {
	white-space: nowrap;
	color: var(--kn-ink);
	background: var(--kn-cell);
	text-align: center;
	font-size: 17px;
	font-weight: 400;
	padding: 20px 10px;
	border: 1px solid var(--kn-line);
}

/* The size column. Matched by position, not by `th`: a row the team adds in
   the editor starts with an ordinary cell, and must look the same. */
.knead-size-guide .knead-size-guide__table tbody tr > :first-child {
	background: var(--kn-navy);
	color: #fff;
	font-size: 24px;
	font-weight: 800;
	padding: 18px 10px;
	width: 13%;
	border: 0;
	border-bottom: 1px solid rgba(255, 255, 255, .15);
	text-align: center;
	position: sticky;
	left: 0;
}

/* A measurement still to be confirmed. */
.knead-size-guide .knead-size-guide__table td.is-tbc {
	color: #8a8580;
}

/* The caption says the bare numbers are centimetres. It shows without
   JavaScript and in the editor. Once the script is running it hides, because
   the designer's guide has no caption (the CM / IN buttons and the unit in each
   cell say the unit instead). It is not lost: the script keeps its wording in
   step with CM / IN and names the table with it, so screen readers still hear
   it, and it is what a unit switch announces. */
.knead-size-guide .knead-size-guide__table figcaption {
	margin: 12px 0 0;
	font-size: 12px;
	letter-spacing: .14em;
	line-height: normal;
	text-transform: uppercase;
	text-align: center;
	color: var(--kn-muted);
}

.knead-size-guide.is-enhanced .knead-size-guide__table figcaption {
	display: none;
}

/* ---------- How to measure ---------- */

.knead-size-guide .knead-size-guide__garment > .knead-size-guide__subhead {
	font-family: var(--kn-sans);
	font-size: 15px;
	font-weight: 700;
	letter-spacing: .14em;
	line-height: normal;
	text-transform: uppercase;
	color: var(--kn-ink);
	margin: 36px 0 14px;
}

.knead-size-guide .knead-size-guide__garment > .knead-size-guide__photos {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 20px;
	max-width: 760px;
	margin: 0 auto;
}

.knead-size-guide .knead-size-guide__photos > .wp-block-image {
	position: relative;
	/* The measurement lines are drawn into each photo, so every photo keeps the
	   design's 520 x 779 frame. A replacement of another shape is cropped to it
	   rather than allowed to change the layout. */
	aspect-ratio: 520 / 779;
	overflow: hidden;
	background: #e8e8e8;
	margin: 0;
}

.knead-size-guide .knead-size-guide__photos > .wp-block-image img {
	width: 100%;
	height: 100%;
	display: block;
	object-fit: cover;
}

.knead-size-guide .knead-size-guide__photos > .wp-block-image figcaption {
	position: absolute;
	left: 12px;
	top: 12px;
	margin: 0;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: .18em;
	line-height: normal;
	text-transform: uppercase;
	color: var(--kn-muted);
}

/* ---------- Legend (A, B, C) ----------
   The design sets the letter and the name on one baseline with the
   description indented beneath. Here they are three blocks, so a small grid
   puts them back in place. */

.knead-size-guide .knead-size-guide__garment > .knead-size-guide__legend {
	display: grid;
	grid-auto-flow: column;
	grid-auto-columns: 1fr;
	margin: 26px 0 0;
}

.knead-size-guide .knead-size-guide__legend > .knead-size-guide__key {
	display: grid;
	grid-template-columns: auto 1fr;
	column-gap: 10px;
	row-gap: 8px;
	align-items: baseline;
	align-content: start;
	padding: 0 18px;
	border-left: 1px solid var(--kn-line);
	margin: 0;
}

.knead-size-guide .knead-size-guide__legend > .knead-size-guide__key:first-child {
	border-left: 0;
	padding-left: 0;
}

.knead-size-guide .knead-size-guide__key > .knead-size-guide__letter {
	/* The design's own stack for the letters, which skips Didot. It only
	   matters while Bodoni Moda is loading (or missing), and then the stand-in
	   face above keeps the legend the height Bodoni gives it. */
	font-family: "Bodoni Moda", "Bodoni Fallback Times", serif;
	font-size: 28px;
	font-weight: 900;
	letter-spacing: 0;
	line-height: normal;
	color: var(--kn-red);
	margin: 0;
}

.knead-size-guide .knead-size-guide__key > .knead-size-guide__key-name {
	font-family: var(--kn-sans);
	font-size: 14px;
	font-weight: 700;
	letter-spacing: .12em;
	line-height: normal;
	text-transform: uppercase;
	color: var(--kn-ink);
	margin: 0;
}

.knead-size-guide .knead-size-guide__key > .knead-size-guide__key-text {
	grid-column: 1 / -1;
	margin: 0;
	padding-left: 30px;
	font-size: 13px;
	line-height: 1.65;
	color: var(--kn-muted);
}

/* ---------- Fit note (the blue bar) ---------- */

.knead-size-guide .knead-size-guide__garment > .knead-size-guide__note {
	display: flex;
	align-items: center;
	gap: 22px;
	background: var(--kn-blue);
	color: #fff;
	padding: 18px 24px;
	/* 4px here plus the 18px above each colour makes the design's 22px under
	   the bar, while a wrapped second line of colours sits 18px below the
	   first, as the design's row gap does. */
	margin: 34px 0 4px;
}

.knead-size-guide .knead-size-guide__note > .knead-size-guide__icon {
	flex: 0 0 56px;
	width: 56px;
	margin: 0;
}

.knead-size-guide .knead-size-guide__note > .knead-size-guide__icon img {
	display: block;
	width: 56px;
	height: 56px;
}

.knead-size-guide .knead-size-guide__note > .knead-size-guide__note-text {
	flex: 1;
	margin: 0;
	text-align: center;
	font-size: 15px;
	font-weight: 600;
	letter-spacing: .14em;
	line-height: 1.7;
	text-transform: uppercase;
	color: #fff;
}

/* ---------- Colours and fabric ---------- */

.knead-size-guide .knead-size-guide__garment > .knead-size-guide__available {
	flex: 0 0 auto;
	margin: 18px 0 0;
	font-size: 12px;
	font-weight: 600;
	letter-spacing: .12em;
	text-transform: uppercase;
	color: var(--kn-muted);
}

.knead-size-guide .knead-size-guide__garment > .knead-size-guide__colours {
	flex: 0 1 auto;
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	align-items: center;
	gap: 18px;
	list-style: none;
	margin: 18px 0 0;
	padding: 0;
	font-size: 12px;
	font-weight: 600;
	letter-spacing: .12em;
	text-transform: uppercase;
}

/* On the page the list steps aside so each colour joins the garment's line
   beside "Available in" and wraps one colour at a time, as the design does.
   As a single box it wrapped as a block: on a phone the label sat alone with
   all three colours on the line below. inc/size-guide.php gives the list
   role="list", which keeps it announced as a list. Not in the editor, where
   the list has to stay one selectable block. */
.knead-size-guide .knead-size-guide__garment > .knead-size-guide__colours:not(.block-editor-block-list__block) {
	display: contents;
}

.knead-size-guide .knead-size-guide__colours > li {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	margin: 0;
	padding: 0;
}

.knead-size-guide .knead-size-guide__colours:not(.block-editor-block-list__block) > li {
	flex: 0 0 auto;
	margin-top: 18px;
}

/*
 * The swatch follows the colour NAME the team types, so changing "Navy" to
 * "Burgundy" changes the dot. inc/size-guide.php reads each item's text on the
 * way to the page and writes it to `data-colour` as a slug ("Royal blue"
 * becomes "royal-blue", "Crème" becomes "creme"). Only the names below have a
 * colour. Any other name shows a dashed ring on the page, so an unknown colour
 * never reads as White; the editor shows a plain ring for every name, because
 * that filter runs on the page and not in the editor. A new colour is one line
 * here. The plugin's colour list (knead_swatch_colour()) now supplies the
 * colour as an inline --kn-swatch on the item, which outranks these four
 * lines; they remain the fallback when the plugin is absent.
 */
.knead-size-guide .knead-size-guide__colours > li::before {
	content: "";
	flex: 0 0 auto;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	border: 1px solid rgba(0, 0, 0, .18);
	background: var(--kn-swatch, transparent);
}

.knead-size-guide .knead-size-guide__colours > li[data-colour]::before {
	border-style: dashed;
	border-color: rgba(0, 0, 0, .45);
}

.knead-size-guide .knead-size-guide__colours > li[data-colour="white"]      { --kn-swatch: #ffffff; }
.knead-size-guide .knead-size-guide__colours > li[data-colour="burgundy"]   { --kn-swatch: #6e1f26; }
.knead-size-guide .knead-size-guide__colours > li[data-colour="navy"]       { --kn-swatch: #1a2440; }
.knead-size-guide .knead-size-guide__colours > li[data-colour="royal-blue"],
.knead-size-guide .knead-size-guide__colours > li[data-colour="royal"]      { --kn-swatch: #1150a1; }

/* A known colour keeps the design's solid ring. */
.knead-size-guide .knead-size-guide__colours > li:is([data-colour="white"], [data-colour="burgundy"], [data-colour="navy"], [data-colour="royal-blue"], [data-colour="royal"], [data-swatch="set"])::before {
	border-style: solid;
	border-color: rgba(0, 0, 0, .18);
}

.knead-size-guide .knead-size-guide__garment > .knead-size-guide__spec {
	text-align: center;
	font-size: 12px;
	letter-spacing: .14em;
	text-transform: uppercase;
	color: var(--kn-muted);
	margin: 18px 0 0;
}

/* ---------- Narrow: a phone, or a narrow pop-up on any screen ----------
   The design states these twice, once for the screen and once for the space
   the guide sits in. The screen rule only adds the outer padding: an element
   cannot query its own width, and the container query already covers every
   other rule whenever the screen one would. */

@media (max-width: 760px) {
	.knead-size-guide.knead-size-guide {
		padding: 28px 16px 32px;
	}
}

@container (max-width: 760px) {
	.knead-size-guide .knead-size-guide__garment > .knead-size-guide__head {
		grid-template-columns: 1fr;
		gap: 14px;
	}

	.knead-size-guide .knead-size-guide__head > .knead-size-guide__title {
		font-size: min(56px, 11vw);
		font-size: min(56px, 12.5cqi);
	}

	.knead-size-guide.knead-size-guide > .knead-size-guide__eyebrow {
		font-size: 12px;
	}

	.knead-size-guide .knead-size-guide__head > .knead-size-guide__intro {
		font-size: 15px;
	}

	.knead-size-guide .knead-size-guide__table tbody tr > :first-child {
		font-size: 18px;
	}

	.knead-size-guide .knead-size-guide__table tbody tr > td {
		font-size: 15px;
		padding: 16px 8px;
	}

	.knead-size-guide .knead-size-guide__table thead th {
		font-size: 11px;
		padding: 14px 8px;
	}

	.knead-size-guide .knead-size-guide__garment > .knead-size-guide__photos {
		gap: 10px;
	}

	.knead-size-guide .knead-size-guide__garment > .knead-size-guide__legend {
		grid-auto-flow: row;
		grid-template-columns: 1fr 1fr;
		row-gap: 20px;
	}

	.knead-size-guide .knead-size-guide__legend > .knead-size-guide__key {
		padding-right: 10px;
		padding-left: 10px;
	}

	.knead-size-guide .knead-size-guide__legend > .knead-size-guide__key:first-child,
	.knead-size-guide .knead-size-guide__legend > .knead-size-guide__key:nth-child(odd) {
		border-left: 0;
		padding-left: 0;
	}

	.knead-size-guide .knead-size-guide__garment > .knead-size-guide__note {
		flex-direction: column;
		gap: 10px;
		padding: 16px;
	}

	.knead-size-guide .knead-size-guide__note > .knead-size-guide__note-text {
		font-size: 13px;
	}
}
