/* Steps (docs/widgets/steps.md), in the design language (spec §3.7). This is Soft, the default:
   markers in a pale tint of the accent, a quiet connector, and text in the scheme's colours. Fonts
   come from the theme. steps-outline.css and steps-solid.css change only the --hafe-steps-d-*
   tokens below, so a Style control's own property always wins over the design.

   One stylesheet draws both directions. The widget's Direction control sets --hafe-steps-h to 1
   (horizontal) or 0 (vertical) per breakpoint, with the matching flex and grid keywords; the
   connector's position and length are sums weighted by that number. Without the control (no
   generated CSS yet), steps are vertical, which fits any width. */

/* Lengths the connector is computed from, resolved once on the list, so a marker with its own
   font size still lines up with its connector. */
@property --hafe-steps-m {
	syntax: "<length>";
	inherits: true;
	initial-value: 40px;
}

@property --hafe-steps-g {
	syntax: "<length>";
	inherits: true;
	initial-value: 32px;
}

@property --hafe-steps-lw {
	syntax: "<length>";
	inherits: true;
	initial-value: 2px;
}

@property --hafe-steps-lg {
	syntax: "<length>";
	inherits: true;
	initial-value: 8px;
}

.hafe-steps {
	--hafe-steps-d-mark: var(--hafe-tint);
	--hafe-steps-d-mark-hover: var(--hafe-tint-strong);
	--hafe-steps-d-mark-ink: var(--hafe-accent-ink);
	--hafe-steps-d-mark-line: transparent;
	--hafe-steps-d-line: var(--hafe-line);
	--hafe-steps-d-now: var(--hafe-accent);
	--hafe-steps-d-now-ink: var(--hafe-on-accent);
	--hafe-steps-d-now-line: transparent;
	--hafe-steps-d-now-ring: none;
	--hafe-steps-d-tag: var(--hafe-tint);
	--hafe-steps-d-tag-ink: var(--hafe-accent-ink);
	--hafe-steps-d-tag-line: transparent;
	--hafe-steps-d-tag-pad: 0.2em 0.7em;
	--hafe-steps-m: var(--hafe-steps-marker-size, 2.5em);
	--hafe-steps-g: var(--hafe-steps-gap, 2em);
	--hafe-steps-lw: var(--hafe-steps-line-width, 2px);
	--hafe-steps-lg: var(--hafe-steps-line-gap, 0.5em);
	--hafe-steps-x: var(--hafe-steps-h, 0);
	display: grid;
	grid-auto-columns: minmax(0, 1fr);
	grid-auto-flow: var(--hafe-steps-flow, row);
	gap: var(--hafe-steps-g);
	margin: 0;
	padding: 0;
	list-style: none;
	overflow-wrap: anywhere;
}

.hafe-steps > .hafe-steps__step {
	position: relative;
	display: flex;
	flex-direction: var(--hafe-steps-step-flow, row);
	align-items: var(--hafe-steps-items, flex-start);
	gap: var(--hafe-steps-marker-gap, 1em);
	min-width: 0;
	margin: 0;
	padding: 0;
	text-align: var(--hafe-steps-text, start);
}

/* The connector runs from this marker to the next one. Vertical: down from below the marker.
   Horizontal: across from beside the marker, whose centre sits at --hafe-steps-mc. */
.hafe-steps > .hafe-steps__step:not(:last-child)::after {
	--hafe-steps-mc: calc(var(--hafe-steps-m) / 2 + var(--hafe-steps-x) * var(--hafe-steps-center, 1) * (50% - var(--hafe-steps-m) / 2));
	--hafe-steps-len: calc(100% + var(--hafe-steps-g) - var(--hafe-steps-m) - 2 * var(--hafe-steps-lg));
	content: "";
	position: absolute;
	box-sizing: content-box;
	inset-block-start: calc((1 - var(--hafe-steps-x)) * (var(--hafe-steps-m) + var(--hafe-steps-lg)) + var(--hafe-steps-x) * (var(--hafe-steps-m) - var(--hafe-steps-lw)) / 2);
	inset-inline-start: calc((1 - var(--hafe-steps-x)) * (var(--hafe-steps-m) - var(--hafe-steps-lw)) / 2 + var(--hafe-steps-x) * (var(--hafe-steps-mc) + var(--hafe-steps-m) / 2 + var(--hafe-steps-lg)));
	inline-size: calc(var(--hafe-steps-x) * var(--hafe-steps-len));
	block-size: calc((1 - var(--hafe-steps-x)) * var(--hafe-steps-len));
	border: 0 var(--hafe-steps-line-style, solid) var(--hafe-steps-line-color, var(--hafe-steps-d-line));
	border-block-start-width: calc(var(--hafe-steps-x) * var(--hafe-steps-lw));
	border-inline-start-width: calc((1 - var(--hafe-steps-x)) * var(--hafe-steps-lw));
	pointer-events: none;
}

