/* Christmas theme: a snowy pine-green night (midnight blue in dark mode),
   twinkling lights, warm paper-coloured cards with red, green and gold. */

@font-face {
  font-family: 'Mountains of Christmas';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/mountains-of-christmas-latin-700-normal.woff2') format('woff2');
}

:root {
  --page-top: #1f4d37;
  --page-bottom: #0d2619;
  --on-bg: #fff8ec;
  --on-bg-muted: #cddfd2;
  --gold: #f2c14e;
  --card: #fffaf2;
  --tint: #fbf0e1;
  --field: #ffffff;
  --text: #2b2421;
  --muted: #6f655e;
  --border: #ead9c2;
  --accent: #b3261e;
  --accent-hover: #93201a;
  --accent-soft: #fbe6e3;
  --green: #2a6a43;
  --green-soft: #e2f1e6;
  --warn-soft: #fff1cf;
  --warn-text: #6b5000;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .28);
  --festive: 'Mountains of Christmas', Georgia, 'Times New Roman', serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --page-top: #10203a;
    --page-bottom: #050b16;
    --on-bg: #f4efe6;
    --on-bg-muted: #a9b6c9;
    --card: #182233;
    --tint: #1f2b3f;
    --field: #101827;
    --text: #f2ede6;
    --muted: #a7b0bd;
    --border: #2d3b52;
    --accent: #e2574c;
    --accent-hover: #f06c63;
    --accent-soft: #3a1f24;
    --green: #74c795;
    --green-soft: #17302a;
    --warn-soft: #3a3016;
    --warn-text: #f1d68a;
    --shadow: 0 10px 30px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  min-height: 100%;
  background: linear-gradient(180deg, var(--page-top), var(--page-bottom)) fixed;
  background-color: var(--page-bottom);
}
body {
  margin: 0; color: var(--text); min-height: 100vh; overflow-x: hidden;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ---------- falling snow (two layers, pure CSS) ---------- */
body::before, body::after {
  content: ''; position: fixed; left: 0; right: 0; bottom: 0; pointer-events: none; z-index: 0;
  will-change: transform;
}
body::before {
  top: -220px;
  background-image:
    radial-gradient(2.5px 2.5px at 20px 30px, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 80px 120px, #fff 50%, transparent 51%),
    radial-gradient(3px 3px at 150px 60px, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 190px 170px, #fff 50%, transparent 51%),
    radial-gradient(2.5px 2.5px at 110px 200px, #fff 50%, transparent 51%);
  background-size: 220px 220px;
  opacity: .75;
  animation: snow-a 14s linear infinite;
}
body::after {
  top: -340px;
  background-image:
    radial-gradient(4px 4px at 40px 80px, #fff 50%, transparent 51%),
    radial-gradient(3px 3px at 230px 40px, #fff 50%, transparent 51%),
    radial-gradient(4.5px 4.5px at 300px 250px, #fff 50%, transparent 51%),
    radial-gradient(3.5px 3.5px at 140px 300px, #fff 50%, transparent 51%);
  background-size: 340px 340px;
  opacity: .45;
  filter: blur(1px);
  animation: snow-b 24s linear infinite;
}
@keyframes snow-a { from { transform: translate3d(0, 0, 0); } to { transform: translate3d(0, 220px, 0); } }
@keyframes snow-b { from { transform: translate3d(0, 0, 0); } to { transform: translate3d(0, 340px, 0); } }

.wrap {
  position: relative; z-index: 1; max-width: 760px; margin: 0 auto;
  /* Keep clear of the notch and home bar when installed on a phone. */
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(40px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

/* ---------- header and string of lights ---------- */
header.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0 0; }
header.top .brand {
  font-family: var(--festive); font-weight: 700; font-size: 1.75rem; line-height: 1.1;
  color: var(--gold); text-decoration: none; text-shadow: 0 2px 10px rgba(0, 0, 0, .35);
}
header.top .right { display: flex; gap: 8px; align-items: center; }
header.top select.lang, header.top button.secondary {
  background: rgba(255, 255, 255, .1); color: var(--on-bg); border-color: rgba(255, 255, 255, .28);
}
header.top select.lang option { color: #2b2421; }
header.top button.secondary:hover { background: rgba(255, 255, 255, .2); }

.lights {
  position: relative; display: flex; justify-content: space-between;
  height: 34px; margin: 4px -4px 14px; padding: 0 4px;
}
.lights::before { /* the wire */
  content: ''; position: absolute; left: 0; right: 0; top: 7px; height: 2px;
  background: rgba(20, 40, 28, .9); border-radius: 2px; box-shadow: 0 1px 0 rgba(255, 255, 255, .08);
}
.lights span {
  --c: #ff4d4d;
  position: relative; width: 11px; height: 17px; margin-top: 12px; border-radius: 50%;
  background: var(--c); box-shadow: 0 3px 14px 3px var(--c);
  animation: twinkle 2.6s ease-in-out infinite;
}
.lights span::before { /* socket */
  content: ''; position: absolute; left: 2px; top: -5px; width: 7px; height: 6px;
  border-radius: 2px; background: #2e3b33;
}
.lights span:nth-child(4n+2) { --c: #ffd24d; animation-delay: -.6s; }
.lights span:nth-child(4n+3) { --c: #55e08a; animation-delay: -1.3s; }
.lights span:nth-child(4n+4) { --c: #5cc8ff; animation-delay: -1.9s; }
.lights span:nth-child(3n) { animation-duration: 3.4s; }
.lights span:nth-child(5n) { animation-duration: 2.1s; }
@keyframes twinkle {
  0%, 100% { opacity: 1; box-shadow: 0 3px 14px 3px var(--c); }
  50% { opacity: .45; box-shadow: 0 0 3px 0 var(--c); }
}

footer.foot { text-align: center; color: var(--on-bg-muted); font-size: .9rem; margin-top: 28px; }
footer.foot .festive { font-family: var(--festive); font-weight: 700; font-size: 1.35rem; color: var(--gold); }

/* ---------- type ---------- */
h1 { font-family: var(--festive); font-weight: 700; font-size: 2.3rem; margin: 0 0 8px; line-height: 1.15; }
h2 { font-family: var(--festive); font-weight: 700; font-size: 1.65rem; margin: 0 0 10px; line-height: 1.2; color: var(--green); }
h3 { font-size: 1rem; margin: 0 0 8px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* Text sitting directly on the night background, outside the cards. */
.wrap > :not(.card) { color: var(--on-bg); }
.wrap > :not(.card) .muted, .wrap > .muted { color: var(--on-bg-muted); }
.wrap > :not(.card) h1, .wrap > h1 { text-shadow: 0 2px 12px rgba(0, 0, 0, .35); }
.wrap > p .link, .wrap > :not(.card) > .link { color: var(--gold); }
.wrap > .actions button.ghost { color: var(--on-bg-muted); }
.wrap > .actions button.ghost:hover { color: var(--gold); }

/* ---------- cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow);
}
/* The highlighted card (the draw, "you give a present to") gets a candy-cane
   ribbon along the top and a bow. */
.card.hero { position: relative; overflow: hidden; padding-top: 30px; border-color: var(--gold); }
.card.hero::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 9px;
  background: repeating-linear-gradient(135deg, var(--accent) 0 12px, #fff 12px 24px);
}
.card.hero::after {
  content: '🎀'; position: absolute; top: 2px; right: 14px; font-size: 2rem; line-height: 1;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .25));
}
.present-card.hero::after { content: none; } /* the present has its own bow */
.card.hero .recipient-name {
  font-family: var(--festive); font-weight: 700; font-size: 2.8rem; line-height: 1.1;
  color: var(--accent); margin: 2px 0 14px;
}

/* ---------- forms and buttons ---------- */
label { display: block; font-weight: 600; font-size: .9rem; margin: 12px 0 4px; }
input[type=text], input[type=email], input[type=password], input[type=url], textarea, select {
  width: 100%; font: inherit; color: var(--text); background: var(--field);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
select.lang { width: auto; padding: 6px 8px; font-size: .875rem; }

button, .btn {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 10px; padding: 10px 16px;
  border: 1px solid var(--accent); background: var(--accent); color: #fff; text-decoration: none; display: inline-block;
}
button:hover { background: var(--accent-hover); }
button.secondary { background: transparent; color: var(--text); border-color: var(--border); }
button.secondary:hover { background: var(--accent-soft); }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); padding: 6px 8px; }
button.ghost:hover { color: var(--accent); background: transparent; }
button.small { padding: 6px 10px; font-size: .85rem; }
button.big {
  font-size: 1.2rem; padding: 14px 30px; border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(242, 193, 78, .25), 0 6px 16px rgba(179, 38, 30, .35);
}
button:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row > .grow { flex: 1 1 180px; min-width: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.check { display: flex; align-items: center; gap: 6px; font-weight: 400; margin: 0; }

/* ---------- lists, badges, notices ---------- */
.list { list-style: none; padding: 0; margin: 0; }
.list > li { padding: 12px 0; border-top: 1px dashed var(--border); }
.list > li:first-child { border-top: 0; }
.event-link { display: flex; justify-content: space-between; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.event-link strong::before { content: '🎄 '; }
.event-link:hover strong { color: var(--accent); }

.badge { display: inline-block; font-size: .75rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--green-soft); color: var(--green); white-space: nowrap; }
.badge.drawn { background: var(--accent-soft); color: var(--accent); }
.badge.archived { background: var(--border); color: var(--muted); }
.badge.info { background: var(--warn-soft); color: var(--warn-text); font-weight: 600; }

.participant { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; align-items: center; }
.participant .who { min-width: 0; }
.participant .who strong { margin-right: 6px; }

.notice { padding: 12px 14px; border-radius: 10px; background: var(--warn-soft); color: var(--warn-text); margin: 10px 0; font-size: .925rem; }
.notice.ok { background: var(--green-soft); color: var(--green); }
.error { color: var(--accent); font-weight: 600; margin-top: 8px; min-height: 1px; }
.error:empty { display: none; }

.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--tint); border: 1px solid var(--border); border-radius: 999px; padding: 2px 10px; font-size: .875rem; }

.suggestions { display: grid; gap: 12px; }
.suggestion { display: flex; gap: 14px; border: 1px solid var(--border); border-radius: 12px; padding: 12px; background: var(--tint); align-items: flex-start; }
.suggestion img { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; display: block; background: var(--border); }
.suggestion-body { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.suggestion-body p { white-space: pre-wrap; }
.link { color: var(--accent); font-weight: 600; text-decoration: none; }
.link:hover { text-decoration: underline; }
.or { text-align: center; font-size: .85rem; color: var(--muted); margin: 6px 0; }
input[type=file] { font-size: .9rem; max-width: 100%; }
details.card > summary { cursor: pointer; }

/* Cards nested in an element on the night background keep card colours. */
.wrap > :not(.card) .card { color: var(--text); }
.wrap > :not(.card) .card .muted { color: var(--muted); }

/* "Install the app" card */
.card.install { display: flex; gap: 14px; align-items: flex-start; padding: 14px 16px; }
.card.install img { border-radius: 12px; flex: none; }
.install-body { flex: 1; min-width: 0; }
.install-body p { margin: 2px 0 8px; }

/* ---------- the wrapped present (participant page) ---------- */
.present-card { text-align: center; }
.present {
  all: unset; display: block; position: relative; width: 150px; height: 150px;
  margin: 14px auto 8px; cursor: pointer; border-radius: 12px;
  animation: wiggle 3.5s ease-in-out infinite;
}
.present:hover { background: transparent; animation-duration: 1.2s; }
.present:focus-visible { outline: 3px solid var(--gold); outline-offset: 6px; }
.present .box, .present .lid {
  position: absolute; border-radius: 6px;
  background: linear-gradient(90deg, transparent 44%, var(--gold) 44%, var(--gold) 56%, transparent 56%), var(--accent);
}
.present .box { left: 14px; right: 14px; bottom: 0; height: 92px; box-shadow: inset 0 -12px 0 rgba(0, 0, 0, .12), 0 10px 22px rgba(0, 0, 0, .3); }
.present .lid {
  left: 4px; right: 4px; bottom: 88px; height: 28px; background-color: var(--accent-hover);
  box-shadow: 0 4px 8px rgba(0, 0, 0, .2); transition: transform .7s cubic-bezier(.3, 1.4, .5, 1), opacity .7s;
}
.present .bow {
  position: absolute; left: 50%; bottom: 106px; transform: translateX(-50%);
  font-size: 44px; line-height: 1; transition: transform .7s, opacity .7s;
}
.present.opening { animation: shake .35s ease-in-out 2; }
.present.opening .lid { transform: translateY(-80px) rotate(-20deg); opacity: 0; }
.present.opening .bow { transform: translate(-50%, -110px) rotate(25deg); opacity: 0; }
@keyframes wiggle {
  0%, 84%, 100% { transform: rotate(0); }
  88% { transform: rotate(-5deg); }
  92% { transform: rotate(5deg); }
  96% { transform: rotate(-3deg); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px) rotate(-3deg); }
  75% { transform: translateX(6px) rotate(3deg); }
}
.reveal-in { animation: reveal .6s ease-out; }
@keyframes reveal { from { opacity: 0; transform: scale(.94) translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- small screens and reduced motion ---------- */
@media (max-width: 480px) {
  .card { padding: 16px; }
  .card.hero { padding-top: 28px; }
  h1 { font-size: 1.9rem; }
  header.top .brand { font-size: 1.45rem; }
  .card.hero .recipient-name { font-size: 2.3rem; }
  .suggestion img { width: 72px; height: 72px; }
  .lights span:nth-child(n+15) { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  body::before, body::after, .lights span, .present, .reveal-in { animation: none !important; }
  .present .lid, .present .bow { transition: none !important; }
}
