/*
Flight Path widget (AW Flight Path): the five Flight Check steps and the after-handover bar.
Phone first: a dashed rail with an orange fill and a ticked node per step.
From 1200px: the 1440 x 1190 S-curve stage from the prototype, scaled with container query units.
At rest the path is complete (fill 100%, every step passed), so Calm mode and JavaScript off are
finished states by construction. T-037 adds the scroll behaviour and only changes --fill and
data-state. Every colour, font and size comes from tokens.css; the geometry is the prototype's.
Last task: T-036. Date: 2026-10-21.
*/

.aw-flight-path {
	position: relative;
	padding-left: max(var(--pad), env(safe-area-inset-left, 0px));
	padding-right: max(var(--pad), env(safe-area-inset-right, 0px));
	color: var(--rule);
}

/* ---------- Vertical list (below 1200px) ---------- */

.aw-flight-path__list {
	position: relative;
	margin: 48px 0 0;
	padding: 0 0 0 44px;
	list-style: none;
}

/* The rail is drawn by the list itself so the ordered list only holds the five steps. */
.aw-flight-path__list::before,
.aw-flight-path__list::after {
	content: "";
	position: absolute;
	left: 15px;
	top: 8px;
	bottom: 8px;
	width: 3px;
}

.aw-flight-path__list::before {
	background: repeating-linear-gradient(180deg, var(--wait) 0 8px, transparent 8px 18px);
}

/* --fill is 1 at rest and is the only thing T-037 writes. */
.aw-flight-path__list::after {
	background: var(--signal);
	transform-origin: top;
	transform: scaleY(var(--fill, 1));
}

.aw-flight-path__step {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 6px;
	padding-bottom: 40px;
}

.aw-flight-path__step:last-child {
	padding-bottom: 8px;
}

.aw-flight-path__node {
	position: absolute;
	left: -44px;
	top: 14px;
	display: grid;
	place-items: center;
	width: 32px;
	height: 32px;
	border: 3px solid var(--wait);
	border-radius: 50%;
	background: var(--paper);
	transition: background-color var(--t-state) ease, border-color var(--t-state) ease;
}

/* The "current" halo is a ring that scales and fades, so it animates on transform and opacity only. */
.aw-flight-path__node::after {
	content: "";
	position: absolute;
	inset: -15px;
	border-radius: 50%;
	background: color-mix(in srgb, var(--signal) 18%, transparent);
	opacity: 0;
	transform: scale(0.6);
	transition: transform var(--t-state) var(--ease-out), opacity var(--t-state) ease;
	pointer-events: none;
}

.aw-flight-path__node svg,
.aw-flight-path__node i {
	grid-area: 1 / 1;
	opacity: 0;
	transition: opacity 250ms ease;
}

.aw-flight-path__node i {
	width: 11px;
	height: 11px;
	border-radius: 50%;
	background: var(--ink);
}

.aw-flight-path__tick {
	fill: none;
	stroke: var(--ink);
	stroke-width: 2.6;
	stroke-linecap: round;
	stroke-linejoin: round;
}

/* The tick draws itself when its step passes. Passed (the rest state) is fully drawn. */
.aw-flight-path__tick path {
	stroke-dasharray: 15;
	stroke-dashoffset: 15;
	transition: stroke-dashoffset 280ms var(--ease-out) 120ms;
}

.aw-flight-path [data-state="passed"] .aw-flight-path__tick path,
.aw-flight-path .aw-flight-path__node[data-state="passed"] .aw-flight-path__tick path {
	stroke-dashoffset: 0;
}

.aw-flight-path__num {
	font-family: var(--font-display);
	font-weight: 800;
	font-size: 96px;
	line-height: 0.8;
	color: transparent;
	-webkit-text-stroke: 1.5px var(--wait);
	transition: color var(--t-state) ease, -webkit-text-stroke-color var(--t-state) ease;
}

.aw-flight-path__step h3,
.aw-flight-path__block h3 {
	display: flex;
	align-items: baseline;
	flex-wrap: wrap;
	gap: 12px;
	margin: 0;
	font-family: var(--font-display);
	font-weight: 800;
	font-size: 40px;
	line-height: 0.95;
	text-transform: uppercase;
}

.aw-flight-path__state {
	font-size: 14px;
	font-weight: 700;
	letter-spacing: 0.14em;
	color: var(--muted);
}

.aw-flight-path__step p,
.aw-flight-path__block p {
	max-width: 46ch;
	margin: 0;
	font-size: 18px;
	line-height: 1.45;
	color: var(--rule);
}

