:root {
	--night: #0f2d45;
	--night-2: #1d4f73;
	--paper: #f7fafc;
	--berry: #b8333e;
	--berry-d: #8f2530;
	--sos: #009ee0;
	--ink: #1c2b36;
	--ease: cubic-bezier(.2, .7, .2, 1);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { background: var(--night); }
body {
	font: 400 1rem/1.55 'Nunito', system-ui, sans-serif;
	color: var(--paper);
	background: radial-gradient(120% 90% at 50% 0%, var(--night-2) 0%, var(--night) 60%) fixed;
	-webkit-font-smoothing: antialiased;
	overflow-x: hidden;
}
.snow { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
.stage {
	position: relative; z-index: 1;
	min-height: 100svh;
	display: grid; justify-items: center; align-content: center;
	padding: max(24px, env(safe-area-inset-top)) 18px 40px;
}

/* ---------- Ümbrik ---------- */
.scene { display: grid; justify-items: center; gap: 22px; transition: opacity .5s var(--ease), transform .5s var(--ease); }
.env {
	--w: min(86vw, 440px);
	position: relative; width: var(--w); aspect-ratio: 3 / 2;
	border: 0; padding: 0; background: none; cursor: pointer;
	perspective: 1200px;
	animation: bob 3.2s ease-in-out infinite;
}
.env:focus-visible { outline: 3px solid var(--paper); outline-offset: 8px; border-radius: 6px; }
.env > span { position: absolute; display: block; }
.env__back { inset: 0; z-index: 0; background: var(--berry-d); border-radius: 6px; }
.env__letter {
	left: 6%; right: 6%; top: 8%; bottom: 8%; z-index: 1;
	background: var(--paper); border-radius: 4px; overflow: hidden;
	box-shadow: 0 2px 10px rgba(0,0,0,.25);
	transition: transform .9s var(--ease) .45s;
}
.env__letter img { width: 100%; height: 100%; object-fit: cover; display: block; }
.env__pocket {
	inset: 0; border-radius: 6px; z-index: 2;
	clip-path: polygon(0 0, 50% 56%, 100% 0, 100% 100%, 0 100%);
	background:
		linear-gradient(to top right, rgba(0,0,0,.10) 49.6%, transparent 50%) left / 50% 100% no-repeat,
		linear-gradient(to top left, rgba(0,0,0,.10) 49.6%, transparent 50%) right / 50% 100% no-repeat,
		var(--berry);
}
.env__to {
	position: absolute; left: 0; right: 0; bottom: 14%;
	text-align: center; font: 700 clamp(1.4rem, 5vw, 1.9rem)/1 'Caveat', cursive; color: var(--paper);
	padding: 0 12%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.env__flap {
	left: 0; right: 0; top: 0; height: 58%; z-index: 3;
	background: linear-gradient(to bottom, #c63d48, var(--berry));
	clip-path: polygon(0 0, 100% 0, 50% 100%);
	border-radius: 6px 6px 0 0;
	transform-origin: top center;
	transition: transform .6s var(--ease), z-index 0s .3s;
}
.env__seal {
	z-index: 4; left: 50%; top: 58%; width: 64px; height: 64px;
	transform: translate(-50%, -50%);
	border-radius: 50%; background: var(--paper);
	box-shadow: 0 0 0 4px rgba(255,255,255,.35), 0 4px 10px rgba(0,0,0,.3);
	display: grid !important; place-items: center; overflow: hidden;
	transition: opacity .3s;
}
.env__seal img { width: 72%; height: 72%; object-fit: contain; }
.env__seal svg { width: 46%; height: 46%; fill: var(--berry); }
.hint { margin: 0; font-size: .95rem; opacity: .85; text-align: center; line-height: 1.5; }
.hint__from { font-size: 1.05rem; font-weight: 700; opacity: 1; }

@keyframes bob { 50% { transform: translateY(-6px); } }

/* Avamine */
.is-opening .env { animation: none; }
.is-opening .env__seal { opacity: 0; }
.is-opening .env__flap { transform: rotateX(180deg); z-index: 0; background: var(--berry-d); }
.is-opening .env__letter { transform: translateY(-62%); }
.is-opening .hint { opacity: 0; }
.is-open .scene { opacity: 0; transform: scale(.92); position: absolute; pointer-events: none; }

/* ---------- Kaart ---------- */
.card {
	position: relative;
	width: min(94vw, 720px);
	background: var(--paper); color: var(--ink);
	border-radius: 10px; overflow: hidden;
	box-shadow: 0 30px 60px -20px rgba(0,0,0,.55);
	display: none;
}
.is-open .card { display: block; animation: rise .8s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(40px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes sink { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(60px) scale(.9); } }
.is-closing .card { animation: sink .45s var(--ease) both; }
.is-closing .foot { opacity: 0; transition: opacity .2s; }
.card:focus { outline: none; }
.card__close {
	position: absolute; top: 10px; right: 10px; z-index: 2;
	width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer;
	background: rgba(15,45,69,.72); display: grid; place-items: center;
	transition: background .2s, transform .2s;
}
.card__close:hover { background: var(--night); transform: scale(1.06); }
.card__close:focus-visible { outline: 3px solid var(--sos); outline-offset: 2px; }
.card__close svg { width: 18px; height: 18px; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; fill: none; }
.sound {
	position: fixed; z-index: 3; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom));
	width: 46px; height: 46px; border-radius: 50%; border: 1px solid rgba(255,255,255,.35); cursor: pointer;
	background: rgba(15,45,69,.6); display: grid; place-items: center; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.sound:focus-visible { outline: 3px solid var(--paper); outline-offset: 3px; }
.sound svg { width: 22px; height: 22px; fill: var(--paper); }
.sound svg .w { fill: none; stroke: var(--paper); stroke-width: 2; stroke-linecap: round; }
.sound .sound__off, .sound.is-muted .sound__on { display: none; }
.sound.is-muted .sound__off { display: block; }
.card__art { margin: 0; background: #e9eef2; }
.card__art img { display: block; width: 100%; max-height: 62vh; object-fit: contain; }
.card__body { padding: clamp(22px, 5vw, 44px); text-align: center; }
.card__hello { margin: 0 0 .3em; font: 700 clamp(2rem, 6vw, 2.6rem)/1.1 'Caveat', cursive; color: var(--berry); }
.card__msg { font: 500 clamp(1.45rem, 4.4vw, 1.85rem)/1.35 'Caveat', cursive; max-width: 34ch; margin: 0 auto; }
.card__sig { margin: 1.1em 0 0; font: 700 clamp(1.3rem, 4vw, 1.6rem)/1.2 'Caveat', cursive; color: #45606f; }
.card__logo { display: block; margin: 22px auto 0; max-width: 180px; max-height: 80px; object-fit: contain; }

/* ---------- Jalus ---------- */
.foot {
	width: min(94vw, 620px); text-align: center; margin-top: 28px;
	font-size: .95rem; opacity: 0; transition: opacity .6s .6s;
	display: none;
}
.is-open .foot { display: block; opacity: 1; }
.foot p { margin: 0 0 14px; }
.foot__links { display: flex; flex-wrap: wrap; gap: 12px 24px; justify-content: center; align-items: center; }
.foot a { color: var(--paper); text-underline-offset: 3px; }
.foot a:focus-visible { outline: 2px solid var(--paper); outline-offset: 3px; }
.foot__cta {
	background: var(--sos); color: #fff !important; text-decoration: none;
	padding: 11px 20px; border-radius: 999px; font-weight: 700;
}

@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { animation: none !important; transition: none !important; }
}
