/* ====== Kris Kringle — Midnight Pine theme ====== */
@import url('https://fonts.googleapis.com/css2?family=Mountains+of+Christmas:wght@700&family=Nunito:wght@400;600;800;900&display=swap');

:root {
  --night: #071a13;
  --pine: #0f3326;
  --pine-light: #1b4d3a;
  --holly: #2e8b57;
  --holly-light: #6fcf97;
  --cranberry: #c8102e;
  --cranberry-dark: #8e0b20;
  --gold: #f2c14e;
  --gold-deep: #c9952b;
  --snow: #fffaf0;
  --frost: #eef6f2;
  --ink: #1d1a17;
  --ink-soft: #5a6660;
  --line: #e2d9c6;

  --font-display: 'Mountains of Christmas', 'Georgia', serif;
  --font-body: 'Nunito', 'Trebuchet MS', sans-serif;

  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-card: 0 18px 40px rgba(0, 0, 0, 0.35), 0 2px 0 rgba(255, 255, 255, 0.6) inset;
  --gutter: clamp(16px, 4vw, 40px);
  --tree-indent: clamp(12px, 2.4vw, 22px);
}

*, *::before, *::after { box-sizing: border-box; }

html { background: var(--night); }

body {
  margin: 0;
  min-height: 100vh;
  font: 400 17px/1.55 var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(242, 193, 78, 0.12), transparent 60%),
    radial-gradient(900px 500px at 0% 10%, rgba(46, 139, 87, 0.25), transparent 60%),
    linear-gradient(180deg, var(--night) 0%, var(--pine) 55%, var(--night) 100%);
  background-attachment: fixed;
  overflow-x: hidden;
}

