:root {
	--night: #100818;
	--wine: #3a0a22;
	--cherry: #d0123d;
	--cherry-deep: #7d0722;
	--gold: #ffc23d;
	--cream: #fff1e0;
	--cream-dim: #e2cfc6;

	--display: 'Fraunces', Georgia, 'Times New Roman', serif;
	--ui: 'Figtree', system-ui, sans-serif;

	--ease-out: cubic-bezier(.2, .8, .2, 1);
	--ease-back: cubic-bezier(.3, 1.4, .5, 1);
	--bottom: calc(24px + env(safe-area-inset-bottom));
}

* { box-sizing: border-box; margin: 0; }

html, body { height: 100%; }

body {
	background: var(--night);
	color: var(--cream);
	font-family: var(--display);
	overflow: hidden;
	-webkit-tap-highlight-color: transparent;
}

.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

/* ---------- Room ---------- */

#room, #stars, #glow, #stage, #confetti {
	position: fixed;
	inset: 0;
}

#room {
	background: radial-gradient(80% 70% at 50% 42%, #e8173f 0%, #c70f37 60%, #a50b2d 100%);
	opacity: 0;
	transition: opacity 1.6s ease;
}
.on #room { opacity: 1; }
.lit #room { opacity: .16; }
.blown #room { opacity: 1; }
.poem #room { opacity: 0; transition-duration: 3s; }

#glow {
	background: radial-gradient(38vmax 34vmax at 50% 58%, rgba(255, 176, 90, .5), transparent 70%);
	opacity: 0;
	transition: opacity 1.2s ease;
	pointer-events: none;
}
.lit #glow { opacity: 1; }
.blown #glow, .poem #glow { opacity: 0; }

#stars { opacity: 0; transition: opacity 4s ease; }
.poem #stars { opacity: 1; }
#stars span {
	position: absolute;
	border-radius: 50%;
	background: var(--cream);
	animation: star 4s ease-in-out infinite;
}
@keyframes star { 50% { opacity: .25; } }

#stage { overflow: hidden; }

#intro {
	position: absolute;
	inset: 0;
	display: grid;
	place-content: center;
	padding: 0 24px;
	text-align: center;
	font-style: italic;
	font-weight: 300;
	font-size: clamp(1.5rem, 5vw, 2.4rem);
	line-height: 1.35;
	color: var(--cream-dim);
	transition: opacity .8s ease;
}
.on #intro { opacity: 0; }

/* ---------- Headline ---------- */

#headline {
	position: absolute;
	inset: 0;
	display: grid;
	place-content: center;
	padding-top: 12dvh;
	z-index: 2;
	text-align: center;
	font-weight: 900;
	font-size: clamp(4rem, min(18vw, 24dvh), 13rem);
	line-height: .92;
	letter-spacing: -.02em;
	color: var(--cream);
	opacity: 0;
	transform: translateY(30px) scale(.94);
	transition: transform .9s var(--ease-back) .25s, opacity .5s ease .25s;
}
.decorated #headline { opacity: 1; transform: none; }
.cake #headline { opacity: 0; transform: scale(1.06); transition-delay: 0s; }

/* ---------- String lights ---------- */

#lights {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 110px;
	z-index: 6;
	transition: opacity 2s ease;
}
.poem #lights { opacity: .3; }
.finale #lights { opacity: 0; }

#lights .wire { fill: none; stroke: #1c1016; stroke-width: 2; }
.on #lights .wire { stroke: var(--wine); transition: stroke 1s; }
#lights .socket { fill: #2a1a20; }
.on #lights .socket { fill: var(--wine); }

.bulb {
	fill: #2e2028;
	transition: fill .35s ease var(--d);
}
.on .bulb {
	fill: var(--c);
	filter: drop-shadow(0 0 7px var(--c));
}
.music .bulb { animation: twinkle 1.5s ease-in-out var(--d) infinite; }
@keyframes twinkle { 50% { opacity: .5; } }

/* ---------- Bunting ---------- */

#bunting {
	position: absolute;
	top: clamp(44px, 8dvh, 72px);
	left: 0;
	right: 0;
	margin-inline: auto;
	width: min(94vw, 640px, 78dvh);
	z-index: 5;
	overflow: visible;
	transform: translateY(-160%);
	transition: transform 1.1s var(--ease-back), opacity 1.4s ease;
	filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .35));
}
.decorated #bunting { transform: none; }
.poem #bunting { opacity: 0; }
#bunting text {
	font-family: var(--display);
	font-weight: 900;
	font-size: 46px;
	text-anchor: middle;
}

/* ---------- Balloons ---------- */

#balloons { position: absolute; inset: 0; z-index: 3; pointer-events: none; }

.balloon {
	position: absolute;
	top: 0;
	left: 0;
	width: var(--bw, 100px);
	transition: transform var(--t, 5s) ease-in-out var(--delay, 0s), width .9s ease;
	will-change: transform;
}
.balloon svg { display: block; width: 100%; overflow: visible; }
.flying .bob { animation: bob 5s ease-in-out var(--d) infinite; transform-origin: 50% 90%; }
@keyframes bob {
	0%, 100% { transform: rotate(-4deg) translateY(0); }
	50% { transform: rotate(4deg) translateY(-10px); }
}
.balloon text {
	font-family: var(--display);
	font-weight: 900;
	font-size: 18px;
	text-anchor: middle;
}

/* ---------- Cake ---------- */

#cake {
	position: absolute;
	left: 0;
	right: 0;
	bottom: calc(var(--bottom) + 72px);
	margin-inline: auto;
	height: min(46dvh, 84vw);
	max-width: 92vw;
	z-index: 4;
	overflow: visible;
	opacity: 0;
	transform: translateY(40px) scale(.8);
	transition: transform .9s var(--ease-back), opacity .6s ease;
}
.cake #cake { opacity: 1; transform: none; }
.poem #cake { opacity: 0; transform: translateY(30px); }

