/*
 * KNEAD. size guide: the controls row, the pop-up, and the product page link.
 *
 * Pairs with assets/js/features/size-guide.js, which builds everything styled
 * here. The guide itself (its table, photos, legend and colours) is styled by
 * the size guide's own stylesheet; nothing in this file reaches into it.
 *
 * The controls copy the designer's reference (knead-size-guide.html, its
 * `.kn-guide button` rules): square outlined buttons, royal blue for the chosen
 * garment, KNEAD. red for the chosen unit, navy ink.
 *
 * Where the reference fails an accessibility check, these controls part from it
 * on purpose, and each place says so: the chosen unit's red, the product page
 * link's grey, and a selected state Windows High Contrast can see. A later
 * fidelity pass must not "correct" them back.
 */

/* ---------- controls: garment tabs left, CM / IN right ---------- */

.knead-size-guide__controls {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	align-items: center;
	gap: 12px;
	margin: 22px 0 16px;
}
.knead-size-guide__controls .knead-size-guide__tabs,
.knead-size-guide__controls .knead-size-guide__units {
	display: flex;
}
/* With one garment there are no tabs; the units still sit on the right. */
.knead-size-guide__controls .knead-size-guide__units {
	margin-left: auto;
}
.knead-size-guide__controls button {
	appearance: none;
	-webkit-appearance: none;
	box-sizing: border-box;
	margin: 0 0 0 -1.5px;
	padding: 11px 16px;
	border: 1.5px solid #1a2440;
	border-radius: 0;
	background: transparent;
	color: #1a2440;
	font-family: inherit;
	font-size: 12px;
	font-weight: 700;
	line-height: 1;
	letter-spacing: .16em;
	text-transform: uppercase;
	cursor: pointer;
}
.knead-size-guide__controls button:first-child {
	margin-left: 0;
}
.knead-size-guide__controls button:hover {
	background: rgba(26, 36, 64, .06);
}
.knead-size-guide__controls button[aria-selected="true"] {
	position: relative;
	background: #1150a1;
	border-color: #1150a1;
	color: #fff;
}
.knead-size-guide__controls button[aria-pressed="true"] {
	position: relative;
	/* Not the reference's KNEAD. red (#eb2028): white on it is 4.40:1, under
	   the 4.5:1 a 12px label needs. This red is a shade darker, 4.78:1, and is
	   used for this one fill only; the focus ring below keeps KNEAD. red. */
	background: #e01f26;
	border-color: #e01f26;
	color: #fff;
}
.knead-size-guide__controls button:focus-visible {
	position: relative;
	z-index: 1;
	outline: 2px solid #eb2028;
	outline-offset: 2px;
	/* The site's own focus ring (style.css) adds a blue band; the guide keeps
	   its red one. */
	box-shadow: none;
}

/* Windows High Contrast (forced colours) throws away every fill, so the chosen
   tab and unit looked exactly like the others. Here they take the system's own
   highlight colours instead. Normal rendering is untouched. */
@media (forced-colors: active) {
	.knead-size-guide__controls button[aria-selected="true"],
	.knead-size-guide__controls button[aria-pressed="true"] {
		forced-color-adjust: none;
		background: Highlight;
		border-color: Highlight;
		color: HighlightText;
	}
	.knead-size-guide__controls button:focus-visible {
		outline-color: Highlight;
	}
}

/* Words only a screen reader hears: "centimetres" after CM, "inches" after IN,
   and the note that the units have changed. */
.knead-size-guide__sr {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	border: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
	text-transform: none;
	letter-spacing: normal;
}

/* ---------- the pop-up ---------- */

/* A centred panel on a wide screen, the measure of the designer's guide. */
.knead-size-guide-dialog {
	box-sizing: border-box;
	width: min(1000px, calc(100vw - 48px));
	max-width: none;
	max-height: calc(100vh - 48px);
	max-height: calc(100dvh - 48px);
	margin: auto;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: #ecebe8;
	color: #1a2440;
	box-shadow: 0 30px 80px rgba(0, 0, 0, .45);
	overflow: auto;
	overscroll-behavior: contain;
	scrollbar-width: thin;
	scrollbar-color: #1150a1 #ecebe8;
}
.knead-size-guide-dialog::backdrop {
	background: rgba(26, 36, 64, .82);
}

/* A full-height sheet on a phone. */
@media (max-width: 760px) {
	.knead-size-guide-dialog {
		width: 100%;
		height: 100%;
		max-height: none;
		margin: 0;
		inset: 0;
		box-shadow: none;
	}
}

/* Anything focused inside the pop-up is scrolled clear of the Close button,
   which floats over the top of the guide: its 16px margin and 40px height,
   plus room for the focus ring. */
.knead-size-guide-dialog .knead-size-guide * {
	scroll-margin-top: 64px;
}

/* The close button stays in the top corner while the guide scrolls under it.
   On a wide screen the bar has no height, so it takes no room from the guide's
   own layout. On a phone it reserves its row (below). */
