/*
 * Homepage section 4: the services index (VOY-911, spec KB-510).
 *
 * Loaded on the front page by the assets/sections loader (VOY-908). Tokens
 * only, no raw hex. Behaviour is assets/sections/home-services.js; it adds
 * .is-js to .vy-svc, and every closed-state rule is scoped to it, so without
 * JavaScript every panel stays open and the section reads in full.
 *
 * CONTENT EDGE and SPACING follow Ben's VOY-908 review, which supersedes the
 * spec's 112px / 80px (and mobile 56px / 20px) padding: every homepage section
 * shares the proof bar's content edge, max(40px, (width - wide) / 2), and adds
 * no top padding or block gap, so the section above sets the gap. The bottom
 * padding is 96px (64px on mobile), the proof bar's rhythm, after Ben's
 * review of section 5 found 48px too tight between the two. The percentage resolves
 * against the full-width section box.
 *
 * SERVICE PAIRS. The dither field draws both of a service's stops on one dark
 * canvas (the 500 above value 0.55, the 700 below), so it reads the two
 * primitive steps directly. Everything else paints with the surface-aware
 * --service-<name> token (design-system v2.12.0, VOY-917).
 */

.wp-block-group.vy-svc {
	--service-wordpress-500: var(--color-violet-300);
	--service-wordpress-700: var(--color-violet-450);
	--service-seo-500:       var(--color-cyan-400);
	--service-seo-700:       var(--color-cyan-550);
	--service-ai-500:        var(--color-service-ai-500);
	--service-ai-700:        var(--color-service-ai-700);
	--service-social-500:    var(--color-service-social-500);
	--service-social-700:    var(--color-service-social-700);
	--service-ads-500:       var(--color-service-ads-500);
	--service-ads-700:       var(--color-service-ads-700);
	--service-marketing-500: var(--color-magenta-400);
	--service-marketing-700: var(--color-magenta-450);

	--svc-ease: cubic-bezier(0.2, 0, 0, 1);
	--svc-500: var(--service-marketing-500);
	--svc-700: var(--service-marketing-700);

	--svc-pad: max(40px, calc((100% - var(--wp--custom--layout--wide, 1440px)) / 2));
	margin-block-start: 0;
	background: var(--bg-canvas);
	color: var(--fg-1);
	padding: 0 var(--svc-pad) 96px;
}

.vy-svc__row--wordpress { --svc-500: var(--service-wordpress-500); --svc-700: var(--service-wordpress-700); }
.vy-svc__row--seo       { --svc-500: var(--service-seo-500);       --svc-700: var(--service-seo-700); }
.vy-svc__row--ai        { --svc-500: var(--service-ai-500);        --svc-700: var(--service-ai-700); }
.vy-svc__row--social    { --svc-500: var(--service-social-500);    --svc-700: var(--service-social-700); }
.vy-svc__row--ads       { --svc-500: var(--service-ads-500);       --svc-700: var(--service-ads-700); }
.vy-svc__row--marketing { --svc-500: var(--service-marketing-500); --svc-700: var(--service-marketing-700); }

.vy-svc.alignfull > .vy-svc__inner {
	max-width: var(--wp--custom--layout--wide);
	margin-inline: auto;
}

/* Flow layout puts a block gap on every child; this section sets its own. */
.vy-svc :is(p, h2, h3, h4, ul, li, .wp-block-group, .wp-block-buttons) {
	margin: 0;
}

/* ---- Header ------------------------------------------------------------ */

.vy-svc .vy-svc__head {
	display: flex;
	justify-content: space-between;
	align-items: flex-end;
	gap: 64px;
	margin-bottom: 48px;
}
/* When the row is short (1024 to about 1280), the intro gives up width
   before the H2 does, so the headline keeps to two lines. */
.vy-svc .vy-svc__titles { max-width: 660px; flex: 1 1 auto; }
.vy-svc .vy-svc__eyebrow {
	font-family: var(--font-mono);
	font-size: 11px;
	line-height: 1.4;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--fg-4);
	margin-bottom: 16px;
}
.vy-svc .vy-svc__h2 {
	font-family: var(--font-display);
	font-weight: 500;
	font-size: 52px;
	line-height: 1.04;
	letter-spacing: -0.03em;
	color: var(--fg-1);
}
.vy-svc .vy-svc__intro {
	font-family: var(--font-body);
	font-size: 17px;
	line-height: 1.62;
	color: var(--fg-2);
	max-width: 520px;
	flex: 0 3 520px;
	min-width: 280px;
}

/* ---- Index and canvas -------------------------------------------------- */