/* States. T-037 writes data-state; at rest every step is "passed".
   The selector covers a node inside a step or block, and a stage node that carries the state itself. */
.aw-flight-path [data-state="passed"] .aw-flight-path__node,
.aw-flight-path .aw-flight-path__node[data-state="passed"] {
	background: var(--signal);
	border-color: var(--signal);
}

.aw-flight-path [data-state="passed"] .aw-flight-path__node svg,
.aw-flight-path .aw-flight-path__node[data-state="passed"] svg {
	opacity: 1;
}

.aw-flight-path [data-state="passed"] .aw-flight-path__num {
	-webkit-text-stroke-color: var(--ink);
}

.aw-flight-path [data-state="current"] .aw-flight-path__node,
.aw-flight-path .aw-flight-path__node[data-state="current"] {
	background: var(--signal);
	border-color: var(--signal);
}

.aw-flight-path [data-state="current"] .aw-flight-path__node::after,
.aw-flight-path .aw-flight-path__node[data-state="current"]::after {
	opacity: 1;
	transform: scale(1);
}

/* Live only: waiting steps sit back until the line reaches them. At rest nothing is dimmed.
   0.7 keeps the paragraph above 4.5:1 on paper. */
.aw-flight-path.is-live .aw-flight-path__step h3,
.aw-flight-path.is-live .aw-flight-path__step p,
.aw-flight-path.is-live .aw-flight-path__block > div > h3,
.aw-flight-path.is-live .aw-flight-path__block > div > p {
	transition: opacity var(--t-state) ease;
}

.aw-flight-path.is-live .aw-flight-path__step[data-state="waiting"] h3,
.aw-flight-path.is-live .aw-flight-path__step[data-state="waiting"] p,
.aw-flight-path.is-live .aw-flight-path__block[data-state="waiting"] > div > h3,
.aw-flight-path.is-live .aw-flight-path__block[data-state="waiting"] > div > p {
	opacity: 0.7;
}

/* Arrival pops. flight-check.js adds .is-arrive to a node or number for one animation, then removes it. */
.aw-flight-path__node.is-arrive {
	animation: aw-flight-path-node-pop 380ms var(--ease-out);
}

.aw-flight-path__num.is-arrive {
	transform-origin: left center;
	animation: aw-flight-path-num-pop 420ms var(--ease-out);
}

.aw-flight-path__block--r .aw-flight-path__num.is-arrive {
	transform-origin: right center;
}

@keyframes aw-flight-path-node-pop {
	0% {
		transform: scale(1);
	}
	40% {
		transform: scale(1.18);
	}
	100% {
		transform: scale(1);
	}
}

@keyframes aw-flight-path-num-pop {
	0% {
		transform: scale(0.94);
	}
	100% {
		transform: scale(1);
	}
}

/* The pen tip: a small ink aircraft (orange would vanish on the orange line) that flies the head of the line, nose along the path. Made by
   flight-check.js, only while live. The element is moved and turned by transform, so the beat and
   the ring live on its pseudo-elements. Without CSS masks it falls back to a plain dot. */
.aw-flight-path__pen {
	position: absolute;
	left: 0;
	top: 0;
	width: 26px;
	height: 26px;
	margin: -13px 0 0 -13px;
	opacity: 0;
	transition: opacity 200ms ease;
	pointer-events: none;
	will-change: transform;
}

.aw-flight-path__pen::before {
	content: "";
	position: absolute;
	inset: 6px;
	border-radius: 50%;
	background: var(--ink);
}

@supports (mask-image: url("x.svg")) or (-webkit-mask-image: url("x.svg")) {
	.aw-flight-path__pen::before {
		inset: 0;
		border-radius: 0;
		-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M23 12C23 10.9 22.2 10.2 21 10.2L15.5 10.2L10.5 3.5L8 3.5L11 10.2L5 10.2L3 7.5L1.5 7.5L2.8 12L1.5 16.5L3 16.5L5 13.8L11 13.8L8 20.5L10.5 20.5L15.5 13.8L21 13.8C22.2 13.8 23 13.1 23 12Z'/%3E%3C/svg%3E") center / contain no-repeat;
		mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M23 12C23 10.9 22.2 10.2 21 10.2L15.5 10.2L10.5 3.5L8 3.5L11 10.2L5 10.2L3 7.5L1.5 7.5L2.8 12L1.5 16.5L3 16.5L5 13.8L11 13.8L8 20.5L10.5 20.5L15.5 13.8L21 13.8C22.2 13.8 23 13.1 23 12Z'/%3E%3C/svg%3E") center / contain no-repeat;
	}
}