.hafe-steps__marker {
	box-sizing: border-box;
	display: flex;
	flex: none;
	align-items: center;
	justify-content: center;
	inline-size: var(--hafe-steps-m);
	block-size: var(--hafe-steps-m);
	overflow: hidden;
	/* The border is always there, see-through in Soft and Solid, so a design never changes the size. */
	border: var(--hafe-steps-marker-border-width, 2px) solid var(--hafe-steps-marker-border, var(--hafe-steps-d-mark-line));
	border-radius: var(--hafe-steps-marker-radius, 50%);
	background: var(--hafe-steps-marker-bg, var(--hafe-steps-d-mark));
	color: var(--hafe-steps-marker-color, var(--hafe-steps-d-mark-ink));
	font-weight: 700;
	line-height: 1;
	transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}

.hafe-steps__step:hover .hafe-steps__marker,
.hafe-steps__step:focus-within .hafe-steps__marker {
	border-color: var(--hafe-steps-marker-hover-border, var(--hafe-steps-marker-border, var(--hafe-steps-d-mark-line)));
	background: var(--hafe-steps-marker-hover-bg, var(--hafe-steps-marker-bg, var(--hafe-steps-d-mark-hover)));
	color: var(--hafe-steps-marker-hover-color, var(--hafe-steps-marker-color, var(--hafe-steps-d-mark-ink)));
}

/* The highlighted step (aria-current), filled with the accent; it keeps its look on hover. */
.hafe-steps__step.is-current .hafe-steps__marker {
	border-color: var(--hafe-steps-marker-now-border, var(--hafe-steps-d-now-line));
	background: var(--hafe-steps-marker-now-bg, var(--hafe-steps-d-now));
	color: var(--hafe-steps-marker-now-color, var(--hafe-steps-d-now-ink));
	/* An outline, not a border: it leaves a see-through gap and never changes the marker's size. */
	outline: var(--hafe-steps-d-now-ring);
	outline-offset: 3px;
}

.hafe-steps__marker svg {
	width: var(--hafe-steps-icon-size, 1.1em);
	height: var(--hafe-steps-icon-size, 1.1em);
	fill: currentColor;
}

.hafe-steps__marker i {
	font-size: var(--hafe-steps-icon-size, 1.1em);
}

.hafe-steps__marker--image {
	padding: 0;
}

.hafe-steps .hafe-steps__marker img {
	display: block;
	width: 100%;
	max-width: none;
	height: 100%;
	object-fit: cover;
}

.hafe-steps__body {
	flex: 1 1 auto;
	align-self: stretch;
	min-width: 0;
}

/* A short tag above the title, such as a duration. */
.hafe-steps__label {
	display: inline-block;
	margin-block-end: 0.5em;
	padding: var(--hafe-steps-d-tag-pad);
	border: 1px solid var(--hafe-steps-d-tag-line);
	border-radius: var(--hafe-pill);
	background: var(--hafe-steps-label-bg, var(--hafe-steps-d-tag));
	color: var(--hafe-steps-label-color, var(--hafe-steps-d-tag-ink));
	font-size: 0.8em;
	font-weight: 600;
	line-height: 1.4;
}

/* The tag says what a title is to the page, and themes size tags very differently, so the title's
   size follows the text around it until the Style tab says otherwise. */
.hafe-steps .hafe-steps__title {
	margin: 0 0 var(--hafe-steps-title-gap, 0.35em);
	color: var(--hafe-steps-title-color, var(--hafe-ink));
	font-size: 1.15em;
	font-weight: 600;
}

/* Vertical: the first line of text is centred on the marker. */
.hafe-steps__body > :first-child {
	margin-block-start: calc((1 - var(--hafe-steps-x)) * max(0px, (var(--hafe-steps-m) - 1lh) / 2));
}

.hafe-steps__title a {
	color: inherit;
	text-decoration: none;
}

.hafe-steps__title a:hover {
	color: var(--hafe-steps-title-hover-color, inherit);
	text-decoration: underline;
}

.hafe-steps__title a:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.hafe-steps__text {
	color: var(--hafe-steps-text-color, var(--hafe-ink-soft));
}

/* Links in a description stand out by more than colour (WCAG 1.4.1), whatever the theme does. */
.hafe-steps__text a {
	text-decoration: underline;
}

.hafe-steps__text > :first-child {
	margin-block-start: 0;
}

.hafe-steps__text > :last-child {
	margin-block-end: 0;
}

.hafe-empty {
	margin: 0;
	padding: 1em;
	border: 1px dashed currentColor;
	opacity: 0.7;
}

@media (prefers-reduced-motion: reduce) {
	.hafe-steps__marker {
		transition: none;
	}
}

@media print {
	.hafe-steps > .hafe-steps__step {
		break-inside: avoid;
	}
}