.vy-svc .vy-svc__index {
	position: relative;
	border-bottom: 1px solid var(--border-hair);
}
.vy-svc .vy-svc__canvas {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	z-index: 0;
	pointer-events: none;
	image-rendering: pixelated;
}
.vy-svc .vy-svc__row {
	position: relative;
	z-index: 1;
	border-top: 1px solid var(--border-hair);
}

/* ---- Row header -------------------------------------------------------- */

.vy-svc .vy-svc__header {
	position: relative;
	display: grid;
	grid-template-columns: 64px minmax(0, 1fr) 360px 44px;
	align-items: center;
	column-gap: 24px;
	min-height: 116px;
	padding-block: 20px;
}
.vy-svc .vy-svc__num {
	font-family: var(--font-mono);
	font-size: 13px;
	color: var(--fg-4);
	transition: color 250ms;
}
.vy-svc .vy-svc__title {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	column-gap: 20px;
	row-gap: 6px;
	transition: transform 350ms var(--svc-ease);
}
.vy-svc .vy-svc__name {
	font-family: var(--font-display);
	font-weight: 500;
	font-size: 64px;
	line-height: 1;
	letter-spacing: -0.035em;
	color: var(--fg-4);
	transition: color 250ms;
}
.vy-svc .vy-svc__sub {
	font-family: var(--font-body);
	font-size: 16px;
	color: var(--fg-5);
	transition: color 250ms;
}
.vy-svc .vy-svc__promise {
	grid-column: 3;
	font-family: var(--font-body);
	font-size: 15px;
	line-height: 1.5;
	color: var(--fg-5);
	transition: color 250ms;
}

/* The toggle the script inserts: it covers the whole header, so the row is
   one button, and draws the 44px + in the fourth column. */
.vy-svc .vy-svc__toggle {
	position: absolute;
	inset: 0;
	z-index: 2;
	display: grid;
	grid-template-columns: 64px minmax(0, 1fr) 360px 44px;
	align-items: center;
	column-gap: 24px;
	margin: 0;
	padding: 0;
	border: 0;
	background: transparent;
	color: inherit;
	font: inherit;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}
.vy-svc .vy-svc__toggle:focus { outline: none; }
.vy-svc .vy-svc__toggle:focus-visible {
	outline: 2px solid var(--accent-bright);
	outline-offset: 2px;
}
.vy-svc .vy-svc__plus {
	grid-column: 4;
	position: relative;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	border: 1px solid var(--border-1);
	transition: border-color 250ms, background-color 250ms, transform 350ms var(--svc-ease);
}
.vy-svc .vy-svc__plus::before,
.vy-svc .vy-svc__plus::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 14px;
	height: 1.5px;
	background: var(--fg-4);
	transform: translate(-50%, -50%);
	transition: background-color 250ms;
}
.vy-svc .vy-svc__plus::after { transform: translate(-50%, -50%) rotate(90deg); }

/* Hover or focus lights the row. Open is the same, plus the filled +. */
.vy-svc .vy-svc__row:is(:has(.vy-svc__toggle:hover), :has(.vy-svc__toggle:focus-visible), .is-open) .vy-svc__num,
.vy-svc .vy-svc__row:is(:has(.vy-svc__toggle:hover), :has(.vy-svc__toggle:focus-visible), .is-open) .vy-svc__name { color: var(--fg-1); }
.vy-svc .vy-svc__row:is(:has(.vy-svc__toggle:hover), :has(.vy-svc__toggle:focus-visible), .is-open) .vy-svc__sub { color: var(--fg-3); }
.vy-svc .vy-svc__row:is(:has(.vy-svc__toggle:hover), :has(.vy-svc__toggle:focus-visible), .is-open) .vy-svc__promise { color: var(--fg-2); }
.vy-svc .vy-svc__row:is(:has(.vy-svc__toggle:hover), :has(.vy-svc__toggle:focus-visible), .is-open) .vy-svc__title { transform: translateX(14px); }
.vy-svc .vy-svc__row:is(:has(.vy-svc__toggle:hover), :has(.vy-svc__toggle:focus-visible), .is-open) .vy-svc__plus { border-color: var(--svc-500); }

.vy-svc .vy-svc__row.is-open .vy-svc__plus {
	background-color: var(--svc-500);
	transform: rotate(45deg);
}
.vy-svc .vy-svc__row.is-open .vy-svc__plus::before,
.vy-svc .vy-svc__row.is-open .vy-svc__plus::after { background: var(--bg-canvas); }

/* ---- Open panel -------------------------------------------------------- */