.aw-flight-path__pen::after {
	content: "";
	position: absolute;
	inset: -6px;
	border: 2px solid var(--signal);
	border-radius: 50%;
	opacity: 0.35;
}

.aw-flight-path__pen.is-on {
	opacity: 1;
}

/* Motion on only: the aircraft beats and a ring spreads from it, so the eye follows the head of the line. */
html.motion-on .aw-flight-path__pen::before {
	animation: aw-flight-path-pen-beat 1s var(--ease-io) infinite;
}

html.motion-on .aw-flight-path__pen::after {
	animation: aw-flight-path-pen-ring 1s ease-out infinite;
}

@keyframes aw-flight-path-pen-beat {
	0%,
	100% {
		transform: scale(0.88);
	}
	50% {
		transform: scale(1.25);
	}
}

@keyframes aw-flight-path-pen-ring {
	0% {
		transform: scale(0.8);
		opacity: 0.6;
	}
	100% {
		transform: scale(1.8);
		opacity: 0;
	}
}

.aw-flight-path [data-state="current"] .aw-flight-path__node i,
.aw-flight-path .aw-flight-path__node[data-state="current"] i {
	opacity: 1;
}

.aw-flight-path [data-state="current"] .aw-flight-path__num {
	color: var(--signal);
	-webkit-text-stroke-color: var(--signal-text);
}

.aw-flight-path [data-state="current"] .aw-flight-path__state {
	color: var(--signal-text);
}

/* The "Checking" tag blinks while the line is on its step, then the script swaps it for "Passed". */
html.motion-on .aw-flight-path [data-state="current"] .aw-flight-path__state {
	animation: aw-flight-path-checking 1s ease-in-out infinite;
}

@keyframes aw-flight-path-checking {
	0%,
	100% {
		opacity: 1;
	}
	50% {
		opacity: 0.15;
	}
}

/* "Passed" arrives instead of snapping in over "Checking". */
.aw-flight-path__state.is-arrive {
	animation: aw-flight-path-tag-in 280ms var(--ease-out);
}

