/*
 * Each card: a title, the nodes a request goes through (the highlighted one in
 * bold), then what happens, lined up across the cards. A night background
 * makes the highlighted card.
 * Qualified to outweigh the core layout rules, printed later.
 */
.wp-block-group.is-style-flows {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: var(--wp--preset--spacing--16);
	counter-reset: portfolio-flow;
}

.wp-block-group.is-style-flows > * {
	--portfolio-flow-duration: var(--wp--custom--duration--flow);
	--portfolio-flow-step: calc(var(--wp--custom--control--node) + var(--wp--preset--spacing--36));

	counter-increment: portfolio-flow;
	display: grid;
	grid-row: span 3;
	grid-template-rows: subgrid;
	gap: var(--wp--preset--spacing--16);
	margin: 0;
}

.wp-block-group.is-style-flows > .has-night-background-color {
	--portfolio-flow-duration: var(--wp--custom--duration--flow-fast);

	border-color: var(--wp--preset--color--night);
	background: var(--wp--preset--color--night);
}

.is-style-flows > * > p:first-child {
	display: flex;
	gap: var(--wp--preset--spacing--10);
	align-items: center;
	font-size: var(--wp--preset--font-size--16);
	font-weight: var(--wp--custom--font-weight--semibold);
}

.is-style-flows > * > p:first-child::before {
	content: counter(portfolio-flow);
	display: flex;
	flex: none;
	align-items: center;
	justify-content: center;
	width: var(--wp--custom--control--pill);
	height: var(--wp--custom--control--pill);
	border-radius: var(--wp--custom--radius--8);
	background: var(--wp--preset--color--tint);
	font-size: var(--wp--preset--font-size--13);
	color: var(--wp--preset--color--blue);
}

.is-style-flows > .has-night-background-color > p:first-child::before {
	background: var(--wp--preset--color--blue);
	color: var(--wp--preset--color--white);
}

.is-style-flows > * > p:last-child {
	font-size: var(--wp--preset--font-size--15);
	line-height: var(--wp--custom--line-height--relaxed);
	color: var(--wp--preset--color--grey);
}

.is-style-flows > .has-night-background-color > p:last-child {
	color: var(--wp--preset--color--grey-on-dark);
}

/* The connector runs behind the nodes, from the first to the last. */
.is-style-flows .wp-block-list {
	--portfolio-flow-connector: var(--wp--custom--color--connector);

	position: relative;
	display: flex;
	flex-direction: column;
	gap: var(--wp--preset--spacing--36);
	align-items: flex-start;
	align-self: start;
	margin: 0;
	padding: 0;
	background-image: linear-gradient(var(--portfolio-flow-connector), var(--portfolio-flow-connector));
	background-position: var(--wp--preset--spacing--20) calc(var(--wp--custom--control--node) / 2);
	background-size: var(--wp--custom--size--rail) calc(100% - var(--wp--custom--control--node));
	background-repeat: no-repeat;
	list-style: none;
}

.is-style-flows .has-night-background-color .wp-block-list {
	--portfolio-flow-connector: var(--wp--custom--color--on-night-outline);
}

/* The packet, centered on the connector, starts on the first node. */
.is-style-flows .wp-block-list::before {
	content: "";
	position: absolute;
	top: calc((var(--wp--custom--control--node) - var(--wp--custom--size--packet)) / 2);
	left: calc(var(--wp--preset--spacing--20) + (var(--wp--custom--size--rail) - var(--wp--custom--size--packet)) / 2);
	width: var(--wp--custom--size--packet);
	height: var(--wp--custom--size--packet);
	border-radius: var(--wp--custom--radius--pill);
	background: var(--wp--preset--color--blue);
	box-shadow: 0 0 0 var(--wp--preset--spacing--4) var(--wp--custom--color--blue-veil);
	opacity: 0;
	pointer-events: none;
}

.is-style-flows .has-night-background-color .wp-block-list::before {
	background: var(--wp--preset--color--white);
	box-shadow: 0 0 0 var(--wp--preset--spacing--4) var(--wp--custom--color--on-night-ring);
}

.is-style-flows li {
	position: relative;
	z-index: 1;
	display: inline-flex;
	align-items: center;
	box-sizing: border-box;
	height: var(--wp--custom--control--node);
	padding-inline: var(--wp--preset--spacing--12);
	border-radius: var(--wp--custom--radius--10);
	background: var(--wp--preset--color--tint);
	font-size: var(--wp--preset--font-size--13);
	font-weight: var(--wp--custom--font-weight--semibold);
	white-space: nowrap;
	color: var(--wp--preset--color--ink);
}

