/*
 * WebUpp, direction 2 (dark). Shared pieces every section uses: container,
 * section rhythm, heads, chips, buttons, glows and the dot grid, the header,
 * the browser frame on dark, the recent work loop and the FAQ. Block layout
 * lives in each block's style.scss. Tokens come from theme.json.
 */

: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-purple: var(--wp--preset--color--brand-purple);
	--wu-gradient: var(--wp--preset--gradient--brand);
	--wu-ease: var(--wp--custom--ease--out);
	--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;
	}
}

html {
	scroll-padding-top: calc(var(--wu-header-h) + 16px);
	background: var(--wu-ground);
	color-scheme: dark;
}

body {
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	text-rendering: optimizeLegibility;
	overflow-x: clip;
}

::selection {
	background: rgba(123, 63, 228, 0.5);
	color: #fff;
}

:where(a, button, summary, input, select, textarea):focus-visible {
	outline: 2px solid var(--wu-purple);
	outline-offset: 3px;
	border-radius: 4px;
}

a:where(:not(.wu-button)):hover {
	text-decoration: underline;
	text-underline-offset: 3px;
}

/* ---------- 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(--wp--custom--glow--red), rgba(235, 38, 58, 0) 100%);
	animation: wu-drift-a 20s ease-in-out infinite alternate;
}

.wu-glow--purple {
	background: radial-gradient(closest-side, var(--wp--custom--glow--purple), rgba(123, 63, 228, 0) 100%);
	animation: wu-drift-b 20s ease-in-out infinite alternate;
}

.wu-glow--blue {
	background: radial-gradient(closest-side, var(--wp--custom--glow--blue), rgba(47, 107, 255, 0) 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(rgba(255, 255, 255, 0.04) 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 rgba(157, 112, 235, 0.28);
	border-radius: 999px;
	/* Opaque (10% purple on ground), so a glow behind never lowers the chip
	   text's contrast: 5.1:1 everywhere. */
	background: #191428;
	color: var(--wu-purple);
	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;
}

.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-surface), var(--wu-surface)) padding-box, var(--wu-gradient) border-box;
	color: #fff;
	box-shadow: 0 0 0 0 rgba(123, 63, 228, 0);
}

.wu-button--primary::before {
	content: "";
	position: absolute;
	inset: -1px;
	z-index: -1;
	border-radius: inherit;
	background-image: var(--wu-gradient);
	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 rgba(123, 63, 228, 0.7);
}

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

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

.wu-button--ghost:hover {
	border-color: rgba(255, 255, 255, 0.4);
	background: rgba(255, 255, 255, 0.06);
	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-purple);
	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-purple);
	text-decoration: underline;
	text-underline-offset: 4px;
}

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

/* ---------- Header (parts/header.html) ---------- */

.wp-site-blocks > header.wp-block-template-part {
	position: sticky;
	top: var(--wp-admin--admin-bar--height, 0px);
	z-index: 100;
	margin: 0;
	border-bottom: 1px solid transparent;
	transition: border-color 0.2s;
}

/*
 * Frosted ground on a pseudo-element: backdrop-filter on the header itself
 * would make it the containing block for the navigation overlay (light
 * build decision 24).
 */
.wp-site-blocks > header.wp-block-template-part::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: -1;
	background: rgba(10, 10, 18, 0.8);
	-webkit-backdrop-filter: saturate(1.6) blur(16px);
	backdrop-filter: saturate(1.6) blur(16px);
}

html.wu-scrolled .wp-site-blocks > header.wp-block-template-part {
	border-bottom-color: var(--wu-line);
}

.wu-header {
	box-sizing: border-box;
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	align-items: center;
	gap: 24px;
	width: 100%;
	max-width: calc(var(--wp--style--global--wide-size, 1240px) + 2 * var(--wu-gutter));
	height: var(--wu-header-h);
	margin-inline: auto;
	padding-inline: var(--wu-gutter);
}

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

.wu-header > .wu-logo {
	justify-self: start;
}

.wu-header > .wp-block-buttons {
	justify-self: end;
}

.wu-header .wu-logo img {
	height: 32px;
}

.wu-header .wp-block-navigation {
	gap: 32px;
	font-size: 15px;
	font-weight: 500;
}

.wu-header .wp-block-navigation-item__content {
	color: var(--wu-muted);
	text-decoration: none;
	transition: color 0.2s;
}

.wu-header .wp-block-navigation-item__content:hover {
	color: var(--wu-text);
	text-decoration: none;
}

.wu-header .wp-block-buttons {
	flex: none;
}