.knead-size-guide-dialog__bar {
	position: sticky;
	top: 0;
	z-index: 2;
	height: 0;
	display: flex;
	justify-content: flex-end;
}
.knead-size-guide-dialog__close {
	appearance: none;
	-webkit-appearance: none;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	height: 40px;
	margin: 16px 16px 0 0;
	padding: 0 14px;
	border: 1.5px solid #1a2440;
	border-radius: 0;
	background: #ecebe8;
	color: #1a2440;
	font-family: inherit;
	font-size: 12px;
	font-weight: 700;
	line-height: 1;
	letter-spacing: .16em;
	text-transform: uppercase;
	cursor: pointer;
}
.knead-size-guide-dialog__close:hover {
	background: #1a2440;
	color: #fff;
}
.knead-size-guide-dialog__close:focus-visible {
	outline: 2px solid #eb2028;
	outline-offset: 2px;
	box-shadow: none;
}
.knead-size-guide-dialog__close svg {
	display: block;
	flex: none;
}
/* On a phone the guide's own top padding is smaller than the Close button, so
   Close sat over whatever came first: the end of "SIZE GUIDE" at 320px, the
   garment title if the eyebrow is emptied, and its focus ring over the title.
   The bar takes the button's row here, and the guide gives back most of its
   padding, so the guide starts 32px lower in the pop-up and nothing sits under
   Close. The page itself is unchanged. */
@media (max-width: 760px) {
	.knead-size-guide-dialog__close {
		margin: 12px 12px 0 0;
	}
	.knead-size-guide-dialog__bar {
		height: 52px;
	}
	.knead-size-guide-dialog .knead-size-guide.knead-size-guide {
		padding-top: 8px;
	}
}

/* Open with a short rise and fade; still for anyone who has asked for less
   motion. */
@media (prefers-reduced-motion: no-preference) {
	.knead-size-guide-dialog[open] {
		animation: knead-size-guide-rise .28s cubic-bezier(.2, .7, .2, 1);
	}
	.knead-size-guide-dialog[open]::backdrop {
		animation: knead-size-guide-fade .28s ease;
	}
}
@keyframes knead-size-guide-rise {
	from { opacity: 0; transform: translateY(16px); }
}
@keyframes knead-size-guide-fade {
	from { opacity: 0; }
}

/* The custom cursor lives under the pop-up (a modal sits above every z-index),
   and the site hides the real cursor while it is on. Inside the pop-up the
   real cursor comes back, and the custom one steps aside until it closes. */
.knead-cursor-on .knead-size-guide-dialog,
.knead-cursor-on .knead-size-guide-dialog * {
	cursor: auto;
}
.knead-cursor-on .knead-size-guide-dialog a,
.knead-cursor-on .knead-size-guide-dialog button {
	cursor: pointer;
}
body:has(> .knead-size-guide-dialog[open]) .knead-cursor-dot,
body:has(> .knead-size-guide-dialog[open]) .knead-cursor-ring {
	opacity: 0;
}

/* ---------- product page: "Size guide" in the "Select size" row ---------- */

/* The row stretches across the column (WooCommerce's column would otherwise
   shrink it to its contents), so the link lands on the right edge, in line with
   Add to bag. */
.knead-size-guide-link-row {
	display: flex;
	align-self: stretch;
	align-items: baseline;
	justify-content: space-between;
	gap: 16px;
}
/* "Select size" keeps its width whatever the page title says: a long title
   wraps the link instead of crushing the label to a letter a line. */
.knead-size-guide-link-row > .wp-block-woocommerce-add-to-cart-with-options-variation-selector-attribute-name {
	flex: none;
}
/* The label's own style (9px, 700, 3px tracking, uppercase), underlined. The
   grey is deliberately not the label's #777777: that is 4.34:1 on the page's
   black, under the 4.5:1 small text needs. #8a8a8a is 5.63:1. */
.knead-size-guide-link-row .knead-size-guide-link {
	font-size: 9px;
	line-height: normal;
	font-weight: 700;
	letter-spacing: 3px;
	text-transform: uppercase;
	color: #8a8a8a;
	text-decoration: underline;
	text-underline-offset: 3px;
	text-decoration-thickness: 1px;
	text-align: right;
	transition: color .15s ease;
}
.knead-size-guide-link-row .knead-size-guide-link:hover {
	color: #F5F0E8;
}
.knead-size-guide-link-row .knead-size-guide-link[aria-busy="true"] {
	cursor: progress;
}

/* ---------- loading: a thin bar while a slow guide is fetched ----------
   Shown by the script only when the wait is long enough to notice. Royal blue
   with a pale edge, the site's accent colours, so it reads on the black pages
   and on the phone menu's white alike. */

.knead-size-guide-progress {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	z-index: 10001;
	height: 3px;
	background: #1B4FBF;
	border-bottom: 1px solid #CADCFC;
	transform: scaleX(0);
	transform-origin: 0 50%;
	opacity: 0;
	pointer-events: none;
}
.knead-size-guide-progress.is-on {
	opacity: 1;
	transform: scaleX(.9);
	transition: transform 6s cubic-bezier(.1, .7, .2, 1);
}
@media (prefers-reduced-motion: reduce) {
	.knead-size-guide-progress.is-on {
		transform: none;
		transition: none;
	}
}