.vy-svc .vy-svc__panel {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 420px;
	gap: 56px;
	padding: 8px 0 48px 88px;
}
.vy-svc.is-js .vy-svc__panel[hidden] { display: none; }
.vy-svc.is-js .vy-svc__row.is-open .vy-svc__panel { animation: vy-svc-up 460ms var(--svc-ease) both; }
.vy-svc.is-js .vy-svc__row.is-open .vy-svc__list li { animation: vy-svc-up 460ms var(--svc-ease) both; }
.vy-svc.is-js .vy-svc__row.is-open .vy-svc__list li:nth-child(2) { animation-delay: 60ms; }
.vy-svc.is-js .vy-svc__row.is-open .vy-svc__list li:nth-child(3) { animation-delay: 120ms; }
.vy-svc.is-js .vy-svc__row.is-open .vy-svc__list li:nth-child(4) { animation-delay: 180ms; }
.vy-svc.is-js .vy-svc__row.is-open .vy-svc__list li:nth-child(5) { animation-delay: 240ms; }
.vy-svc.is-js .vy-svc__row.is-open .vy-svc__list li:nth-child(6) { animation-delay: 300ms; }

@keyframes vy-svc-up {
	from { opacity: 0; transform: translateY(12px); }
	to   { opacity: 1; transform: none; }
}

.vy-svc .vy-svc__main {
	display: flex;
	flex-direction: column;
	gap: 24px;
}
.vy-svc .vy-svc__lead { display: none; }
.vy-svc .vy-svc__story {
	font-family: var(--font-body);
	font-size: 18px;
	line-height: 1.62;
	color: var(--fg-1);
}
.vy-svc .vy-svc__note {
	font-family: var(--font-body);
	font-size: 15px;
	line-height: 1.55;
	color: var(--fg-3);
}
.vy-svc .vy-svc__cols {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
	gap: 40px;
	border-top: 1px solid var(--border-hair);
	padding-top: 24px;
}
.vy-svc .vy-svc__get,
.vy-svc .vy-svc__month {
	display: flex;
	flex-direction: column;
	gap: 14px;
}
.vy-svc .vy-svc__label {
	font-family: var(--font-mono);
	font-weight: 400;
	font-size: 11px;
	line-height: 1.4;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--fg-4);
}
.vy-svc .vy-svc__list {
	list-style: none;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 10px;
}
.vy-svc .vy-svc__list li,
.vy-svc .vy-svc__month-text {
	font-family: var(--font-body);
	font-size: 15px;
	line-height: 1.55;
	color: var(--fg-2);
}
.vy-svc .vy-svc__list li {
	position: relative;
	padding-left: 18px;
}
.vy-svc .vy-svc__list li::before {
	content: "";
	position: absolute;
	left: 0;
	top: 0.62em;
	width: 6px;
	height: 6px;
	background: var(--svc-500);
}

/* The solid button. className lands on the wrapper, never on the link. */
.vy-svc .vy-svc__cta { margin-top: 6px; }
.vy-svc .vy-svc__cta .wp-block-button__link {
	display: inline-flex;
	align-items: center;
	min-height: 42px;
	padding: 0 18px;
	border: 0;
	border-radius: 2px;
	background: var(--svc-500);
	color: var(--bg-canvas);
	font-family: var(--font-body);
	font-size: 14px;
	font-weight: 600;
	text-decoration: none;
	transition: filter 250ms;
}
.vy-svc .vy-svc__cta .wp-block-button__link:hover { filter: brightness(1.08); }
.vy-svc .vy-svc__cta .wp-block-button__link:focus-visible,
.vy-svc .vy-svc__links a:focus-visible {
	outline: 2px solid var(--accent-bright);
	outline-offset: 2px;
}

.vy-svc .vy-svc__side {
	display: flex;
	flex-direction: column;
	gap: 24px;
	align-self: start;
}
.vy-svc .vy-svc__result {
	padding: 28px;
	border-radius: 12px;
	background: var(--bg-raised);
	border: 1px solid color-mix(in srgb, var(--svc-500) 45%, transparent);
	display: flex;
	flex-direction: column;
	gap: 14px;
	transform: perspective(900px) rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg));
	transition: transform 160ms ease-out;
}
.vy-svc .vy-svc__result-label {
	font-family: var(--font-mono);
	font-size: 11px;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--svc-500);
}
.vy-svc .vy-svc__result-text {
	font-family: var(--font-display);
	font-size: 21px;
	line-height: 1.4;
	color: var(--fg-1);
}
.vy-svc .vy-svc__result-source {
	font-family: var(--font-mono);
	font-size: 11px;
	line-height: 1.5;
	color: var(--fg-4);
}

