/* Registered so the bar and its marker can animate to the same percentage. */
@property --scw-gp-p {
	syntax: "<percentage>";
	inherits: true;
	initial-value: 0%;
}

.scw-gp {
	--scw-gp-h: 24px;
	--scw-gp-m: 48px;
	--scw-gp-icon: 24px;
	--scw-gp-gap: 20px;
	--scw-gp-track: rgb(128 128 128 / 0.28);
	--scw-gp-fill: currentColor;
	--scw-gp-marker: #fff;
	--scw-gp-p: var(--scw-gp-to, 0%);
	display: grid;
	gap: var(--scw-gp-gap);
	width: 100%;
	transition: --scw-gp-p 1.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Set by the script until the widget scrolls into view. */
.scw-gp.is-waiting {
	--scw-gp-p: 0%;
	transition: none;
}

.scw-gp__head {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 0.2em 0.6em;
}

.scw-gp__number {
	font-size: clamp(3rem, 2.2rem + 3.6vw, 4.25rem);
	font-weight: 700;
	line-height: 1;
	font-variant-numeric: tabular-nums;
}

.scw-gp__bar {
	display: flex;
	align-items: center;
	gap: 0.75em;
}

.scw-gp__track {
	position: relative;
	flex: 1;
	height: var(--scw-gp-h);
	/* Room for a marker taller than the bar. */
	margin-block: max(0px, calc((var(--scw-gp-m) - var(--scw-gp-h)) / 2));
	border-radius: 99px;
	background: var(--scw-gp-track);
}

/* Never narrower than the marker's centre, so the two stay joined at 0%. */
.scw-gp__fill {
	position: absolute;
	inset: 0 auto 0 0;
	width: max(var(--scw-gp-p), calc(var(--scw-gp-m) / 2));
	border-radius: inherit;
	background: repeating-linear-gradient(135deg, var(--scw-gp-fill) 0 14px, var(--scw-gp-stripe, var(--scw-gp-fill)) 14px 28px);
}

/* Clamped so the marker stays inside the track at 0% and 100%. */
.scw-gp__marker {
	position: absolute;
	top: 50%;
	left: clamp(calc(var(--scw-gp-m) / 2), var(--scw-gp-p), calc(100% - var(--scw-gp-m) / 2));
	translate: -50% -50%;
	display: grid;
	place-items: center;
	width: var(--scw-gp-m);
	height: var(--scw-gp-m);
	border-radius: 50%;
	background: var(--scw-gp-marker);
	color: var(--scw-gp-icon-color, var(--scw-gp-fill));
	font-size: var(--scw-gp-icon);
	line-height: 1;
	box-shadow: 0 6px 14px rgb(0 0 0 / 0.3);
}

.scw-gp__marker svg {
	width: 1em;
	height: 1em;
}

.scw-gp__marker .e-font-icon-svg {
	fill: currentColor;
}

.scw-gp__goal {
	font-size: 0.8em;
	font-weight: 700;
	line-height: 1;
	font-variant-numeric: tabular-nums;
}

.scw-gp__track .scw-gp__goal {
	position: absolute;
	top: 50%;
	right: 0.9em;
	translate: 0 -50%;
}

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