/* How Long Until… — self-contained, no dependencies. */

:root {
	--bg: #0f141b;
	--surface: #171f2a;
	--primary: #5b8def;
	--silver: #9aaac4;
	--text: #edf1f7;
	--muted: #a7b2c1;
	--border: #2a3441;

	--font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
	--font-display: "Space Grotesk", "Inter", -apple-system, system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
	height: 100%;
}

body {
	margin: 0;
	background:
		radial-gradient(ellipse 90% 60% at 50% -10%, rgba(91, 141, 239, 0.22), transparent 70%),
		var(--bg);
	color: var(--text);
	font-family: var(--font);
	display: grid;
	place-items: center;
	padding: clamp(1rem, 4vw, 3rem);
	overflow-x: hidden;
}

.screen-reader-text {
	position: absolute;
	width: 1px; height: 1px;
	padding: 0; margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.stage {
	width: 100%;
	max-width: 62rem;
	text-align: center;
}

.eyebrow {
	font-family: var(--font-display);
	font-size: 0.75rem;
	font-weight: 700;
	letter-spacing: 0.22em;
	text-transform: uppercase;
	color: var(--primary);
	margin: 0 0 0.75rem;
}

.target {
	font-family: var(--font-display);
	font-size: clamp(1.75rem, 1rem + 4.4vw, 3.75rem);
	font-weight: 700;
	line-height: 1.1;
	letter-spacing: -0.03em;
	margin: 0 0 clamp(1.5rem, 4vw, 2.75rem);
	text-wrap: balance;
	background: linear-gradient(120deg, var(--text) 20%, var(--silver) 100%);
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent;
}

/* ---- the clock ---- */

.clock {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: clamp(0.5rem, 2vw, 1.25rem);
	margin-bottom: 1.75rem;
}

.unit {
	flex: 0 1 auto;
	min-width: clamp(4.25rem, 13vw, 7.5rem);
	padding: clamp(0.75rem, 2vw, 1.25rem) clamp(0.5rem, 1.5vw, 1rem);
	background: rgba(23, 31, 42, 0.72);
	border: 1px solid var(--border);
	border-radius: 14px;
	backdrop-filter: blur(6px);
}

.unit[hidden] { display: none; }

.unit__value {
	display: block;
	font-family: var(--font-display);
	font-size: clamp(1.5rem, 0.9rem + 3.4vw, 3rem);
	font-weight: 700;
	line-height: 1;
	letter-spacing: -0.04em;
	font-variant-numeric: tabular-nums;
	/* Fixed-width digits stop the layout twitching every tick. */
}

.unit__label {
	display: block;
	margin-top: 0.4rem;
	font-size: clamp(0.625rem, 0.5rem + 0.3vw, 0.75rem);
	font-weight: 500;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--muted);
}

/* Seconds get the accent — it is the only one visibly moving. */
.unit:last-child .unit__value { color: var(--primary); }

.huge {
	font-family: var(--font-display);
	font-size: clamp(1.75rem, 1rem + 4vw, 3.25rem);
	font-weight: 700;
	letter-spacing: -0.03em;
	color: var(--primary);
	margin: 0 0 1.75rem;
	font-variant-numeric: tabular-nums;
}

.huge[hidden] { display: none; }

.note {
	max-width: 44ch;
	margin: 0 auto clamp(1.75rem, 4vw, 2.5rem);
	color: var(--muted);
	font-size: clamp(0.875rem, 0.8rem + 0.3vw, 1.0625rem);
	line-height: 1.6;
	text-wrap: pretty;
	min-height: 3.2em;
}

/* ---- controls ---- */

.controls {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	flex-wrap: wrap;
}

.ctrl {
	display: inline-grid;
	place-items: center;
	width: 44px;
	height: 44px;
	flex: none;
	border: 1px solid var(--border);
	border-radius: 999px;
	background: rgba(23, 31, 42, 0.72);
	color: var(--muted);
	cursor: pointer;
}

.ctrl svg {
	width: 20px;
	height: 20px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2.5;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.ctrl:hover {
	color: var(--text);
	border-color: var(--silver);
}

.picker {
	font-family: var(--font);
	font-size: 0.9375rem;
	color: var(--text);
	background: rgba(23, 31, 42, 0.72);
	border: 1px solid var(--border);
	border-radius: 999px;
	padding: 0.7rem 1.25rem;
	cursor: pointer;
	max-width: min(24rem, 70vw);
	appearance: none;
	text-align: center;
	text-align-last: center;
}

.picker:hover { border-color: var(--silver); }
.picker option { background: var(--surface); color: var(--text); }

.hint {
	margin: 1.25rem 0 0;
	font-size: 0.75rem;
	letter-spacing: 0.06em;
	color: var(--muted);
	opacity: 0.65;
}

@media (hover: none) {
	.hint { display: none; }
}

:focus-visible {
	outline: 2px solid var(--primary);
	outline-offset: 3px;
}

@media (prefers-reduced-motion: no-preference) {
	.ctrl, .picker { transition: color 150ms ease, border-color 150ms ease; }
	.target, .note { transition: opacity 200ms ease; }
	.stage.is-swapping .target,
	.stage.is-swapping .note { opacity: 0; }
}

/* The site embeds this in a light-themed page too; keep it dark either way. */
@media (prefers-color-scheme: light) {
	body { color-scheme: dark; }
}