.vy-svc .vy-svc__links {
	list-style: none;
	padding: 0;
}
.vy-svc .vy-svc__links li { border-bottom: 1px solid var(--border-hair); }
.vy-svc .vy-svc__links a {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	min-height: 48px;
	font-family: var(--font-body);
	font-size: 15px;
	font-weight: 500;
	color: var(--fg-1);
	text-decoration: none;
}
.vy-svc .vy-svc__links a::after {
	content: "\2192" / "";
	color: var(--svc-500);
	transition: transform 250ms var(--svc-ease);
}
.vy-svc .vy-svc__links a:hover::after { transform: translateX(4px); }

/* ---- Tablet: 768 to 1023 ----------------------------------------------- */

@media (max-width: 1023px) {
	.vy-svc .vy-svc__head { flex-direction: column; align-items: flex-start; gap: 24px; }
	/* Stacked, a flex basis is a height: drop it. */
	.vy-svc .vy-svc__titles,
	.vy-svc .vy-svc__intro { flex: none; min-width: 0; }
	.vy-svc .vy-svc__header,
	.vy-svc .vy-svc__toggle { grid-template-columns: 64px minmax(0, 1fr) 44px; }
	.vy-svc .vy-svc__promise { display: none; }
	.vy-svc .vy-svc__plus { grid-column: 3; }
	.vy-svc .vy-svc__panel { grid-template-columns: minmax(0, 1fr); gap: 40px; }
}

/* ---- Mobile: under 768 ------------------------------------------------- */

@media (max-width: 767px) {
	.wp-block-group.vy-svc { padding-bottom: 64px; }
	.vy-svc .vy-svc__head { gap: 16px; margin-bottom: 28px; }
	.vy-svc .vy-svc__eyebrow { font-size: 10px; margin-bottom: 12px; }
	.vy-svc .vy-svc__h2 { font-size: 34px; line-height: 1.08; }
	.vy-svc .vy-svc__intro { font-size: 15px; line-height: 1.6; }

	.vy-svc .vy-svc__header,
	.vy-svc .vy-svc__toggle { grid-template-columns: 30px minmax(0, 1fr) 44px; column-gap: 12px; }
	.vy-svc .vy-svc__header { min-height: 96px; padding-block: 14px; }
	.vy-svc .vy-svc__num { font-size: 12px; }
	.vy-svc .vy-svc__title { flex-direction: column; align-items: flex-start; }
	.vy-svc .vy-svc__name { font-size: 32px; }
	.vy-svc .vy-svc__sub { font-size: 13px; }
	.vy-svc .vy-svc__row:is(:has(.vy-svc__toggle:hover), :has(.vy-svc__toggle:focus-visible), .is-open) .vy-svc__title { transform: none; }

	/* Without the script the promise stays in the header, under the name. */
	.vy-svc:not(.is-js) .vy-svc__promise { display: block; grid-column: 2; }

	/* One stacked column in the order KB-510 gives. The wrappers dissolve so
	   their children can be ordered as siblings. */
	.vy-svc .vy-svc__panel {
		display: flex;
		flex-direction: column;
		gap: 16px;
		padding: 0 0 28px;
	}
	.vy-svc .vy-svc__main,
	.vy-svc .vy-svc__side,
	.vy-svc .vy-svc__cols,
	.vy-svc .vy-svc__get,
	.vy-svc .vy-svc__month { display: contents; }
	.vy-svc .vy-svc__lead {
		display: block;
		order: 0;
		font-family: var(--font-display);
		font-size: 20px;
		line-height: 1.3;
		color: var(--fg-1);
	}
	.vy-svc .vy-svc__story { order: 1; font-size: 15px; }
	.vy-svc .vy-svc__note { order: 2; }
	.vy-svc .vy-svc__get > .vy-svc__label { order: 3; border-top: 1px solid var(--border-hair); padding-top: 16px; }
	.vy-svc .vy-svc__list { order: 4; }
	.vy-svc .vy-svc__month > .vy-svc__label { order: 5; }
	.vy-svc .vy-svc__month-text { order: 6; }
	.vy-svc .vy-svc__cta { order: 7; }
	.vy-svc .vy-svc__cta .wp-block-button__link { min-height: 44px; }
	.vy-svc .vy-svc__result { order: 8; padding: 20px; transform: none; }
	.vy-svc .vy-svc__result-text { font-size: 18px; }
	.vy-svc .vy-svc__links { order: 9; }
}

/* ---- Reduced motion: instant state changes ----------------------------- */

@media (prefers-reduced-motion: reduce) {
	.vy-svc *,
	.vy-svc *::before,
	.vy-svc *::after {
		transition: none !important;
		animation: none !important;
	}
	.vy-svc .vy-svc__result { transform: none; }
}