/* ---------- Snowfall (pure CSS, two parallax layers) ---------- */
.snow, .snow::after {
  position: fixed;
  inset: -100vh 0 0 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    radial-gradient(3px 3px at 20px 30px, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 90px 120px, rgba(255, 255, 255, 0.85) 50%, transparent 51%),
    radial-gradient(4px 4px at 160px 60px, rgba(255, 255, 255, 0.9) 50%, transparent 51%),
    radial-gradient(2px 2px at 230px 180px, #fff 50%, transparent 51%),
    radial-gradient(3px 3px at 300px 90px, rgba(255, 255, 255, 0.7) 50%, transparent 51%);
  background-size: 320px 220px;
  animation: snowfall 18s linear infinite;
  opacity: 0.55;
}
.snow::after {
  content: '';
  inset: 0;
  background-size: 210px 160px;
  animation-duration: 11s;
  opacity: 0.8;
  filter: blur(0.6px);
}
@keyframes snowfall {
  from { transform: translateY(0); }
  to { transform: translateY(100vh); }
}

/* ---------- Fairy lights ---------- */
.lights {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 0;
  padding: 10px var(--gutter) 0;
  list-style: none;
  overflow: hidden;
  border-top: 3px solid #0b2219;
}
.lights li {
  flex: 0 0 auto;
  width: 12px;
  height: 22px;
  border-radius: 50%;
  background: var(--bulb);
  box-shadow: 0 4px 18px 3px var(--bulb);
  animation: twinkle 2.4s ease-in-out infinite alternate;
}
.lights li::before {
  content: '';
  display: block;
  width: 8px;
  height: 6px;
  margin: -6px auto 0;
  border-radius: 2px;
  background: #24372f;
}
.lights li:nth-child(4n + 1) { --bulb: var(--cranberry); }
.lights li:nth-child(4n + 2) { --bulb: var(--gold); animation-delay: 0.6s; }
.lights li:nth-child(4n + 3) { --bulb: var(--holly-light); animation-delay: 1.2s; }
.lights li:nth-child(4n + 4) { --bulb: #7cc6ff; animation-delay: 1.8s; }
@keyframes twinkle {
  0%, 60% { opacity: 1; }
  100% { opacity: 0.35; box-shadow: 0 2px 6px 0 var(--bulb); }
}

/* ---------- A bemused kangaroo, wondering why it's snowing ---------- */
.roo {
  --roo-cycle: 9s;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 18px;
}
.roo__thought {
  position: relative;
  display: grid;
  margin: 0 0 14px;
  padding: 8px 16px;
  background: var(--snow);
  border-radius: 18px;
  color: var(--ink);
  font-weight: 800;
  font-size: 14px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}
/* Thought-bubble puffs trailing down to the roo. */
.roo__thought::before, .roo__thought::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  background: var(--snow);
}
.roo__thought::before { width: 12px; height: 12px; bottom: -10px; left: calc(50% - 18px); }
.roo__thought::after { width: 7px; height: 7px; bottom: -18px; left: calc(50% - 10px); }
.roo__thought span {
  grid-area: 1 / 1;
  text-align: center;
  opacity: 0;
  animation: roo-thought calc(var(--roo-cycle) * 3) infinite;
}
.roo__thought span:nth-child(2) { animation-delay: var(--roo-cycle); }
.roo__thought span:nth-child(3) { animation-delay: calc(var(--roo-cycle) * 2); }
.roo__body {
  position: relative;
  font-size: 96px;
  line-height: 1;
  transform-origin: 50% 100%;
  animation: roo-ponder var(--roo-cycle) ease-in-out infinite;
}
/* Snow settles on the roo's head until it shakes it off. */
.roo__snow-cap {
  /* em units keep the cap on the roo's head as the emoji scales. */
  position: absolute;
  top: 0.15em;
  left: 0.16em;
  width: 0.24em;
  height: 0.11em;
  border-radius: 55% 55% 35% 35%;
  background: #fff;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.8);
  transform-origin: 50% 100%;
  animation: roo-snow-cap var(--roo-cycle) ease-in infinite;
}
@keyframes roo-thought {
  0%, 3% { opacity: 0; }
  8%, 28% { opacity: 1; }
  33%, 100% { opacity: 0; }
}
@keyframes roo-ponder {
  0%, 20% { transform: rotate(0); }
  30%, 55% { transform: rotate(6deg); }
  65%, 74% { transform: rotate(0); }
  77% { transform: rotate(-10deg); }
  80% { transform: rotate(10deg); }
  83% { transform: rotate(-7deg); }
  86%, 100% { transform: rotate(0); }
}
@keyframes roo-snow-cap {
  0% { transform: scale(0.3, 0); opacity: 1; }
  74% { transform: scale(1, 1); opacity: 1; }
  82% { transform: translate(-34px, -26px) rotate(-50deg) scale(0.6); opacity: 0; }
  100% { transform: scale(0.3, 0); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .snow, .snow::after, .lights li, .loading::before, .roo__body, .roo__snow-cap { animation: none; }
  .roo__thought span { animation: none; }
  .roo__thought span:first-child { opacity: 1; }
}

/* ---------- Layout ---------- */
.page {
  position: relative;
  z-index: 1;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 var(--gutter) 64px;
}

.masthead {
  text-align: center;
  padding: clamp(28px, 6vw, 64px) 0 clamp(20px, 4vw, 36px);
  color: var(--snow);
}
.masthead__eyebrow {
  display: inline-block;
  margin: 0 0 8px;
  padding: 4px 14px;
  border: 1px solid rgba(242, 193, 78, 0.5);
  border-radius: 999px;
  color: var(--gold);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.masthead__title {
  margin: 0;
  font: 700 clamp(48px, 10vw, 104px)/1 var(--font-display);
  color: var(--snow);
  text-shadow: 0 3px 0 var(--cranberry-dark), 0 10px 30px rgba(200, 16, 46, 0.45);
}
.masthead__title a { color: inherit; text-decoration: none; }
.masthead__subtitle {
  max-width: 620px;
  margin: 14px auto 0;
  color: var(--frost);
  font-size: clamp(16px, 2.2vw, 20px);
}
.countdown {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 20px;
  padding: 10px 20px;
  border-radius: 999px;
  background: rgba(255, 250, 240, 0.08);
  border: 1px solid rgba(255, 250, 240, 0.18);
  color: var(--snow);
  font-weight: 800;
}
.countdown:empty { display: none; }
.countdown__number {
  font: 700 30px/1 var(--font-display);
  color: var(--gold);
}

/* ---------- Present-style cards ---------- */
.card {
  position: relative;
  margin: 0 0 clamp(24px, 4vw, 40px);
  padding: clamp(22px, 4vw, 40px);
  background: var(--snow);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}
/* Ribbon wrapped around the present, with a bow on the top edge. */
.card::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  right: clamp(28px, 8vw, 90px);
  width: 16px;
  background: linear-gradient(90deg, var(--cranberry-dark), var(--cranberry) 45%, var(--cranberry-dark));
  opacity: 0.9;
}
.card::after {
  content: '🎀';
  position: absolute;
  top: -26px;
  right: calc(clamp(28px, 8vw, 90px) - 18px);
  font-size: 40px;
  line-height: 1;
  filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.35));
}
.card > * { position: relative; }
/* On phones the ribbon would cut through form fields, so keep only the bow. */
@media (max-width: 640px) {
  .card::before { display: none; }
  .card__title, .card__lead, .results-group__header { padding-right: 0; }
}
.card__title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 6px;
  padding-right: clamp(40px, 10vw, 110px);
  font: 700 clamp(34px, 5vw, 50px)/1.1 var(--font-display);
  color: var(--pine);
}
.card__lead { margin: 0 0 22px; padding-right: clamp(40px, 10vw, 110px); color: var(--ink-soft); }

