/*
 * PureCSS.com
 * https://purecss.com/rolling-price-toggle/
 * A monthly and yearly switch whose price rolls like a counter, using radio state and lh units.
 */

.demo-rolling-price-toggle .rp-card {
	display: grid;
	justify-items: center;
	gap: .75rem;
}

.demo-rolling-price-toggle .rp-switch {
	display: flex;
	gap: 2px;
	padding: 3px;
	border: 1px solid var(--border);
	border-radius: 999px;
	background: var(--bg);
}

.demo-rolling-price-toggle .rp-option {
	padding: .3rem .85rem;
	border-radius: 999px;
	font-size: .8rem;
	color: var(--text-muted);
	cursor: pointer;
	transition: color .2s, background .2s;
}

.demo-rolling-price-toggle .rp-option input {
	position: absolute;
	opacity: 0;
	width: 1px;
	height: 1px;
}

.demo-rolling-price-toggle .rp-option:has(input:checked) {
	color: var(--bg);
	background: var(--accent);
}

.demo-rolling-price-toggle .rp-option:has(input:focus-visible) {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

.demo-rolling-price-toggle .rp-price {
	display: flex;
	align-items: baseline;
	margin: 0;
	font-size: 3rem;
	font-weight: 800;
	line-height: 1.1;
	font-variant-numeric: tabular-nums;
	color: var(--text);
}

.demo-rolling-price-toggle .rp-price small {
	margin-left: .2rem;
	font-size: .95rem;
	font-weight: 500;
	color: var(--text-muted);
}

/* a window one line tall onto a column of ten digits */
.demo-rolling-price-toggle .rp-digit {
	display: inline-block;
	height: 1lh;
	overflow: hidden;
	--d: var(--m);
}

.demo-rolling-price-toggle .rp-reel {
	display: block;
	translate: 0 calc(var(--d) * -1lh);
	transition: translate .6s cubic-bezier(.2, .9, .25, 1.15) var(--delay, 0s);
}

.demo-rolling-price-toggle .rp-reel span {
	display: block;
}

.demo-rolling-price-toggle .rp-card:has(.rp-yearly:checked) .rp-digit {
	--d: var(--y);
}

/* the rolling digits are hidden from screen readers, so one of these says the price */
.demo-rolling-price-toggle .rp-spoken {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	overflow: hidden;
	clip-path: inset(50%);
}

.demo-rolling-price-toggle .rp-spoken-yearly {
	display: none;
}

.demo-rolling-price-toggle .rp-card:has(.rp-yearly:checked) .rp-spoken-monthly {
	display: none;
}

.demo-rolling-price-toggle .rp-card:has(.rp-yearly:checked) .rp-spoken-yearly {
	display: block;
}

@media (prefers-reduced-motion: reduce) {
	.demo-rolling-price-toggle .rp-reel { transition: none; }
}
