/*
 * Tilastot (avalon/stats + avalon/stat): a slim strip of numbers.
 * On a white or light section the numbers sit in tint boxes; on navy they are plain (no boxes), with hairlines.
 * A picture instead of an icon (e.g. the Avainlippu / Suomalaista palvelua logo) is as high as the icons (40 / 38 /
 * 32px), with no disc behind it, and drawn in the icons' colour: an inline SVG with the picture as its mask
 * (stat/render.php) filled with the text colour – navy on a light background, turquoise on navy – so all the icons
 * of the strip match.
 * Phones keep three side by side (about 150px high); labels >= 13px.
 */

.ab-stats .ab-grid {
	--ab-stat-gap: 24px;
	gap: var(--ab-stat-gap);
	padding: 0;
}

.ab-stat {
	--ab-heading: var(--wp--preset--color--heading, #012b55);
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: flex-start;
	box-sizing: border-box;
	min-width: 0;
	min-height: 0;
	padding: 24px 20px 22px;
	border: 0;
	border-radius: var(--ab-radius, 12px);
	background: var(--ab-tint, #eaf8f9);
	color: var(--ab-heading);
	text-align: center;
}

.ab-stat__media {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	margin-bottom: 10px;
}

.ab-stat__icon {
	display: block;
	width: auto;
	height: 36px;
	color: var(--ab-navy, #002b56);
}

.ab-stat__img {
	display: block;
	width: auto;
	max-width: 64px;
	height: 40px;
	color: var(--ab-navy, #002b56);
	object-fit: contain;
}

.ab-stat__number {
	margin: 0;
	font-size: 38px;
	font-weight: 700;
	line-height: 1.1;
	letter-spacing: 0;
	hyphens: auto;
	overflow-wrap: normal;
}

.ab-stat__label {
	margin: 6px 0 0;
	font-size: 16px;
	font-weight: 400;
	line-height: 1.35;
	letter-spacing: 0;
	text-transform: none;
}

/* ---------------------------------------------------------------- plain on navy */

.ab-stats.is-dark .ab-stat {
	--ab-heading: #fff;
	padding: 8px 8px 4px;
	background: none;
	color: #fff;
}

.ab-stats.is-dark :is(.ab-stat__icon, .ab-stat__img) {
	color: var(--wp--preset--color--accent, #30cbd3);
}

.ab-stats.is-dark .ab-stat__label {
	color: rgba(255, 255, 255, 0.85);
}

/* hairlines between the numbers on navy, in the middle of the gap */
.ab-stats.is-dark .ab-stat {
	position: relative;
}

.ab-stats.is-dark .ab-stat + .ab-stat::before {
	content: "";
	position: absolute;
	top: 12%;
	bottom: 12%;
	left: calc(var(--ab-stat-gap, 24px) / -2);
	width: 1px;
	background: rgba(255, 255, 255, 0.22);
}

/* ---------------------------------------------------------------- tablet */

@media (min-width: 769px) and (max-width: 1024px) {
	.ab-stats .ab-grid {
		--ab-stat-gap: 16px;
	}

	.ab-stat {
		padding: 22px 12px 20px;
	}

	.ab-stat__icon {
		height: 34px;
	}

	.ab-stat__img {
		height: 38px;
	}

	.ab-stat__number {
		font-size: 30px;
	}

	.ab-stat__label {
		font-size: 14px;
	}
}

/* ---------------------------------------------------------------- phones */

@media (max-width: 768px) {
	.ab-stats .ab-grid {
		--ab-stat-gap: 8px;
		grid-template-columns: repeat(var(--ab-cols-s, 3), minmax(0, 1fr)) !important;
		padding: 0;
	}

	.ab-stat {
		min-height: 0;
		padding: 14px 4px 12px;
	}

	.ab-stat__media {
		min-height: 32px;
		margin-bottom: 6px;
	}

	.ab-stat__icon {
		height: 28px;
	}

	.ab-stat__img {
		max-width: 48px;
		height: 32px;
	}

	.ab-stats.is-dark .ab-stat {
		padding: 4px 2px 0;
	}

	.ab-stat__number {
		margin-bottom: 0;
		font-size: clamp(18px, 5.4vw, 24px);
	}

	/* a long word as the "number" (e.g. "Nyckelflaggan" on the Swedish front page) */
	.ab-stat--word .ab-stat__number {
		font-size: clamp(14px, 3.9vw, 20px);
		overflow-wrap: anywhere;
	}

	.ab-stat__label {
		margin-top: 4px;
		font-size: 13px;
		line-height: 1.3;
		letter-spacing: 0;
	}
}

@media (max-width: 380px) {
	.ab-stat {
		padding: 14px 2px 12px;
	}

	.ab-stat__number {
		font-size: 18px;
	}

	.ab-stat--word .ab-stat__number {
		font-size: 14px;
	}
}