.is-style-flows .has-night-background-color li {
	background: var(--wp--custom--color--on-night-raised);
	color: var(--wp--preset--color--white);
}

.is-style-flows .wp-block-list li:has(strong) {
	background: var(--wp--preset--color--blue);
	color: var(--wp--preset--color--white);
}

.is-style-flows li strong {
	font-weight: inherit;
}

/* The ring a node shows when the packet reaches it. */
.is-style-flows li::after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: inherit;
	box-shadow: 0 0 0 var(--wp--preset--spacing--6) var(--portfolio-flow-ring, var(--wp--preset--color--blue));
	opacity: 0;
}

.is-style-flows li:first-child::after {
	box-shadow: 0 0 0 var(--wp--custom--border--accent) var(--wp--preset--color--blue);
}

.is-style-flows .has-night-background-color li::after {
	--portfolio-flow-ring: var(--wp--preset--color--white);
}

@media (min-width: 1001px) {

	.wp-block-group.is-style-flows {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

@media (prefers-reduced-motion: no-preference) {

	.is-style-flows .wp-block-list::before {
		animation: portfolio-flow-two var(--portfolio-flow-duration) var(--wp--custom--easing--in-out) infinite;
	}

	.is-style-flows .wp-block-list:has(> li:nth-child(3))::before {
		animation-name: portfolio-flow-three;
	}

	.is-style-flows li,
	.is-style-flows li::after {
		animation-duration: var(--portfolio-flow-duration);
		animation-timing-function: ease;
		animation-iteration-count: infinite;
	}

	.is-style-flows li:first-child::after {
		animation-name: portfolio-flow-ring-first;
	}

	.is-style-flows li:nth-child(2):not(:last-child) {
		animation-name: portfolio-flow-node-middle;
	}

	.is-style-flows li:nth-child(2):not(:last-child)::after {
		animation-name: portfolio-flow-ring-middle;
	}

	.is-style-flows li:nth-child(3) {
		animation-name: portfolio-flow-node-last;
	}

	.is-style-flows li:nth-child(3)::after {
		animation-name: portfolio-flow-ring-last;
	}

	.is-style-flows li:nth-child(2):last-child {
		animation-name: portfolio-flow-node-second;
	}

	.is-style-flows li:nth-child(2):last-child::after {
		animation-name: portfolio-flow-ring-second;
	}

	.is-style-flows > :nth-child(3) .wp-block-list::before,
	.is-style-flows > :nth-child(3) li,
	.is-style-flows > :nth-child(3) li::after {
		animation-delay: calc(-0.5 * var(--portfolio-flow-duration));
	}
}

@keyframes portfolio-flow-two {

	0% {
		opacity: 0;
		translate: 0;
	}

	10% {
		opacity: 1;
	}

	70% {
		opacity: 1;
		translate: 0 var(--portfolio-flow-step);
	}

	90%,
	100% {
		opacity: 0;
		translate: 0 var(--portfolio-flow-step);
	}
}

@keyframes portfolio-flow-three {

	0% {
		opacity: 0;
		translate: 0;
	}

	6% {
		opacity: 1;
	}

	40%,
	52% {
		opacity: 1;
		translate: 0 var(--portfolio-flow-step);
	}

	86% {
		opacity: 1;
		translate: 0 calc(2 * var(--portfolio-flow-step));
	}

	96%,
	100% {
		opacity: 0;
		translate: 0 calc(2 * var(--portfolio-flow-step));
	}
}

@keyframes portfolio-flow-ring-first {

	0%,
	8% {
		opacity: 0.35;
	}

	16%,
	100% {
		opacity: 0;
	}
}

@keyframes portfolio-flow-node-middle {

	0%,
	38%,
	56%,
	100% {
		scale: 1;
	}

	44% {
		scale: 1.04;
	}
}

@keyframes portfolio-flow-ring-middle {

	0%,
	38%,
	56%,
	100% {
		opacity: 0;
	}

	44% {
		opacity: 0.3;
	}
}

@keyframes portfolio-flow-node-last {

	0%,
	84%,
	100% {
		scale: 1;
	}

	90% {
		scale: 1.04;
	}
}

@keyframes portfolio-flow-ring-last {

	0%,
	84%,
	100% {
		opacity: 0;
	}

	90% {
		opacity: 0.3;
	}
}

@keyframes portfolio-flow-node-second {

	0%,
	66%,
	90%,
	100% {
		scale: 1;
	}

	74% {
		scale: 1.05;
	}
}

@keyframes portfolio-flow-ring-second {

	0%,
	66%,
	90%,
	100% {
		opacity: 0;
	}

	74% {
		opacity: 0.22;
	}
}
