:root {
  --night: #0b1d2a;
  --night-mid: #12304a;
  --fell-near: #2f5d4f;
  --snow: #f7f4ec;
  --card: #fbf7ee;
  --ink: #23302c;
  --muted: #5f6b66;
  --berry: #c8102e;
  --berry-dark: #8e1c2d;
  --gold: #e7c36a;
  --line: rgba(35, 48, 44, .14);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html { background: #f7f4ec; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  font: 16px/1.55 var(--sans);
  background: var(--fell-near);
  overflow-x: hidden;
}

/* ---------- Night sky, moon and stars ---------- */
.top { position: relative; overflow: hidden; background: linear-gradient(180deg, var(--night) 0%, var(--night-mid) 62%, #1c4256 100%); }
.sky { position: absolute; inset: 0; pointer-events: none; }
.moon { position: absolute; top: 26px; right: 7%; width: clamp(48px, 7vw, 80px); filter: drop-shadow(0 0 18px rgba(253, 243, 207, .5)); }
.star { position: absolute; width: 3px; height: 3px; border-radius: 50%; background: var(--snow); box-shadow: 0 0 6px rgba(255,255,255,.8); animation: twinkle 3.2s ease-in-out infinite; }
@keyframes twinkle { 50% { opacity: .15; transform: scale(.6); } }

/* ---------- Santa's sleigh crossing the sky ---------- */
.sleigh-run { position: absolute; top: 9%; left: 0; z-index: 2; width: clamp(180px, 24vw, 300px); animation: fly 24s linear infinite; pointer-events: none; }
.sleigh { width: 100%; overflow: visible; animation: bob 2.4s ease-in-out infinite; }
@keyframes fly {
  0% { transform: translateX(-110%) translateY(40px) rotate(-4deg); }
  50% { transform: translateX(calc(50vw - 50%)) translateY(-6px) rotate(-1deg); }
  100% { transform: translateX(100vw) translateY(30px) rotate(-5deg); }
}
@keyframes bob { 50% { transform: translateY(-8px); } }
.sleigh .legs path { stroke: #6b4329; stroke-width: 3; stroke-linecap: round; fill: none; }
.legs .leg-a { animation: gallop .5s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: top; }
.legs .leg-b { animation: gallop .5s ease-in-out infinite alternate-reverse; transform-box: fill-box; transform-origin: top; }
@keyframes gallop { from { transform: rotate(-18deg); } to { transform: rotate(18deg); } }
.deer { animation: deer-bob .5s ease-in-out infinite alternate; }
.d2 { animation-delay: .15s; } .d3 { animation-delay: .3s; }
@keyframes deer-bob { to { translate: 0 -3px; } }
.sleigh .wave { transform-box: fill-box; transform-origin: 0% 100%; animation: wave 1s ease-in-out infinite alternate; }
@keyframes wave { from { transform: rotate(-12deg); } to { transform: rotate(18deg); } }
.nose { animation: glow 1.4s ease-in-out infinite; }
.glow { animation: halo 1.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes glow { 50% { fill: #ff8a8a; } }
@keyframes halo { 50% { transform: scale(1.6); opacity: .1; } }
.trail circle { animation: sparkle 1s ease-in-out infinite; }
.trail circle:nth-child(2) { animation-delay: .3s; } .trail circle:nth-child(3) { animation-delay: .6s; }
@keyframes sparkle { 50% { opacity: .1; } }

/* ---------- Heading ---------- */
.masthead { position: relative; z-index: 3; padding: 70px 20px 0; text-align: center; color: var(--snow); }
.kicker { margin: 0; font: 700 13px/1 var(--sans); letter-spacing: .3em; text-transform: uppercase; color: var(--gold); }
h1 { margin: 14px 0 8px; font: 400 clamp(48px, 12vw, 96px)/1 var(--serif); letter-spacing: -.01em; text-shadow: 0 4px 24px rgba(0,0,0,.35); }
h1::after { content: ""; display: block; width: 120px; height: 10px; margin: 12px auto 0; background: radial-gradient(circle, #d7263d 4px, transparent 5px) 0 0 / 20px 10px repeat-x; opacity: .9; }
.lede { margin: 0 auto; max-width: 32ch; color: rgba(247,244,236,.82); font: italic 18px/1.4 var(--serif); }

/* ---------- The fells ---------- */
/* Height follows the width (the scene is 1440 by 360), so wide screens don't crop the peaks. */
.fells { position: relative; z-index: 1; display: block; width: 100%; height: max(230px, min(25vw, 560px)); margin-top: -40px; }
.shimmer { animation: shimmer 4s ease-in-out infinite; }
@keyframes shimmer { 50% { transform: translateX(14px); opacity: .2; } }
.peeker { animation: peek 5s ease-in-out infinite; }
@keyframes peek { 0%, 30%, 100% { translate: 0 22px; } 40%, 80% { translate: 0 0; } 55% { rotate: -8deg; } 65% { rotate: 8deg; } }
.blink { animation: blink 4s infinite; transform-box: fill-box; transform-origin: center; }
@keyframes blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
.stuck { animation: kick .4s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: bottom; }
@keyframes kick { from { transform: rotate(-6deg); } to { transform: rotate(6deg); } }
.smoke circle { animation: smoke 3s ease-out infinite; transform-box: fill-box; transform-origin: center; opacity: 0; }
.smoke circle:nth-child(2) { animation-delay: 1s; } .smoke circle:nth-child(3) { animation-delay: 2s; }
@keyframes smoke { 0% { opacity: .9; transform: translate(0, 20px) scale(.5); } 100% { opacity: 0; transform: translate(-14px, -20px) scale(1.4); } }
.window { animation: flicker 2.6s ease-in-out infinite; }
@keyframes flicker { 50% { fill: #ffbf4d; } }
.herdwick { animation: graze 6s ease-in-out infinite; }
.sheep-head { transform-box: fill-box; transform-origin: 20% 80%; animation: nod 3s ease-in-out infinite; }
@keyframes graze { 50% { translate: 18px 0; } }
@keyframes nod { 40%, 60% { transform: rotate(14deg); } }

/* ---------- Falling snow, three depths ---------- */
.snow { position: fixed; inset: -240px 0 0; z-index: 4; pointer-events: none; background-repeat: repeat; }
.snow.far {
  background-image: radial-gradient(1.2px 1.2px at 20px 30px, #fff, transparent), radial-gradient(1px 1px at 90px 120px, #fff, transparent), radial-gradient(1.4px 1.4px at 150px 60px, #fff, transparent);
  background-size: 180px 180px; opacity: .55; animation: fall 30s linear infinite;
}
.snow.mid {
  background-image: radial-gradient(2px 2px at 40px 50px, #fff, transparent), radial-gradient(2.4px 2.4px at 160px 170px, #fff, transparent), radial-gradient(1.8px 1.8px at 230px 20px, #fff, transparent);
  background-size: 260px 240px; opacity: .7; animation: fall 20s linear infinite;
}
.snow.near {
  background-image: radial-gradient(3.2px 3.2px at 60px 80px, #fff, transparent), radial-gradient(3.6px 3.6px at 280px 220px, #fff, transparent);
  background-size: 360px 320px; opacity: .8; animation: fall 13s linear infinite, drift 6s ease-in-out infinite alternate;
}
@keyframes fall { to { background-position: 0 960px; } }
@keyframes drift { to { translate: 30px 0; } }

/* ---------- Content ---------- */
main { position: relative; z-index: 5; width: 100%; max-width: 620px; margin: 0 auto; padding: 8px 16px 20px; flex: 1; }

.card { position: relative; margin: 0 0 26px; padding: 30px 24px 26px; border-radius: 18px; background: var(--card); box-shadow: 0 18px 40px rgba(5, 18, 18, .35); }
/* A drift of snow along the top of every card */
.card::before {
  content: ""; position: absolute; left: 6px; right: 6px; top: -9px; height: 18px; pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 18'%3E%3Cpath d='M0 12 Q10 0 22 8 Q32 2 44 9 Q56 -1 68 8 Q80 3 92 10 Q104 0 120 9 L120 18 L0 18 Z' fill='%23ffffff'/%3E%3C/svg%3E") repeat-x 0 0 / 120px 18px;
  filter: drop-shadow(0 -1px 1px rgba(0,0,0,.08));
}
.card h2 { margin: 0 0 12px; font: 400 28px/1.15 var(--serif); }
.card h3 { margin: 20px 0 8px; font: 600 13px/1 var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.notice { text-align: center; }
.notice p { margin: 0; color: var(--muted); }
.quiet { margin: 0; color: var(--muted); font-size: 15px; }

/* Fairy lights over the greeting */
.hello { padding-top: 40px; }
.lights { position: absolute; left: 12px; right: 12px; top: 4px; width: calc(100% - 24px); height: 34px; }
.bulbs ellipse { animation: bulb 1.6s ease-in-out infinite; }
.bulbs ellipse:nth-child(2n) { animation-delay: .8s; }
.bulbs ellipse:nth-child(3n) { animation-delay: .4s; }
@keyframes bulb { 50% { opacity: .35; } }

.hello h2 span { color: var(--berry); }
.details { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 16px 0 0; }
.details div { padding: 12px; border: 1px solid var(--line); border-radius: 12px; text-align: center; background: #fff; }
.details dt { font: 600 11px/1.2 var(--sans); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.details dd { margin: 6px 0 0; font: 400 20px/1.2 var(--serif); }

/* The envelope */
.envelope {
  position: relative; display: block; width: min(320px, 100%); aspect-ratio: 16 / 10; margin: 8px auto 12px;
  border: 0; border-radius: 10px; cursor: pointer; overflow: hidden;
  background: linear-gradient(160deg, #d63a46, var(--berry-dark));
  box-shadow: 0 14px 30px rgba(142, 28, 45, .35);
  animation: jiggle 3s ease-in-out infinite;
}
@keyframes jiggle { 0%, 84%, 100% { transform: rotate(0); } 88% { transform: rotate(-3deg); } 92% { transform: rotate(3deg); } 96% { transform: rotate(-2deg); } }
.envelope:hover, .envelope:focus-visible { animation: none; transform: translateY(-3px) scale(1.02); }
.envelope:focus-visible { outline: 3px solid var(--gold); outline-offset: 4px; }
.envelope .flap {
  position: absolute; inset: 0 0 auto; height: 58%;
  background: linear-gradient(200deg, #e2505a, #a52234);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top; transition: transform .45s ease;
}
.envelope .seal {
  position: absolute; left: 50%; top: 58%; transform: translate(-50%, -50%);
  display: grid; place-items: center; width: 54px; height: 54px; border-radius: 50%;
  color: var(--berry-dark); background: var(--gold); font-size: 24px;
  box-shadow: 0 4px 10px rgba(0,0,0,.25); transition: opacity .3s ease;
}
.envelope .label { position: absolute; inset: auto 0 14px; color: var(--snow); font: 600 13px/1 var(--sans); letter-spacing: .14em; text-transform: uppercase; }
.envelope.opening .flap { transform: rotateX(180deg); }
.envelope.opening .seal { opacity: 0; }
#envelope-wrap { text-align: center; }

#revealed { animation: pop .5s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
.drawn-name { margin: 6px 0 0; font: 400 clamp(44px, 11vw, 64px)/1.05 var(--serif); color: var(--berry); }
.wishes { margin: 0; padding-left: 20px; }
.wishes li { margin: 4px 0; }
.wishes li::marker { content: "★ "; color: var(--gold); }
.note { margin: 12px 0 0; padding: 10px 14px; border-left: 3px solid var(--gold); color: var(--muted); font: italic 16px/1.45 var(--serif); }

/* Burst of flakes and stars when the envelope opens */
.burst { position: fixed; z-index: 20; width: 18px; height: 18px; pointer-events: none; animation: burst 1.3s ease-out forwards; }
@keyframes burst { to { transform: translate(var(--dx), var(--dy)) rotate(var(--spin)); opacity: 0; } }

/* Wishlist form */
.ideas { margin: 16px 0 8px; padding: 0; list-style: none; counter-reset: idea; }
.ideas li { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; counter-increment: idea; }
.ideas li::before { content: counter(idea); flex: none; width: 22px; color: var(--muted); font: 400 18px/1 var(--serif); text-align: right; }
input, textarea {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px;
  color: var(--ink); background: #fff; font: inherit;
}
input:focus, textarea:focus { outline: none; border-color: var(--berry); box-shadow: 0 0 0 3px rgba(200, 16, 46, .15); }
textarea { resize: vertical; }
.remove { flex: none; width: 36px; height: 36px; border: 0; border-radius: 50%; color: var(--muted); background: transparent; font-size: 22px; cursor: pointer; }
.remove:hover { color: var(--berry); background: rgba(200, 16, 46, .08); }
.note-field { display: block; margin-top: 16px; font: 600 13px/1.4 var(--sans); color: var(--muted); }
.note-field textarea { margin-top: 6px; font-weight: 400; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin-top: 18px; }
.primary {
  padding: 13px 22px; border: 0; border-radius: 999px; color: var(--snow); font: 600 15px/1 var(--sans); cursor: pointer;
  background: repeating-linear-gradient(-45deg, var(--berry) 0 12px, #e0303f 12px 24px);
  box-shadow: 0 6px 14px rgba(200, 16, 46, .3);
}
.primary:hover { background: repeating-linear-gradient(-45deg, var(--berry-dark) 0 12px, var(--berry) 12px 24px); }
.primary:disabled { opacity: .6; cursor: wait; }
.status { margin: 0; color: var(--muted); font-size: 14px; }
.text-button { padding: 4px 0; border: 0; color: var(--berry); background: transparent; font: 600 14px/1.4 var(--sans); cursor: pointer; }
.text-button:hover { text-decoration: underline; }
#hide { margin-top: 14px; }

.foot { padding: 6px 0 0; text-align: center; color: rgba(247,244,236,.85); font-size: 14px; }
.foot p { margin: 0 0 6px; font: italic 16px/1.4 var(--serif); }
.foot .text-button { color: var(--gold); }

/* ---------- Snowy ground with characters ---------- */
/* 1440 by 230, so 16vw keeps the snowmen's hats on however wide the screen. */
.ground { position: relative; z-index: 5; display: block; width: 100%; height: max(210px, 16vw); margin-top: auto; }
.snowman { animation: sway 3s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 100%; }
@keyframes sway { 50% { rotate: 2deg; } }
.arm-right { transform-box: fill-box; transform-origin: 0% 100%; animation: wave-arm .7s ease-in-out infinite alternate; }
@keyframes wave-arm { from { transform: rotate(-10deg); } to { transform: rotate(22deg); } }
.wonky { animation: wobble 2.2s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 100%; }
@keyframes wobble { 25% { rotate: -6deg; } 75% { rotate: 5deg; } }
.carrot.wobble { transform-box: fill-box; transform-origin: 0% 50%; animation: droop 2.2s ease-in-out infinite; }
@keyframes droop { 50% { transform: rotate(28deg); } }
.prance-run { animation: prance-across 18s linear infinite; }
@keyframes prance-across { from { transform: translate(-90px, 112px); } to { transform: translate(1530px, 112px); } }
.prance { animation: hop .5s ease-in-out infinite alternate; }
@keyframes hop { to { transform: translateY(-16px) rotate(-4deg); } }

/* Phones see only the middle of the ground scene, so bring the snowmen and presents in. */
@media (max-width: 860px) {
  .snowman-spot { transform: translate(548px, 22px); }
  .presents-spot { transform: translate(692px, 92px); }
  .wonky-spot { transform: translate(796px, 66px); }
}

/* Calm for anyone who prefers less movement */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .sleigh-run { left: 52%; top: 12%; }
  .snow { display: none; }
}

@media (max-width: 520px) {
  .masthead { padding-top: 60px; }
  .card { padding: 26px 18px 22px; }
  .hello { padding-top: 38px; }
  .details { grid-template-columns: 1fr; }
  .details div { display: flex; justify-content: space-between; align-items: baseline; text-align: left; }
  .details dd { margin: 0; }
  .sleigh-run { top: 4%; }
}