.flame { opacity: 0; transition: opacity .4s ease; filter: drop-shadow(0 0 6px #ffb01f) drop-shadow(0 0 16px rgba(255, 176, 31, .7)); }
.lit .flame { opacity: 1; }
.blown .flame { opacity: 0; transition-duration: .15s; }
.flame path { transform-box: fill-box; transform-origin: 50% 100%; }
.lit .flame path { animation: flicker .5s ease-in-out infinite alternate; animation-delay: var(--d); }
@keyframes flicker {
	from { transform: scale(1, 1) rotate(-2deg); }
	to { transform: scale(.9, 1.12) rotate(2deg); }
}

.smoke { opacity: 0; fill: none; stroke: #e7dcd6; stroke-width: 2.5; stroke-linecap: round; }
.blown .smoke { animation: smoke 1.8s ease-out var(--d) both; }
@keyframes smoke {
	0% { opacity: 0; transform: translateY(6px); }
	25% { opacity: .7; }
	100% { opacity: 0; transform: translateY(-34px); }
}

/* ---------- Poem ---------- */

#poem {
	position: absolute;
	inset: 0;
	z-index: 7;
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	gap: .5em;
	padding: 72px 24px 72px;
	text-align: center;
	font-style: italic;
	font-weight: 300;
	font-size: clamp(1.4rem, 5.2vw, 2.25rem);
	line-height: 1.3;
	transition: opacity .7s ease;
	pointer-events: none;
}
#poem.out { opacity: 0; }
#poem p {
	max-width: 24em;
	opacity: 0;
	transform: translateY(12px);
	transition: opacity 1s ease, transform 1.1s var(--ease-out);
}
#poem p.in { opacity: 1; transform: none; }
#poem p.lead { font-weight: 400; color: var(--gold); }

#hint {
	position: absolute;
	left: 0;
	right: 0;
	bottom: var(--bottom);
	z-index: 7;
	text-align: center;
	font-family: var(--ui);
	font-size: .85rem;
	color: var(--cream-dim);
	opacity: 0;
	transition: opacity .8s ease;
	pointer-events: none;
}
#hint.show { opacity: .8; }

#north {
	position: absolute;
	top: 9dvh;
	left: 0;
	right: 0;
	margin-inline: auto;
	width: clamp(44px, 8dvh, 72px);
	z-index: 7;
	overflow: visible;
	opacity: 0;
	transform: scale(.4);
	transition: opacity 2s ease, transform 2.4s var(--ease-out), top 2.4s var(--ease-out);
	pointer-events: none;
}
#north path {
	fill: var(--gold);
	filter: drop-shadow(0 0 8px var(--gold)) drop-shadow(0 0 26px rgba(255, 194, 61, .7));
}
.north #north { opacity: 1; transform: none; }
.finale #north { top: 20dvh; transform: scale(1.5); }

#finale {
	position: absolute;
	inset: 0;
	z-index: 7;
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	gap: 1.25rem;
	padding: 0 24px;
	text-align: center;
	pointer-events: none;
}
#finale p { opacity: 0; transition: opacity 2.4s ease; }
.finale #finale .love { opacity: 1; }
.signed #finale .sign { opacity: 1; }
.love {
	font-style: italic;
	font-weight: 400;
	font-size: clamp(2.9rem, 12vw, 6.5rem);
	line-height: 1.05;
	letter-spacing: -.01em;
}
.sign {
	font-style: italic;
	font-weight: 300;
	font-size: clamp(1.1rem, 3.6vw, 1.5rem);
	color: var(--gold);
}

/* ---------- Controls ---------- */

#confetti { z-index: 9; pointer-events: none; }

#next {
	position: fixed;
	left: 50%;
	bottom: var(--bottom);
	z-index: 10;
	min-height: 52px;
	max-width: calc(100vw - 32px);
	padding: 0 28px;
	border: 0;
	border-radius: 999px;
	background: var(--cream);
	color: var(--cherry-deep);
	font-family: var(--ui);
	font-weight: 600;
	font-size: 1.05rem;
	white-space: nowrap;
	cursor: pointer;
	transform: translateX(-50%);
	box-shadow: 0 6px 0 rgba(58, 10, 34, .45);
	transition: opacity .35s ease, transform .18s var(--ease-out), background .18s ease;
}
#next:hover { background: #fff; transform: translateX(-50%) translateY(-2px); }
#next:active { transform: translateX(-50%) scale(.97); }
#next:focus-visible, #mute:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
#next[disabled] { opacity: 0; pointer-events: none; }

#mute {
	position: fixed;
	top: calc(12px + env(safe-area-inset-top));
	right: 12px;
	z-index: 10;
	display: grid;
	place-items: center;
	width: 44px;
	height: 44px;
	padding: 10px;
	border: 0;
	border-radius: 50%;
	background: rgba(58, 10, 34, .6);
	color: var(--cream);
	cursor: pointer;
	opacity: 0;
	pointer-events: none;
	transition: opacity .6s ease, background .18s ease;
}
.music #mute { opacity: 1; pointer-events: auto; }
#mute:hover { background: rgba(58, 10, 34, .9); }
#mute svg { width: 100%; }
#mute .cross { display: none; }
#mute[aria-pressed="true"] .cross { display: block; }
#mute[aria-pressed="true"] .waves { display: none; }

@media (prefers-reduced-motion: reduce) {
	.music .bulb, .flying .bob, .lit .flame path, #stars span { animation: none; }
	.balloon { transition-duration: .01s; }
	#bunting, #cake { transition-duration: .3s; }
}