@keyframes aw-flight-path-tag-in {
	from {
		opacity: 0;
		transform: translateY(4px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* ---------- After-handover bar ---------- */

.aw-flight-path__after {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 14px 32px;
	margin-top: 8px;
	padding: 24px max(24px, var(--pad));
	background: var(--ink);
	color: var(--paper);
}

.aw-flight-path__tag {
	display: flex;
	align-items: center;
	gap: 12px;
	font-family: var(--font-display);
	font-weight: 700;
	font-size: 15px;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--signal);
}

.aw-flight-path__dot {
	flex: none;
	width: 10px;
	height: 10px;
	border-radius: 50%;
	background: var(--signal);
}

html.motion-on .aw-flight-path__dot {
	animation: aw-flight-path-pulse 1.8s ease-in-out infinite;
}

@keyframes aw-flight-path-pulse {
	0%,
	100% {
		opacity: 1;
	}
	50% {
		opacity: 0.3;
	}
}

.aw-flight-path__after h3 {
	margin: 0;
	font-family: var(--font-display);
	font-weight: 800;
	font-size: clamp(30px, 3vw, 40px);
	line-height: 0.95;
	text-transform: uppercase;
}

.aw-flight-path__after p {
	margin: 0;
	font-size: 16px;
	color: var(--stone);
}

.aw-flight-path__beat {
	flex: 1 1 200px;
	min-width: 120px;
	height: 44px;
}

.aw-flight-path__beat-track {
	fill: none;
	stroke: var(--muted);
	stroke-width: 2;
	stroke-linejoin: round;
}

.aw-flight-path__beat-pulse {
	fill: none;
	stroke: var(--signal);
	stroke-width: 3;
	stroke-linejoin: round;
	stroke-dasharray: 110 700;
}

html.motion-on .aw-flight-path__beat-pulse {
	animation: aw-flight-path-beat 2.8s linear infinite;
}

@keyframes aw-flight-path-beat {
	from {
		stroke-dashoffset: 810;
	}
	to {
		stroke-dashoffset: 0;
	}
}

.aw-flight-path__when {
	font-family: var(--font-display);
	font-weight: 700;
	font-size: 15px;
	letter-spacing: 0.14em;
	text-transform: uppercase;
}

/* ---------- S-curve stage (1200px and up) ---------- */

.aw-flight-path__stage-wrap {
	display: none;
}

@media (min-width: 1200px) {
	/* The vertical list stays in the page for screen readers and search engines. */
	.aw-flight-path__list {
		position: absolute;
		width: 1px;
		height: 1px;
		margin: -1px;
		padding: 0;
		border: 0;
		overflow: hidden;
		clip: rect(0 0 0 0);
		white-space: nowrap;
	}

	/* Bleeds into the side gutters up to 1440px, as the prototype's .fc-wide does. */
	.aw-flight-path__stage-wrap {
		display: block;
		position: relative;
		width: min(1440px, calc(100% + 2 * var(--pad)));
		margin-left: max(calc(-1 * var(--pad)), calc((100% - 1440px) / 2));
		margin-top: 40px;
		aspect-ratio: 1440 / 1190;
		container-type: inline-size;
	}

	.aw-flight-path__stage {
		position: absolute;
		inset: 0;
	}

	.aw-flight-path__track {
		position: absolute;
		inset: 0;
		width: 100%;
		height: 100%;
	}

	.aw-flight-path__dash {
		fill: none;
		stroke: var(--wait);
		stroke-width: 3;
		stroke-dasharray: 8 10;
	}

	.aw-flight-path__draw {
		fill: none;
		stroke: var(--signal);
		stroke-width: 5;
	}

	/* Stage geometry: the prototype's 1440 x 1190 coordinates as percentages. */
	.aw-flight-path__stage .aw-flight-path__node {
		left: auto;
		top: auto;
		width: 2.2222cqw;
		height: auto;
		aspect-ratio: 1;
		border-width: 0.2083cqw;
	}

	.aw-flight-path__stage .aw-flight-path__node svg {
		width: 1.25cqw;
		height: 1.25cqw;
	}

	.aw-flight-path__stage .aw-flight-path__node i {
		width: 0.7639cqw;
		height: 0.7639cqw;
	}

	.aw-flight-path__stage .aw-flight-path__node::after {
		inset: calc(-0.8333cqw - 0.2083cqw);
	}

	.aw-flight-path__pen {
		width: 1.8056cqw;
		height: 1.8056cqw;
		margin: -0.9028cqw 0 0 -0.9028cqw;
	}

	.aw-flight-path__pen::after {
		inset: -0.4167cqw;
	}

	.aw-flight-path__stage .aw-flight-path__node[data-node="0"] {
		left: 9.6528%;
		top: 13.3613%;
	}

	.aw-flight-path__stage .aw-flight-path__node[data-node="1"] {
		left: 88.125%;
		top: 31.0084%;
	}

	.aw-flight-path__stage .aw-flight-path__node[data-node="2"] {
		left: 9.6528%;
		top: 48.6555%;
	}

	.aw-flight-path__stage .aw-flight-path__node[data-node="3"] {
		left: 88.125%;
		top: 66.3025%;
	}

	.aw-flight-path__stage .aw-flight-path__node[data-node="4"] {
		left: 9.6528%;
		top: 83.9496%;
	}

	.aw-flight-path__block {
		position: absolute;
		display: flex;
		align-items: center;
		gap: 1.9444cqw;
		width: 54.1667%;
	}

	.aw-flight-path__block > div {
		display: flex;
		flex-direction: column;
		gap: 0.4167cqw;
		min-width: 0;
	}

	.aw-flight-path__block--r {
		flex-direction: row-reverse;
		text-align: right;
	}

	/* Right-hand steps put the state tag on the left of the title, as the prototype does. */
	.aw-flight-path__block--r h3 {
		flex-direction: row-reverse;
		justify-content: flex-start;
	}

	.aw-flight-path__block--r p {
		margin-left: auto;
	}

	.aw-flight-path__block .aw-flight-path__num {
		flex: none;
		font-size: 10.4167cqw;
		-webkit-text-stroke-width: 0.1042cqw;
	}

	.aw-flight-path__block h3 {
		gap: 0.8333cqw;
		font-size: 3.1944cqw;
	}

	.aw-flight-path__block .aw-flight-path__state {
		font-size: 0.9722cqw;
	}

	.aw-flight-path__block p {
		max-width: 46ch;
		font-size: 1.25cqw;
		line-height: 1.45;
	}

	.aw-flight-path__block[data-block="0"] {
		left: 20.8333%;
		top: 8.4034%;
	}

	.aw-flight-path__block[data-block="1"] {
		left: 25%;
		top: 26.0504%;
	}

	.aw-flight-path__block[data-block="2"] {
		left: 20.8333%;
		top: 43.6975%;
	}

	.aw-flight-path__block[data-block="3"] {
		left: 25%;
		top: 61.3445%;
	}

	.aw-flight-path__block[data-block="4"] {
		left: 20.8333%;
		top: 78.9916%;
	}

	.aw-flight-path__after {
		margin-top: 0;
	}
}
