/**
 * Countdown Section — front-end styles.
 * Scoped under .cds-section to minimize theme collisions.
 */

.cds-section {
	/* Full-width breakout: ignore the theme's content container. */
	position: relative;
	left: 50%;
	right: 50%;
	width: 100vw;
	max-width: 100vw;
	margin-left: -50vw;
	margin-right: -50vw;

	box-sizing: border-box;
	overflow: hidden;
	padding: clamp(2.5rem, 7vw, 6rem) 1rem;

	background-color: #2b2b2b;
	background-image: var(--cds-bg, none);
	background-size: cover;
	background-position: center;
	background-repeat: no-repeat;

	color: var(--cds-text, #fff);
	text-align: center;
}

.cds-section *,
.cds-section *::before,
.cds-section *::after {
	box-sizing: border-box;
}

.cds-overlay {
	position: absolute;
	inset: 0;
	background-color: rgba(0, 0, 0, var(--cds-overlay, 0.4));
	pointer-events: none;
}

.cds-inner {
	position: relative;
	z-index: 1;
	max-width: 1100px;
	margin: 0 auto;
}

.cds-heading {
	margin: 0 0 clamp(1.25rem, 3vw, 2.25rem);
	color: var(--cds-text, #fff);
	font-family: var(--cds-heading-font, inherit);
	font-size: clamp(1.5rem, 4vw, 2.75rem);
	font-weight: 700;
	line-height: 1.15;
	letter-spacing: 0.02em;
	text-transform: uppercase;
}

.cds-timer {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-start;
	justify-content: center;
	gap: clamp(0.4rem, 1.5vw, 1rem);
}

/* Resilience against wpautop. Depending on the theme / page builder / ACF
   WYSIWYG field, WordPress may run wpautop over the already-rendered shortcode
   and inject stray <p> (and <br>) nodes between our block-level units. Our own
   markup never places a <p> or <br> as a direct child of the timer, so any that
   appear here are artifacts — drop them from the flex flow so they can't throw
   off the two-per-row layout. */
.cds-timer > p,
.cds-timer > br {
	display: none;
}

.cds-unit {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.6rem;
}

.cds-tiles {
	display: flex;
	gap: clamp(0.25rem, 0.8vw, 0.5rem);
}

.cds-tile {
	display: flex;
	align-items: center;
	justify-content: center;
	min-width: clamp(2.4rem, 8vw, 4.25rem);
	padding: clamp(0.5rem, 2vw, 1.1rem) clamp(0.35rem, 1.2vw, 0.75rem);

	background-color: var(--cds-accent, #13b1b1);
	color: var(--cds-number, #fff);

	font-family: var(--cds-number-font, inherit);
	font-size: clamp(1.75rem, 6vw, 3.5rem);
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	line-height: 1;
	border-radius: 2px;
}

/* Optional highlight on the very first digit tile. Falls back to the accent
   color when no highlight is configured, so the look is unchanged by default. */
.cds-timer .cds-unit:first-of-type .cds-tiles .cds-tile:first-child {
	background-color: var(--cds-highlight, var(--cds-accent, #13b1b1));
}

.cds-sep {
	align-self: flex-start;
	margin-top: clamp(0.4rem, 2vw, 1rem);
	color: var(--cds-text, #fff);
	font-size: clamp(1.5rem, 5vw, 3rem);
	font-weight: 700;
	line-height: 1;
}

.cds-label {
	color: var(--cds-text, #fff);
	font-family: var(--cds-body-font, inherit);
	font-size: clamp(0.7rem, 1.6vw, 0.95rem);
	font-weight: 600;
	letter-spacing: 0.12em;
	text-transform: uppercase;
}

.cds-subtext {
	margin: clamp(1.5rem, 4vw, 2.5rem) auto 0;
	max-width: 50ch;
	color: var(--cds-text, #fff);
	font-family: var(--cds-body-font, inherit);
	font-size: clamp(1rem, 2.2vw, 1.25rem);
	line-height: 1.5;
}

.cds-noscript {
	margin-top: 1.5rem;
	color: var(--cds-text, #fff);
	font-size: 1.1rem;
}

/* Finished state: replace the tiles with the completion message. */
.cds-timer.is-expired {
	font-family: var(--cds-body-font, inherit);
	font-size: clamp(1.5rem, 4vw, 2.5rem);
	font-weight: 700;
	color: var(--cds-text, #fff);
}

/* Subtle change animation, disabled for reduced-motion users. */
.cds-tile {
	transition: transform 0.18s ease;
}
.cds-tile.cds-bump {
	transform: translateY(-3px) scale(1.04);
}
@media (prefers-reduced-motion: reduce) {
	.cds-tile {
		transition: none;
	}
	.cds-tile.cds-bump {
		transform: none;
	}
}

/* Accessible visually-hidden helper (in case the theme lacks it). */
.cds-section .screen-reader-text,
.cds-sr-status {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* On mobile, drop the colon separators and bump the numbers and labels up a
   notch — the clamped defaults bottom out too small on phones. */
@media (max-width: 500px) {
	.cds-sep {
		display: none; /* colons don't make sense once units wrap into a grid */
	}
	.cds-timer {
		gap: 1.75rem 0.6rem; /* row gap, column gap */
	}
	.cds-unit {
		flex: 0 0 auto;
		gap: 0.85rem; /* a little more space between tiles and label */
	}
	.cds-tile {
		min-width: 3.5rem;
		padding: 0.9rem 0.5rem;
		font-size: 2.75rem;
	}
	.cds-label {
		font-size: 1rem;
		letter-spacing: 0.14em;
	}
}

/* Phones 350px and wider: two units per row, each ~half width. A lone trailing
   unit (odd number of units) wraps to its own row and, thanks to the timer's
   justify-content:center, sits centered across the full width. */
@media (min-width: 350px) and (max-width: 500px) {
	.cds-unit {
		/* Two units fit per row; a third wraps to the next row. */
		width: calc(50% - 0.3rem);
	}
}

/* Very narrow phones (under 350px): stack one unit per row, full width. */
@media (max-width: 349.98px) {
	.cds-unit {
		width: 100%;
	}
}