/* The header button is a core button styled as the primary. */
.wu-header .wp-block-button__link {
	position: relative;
	isolation: isolate;
	padding: 10px 16px;
	border: 1px solid transparent;
	background: linear-gradient(var(--wu-surface), var(--wu-surface)) padding-box, var(--wu-gradient) border-box;
	color: #fff;
	font-size: 14px;
	transition: box-shadow 0.25s var(--wu-ease), transform 0.25s var(--wu-ease);
}

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

.wu-header .wp-block-button__link:hover {
	transform: translateY(-1px);
	box-shadow: 0 10px 30px -10px rgba(123, 63, 228, 0.7);
	text-decoration: none;
}

.wu-header .wp-block-button__link:hover::before {
	opacity: 1;
}

/* Burger below desktop (core switches at 600px; the house breakpoint is 1025px). */
@media (max-width: 1024.98px) {
	.wu-header {
		grid-template-columns: 1fr auto auto;
		gap: 12px;
	}

	.wu-header .wp-block-navigation__responsive-container-open:not(.always-shown) {
		display: flex;
	}

	.wu-header .wp-block-navigation__responsive-container:not(.hidden-by-default):not(.is-menu-open) {
		display: none;
	}

	.wu-header > .wp-block-navigation {
		order: 3;
	}
}

@media (max-width: 420px) {
	.wu-header .wp-block-button__link {
		padding: 9px 12px;
		font-size: 13px;
	}
}

.wu-header .wp-block-navigation__responsive-container-open,
.wu-header .wp-block-navigation__responsive-container-close {
	color: var(--wu-text);
}

/* Full-screen dark overlay menu. */
.wu-header .wp-block-navigation__responsive-container.is-menu-open {
	padding: 20px var(--wu-gutter);
	background: var(--wu-ground) !important;
	background-image: radial-gradient(600px 400px at 100% 0%, rgba(123, 63, 228, 0.2), transparent 70%), radial-gradient(500px 400px at 0% 100%, rgba(47, 107, 255, 0.14), transparent 70%) !important;
	color: var(--wu-text) !important;
}

.wu-header .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-container-content {
	padding-top: 64px;
}

.wu-header .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__container {
	gap: 0;
	width: 100%;
}

.wu-header .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item {
	width: 100%;
	border-bottom: 1px solid var(--wu-line);
}

.wu-header .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item__content {
	display: block;
	width: 100%;
	padding: 18px 0;
	color: var(--wu-text);
	font-family: var(--wu-display);
	font-size: 30px;
	font-weight: 700;
	letter-spacing: -0.02em;
}

.wu-header .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-container-content,
.wu-header .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__container {
	align-items: flex-start;
}

/* ---------- Browser frame on dark (parent inc/browser-frame.php) ---------- */

.upp-frame {
	--upp-frame-bar: 30px;
	border: 1px solid var(--wu-line-strong);
	border-radius: 12px;
	background: var(--wu-surface);
	box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset, 0 24px 60px -24px rgba(0, 0, 0, 0.8);
}

.upp-frame__bar {
	border-bottom: 1px solid var(--wu-line);
	background: var(--wu-surface);
}

.upp-frame__dots span {
	background: rgba(255, 255, 255, 0.14);
}

.upp-frame__address {
	background: var(--wu-surface-2);
	color: var(--wu-muted);
	font-family: var(--wu-mono);
	font-size: 10.5px;
	letter-spacing: 0;
}

.upp-frame__screen {
	background: var(--wu-surface-2);
}

/* Glow option: upp_browser_frame( id, { glow: 'red' | 'purple' | 'blue' | 'cycle' } ). */
.upp-frame--glow {
	--upp-glow: rgba(123, 63, 228, 0.45);
	box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset, 0 30px 80px -28px var(--upp-glow), 0 0 0 1px rgba(255, 255, 255, 0.02);
}

.upp-frame--glow-red { --upp-glow: rgba(235, 38, 58, 0.5); }
.upp-frame--glow-purple { --upp-glow: rgba(123, 63, 228, 0.55); }
.upp-frame--glow-blue { --upp-glow: rgba(47, 107, 255, 0.5); }

/* ---------- Recent work (core/group + core/query from the page file) ---------- */

.wu-work .wu-work__loop .wp-block-post-template.is-layout-grid {
	gap: 56px 40px;
}

@media (min-width: 1025px) {
	.wu-work .wu-work__loop .wp-block-post-template.is-layout-grid {
		gap: 80px 56px;
	}
}

@media (max-width: 767.98px) {
	.wu-work .wu-work__loop .wp-block-post-template.is-layout-grid {
		grid-template-columns: minmax(0, 1fr);
	}
}

