/*
 * Upp Base: shared section primitives for the dark section blocks
 * (upp/glow-hero, upp/ticker, upp/bento, upp/sequence, upp/stats) and any
 * child's own sections: container, section rhythm, glows and the dot grid,
 * section heads, chips, buttons, text links.
 *
 * Promoted from the WebUpp child on 2026-10-12. The parent supplies the
 * sections; a child supplies tokens. Everything here reads the --wu-*
 * custom properties below. Their defaults come from the theme.json preset
 * slugs every dark child shares (ground, surface, surface-2, line,
 * line-strong, text, muted, success, gradient "brand"); the brand-specific
 * ones (accent, chip, glow slots, glow tint) must be set by the child.
 *
 * The class prefix stays "wu-" so the WebUpp page's markup did not change
 * when these moved; see docs/SPIKE-LOG.md, VirtualCRO build, task 0.
 *
 * A trap for children with a second scheme: a custom property that refers
 * to another is resolved on the element that declares it, so a scheme must
 * remap the preset colours on :root (where these are declared), not on
 * body.
 */

:root {
	--wu-ground: var(--wp--preset--color--ground);
	--wu-surface: var(--wp--preset--color--surface);
	--wu-surface-2: var(--wp--preset--color--surface-2);
	--wu-line: var(--wp--preset--color--line);
	--wu-line-strong: var(--wp--preset--color--line-strong);
	--wu-text: var(--wp--preset--color--text);
	--wu-muted: var(--wp--preset--color--muted);
	--wu-success: var(--wp--preset--color--success);
	--wu-gradient: var(--wp--preset--gradient--brand);
	/* Brand slots a child sets: text accent (chips, links, focus), the
	   tint of hover glows and shadows, three backdrop glows (named after
	   WebUpp's, used as first, second and third), the chip pill. */
	--wu-accent: var(--wu-text);
	--wu-glow-tint: var(--wu-text);
	--wu-glow-red: transparent;
	--wu-glow-purple: transparent;
	--wu-glow-blue: transparent;
	--wu-chip-bg: var(--wu-surface);
	--wu-chip-border: var(--wu-line-strong);
	--wu-dot: rgba(255, 255, 255, 0.04);
	--wu-ghost-face: rgba(255, 255, 255, 0.02);
	--wu-ghost-face-hover: rgba(255, 255, 255, 0.06);
	--wu-ghost-border-hover: rgba(255, 255, 255, 0.4);
	/* Primary button: face, text, and the gradient that fades in on hover
	   (white text on it). */
	--wu-button-face: var(--wu-surface);
	--wu-button-text: #fff;
	--wu-button-hover-face: var(--wu-gradient);
	--wu-panel-top: color-mix(in srgb, var(--wu-surface-2) 72%, transparent);
	--wu-panel-bottom: color-mix(in srgb, var(--wu-surface) 72%, transparent);
	--wu-ease: var(--wp--custom--ease--out, cubic-bezier(0.33, 1, 0.68, 1));
	--wu-radius: var(--wp--custom--radius, 10px);
	--wu-card-radius: var(--wp--custom--card-radius, 16px);
	--wu-header-h: var(--wp--custom--header-height, 72px);
	--wu-gutter: 16px;
	--wu-section-y: 64px;
	--wu-mono: var(--wp--preset--font-family--mono);
	--wu-display: var(--wp--preset--font-family--heading);
}

@media (min-width: 768px) {
	:root {
		--wu-gutter: 32px;
		--wu-section-y: 80px;
	}
}

@media (min-width: 1025px) {
	:root {
		--wu-gutter: 40px;
		--wu-section-y: 120px;
	}
}

/* ---------- Container and section rhythm ---------- */

.wu-wrap {
	box-sizing: border-box;
	width: 100%;
	max-width: calc(var(--wp--style--global--wide-size, 1240px) + 2 * var(--wu-gutter));
	margin-inline: auto;
	padding-inline: var(--wu-gutter);
}

.wu-section {
	position: relative;
	padding-block: var(--wu-section-y);
	color: var(--wu-text);
}

/* A hairline between sections, inside the container. */
.wu-section--rule::before {
	content: "";
	position: absolute;
	top: 0;
	left: 50%;
	width: min(calc(100% - 2 * var(--wu-gutter)), var(--wp--style--global--wide-size, 1240px));
	height: 1px;
	transform: translateX(-50%);
	background: linear-gradient(90deg, transparent, var(--wu-line) 20%, var(--wu-line) 80%, transparent);
}

