/* Rabin Craft — Odometer Stats. Needs core.css.
   Each digit column shows one cell of a 20-cell reel (0–9 twice). The reel rests on its final digit
   in the second set; before .is-in (added by odometer.js on first view) it waits at the first 0,
   so the roll passes one full turn plus the digit. Rightmost digits start a little later.
   Styles: roll (plain), boxed (a cell per digit), flip (split-flap tiles, no reels), ring (a gauge
   round the figure) and roman (letters that rise). All motion is transitions started by .is-in. */

.mkit-odo {
	--cell: 1em;
	width: 100%;
	color: var(--mkit-muted);
}

.mkit-odo__list {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr));
	gap: clamp(1.5rem, 3vw, 2.75rem);
	margin: 0;
	padding: 0;
	list-style: none;
}

.mkit-odo--center .mkit-odo__item {
	align-items: center;
	text-align: center;
}

.mkit-odo__item {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: .6rem;
	margin: 0;
}

.mkit-odo--rules .mkit-odo__item {
	padding-top: 1.1rem;
	border-top: 1px solid var(--mkit-line);
}

.mkit-odo--rules .mkit-odo__item::before {
	content: "";
	position: absolute;
	top: -1px;
	left: 0;
	width: 2.75rem;
	height: 2px;
	background: var(--mkit-accent);
	transform-origin: 0 50%;
}

.mkit-odo--center.mkit-odo--rules .mkit-odo__item::before {
	left: calc(50% - 1.375rem);
	transform-origin: 50% 50%;
}

.mkit-odo__value {
	color: var(--mkit-text);
	font-size: clamp(2.6rem, 1.7rem + 3.4vw, 4.75rem);
	font-weight: 600;
	line-height: 1;
	letter-spacing: -.04em;
	font-variant-numeric: tabular-nums;
}

.mkit-odo__digits {
	display: inline-flex;
	align-items: flex-start;
}

.mkit-odo__col {
	display: inline-block;
	width: 1ch;
	height: var(--cell);
	overflow: hidden;
}

.mkit-odo__reel {
	display: flex;
	flex-direction: column;
	translate: 0 calc((var(--d) + 10) * var(--cell) * -1);
}

.mkit-odo__reel i {
	display: block;
	height: var(--cell);
	font-style: normal;
	line-height: var(--cell);
	text-align: center;
}

.mkit-odo__sep {
	display: inline-block;
	height: var(--cell);
	line-height: var(--cell);
}

.mkit-odo__affix {
	display: inline-block;
	height: var(--cell);
	margin-inline: .04em;
	line-height: var(--cell);
	color: var(--mkit-accent-soft);
	font-size: .7em;
	letter-spacing: -.02em;
	align-self: flex-start;
	padding-top: .08em;
}

.mkit-odo__label {
	max-width: 24ch;
	font-size: .975rem;
	line-height: 1.45;
}

/* Rolling down: the reel is laid out 9→0 so the resting digit is still one cell, and it waits on the last 0 */
.mkit-odo--down .mkit-odo__reel {
	flex-direction: column-reverse;
	translate: 0 calc((9 - var(--d)) * var(--cell) * -1);
}

.mkit-odo--accent-digit .is-last {
	color: var(--mkit-accent-soft);
}

/* One tile or letter per character (flip, roman) */
.mkit-odo__ch {
	display: inline-block;
	height: var(--cell);
	line-height: var(--cell);
	text-align: center;
}

/* Boxed and flip: a cell per digit. The cell is taller than the digit, so no padding is needed
   (padding would show the reel's neighbouring digits). */
.mkit-odo--boxed,
.mkit-odo--flip {
	--cell: 1.42em;
}

:is(.mkit-odo--boxed, .mkit-odo--flip) .mkit-odo__value {
	letter-spacing: 0;
}

.mkit-odo--boxed .mkit-odo__col,
.mkit-odo--flip .mkit-odo__ch {
	box-sizing: content-box;
	width: 1.42ch;
	margin-inline: .045em;
	border: 1px solid var(--mkit-line);
	border-radius: var(--mkit-odo-cell-radius, .16em);
	background: var(--mkit-chip-bg);
}

.mkit-odo--flip .mkit-odo__digits {
	perspective: 600px;
}

.mkit-odo--flip .mkit-odo__ch {
	position: relative;
	width: auto;
	min-width: 1.42ch;
	padding-inline: .06em;
	transform-origin: 50% 0;
	backface-visibility: hidden;
}

/* The hinge line of a split-flap tile */
.mkit-odo--flip .mkit-odo__ch::after {
	content: "";
	position: absolute;
	inset: 50% 0 auto;
	height: 1px;
	background: var(--mkit-line);
}

/* Ring: the figure sits inside a gauge. pathLength="100" on the arc makes --p the unfilled percentage. */
.mkit-odo__ring {
	position: relative;
	display: grid;
	place-items: center;
	align-self: flex-start;
	width: min(100%, var(--mkit-odo-ring-size, 9.5rem));
	aspect-ratio: 1;
}

.mkit-odo--center .mkit-odo__ring,
.mkit-odo--center .mkit-odo__icon {
	align-self: center;
}

.mkit-odo__ring svg {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	rotate: -90deg;
	overflow: visible;
}

.mkit-odo__ring circle {
	fill: none;
	stroke-width: var(--mkit-odo-ring-width, 3.5);
}