/* Glow colour cycles through the brand with the loop position. */
.wu-work .wp-block-post:nth-child(3n+1) .upp-frame--glow { --upp-glow: rgba(235, 38, 58, 0.42); }
.wu-work .wp-block-post:nth-child(3n+2) .upp-frame--glow { --upp-glow: rgba(123, 63, 228, 0.5); }
.wu-work .wp-block-post:nth-child(3n+3) .upp-frame--glow { --upp-glow: rgba(47, 107, 255, 0.45); }

.wu-work .upp-card__frame {
	transition: transform 0.35s var(--wu-ease), box-shadow 0.35s var(--wu-ease), border-color 0.2s;
}

.wu-work .upp-card__link:hover .upp-card__frame {
	transform: translateY(-6px);
	border-color: rgba(255, 255, 255, 0.24);
	box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset, 0 40px 100px -28px var(--upp-glow);
}

.wu-work .upp-card__body {
	padding-top: 24px;
}

.wu-work .upp-card__title {
	color: var(--wu-text);
	font-family: var(--wu-display);
	font-size: var(--wp--preset--font-size--heading-3);
	font-weight: 700;
	letter-spacing: -0.01em;
}

.wu-work .upp-card__link:hover .upp-card__title {
	text-decoration-color: var(--wu-purple);
}

.wu-work .upp-card__excerpt {
	color: var(--wu-muted);
	font-size: 16px;
	line-height: 1.55;
}

.wu-work .upp-card__link:hover {
	text-decoration: none;
}

.wu-work .wu-work__more {
	margin: 72px 0 0;
	text-align: center;
}

/* ---------- FAQ (core/group + core/details from the page file) ---------- */

.wu-faq__grid {
	display: grid;
	gap: 40px;
}

@media (min-width: 1025px) {
	.wu-faq__grid {
		grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
		gap: 80px;
		align-items: start;
	}

	.wu-faq__intro {
		position: sticky;
		top: calc(var(--wu-header-h) + 40px);
	}
}

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

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

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

.wu-faq__list {
	overflow: hidden;
	border: 1px solid var(--wu-line);
	border-radius: var(--wu-card-radius);
	background: var(--wu-surface);
}

.wu-faq__list > .wp-block-details {
	margin: 0;
	border-top: 1px solid var(--wu-line);
	transition: background-color 0.2s;
}

.wu-faq__list > .wp-block-details:first-child {
	border-top: 0;
}

.wu-faq__list > .wp-block-details:hover,
.wu-faq__list > .wp-block-details[open] {
	background: var(--wu-surface-2);
}

.wu-faq__list > .wp-block-details > summary {
	position: relative;
	padding: 22px 64px 22px 28px;
	color: var(--wu-text);
	font-size: 17px;
	font-weight: 500;
	line-height: 1.4;
	list-style: none;
	cursor: pointer;
}

.wu-faq__list > .wp-block-details > summary::-webkit-details-marker {
	display: none;
}

/* Chevron that turns when open. */
.wu-faq__list > .wp-block-details > summary::after {
	content: "";
	position: absolute;
	top: 50%;
	right: 28px;
	width: 9px;
	height: 9px;
	margin-top: -7px;
	border-right: 1.75px solid var(--wu-muted);
	border-bottom: 1.75px solid var(--wu-muted);
	transform: rotate(45deg);
	transition: transform 0.3s var(--wu-ease), border-color 0.2s, margin-top 0.3s var(--wu-ease);
}

.wu-faq__list > .wp-block-details[open] > summary::after {
	margin-top: -2px;
	border-color: var(--wu-purple);
	transform: rotate(-135deg);
}

.wu-faq__list > .wp-block-details > p {
	max-width: 62ch;
	margin: -6px 0 0;
	padding: 0 64px 24px 28px;
	color: var(--wu-muted);
	font-size: 16px;
}

@media (max-width: 767.98px) {
	.wu-faq__list > .wp-block-details > summary {
		padding: 20px 52px 20px 20px;
	}

	.wu-faq__list > .wp-block-details > summary::after {
		right: 22px;
	}

	.wu-faq__list > .wp-block-details > p {
		padding: 0 20px 22px;
	}
}

/* A text link written in a core paragraph gets its arrow from CSS. */
.wu-faq__intro .wu-textlink::after {
	content: "";
	width: 16px;
	height: 16px;
	background: currentColor;
	-webkit-mask: url("../icons/arrow-right.svg") center / contain no-repeat;
	mask: url("../icons/arrow-right.svg") center / contain no-repeat;
	transition: transform 0.2s var(--wu-ease);
}

.wu-faq__intro .wu-textlink:hover::after {
	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,
	.wu-header .wp-block-button__link:hover,
	.wu-work .upp-card__link:hover .upp-card__frame {
		transition: none;
		transform: none;
	}
}
