/*
 * The "Choosing the right college can be confusing" step bar.
 *
 * --progress runs from 1 to 7 over one loop. A step is reached once the
 * progress passes its number (--reached) and finished one unit later (--done),
 * and the line to the next step fills as that step finishes (--line).
 * The first step is always finished, so the bar only ever has to connect the
 * second step onwards.
 */
@property --progress {
	syntax: '<number>';
	inherits: true;
	initial-value: 1;
}

@property --clear {
	syntax: '<number>';
	inherits: true;
	initial-value: 0;
}

/* The extra selector keeps the page's own rule for lists (indent and margin) from moving the bar. */
.content-block ol.admission-steps {
	--progress: 1;
	--clear: 0;
	display: grid;
	grid-template-columns: repeat(6, 1fr);
	gap: 19px;
	margin: 0;
	padding: 0;
	list-style: none;
	font-family: Roboto, sans-serif;
	animation: admission-steps-progress 11s linear infinite;
}

.admission-step {
	--reached: calc(clamp(0, (var(--progress) - var(--i)) * 4, 1) * (1 - var(--clear)));
	--done: calc(clamp(0, (var(--progress) - var(--i) - 1) * 4, 1) * (1 - var(--clear)));
	--line: calc(clamp(0, (var(--progress) - var(--i) - 1) * 4, 1) * (1 - var(--clear)));
	position: relative;
	display: flex;
	align-items: center;
	gap: 12%;
	box-sizing: border-box;
	min-height: 40px;
	padding: 6px 4%;
	border: 1px solid color-mix(in srgb, transparent calc(var(--done) * 100%), color-mix(in srgb, #555 calc(var(--reached) * 100%), #e6e6ef));
	border-radius: 3px;
	background: color-mix(in srgb, #d3f3e6 calc(var(--done) * 100%), #fff);
	color: color-mix(in srgb, #4ec08e calc(var(--done) * 100%), color-mix(in srgb, #222 calc(var(--reached) * 100%), #d3d3e0));
	font-size: clamp(11px, 1.1vw, 14px);
	font-weight: 600;
	line-height: 1.15;
	opacity: calc(0.45 + 0.55 * var(--reached));
}

.admission-step-label {
	min-width: 0;
	overflow-wrap: anywhere;
}

.admission-step:first-child {
	--reached: 1;
	--done: 1;
	opacity: 1;
}

.admission-step::before {
	content: "";
	flex: none;
	width: 20px;
	height: 20px;
	box-sizing: border-box;
	border: 2px solid color-mix(in srgb, #52c391 calc(var(--done) * 100%), color-mix(in srgb, #222 calc(var(--reached) * 100%), #d3d3e0));
	border-radius: 50%;
	background: color-mix(in srgb, #52c391 calc(var(--done) * 100%), transparent);
}

.admission-step::after {
	content: "";
	position: absolute;
	top: 50%;
	left: calc(4% + 7px);
	width: 5px;
	height: 9px;
	margin-top: -6px;
	border: solid #fff;
	border-width: 0 2px 2px 0;
	transform: rotate(45deg);
	opacity: var(--done);
}

/* The short line to the next step, filled once this step is done. */
.admission-step-label::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 100%;
	width: 19px;
	height: 2px;
	margin-top: -1px;
	background: linear-gradient(to right, #52c391 calc(var(--line) * 100%), #e6e6ef calc(var(--line) * 100%));
}

.admission-step:last-child .admission-step-label::after {
	display: none;
}

/*
 * Once every step is done, the steps after the first all go back to waiting at
 * the same time (--clear), their outlines staying in view, and the bar starts
 * over by connecting the second step. The first step stays filled throughout.
 */
@keyframes admission-steps-progress {
	0% { --progress: 1; --clear: 0; }
	82% { --progress: 7; }
	93% { --progress: 7; --clear: 0; }
	98% { --progress: 7; --clear: 1; }
	98.01% { --progress: 1; --clear: 1; }
	98.02% { --progress: 1; --clear: 0; }
	100% { --progress: 1; --clear: 0; }
}

/* Tablets: three steps to a row, so the lines between the rows are left out. */
@media (max-width: 1100px) {
	.content-block ol.admission-steps {
		grid-template-columns: repeat(3, 1fr);
		gap: 12px;
	}

	.admission-step {
		font-size: 14px;
	}

	.admission-step-label::after {
		display: none;
	}
}

/* Phones: two steps to a row. */
@media (max-width: 560px) {
	.content-block ol.admission-steps {
		grid-template-columns: repeat(2, 1fr);
		gap: 10px;
	}

	.admission-step {
		gap: 8px;
		font-size: 13px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.content-block ol.admission-steps {
		--progress: 1.5;
		animation: none;
	}
}