.upp-main > .wp-block-post-content,
.upp-main > .wp-block-post-content > * {
	margin-block: 0;
}

.upp-main > .wp-block-post-content {
	padding-inline: 0;
}

/* ---------- Glows and the dot grid ---------- */

/*
 * Glows are large radial gradients at 22% (theme.json custom.glow), so they
 * are soft without a filter: blur() on a viewport-sized layer costs a full
 * repaint per frame. They drift on transform only, 20 s, and stand still
 * under reduced motion.
 */
.wu-glows {
	position: absolute;
	inset: 0;
	overflow: hidden;
	pointer-events: none;
	z-index: 0;
}

.wu-glow {
	position: absolute;
	width: 900px;
	height: 900px;
	border-radius: 50%;
	will-change: transform;
}

.wu-glow--red {
	background: radial-gradient(closest-side, var(--wu-glow-red), transparent 100%);
	animation: wu-drift-a 20s ease-in-out infinite alternate;
}

.wu-glow--purple {
	background: radial-gradient(closest-side, var(--wu-glow-purple), transparent 100%);
	animation: wu-drift-b 20s ease-in-out infinite alternate;
}

.wu-glow--blue {
	background: radial-gradient(closest-side, var(--wu-glow-blue), transparent 100%);
	animation: wu-drift-c 20s ease-in-out infinite alternate;
}

@keyframes wu-drift-a {
	0% { transform: translate3d(0, 0, 0) scale(1); }
	50% { transform: translate3d(80px, 40px, 0) scale(1.08); }
	100% { transform: translate3d(20px, 100px, 0) scale(0.96); }
}

@keyframes wu-drift-b {
	0% { transform: translate3d(0, 0, 0) scale(1); }
	50% { transform: translate3d(-90px, 50px, 0) scale(1.1); }
	100% { transform: translate3d(60px, -40px, 0) scale(1); }
}

@keyframes wu-drift-c {
	0% { transform: translate3d(0, 0, 0) scale(1.04); }
	50% { transform: translate3d(-60px, -70px, 0) scale(0.95); }
	100% { transform: translate3d(-120px, 30px, 0) scale(1.06); }
}