.mkit-odo__track {
	stroke: var(--mkit-line);
}

.mkit-odo__arc {
	stroke: var(--mkit-accent);
	stroke-linecap: round;
	stroke-dasharray: 100;
	stroke-dashoffset: var(--p, 0);
}

.mkit-odo--ring .mkit-odo__value {
	font-size: clamp(1.6rem, 1.25rem + 1.1vw, 2.2rem);
	letter-spacing: -.02em;
}

/* Icon badge above the figure (decorative) */
.mkit-odo__icon {
	display: grid;
	place-items: center;
	align-self: flex-start;
	width: 2.75rem;
	height: 2.75rem;
	border-radius: 50%;
	background: color-mix(in srgb, var(--mkit-accent) 22%, transparent);
	color: var(--mkit-accent-soft);
}

.mkit-odo__icon svg {
	width: 1.35rem;
	height: 1.35rem;
}

.mkit-odo__icon i {
	font-size: 1.25rem;
	font-style: normal;
}

/* Cards replace the rules */
.mkit-odo--card .mkit-odo__item {
	padding: clamp(1.1rem, 2vw, 1.6rem);
	border: 1px solid transparent;
	border-radius: var(--mkit-card-radius, 18px);
}

/* A card is narrower than a bare stat, so the figure is also capped by the card's own width */
.mkit-odo--card .mkit-odo__item {
	container-type: inline-size;
}

.mkit-odo--card:not(.mkit-odo--ring) .mkit-odo__value {
	font-size: min(clamp(2.6rem, 1.7rem + 3.4vw, 4.75rem), 22cqi);
}

.mkit-odo--card-outline .mkit-odo__item {
	border-color: var(--mkit-line);
}

.mkit-odo--card-filled .mkit-odo__item {
	background: var(--mkit-chip-bg);
}

.mkit-odo--card .mkit-odo__item::before {
	content: none;
}

.mkit-odo--card .mkit-odo__list {
	gap: clamp(.9rem, 1.6vw, 1.4rem);
}

@media (min-width: 768px) {
	.mkit-odo--cols .mkit-odo__list {
		grid-template-columns: repeat(var(--mkit-odo-cols), minmax(0, 1fr));
	}
}

@media (prefers-reduced-motion: no-preference) {
	.mkit-js .mkit-odo:not(.is-in) .mkit-odo__reel {
		translate: 0 0;
	}
	.mkit-js .mkit-odo:not(.is-in) :is(.mkit-odo__affix, .mkit-odo__sep, .mkit-odo__label) {
		opacity: 0;
	}
	.mkit-js .mkit-odo--rules:not(.is-in) .mkit-odo__item::before {
		scale: 0 1;
	}
	.mkit-odo.is-in .mkit-odo__reel {
		transition: translate var(--mkit-dur, 1.8s) cubic-bezier(.16, 1, .3, 1);
		transition-delay: calc(var(--j, 0) * 120ms + var(--k, 0) * 70ms);
	}
	.mkit-odo.is-in :is(.mkit-odo__affix, .mkit-odo__sep, .mkit-odo__label) {
		transition: opacity .6s var(--mkit-ease);
		transition-delay: calc(var(--j, 0) * 120ms + var(--mkit-dur, 1.8s) * .45);
	}
	.mkit-odo.is-in .mkit-odo__item::before {
		transition: scale .9s var(--mkit-ease);
		transition-delay: calc(var(--j, 0) * 120ms);
	}

	.mkit-js .mkit-odo--down:not(.is-in) .mkit-odo__reel {
		translate: 0 calc(19 * var(--cell) * -1);
	}
	.mkit-js .mkit-odo--flip:not(.is-in) .mkit-odo__ch {
		transform: rotateX(-90deg);
		opacity: 0;
	}
	.mkit-js .mkit-odo--roman:not(.is-in) .mkit-odo__ch {
		translate: 0 .45em;
		opacity: 0;
	}
	.mkit-js .mkit-odo:not(.is-in) .mkit-odo__arc {
		stroke-dashoffset: 100;
	}
	.mkit-js .mkit-odo:not(.is-in) .mkit-odo__icon {
		scale: .5;
		opacity: 0;
	}
	.mkit-odo--flip.is-in .mkit-odo__ch {
		transition: transform .7s var(--mkit-spring, cubic-bezier(.2, 1.3, .4, 1)), opacity .2s linear;
		transition-delay: calc(var(--j, 0) * 120ms + var(--k, 0) * 90ms);
	}
	.mkit-odo--roman.is-in .mkit-odo__ch {
		transition: translate .7s cubic-bezier(.16, 1, .3, 1), opacity .5s var(--mkit-ease);
		transition-delay: calc(var(--j, 0) * 120ms + var(--k, 0) * 110ms);
	}
	.mkit-odo.is-in .mkit-odo__arc {
		transition: stroke-dashoffset var(--mkit-dur, 1.8s) cubic-bezier(.16, 1, .3, 1);
		transition-delay: calc(var(--j, 0) * 120ms);
	}
	.mkit-odo.is-in .mkit-odo__icon {
		transition: scale .6s var(--mkit-spring, cubic-bezier(.2, 1.3, .4, 1)), opacity .3s linear;
		transition-delay: calc(var(--j, 0) * 120ms);
	}
}
