/**
 * Stats Counter Bar — Dark gradient overlay with animated numbers.
 *
 * Mobile-first: 2x2 grid -> 4-column row at 48rem.
 * Numbers in Gilda Display, labels in Raleway uppercase.
 * Vertical gold dividers between stats on desktop.
 *
 * @package BuryGolfClub
 * @since   1.0.0
 */

/* ========================================================================
   Stats Counter — Container
   ======================================================================== */

.stats-counter {
	position: relative;
	background-color: var(--wp--preset--color--primary-deep, #061225);
	overflow: hidden;
}

.stats-counter::before {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(
		135deg,
		rgba(7, 20, 40, 1) 0%,
		rgba(10, 25, 50, 0.98) 100%
	);
	z-index: 1;
}

.stats-counter__inner {
	position: relative;
	z-index: 2;
	max-width: var(--wp--style--global--wide-size, 90rem);
	margin-inline: auto;
	padding-inline: clamp(1.25rem, 5vw, 1.5rem);
	padding-block: clamp(3rem, 6vw, 5rem);
}

/* ========================================================================
   Stats Counter — Grid (mobile-first: 2x2)
   ======================================================================== */

.stats-counter__grid {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: clamp(1.5rem, 4vw, 2.5rem);
	margin: 0;
	padding: 0;
	list-style: none;
}

@media (min-width: 48rem) {
	.stats-counter__grid {
		grid-template-columns: repeat(4, 1fr);
		gap: 0;
	}
}

/* ========================================================================
   Stats Counter — Individual Stat Item
   ======================================================================== */

.stats-counter__item {
	display: flex;
	flex-direction: column-reverse;
	align-items: center;
	text-align: center;
	padding-block: var(--wp--preset--spacing--20);
}

/* Vertical divider between items on desktop */
@media (min-width: 48rem) {
	.stats-counter__item {
		position: relative;
		padding-inline: var(--wp--preset--spacing--30);
	}

	.stats-counter__item::after {
		content: "";
		position: absolute;
		right: 0;
		top: 50%;
		transform: translateY(-50%);
		width: 1px;
		height: 3.5rem;
		background: linear-gradient(
			to bottom,
			transparent 0%,
			var(--wp--preset--color--gold) 50%,
			transparent 100%
		);
	}

	.stats-counter__item:last-child::after {
		display: none;
	}
}

/* ========================================================================
   Stats Counter — Number (large, Gilda Display)
   ======================================================================== */

.stats-counter__value {
	margin: 0;
	font-family: var(--wp--preset--font-family--heading);
	font-size: clamp(2.5rem, 4vw + 1rem, 5rem);
	font-weight: 400;
	color: var(--wp--preset--color--text-light);
	line-height: 1.1;
	margin-bottom: var(--wp--preset--spacing--10);
}

.stats-counter__prefix,
.stats-counter__suffix {
	font-family: var(--wp--preset--font-family--heading);
}

.stats-counter__number {
	/* Tabular nums prevent layout shift during counting */
	font-variant-numeric: tabular-nums;
}

/* ========================================================================
   Stats Counter — Label (Raleway uppercase)
   ======================================================================== */

.stats-counter__label {
	font-family: var(--wp--preset--font-family--body);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.15em;
	color: var(--wp--preset--color--gold);
}

/* ========================================================================
   Stats Counter — Animation States
   ======================================================================== */

.stats-counter__item {
	opacity: 0;
	transform: translateY(1.25rem);
	transition: opacity 0.6s ease, transform 0.6s ease;
}

.stats-counter--visible .stats-counter__item {
	opacity: 1;
	transform: translateY(0);
}

/* Stagger the reveal */
.stats-counter--visible .stats-counter__item:nth-child(1) { transition-delay: 0s; }
.stats-counter--visible .stats-counter__item:nth-child(2) { transition-delay: 0.1s; }
.stats-counter--visible .stats-counter__item:nth-child(3) { transition-delay: 0.2s; }
.stats-counter--visible .stats-counter__item:nth-child(4) { transition-delay: 0.3s; }

/* No-JS fallback: show items immediately */
.no-js .stats-counter__item,
html:not(.js) .stats-counter__item {
	opacity: 1;
	transform: none;
}

/* CSS-only timeout fallback — if JS hasn't added the visible class after 3s,
   force items visible via animation-delay to prevent permanently hidden stats. */
@keyframes stats-fallback-reveal {
	to { opacity: 1; transform: translateY(0); }
}

.stats-counter:not(.stats-counter--visible) .stats-counter__item {
	animation: stats-fallback-reveal 0.6s ease 3s forwards;
}

/* Reduced motion: skip animations */
@media (prefers-reduced-motion: reduce) {
	.stats-counter__item {
		opacity: 1;
		transform: none;
		transition: none;
	}
}