/* Dot grid at 4% white that fades out towards the content it sits under. */
.wu-dots {
	position: absolute;
	inset: 0;
	z-index: 0;
	pointer-events: none;
	background-image: radial-gradient(var(--wu-dot) 1px, transparent 1.5px);
	background-size: 28px 28px;
	background-position: -14px -14px;
	-webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 30%, #000 0%, rgba(0, 0, 0, 0.5) 45%, transparent 80%);
	mask-image: radial-gradient(ellipse 70% 60% at 50% 30%, #000 0%, rgba(0, 0, 0, 0.5) 45%, transparent 80%);
}

/* ---------- Section head: chip, h2, standfirst ---------- */

.wu-head {
	max-width: 760px;
	margin-bottom: 48px;
}

@media (min-width: 1025px) {
	.wu-head {
		margin-bottom: 64px;
	}
}

.wu-head--center {
	margin-inline: auto;
	text-align: center;
}

.wu-head > * {
	margin-block: 0;
}

.wu-head > * + * {
	margin-top: 18px;
}

.wu-head > .wu-chip + * {
	margin-top: 20px;
}

.wu-h2 {
	font-family: var(--wu-display);
	font-size: var(--wp--preset--font-size--heading-2);
	font-weight: 700;
	line-height: 1.1;
	letter-spacing: -0.02em;
	text-wrap: balance;
}

.wu-standfirst {
	max-width: 60ch;
	color: var(--wu-muted);
	font-size: var(--wp--preset--font-size--standfirst);
	line-height: 1.5;
	text-wrap: pretty;
}

.wu-head--center .wu-standfirst {
	margin-inline: auto;
}

/* Chips and small data: JetBrains Mono, uppercase, tracked. */
.wu-chip {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 6px 12px;
	border: 1px solid var(--wu-chip-border);
	border-radius: 999px;
	/* Opaque (10% purple on ground), so a glow behind never lowers the chip
	   text's contrast: 5.1:1 everywhere. */
	background: var(--wu-chip-bg);
	color: var(--wu-accent);
	font-family: var(--wu-mono);
	font-size: var(--wp--preset--font-size--chip);
	font-weight: 500;
	line-height: 1.4;
	letter-spacing: 0.12em;
	text-transform: uppercase;
}

/* Numbered label: a number, a drawn rule and the section name (a real rule, not typed dashes).
   Set by a block's "Section number" field instead of the pill chip. */
.wu-label {
	display: flex;
	align-items: center;
	gap: 14px;
	margin: 0;
	color: var(--wu-accent);
	font-family: var(--wu-mono);
	font-size: var(--wp--preset--font-size--chip, 12px);
	font-weight: 500;
	line-height: 1.4;
	letter-spacing: 0.12em;
	text-transform: uppercase;
}

.wu-label__num {
	font-variant-numeric: tabular-nums;
}

.wu-label__rule {
	flex: none;
	width: 48px;
	height: 1px;
	background: currentColor;
	opacity: 0.6;
}

.wu-head--center .wu-label {
	justify-content: center;
}

.wu-mono {
	font-family: var(--wu-mono);
	font-size: 13px;
	font-weight: 500;
	letter-spacing: 0.02em;
	color: var(--wu-muted);
}

/* Gradient wash on a phrase (h1 key phrase). Large text only. */
.wu-wash {
	background-image: var(--wu-gradient);
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent;
	-webkit-box-decoration-break: clone;
	box-decoration-break: clone;
}

/* ---------- Buttons ---------- */

.wu-button {
	box-sizing: border-box;
	position: relative;
	isolation: isolate;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 14px 22px;
	border: 1px solid transparent;
	border-radius: var(--wu-radius);
	font-family: var(--wp--preset--font-family--body);
	font-size: 15px;
	font-weight: 500;
	line-height: 1;
	text-decoration: none;
	white-space: nowrap;
	cursor: pointer;
	transition: transform 0.25s var(--wu-ease), border-color 0.2s, background-color 0.2s, box-shadow 0.25s var(--wu-ease), color 0.2s;
}

.wu-button:hover {
	transform: translateY(-1px);
	text-decoration: none;
}

/*
 * Primary: a 1px gradient hairline (two backgrounds, padding-box and
 * border-box) round a dark face, white text. Hover fades a gradient face in
 * on a pseudo-element; the face is sized 220% and centred so the text sits
 * on the purple run (white on it measures 5.4:1 or better, see the log).
 */
.wu-button--primary,
.wu-button--primary:visited {
	background: linear-gradient(var(--wu-button-face), var(--wu-button-face)) padding-box, var(--wu-gradient) border-box;
	color: var(--wu-button-text);
	box-shadow: 0 0 0 0 transparent;
}

.wu-button--primary::before {
	content: "";
	position: absolute;
	inset: -1px;
	z-index: -1;
	border-radius: inherit;
	background-image: var(--wu-button-hover-face);
	background-size: 220% 100%;
	background-position: 50% 50%;
	opacity: 0;
	transition: opacity 0.3s var(--wu-ease);
}

.wu-button--primary:hover {
	color: #fff;
	box-shadow: 0 10px 40px -10px color-mix(in srgb, var(--wu-glow-tint) 70%, transparent);
}

.wu-button--primary:hover::before {
	opacity: 1;
}

.wu-button--ghost,
.wu-button--ghost:visited {
	border-color: var(--wu-line-strong);
	background: var(--wu-ghost-face);
	color: var(--wu-text);
}

.wu-button--ghost:hover {
	border-color: var(--wu-ghost-border-hover);
	background: var(--wu-ghost-face-hover);
	color: var(--wu-text);
}

.wu-button svg {
	width: 16px;
	height: 16px;
	transition: transform 0.2s var(--wu-ease);
}

.wu-button:hover svg {
	transform: translateX(3px);
}

.wu-actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 12px;
}

.wu-textlink {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	color: var(--wu-accent);
	font-weight: 500;
	text-decoration: none;
}

.wu-textlink svg {
	width: 16px;
	height: 16px;
	transition: transform 0.2s var(--wu-ease);
}

.wu-textlink:hover {
	color: var(--wu-accent);
	text-decoration: underline;
	text-underline-offset: 4px;
}

.wu-textlink:hover svg {
	transform: translateX(3px);
}


/* ---------- Reduced motion: glows still, no hover travel ---------- */

@media (prefers-reduced-motion: reduce) {
	.wu-glow {
		animation: none;
	}

	.wu-button,
	.wu-button:hover,
	.wu-button svg,
	.wu-textlink svg {
		transition: none;
		transform: none;
	}
}