a { color: var(--cranberry); font-weight: 800; }

/* ---------- Forms & buttons ---------- */
label {
  display: block;
  margin-bottom: 6px;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
input[type='text'], input[type='search'], input[type='password'], select {
  width: 100%;
  padding: 12px 14px;
  font: 600 16px var(--font-body);
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus-visible, select:focus-visible, .button:focus-visible {
  outline: none;
  border-color: var(--holly);
  box-shadow: 0 0 0 4px rgba(46, 139, 87, 0.25);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  font: 900 16px var(--font-body);
  color: var(--snow);
  background: linear-gradient(180deg, var(--cranberry), var(--cranberry-dark));
  border: 2px solid var(--gold);
  border-radius: 999px;
  box-shadow: 0 6px 0 #5c0715, 0 10px 20px rgba(142, 11, 32, 0.35);
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
}
.button:hover { transform: translateY(-1px); }
.button:active { transform: translateY(4px); box-shadow: 0 2px 0 #5c0715; }
.button:disabled { opacity: 0.6; cursor: progress; transform: none; }
.button--gold {
  color: var(--ink);
  background: linear-gradient(180deg, #ffd978, var(--gold-deep));
  border-color: #fff3cf;
  box-shadow: 0 6px 0 #8a6416, 0 10px 20px rgba(201, 149, 43, 0.35);
}
.button--gold:active { box-shadow: 0 2px 0 #8a6416; }
.button--quiet {
  padding: 8px 14px;
  font-size: 14px;
  color: var(--pine);
  background: var(--frost);
  border: 2px solid var(--line);
  box-shadow: none;
}
.button--quiet:active { box-shadow: none; transform: translateY(1px); }
.button--danger { color: var(--cranberry-dark); }

.signup {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px;
}
.signup__field { flex: 1 1 260px; }

/* ---------- Home page rules ---------- */
.rules {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.rules li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 16px;
  background: #fff;
  border: 2px dashed var(--line);
  border-radius: var(--radius-md);
  font-weight: 600;
}
.rules__icon { font-size: 26px; line-height: 1; }

/* ---------- Share box ---------- */
.share {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  align-items: center;
  margin: 0 0 18px;
  padding: 14px 16px;
  background: #fff7e0;
  border: 2px solid #f4dc9c;
  border-radius: var(--radius-md);
}
.share__label { margin: 0; flex-basis: 100%; }
.share__url {
  flex: 1 1 280px;
  min-width: 0;
  overflow-wrap: anywhere;
  font: 700 14px/1.4 ui-monospace, 'SF Mono', Menlo, monospace;
  color: var(--pine);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-end;
  margin-bottom: 8px;
}
.toolbar__search { flex: 1 1 260px; }

/* ---------- Alerts & admin forms ---------- */
.alert, .notice {
  margin: 0 0 18px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-weight: 800;
}
.alert { background: #fde4e7; border: 2px solid #f4b3bd; color: var(--cranberry-dark); }
.alert[hidden] { display: none; }
.alert--toast {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: 20px;
  width: min(560px, calc(100vw - 32px));
  margin: 0;
  transform: translateX(-50%);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}
.notice { background: #e2f4e9; border: 2px solid #b5dfc6; color: #1d5e3a; }

.card--narrow { max-width: 560px; margin-left: auto; margin-right: auto; }
.stacked-form { display: grid; gap: 16px; justify-items: start; }
.stacked-form > div { width: 100%; }
.logout { margin-top: 18px; }
.admin-link { text-align: center; margin: 0 0 24px; }
.admin-link a { color: var(--gold); }

/* ---------- Results: gift tags ---------- */
.results-group { margin-top: 30px; }
.results-group__header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 16px;
  margin-bottom: 14px;
  padding-bottom: 8px;
  padding-right: clamp(40px, 10vw, 110px);
  border-bottom: 3px dotted var(--line);
}
.results-group__title {
  margin: 0;
  font: 700 clamp(28px, 4vw, 36px)/1.1 var(--font-display);
  color: var(--cranberry);
}
.results-group__stats { margin: 0; font-size: 14px; color: var(--ink-soft); }

.tags {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}
.tag {
  position: relative;
  padding: 18px 18px 14px 30px;
  background: linear-gradient(135deg, #fff 0%, #fffaf0 100%);
  border: 2px solid var(--line);
  border-radius: 6px 18px 18px 6px;
  box-shadow: 0 6px 14px rgba(15, 51, 38, 0.1);
  transition: transform 0.15s, box-shadow 0.15s;
}
/* The punched hole of a gift tag. */
.tag::before {
  content: '';
  position: absolute;
  top: 18px;
  left: 10px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--pine);
  box-shadow: 0 0 0 3px var(--gold);
}
.tag:hover { transform: rotate(-1deg) translateY(-2px); box-shadow: 0 12px 22px rgba(15, 51, 38, 0.16); }
.tag__giver, .tag__receiver {
  display: block;
  font-weight: 900;
  font-size: 18px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.tag__arrow {
  display: block;
  margin: 4px 0;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--holly);
}
.tag__receiver { color: var(--cranberry); }
.tag__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  font-size: 13px;
  color: var(--ink-soft);
}
.tag__distance {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  font: 800 13px var(--font-body);
  color: var(--pine);
  background: var(--frost);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}
.tag__distance:hover, .tag__distance:focus-visible {
  outline: none;
  border-color: var(--holly);
  background: #ddf3e6;
}
.tag--year-off { background: var(--frost); }
.tag--year-off .tag__receiver { color: var(--holly); }
.tag[hidden] { display: none; }

.empty-state {
  padding: 30px 20px;
  text-align: center;
  color: var(--ink-soft);
  font-weight: 600;
}
.empty-state__icon { display: block; font-size: 44px; margin-bottom: 8px; }

.save-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-top: 28px;
}
.save-bar__status { margin: 0; font-weight: 800; color: var(--holly); }
.save-bar__status--error { color: var(--cranberry); }

.loading {
  padding: 24px;
  text-align: center;
  font-weight: 800;
  color: var(--ink-soft);
}
.loading::before {
  content: '❄';
  display: inline-block;
  margin-right: 8px;
  color: var(--holly);
  animation: spin 1.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- How are we connected? dialog ---------- */
.connection {
  width: min(760px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--snow);
  color: var(--ink);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.45);
}
.connection::backdrop { background: rgba(7, 26, 19, 0.7); backdrop-filter: blur(2px); }
.connection__body { position: relative; padding: clamp(20px, 4vw, 32px); }
.connection__close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: var(--frost);
  color: var(--pine);
  font-size: 16px;
  cursor: pointer;
}
.connection__close:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(46, 139, 87, 0.4); }
.connection__title {
  margin: 0 40px 4px 0;
  font: 700 clamp(28px, 4vw, 36px)/1.1 var(--font-display);
  color: var(--pine);
}
.connection__eyebrow {
  margin: 0 0 6px;
  color: var(--cranberry);
  font-weight: 900;
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.connection__summary { margin: 0 0 4px; font-weight: 700; }
.connection__quip { margin: 0 0 16px; color: var(--holly); font-weight: 800; font-style: italic; }
.connection__diagram {
  overflow-x: auto;
  padding: 8px 0;
  border: 2px dashed var(--line);
  border-radius: var(--radius-md);
  background: #fff;
}
.connection__svg { display: block; height: auto; margin: 0 auto; }
.connection__legend { margin: 12px 0 0; font-size: 14px; color: var(--ink-soft); }
.connection-link { stroke: var(--gold-deep); stroke-width: 3; }
.connection-link--partner { stroke: var(--cranberry); stroke-dasharray: 6 5; }
.connection-link__heart { font-size: 16px; text-anchor: middle; dominant-baseline: central; }
.connection-node rect { fill: #fff; stroke: var(--line); stroke-width: 2; }
.connection-node text {
  font: 800 13px var(--font-body);
  fill: var(--ink);
  text-anchor: middle;
  dominant-baseline: central;
}
.connection-node--giver rect { fill: #fff7e0; stroke: var(--gold-deep); }
.connection-node--receiver rect { fill: #fde4e7; stroke: var(--cranberry); }
.connection-node--receiver text { fill: var(--cranberry-dark); }
.connection-node--ancestor rect { fill: var(--pine); stroke: var(--pine); }
.connection-node--ancestor text { fill: var(--snow); }

/* ---------- Family tree ---------- */
.person__children {
  margin-left: clamp(14px, 3vw, 34px);
  padding-left: var(--tree-indent);
  border-left: 3px dashed rgba(201, 149, 43, 0.6);
}
.person__children:empty { display: none; }
.person__card {
  position: relative;
  margin: 12px 0;
  padding: 14px 16px;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 10px rgba(15, 51, 38, 0.06);
}
/* A bauble hanging off the garland for each nested person. */
.person__children > .person > .person__card::before {
  content: '';
  position: absolute;
  top: 20px;
  left: calc(-1 * var(--tree-indent) - 11px);
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff 0 2px, var(--bauble, var(--cranberry)) 3px);
  box-shadow: 0 0 0 3px var(--snow);
}
.person__children > .person:nth-child(3n + 2) > .person__card { --bauble: var(--gold-deep); }
.person__children > .person:nth-child(3n + 3) > .person__card { --bauble: var(--holly); }
.person--sitting-out > .person__card { background: var(--frost); }
.person--sitting-out > .person__card .person__name { color: var(--ink-soft); }

.person__summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
}
.person__name { font-weight: 900; font-size: 18px; }
.person__heart { font-size: 15px; line-height: 1; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.badge--kid { background: #dcedfb; color: #1f5d8f; }
.badge--young-adult { background: #ddf3e6; color: #1d5e3a; }
.badge--old-guard { background: #fff0c7; color: #7a5810; }
.badge--sitting-out { background: #e7e7e7; color: #555; }

.person__fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}
.checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  margin: 0;
  align-self: end;
  text-transform: none;
  letter-spacing: 0;
  font-size: 15px;
  color: var(--ink);
}
.checkbox input { width: 22px; height: 22px; accent-color: var(--holly); }
.person__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.footer {
  position: relative;
  z-index: 1;
  padding: 0 var(--gutter) 40px;
  text-align: center;
  color: rgba(238, 246, 242, 0.6);
  font-size: 14px;
}
