.delivery-demo {
	--delivery-accent: light-dark(#087b6b, #48dbc5);
	--delivery-warn: light-dark(#895006, #ffd085);
	margin: 26px 0 34px;
	padding: clamp(16px, 3vw, 28px);
	border: 1px solid var(--rule);
	border-top: 5px solid var(--delivery-accent);
	border-radius: 12px;
	background: var(--panel);
	font-size: 16px;
	line-height: 1.5;
}
.delivery-demo [hidden] {
	display: none;
}
.delivery-demo-heading {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 10px 18px;
}
.delivery-demo .delivery-demo-heading h3 {
	margin: 0;
	font-size: 24px;
	letter-spacing: -0.6px;
}
.delivery-simulation {
	color: var(--sub);
	font-size: 13px;
}
.delivery-demo .delivery-intro {
	margin: 12px 0 20px;
}
.delivery-chapters {
	display: flex;
	list-style: none;
	padding: 0;
	margin: 0 0 22px;
	gap: 6px;
}
.delivery-chapters li {
	flex: 1;
	border-bottom: 3px solid var(--rule);
	padding: 0 0 8px;
	font-size: 14px;
	color: var(--sub);
}
.delivery-chapters li[aria-current] {
	border-color: var(--delivery-accent);
	color: var(--ink);
	font-weight: 700;
}
.delivery-stage {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 52px minmax(0, 1fr);
	align-items: stretch;
}
.delivery-panel {
	min-width: 0;
	padding: 16px;
	background: var(--wash);
	border-radius: 8px;
	display: flex;
	flex-direction: column;
}
.delivery-demo h4 {
	font:
		600 16px/1.35 'DM Sans',
		sans-serif;
	margin: 0;
}
.delivery-panel svg {
	width: 78px;
	height: 52px;
	margin: 14px 0 10px;
	stroke: var(--delivery-accent);
	stroke-width: 2.5;
	fill: none;
	stroke-linejoin: round;
}
.delivery-panel strong {
	font:
		600 clamp(20px, 2.2vw, 27px)/1.15 'Space Grotesk',
		sans-serif;
	display: block;
	min-height: 64px;
	overflow-wrap: break-word;
}
.delivery-panel > span:not(.delivery-parcel) {
	font-size: 13px;
	margin: 8px 0;
	color: var(--sub);
}
.delivery-demo .delivery-panel p {
	font-size: 14px;
	margin: 0;
}
.delivery-wire {
	position: relative;
	align-self: center;
	height: 3px;
	background: var(--delivery-accent);
}
.delivery-wire::after {
	content: '';
	position: absolute;
	right: 0;
	top: -4px;
	width: 9px;
	height: 9px;
	border-top: 2px solid var(--delivery-accent);
	border-right: 2px solid var(--delivery-accent);
	transform: rotate(45deg);
}
.delivery-wire span {
	position: absolute;
	width: 10px;
	height: 10px;
	border-radius: 50%;
	top: -4px;
	background: var(--delivery-accent);
	opacity: 0;
}
.delivery-demo[data-connected='false'] .delivery-wire {
	background: repeating-linear-gradient(90deg, var(--sub) 0 6px, transparent 6px 12px);
}
.delivery-demo[data-connected='false'] .delivery-wire::after {
	display: none;
}
.delivery-signals {
	display: flex;
	justify-content: space-between;
	gap: 12px;
	margin: 12px 0 20px;
	font-size: 13px;
	color: var(--sub);
}
.delivery-signals span:last-child {
	text-align: right;
}
.delivery-demo[data-connected='true'] [data-connection] {
	color: var(--delivery-accent);
}
.delivery-demo:is([data-stage='3'], [data-stage='4']) [data-freshness] {
	color: var(--delivery-warn);
	font-weight: 700;
}
.delivery-story {
	min-height: 115px;
	border-top: 1px solid var(--rule);
	padding-top: 18px;
}
.delivery-demo .delivery-story h4 {
	font-size: 18px;
}
.delivery-demo .delivery-story p {
	margin: 8px 0 0;
}
.delivery-controls {
	display: flex;
	flex-wrap: wrap;
	gap: 12px 20px;
	align-items: center;
	margin-top: 20px;
}
.delivery-controls .button {
	text-align: left;
	white-space: normal;
}
.delivery-history {
	margin-top: 20px;
	border-top: 1px solid var(--rule);
	padding-top: 18px;
}
.delivery-demo .delivery-history p {
	margin: 12px 0 0;
}
.delivery-history ol {
	list-style: none;
	padding: 0;
	margin: 12px 0;
}
.delivery-history li {
	display: flex;
	gap: 20px;
	padding: 7px 0;
	border-bottom: 1px solid var(--rule);
}
.delivery-history time {
	color: var(--sub);
}
.delivery-demo .delivery-caption {
	margin: 20px 0 0;
	font-size: 12px;
	color: var(--sub);
}
@media (prefers-reduced-motion: no-preference) {
	.delivery-demo:is([data-stage='1'], [data-stage='2'], [data-stage='5']) .delivery-wire span {
		animation: delivery-packet 0.35s ease-out;
	}
	.motion-paused .delivery-demo .delivery-wire span {
		animation: none;
	}
}
@keyframes delivery-packet {
	from {
		left: 0;
		opacity: 1;
	}
	to {
		left: calc(100% - 10px);
		opacity: 0;
	}
}
@media (max-width: 600px) {
	.delivery-stage {
		grid-template-columns: minmax(0, 1fr) 24px minmax(0, 1fr);
	}
	.delivery-panel {
		padding: 12px;
	}
	.delivery-demo .delivery-panel h4 {
		font-size: 14px;
		min-height: 38px;
	}
	.delivery-panel strong {
		font-size: 21px;
		min-height: 74px;
	}
	.delivery-panel svg {
		width: 60px;
	}
	.delivery-chapters li {
		font-size: 13px;
	}
	.delivery-controls .button {
		width: 100%;
	}
	.delivery-story {
		min-height: 160px;
	}
}

@media (prefers-reduced-motion: no-preference) {
	.delivery-demo[data-stage='2'] .delivery-wire span {
		animation-name: delivery-live-packet;
	}
	.motion-paused .delivery-demo[data-stage='2'] .delivery-wire span {
		animation: none;
	}
}
/* A different name restarts the packet between consecutive connected moments. */
@keyframes delivery-live-packet {
	from {
		left: 0;
		opacity: 1;
	}
	to {
		left: calc(100% - 10px);
		opacity: 0;
	}
}

@media (max-width: 420px) {
	.delivery-panel {
		padding: 10px;
	}
	.delivery-panel strong {
		font-size: clamp(18px, 5.4vw, 21px);
	}
	.delivery-panel p {
		display: none;
	}
	.delivery-panel svg {
		height: 36px;
		margin: 8px 0;
	}
	.delivery-demo .delivery-demo-heading h3 {
		font-size: 21px;
	}
	.delivery-demo .delivery-intro {
		font-size: 14px;
	}
	.delivery-demo .delivery-story p {
		font-size: 14px;
	}
	.delivery-story {
		min-height: 140px;
	}
}

.delivery-disclosure {
	margin: 24px 0 32px;
	border: 1px solid var(--rule);
	border-radius: 12px;
	background: var(--panel);
}
.delivery-disclosure > summary {
	cursor: pointer;
	padding: 18px 22px;
	font-weight: 700;
	color: var(--action);
}
.delivery-disclosure > .delivery-demo {
	margin: 0;
	border: 0;
}

.delivery-current-card {
	padding: 12px;
	border: 1px solid var(--delivery-accent);
	border-left-width: 4px;
	border-radius: 8px;
	background: var(--panel);
}
.delivery-current-card .delivery-state-label {
	display: block;
	font-size: 11px;
	font-weight: 700;
	color: var(--delivery-accent);
	margin-bottom: 8px;
}
.delivery-current-card [data-customer-time] {
	display: block;
	font-size: 12px;
	color: var(--sub);
	margin: 8px 0;
}
.delivery-demo:is([data-stage='3'], [data-stage='4']) .delivery-current-card {
	border-color: var(--delivery-warn);
}
.delivery-demo:is([data-stage='3'], [data-stage='4']) .delivery-state-label {
	color: var(--delivery-warn);
}
.delivery-history [data-history-result] {
	padding: 16px;
	border: 1px solid var(--rule);
	border-radius: 8px;
	background: var(--wash);
}
.delivery-history li {
	position: relative;
	display: grid;
	grid-template-columns: 12px 42px minmax(0, 1fr);
	gap: 10px;
	border: 0;
	padding: 8px 0;
}
.delivery-history li:not(:last-child)::after {
	content: '';
	position: absolute;
	width: 2px;
	left: 5px;
	top: 20px;
	bottom: -13px;
	background: var(--rule);
}
.delivery-history-marker {
	width: 12px;
	height: 12px;
	margin-top: 5px;
	border: 2px solid var(--delivery-accent);
	border-radius: 50%;
	background: var(--panel);
	z-index: 1;
}
.delivery-history li strong,
.delivery-history li small {
	display: block;
}
.delivery-history li small {
	color: var(--sub);
	font-size: 13px;
}
@media (max-width: 420px) {
	.delivery-current-card {
		padding: 8px;
	}
	.delivery-current-card .delivery-state-label {
		font-size: 10px;
	}
}
