/* Layout: a pine header with a string of lights and a snow drift, then one long page like the old doc.
   Each person is a card: their ornament and name, a "Show what's bought" button, Good to know, their wishes
   as bulleted rows, and a box to add one. A bought wish, once revealed, is wrapped in striped paper with a bow. */
:root {
  --sky: #EEF4F6;
  --paper: #FFFFFF;
  --paper-2: #F3F7F8;
  --ink: #1A2B25;
  --ink-soft: #566962;
  --rule: #D8E3E6;
  --pine: #1E5A44;
  --pine-deep: #123C2D;
  --on-pine: #F3FAF6;
  --action: #1D6A4D;
  --on-action: #FFFFFF;
  --berry: #BC2F48;
  --on-berry: #FFFFFF;
  --berry-soft: #FBE3E8;
  --gold: #A9740C;
  --gold-bright: #F2C14E;
  --gold-soft: #FAEFD5;
  --bulb-1: #FF5C70;
  --bulb-2: #FFCB4F;
  --bulb-3: #6FE3A6;
  --bulb-4: #6DB8FF;
  --flake: rgba(255, 255, 255, 0.95);
  --flake-shadow: rgba(70, 110, 130, 0.45);
  --shadow: 0 1px 2px rgba(20, 50, 40, 0.06), 0 12px 26px -16px rgba(20, 50, 40, 0.32);
  --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --font-body: "Nunito", ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-hand: "Caveat", "Bradley Hand", "Segoe Print", cursive;
  --r: 22px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --sky: #0B1620;
    --paper: #13212B;
    --paper-2: #182A36;
    --ink: #E7F0F2;
    --ink-soft: #9DB1B8;
    --rule: #253949;
    --pine: #133D2F;
    --pine-deep: #0A261C;
    --on-pine: #EAF6EF;
    --action: #58C291;
    --on-action: #06140D;
    --berry: #F27D92;
    --on-berry: #2A0C14;
    --berry-soft: #3A1A25;
    --gold: #F0BE4A;
    --gold-soft: #372B10;
    --flake: rgba(255, 255, 255, 0.85);
    --flake-shadow: rgba(0, 0, 0, 0);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 14px 30px -18px rgba(0, 0, 0, 0.8);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--sky);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
svg { max-width: 100%; }
.wrap {
  max-width: 1140px;
  margin: 0 auto;
  padding-left: max(20px, env(safe-area-inset-left, 0px));
  padding-right: max(20px, env(safe-area-inset-right, 0px));
}
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ic { display: inline-flex; align-items: center; justify-content: center; flex: none; }
:focus-visible { outline: 3px solid var(--gold-bright); outline-offset: 2px; }

/* ---------- snow + header ---------- */
#snow { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }
.top {
  position: relative;
  z-index: 1;
  padding-top: env(safe-area-inset-top, 0px);
  background: radial-gradient(120% 160% at 50% 0%, var(--pine) 0%, var(--pine-deep) 100%);
  color: var(--on-pine);
}
.lights { display: block; width: 100%; height: 48px; overflow: visible; }
.lights .wire { fill: none; stroke: rgba(6, 22, 16, 0.75); stroke-width: 2; }
.lights .socket { fill: #0E2A20; }
.lights .b0 { fill: var(--bulb-1); }
.lights .b1 { fill: var(--bulb-2); }
.lights .b2 { fill: var(--bulb-3); }
.lights .b3 { fill: var(--bulb-4); }
.lights .glow { opacity: 0.45; filter: blur(5px); }
.lights .bulb { animation: twinkle 3.4s ease-in-out infinite; }
@keyframes twinkle { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
.top-inner { padding-block: 4px 70px; text-align: center; }
.hello { margin: 0; font-family: var(--font-hand); font-weight: 700; font-size: 30px; line-height: 1.1; color: var(--gold-bright); }
h1 {
  margin: 4px 0 12px;
  font-family: var(--font-display);
  font-variation-settings: "SOFT" 100, "WONK" 1;
  font-weight: 800;
  font-size: clamp(46px, 8.5vw, 92px);
  line-height: 0.95;
  letter-spacing: -0.02em;
  text-wrap: balance;
}
.sleeps { margin: 0; font-size: 18px; font-weight: 700; opacity: 0.95; }
.sleeps b {
  margin-right: 4px;
  font-family: var(--font-display);
  font-variation-settings: "SOFT" 100, "WONK" 1;
  font-weight: 900;
  font-size: 1.6em;
  line-height: 1;
  color: var(--gold-bright);
}
.drift { position: absolute; left: 0; right: 0; bottom: -1px; width: 100%; height: 44px; fill: var(--sky); }

/* ---------- the page ---------- */
.doc {
  position: relative;
  z-index: 3;
  max-width: 900px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding-block: 4px 140px;
}
.loading { padding: 60px 0; text-align: center; font-family: var(--font-hand); font-size: 32px; color: var(--ink-soft); }
.intro {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: -18px 0 0;
  padding: 16px 20px;
  border-radius: 18px;
  background: var(--gold-soft);
  box-shadow: var(--shadow);
  font-size: 16px;
}
.intro .ic { color: var(--gold); margin-top: 2px; }
.jump { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.jump a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 14px 5px 6px;
  border-radius: 999px;
  background: var(--paper);
  box-shadow: var(--shadow);
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
  text-decoration: none;
}
.jump a:hover { color: var(--action); }
.jump .dot { flex: none; width: 18px; height: 18px; border-radius: 50%; background: radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0) 45%), var(--c); }
.jump-group { display: contents; }
.jump-label { display: none; }
.lists { display: flex; flex-direction: column; gap: 22px; }
.group-title {
  margin: 18px 0 -6px;
  font-family: var(--font-hand);
  font-weight: 700;
  font-size: 44px;
  line-height: 1;
  color: var(--berry);
}

/* ---------- a person ---------- */
.person {
  --c: var(--pine);
  padding: 22px 24px 18px;
  border-radius: var(--r);
  border-top: 6px solid var(--c); /* the family's color */
  background: var(--paper);
  box-shadow: var(--shadow);
  scroll-margin-top: 20px;
  transition: box-shadow 0.2s ease;
}
.person.revealed { box-shadow: 0 0 0 3px var(--berry), var(--shadow); }
.person-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 14px; }
.person-head .grow { flex: 1; min-width: 0; }
.person-name {
  margin: 0;
  font-family: var(--font-display);
  font-variation-settings: "SOFT" 100, "WONK" 0;
  font-weight: 700;
  font-size: clamp(24px, 3vw, 30px);
  line-height: 1.1;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}
.sub { margin: 2px 0 0; color: var(--ink-soft); font-size: 15px; font-variant-numeric: tabular-nums; }
.orn { position: relative; display: inline-block; flex: none; width: 50px; height: 58px; }
.orn::before { /* gold cap */
  content: "";
  position: absolute;
  top: 3px;
  left: 50%;
  width: 17px;
  height: 9px;
  margin-left: -8.5px;
  border-radius: 3px 3px 1px 1px;
  background: linear-gradient(var(--gold-bright), var(--gold));
}
.orn::after { /* hanging loop */
  content: "";
  position: absolute;
  top: -4px;
  left: 50%;
  width: 10px;
  height: 10px;
  margin-left: -5px;
  border: 2px solid var(--gold);
  border-radius: 50%;
}
.orn-ball {
  position: absolute;
  bottom: 0;
  left: 0;
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0) 40%), var(--c);
  color: #FFFFFF;
  font-family: var(--font-display);
  font-variation-settings: "SOFT" 100, "WONK" 1;
  font-weight: 800;
  font-size: 22px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
.reveal {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border: 2px solid var(--berry);
  border-radius: 999px;
  background: transparent;
  color: var(--berry);
  font: inherit;
  font-size: 15px;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
}
.reveal:hover { background: var(--berry-soft); }
.reveal[aria-pressed="true"] { background: var(--berry); color: var(--on-berry); }
.reveal:disabled { opacity: 0.6; cursor: default; }
.reveal-note { margin: 12px 0 0; font-family: var(--font-hand); font-size: 24px; font-weight: 700; line-height: 1.1; color: var(--berry); }
.empty-line { margin: 14px 0 4px; font-family: var(--font-hand); font-size: 24px; color: var(--ink-soft); }

/* Good to know */
.about {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 14px;
  padding: 14px 18px 16px;
  border-radius: 16px;
  background: var(--gold-soft);
}
.about-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.about-title { font-family: var(--font-hand); font-size: 26px; font-weight: 700; line-height: 1; color: var(--gold); }
.about-text { font-size: 16px; line-height: 1.55; white-space: pre-line; overflow-wrap: anywhere; }

/* wishes */
.rows { list-style: none; margin: 10px 0 0; padding: 0; }
.row {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 10px 14px 34px;
  border-top: 1px dashed var(--rule);
}
.rows > .row:first-child { border-top-color: transparent; }
.row::before { /* the bullet: a tiny ornament in this person's color */
  content: "";
  position: absolute;
  left: 10px;
  top: 21px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0) 45%), var(--c);
}
.row-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.row-title { font-size: 18px; font-weight: 800; line-height: 1.3; overflow-wrap: anywhere; }
.row-title.unnamed { color: var(--ink-soft); font-weight: 700; }
.row-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; font-size: 15px; }
.row-notes { margin: 0; color: var(--ink-soft); font-size: 15.5px; white-space: pre-line; overflow-wrap: anywhere; }
.row-status { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
.row-actions { flex: none; display: flex; align-items: center; gap: 6px; }
.link { display: inline-flex; align-items: center; gap: 4px; color: var(--action); font-weight: 800; text-decoration: none; overflow-wrap: anywhere; }
.link:hover { text-decoration: underline; }
.price { color: var(--ink-soft); font-weight: 700; font-variant-numeric: tabular-nums; }
.top-pick { display: inline-flex; align-items: center; gap: 4px; color: var(--gold); font-size: 13px; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; }
.bought-tag { font-family: var(--font-hand); font-size: 26px; font-weight: 700; line-height: 1; color: var(--berry); }
.flag { display: inline-flex; padding: 4px 12px; border-radius: 999px; background: var(--gold-soft); color: var(--ink); font-size: 14px; font-weight: 700; }
/* Revealed and bought: wrapped in striped paper with a ribbon and a bow. */
.row.wrapped {
  margin: 8px 0;
  padding-right: 78px;
  border-top-color: transparent;
  border-radius: 16px;
  background: repeating-linear-gradient(-45deg, var(--paper) 0 16px, var(--berry-soft) 16px 32px);
}
.row.wrapped + .row { border-top-color: transparent; }
.row.wrapped::after { content: ""; position: absolute; top: 0; bottom: 0; right: 34px; width: 12px; background: var(--berry); }
.row.wrapped .row-title { color: var(--ink-soft); }
.bow { position: absolute; top: -12px; right: 14px; width: 52px; height: 32px; color: var(--berry); z-index: 1; }
.row.removed { margin-top: 8px; border: 2px dashed var(--rule); border-radius: 16px; background: var(--paper-2); }
.row.removed::before { background: var(--rule); }
.row.removed .row-title { color: var(--ink-soft); text-decoration: line-through; }
.row.editing { display: block; padding: 18px 4px 10px; }
.row.editing::before { display: none; }

.add-row { display: flex; gap: 10px; margin-top: 10px; }
.add-row .field { flex: 1; }
.person-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; margin-top: 12px; }
.confirm-inline { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; font-weight: 700; }
.rename { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.rename .field { flex: 1; min-width: 160px; }
.add-person { display: flex; justify-content: center; margin-top: 10px; }
.add-person-form .actions { margin-top: 12px; }
.pick { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; }
.pick .field { width: auto; padding-block: 8px; }

/* ---------- controls ---------- */
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: 2px solid transparent;
  border-radius: 999px;
  background: var(--paper-2);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease;
}
.btn:hover { filter: brightness(0.96); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; cursor: default; transform: none; }
.btn.go { background: var(--action); color: var(--on-action); }
.btn.buy { background: var(--berry); color: var(--on-berry); }
.btn.ghost { background: transparent; color: var(--ink-soft); }
.btn.ghost:hover { background: var(--paper-2); color: var(--ink); filter: none; }
.btn.danger { background: transparent; color: var(--berry); border-color: currentColor; }
.btn.danger.solid { background: var(--berry); border-color: var(--berry); color: var(--on-berry); }
.btn.small { padding: 7px 14px; font-size: 14px; }
.iconbtn {
  appearance: none;
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--paper-2);
  color: var(--ink-soft);
  cursor: pointer;
}
.iconbtn:hover { color: var(--ink); }
.iconbtn:disabled { opacity: 0.3; cursor: default; }
.textlink {
  appearance: none;
  padding: 0;
  border: 0;
  background: none;
  color: var(--action);
  font: inherit;
  font-size: 15px;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}
.textlink:hover { text-decoration: underline; }
.textlink.danger-link { color: var(--berry); }
.lbl { display: block; margin-bottom: 6px; color: var(--ink-soft); font-size: 14px; font-weight: 800; }
.field {
  width: 100%;
  min-width: 0;
  padding: 12px 14px;
  border: 2px solid var(--rule);
  border-radius: 14px;
  background: var(--paper-2);
  color: var(--ink);
  font: inherit;
  font-size: 17px;
}
.field::placeholder { color: var(--ink-soft); opacity: 0.8; }
.field:focus { outline: none; border-color: var(--action); background: var(--paper); }
textarea.field { resize: vertical; min-height: 72px; line-height: 1.45; }
.check { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 0; accent-color: var(--action); }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; align-items: end; }
.err { color: var(--berry); font-weight: 700; font-size: 15px; }
.edit-form { display: flex; flex-direction: column; gap: 14px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.actions .spacer { flex: 1; }
.confirm { display: flex; flex-direction: column; gap: 12px; padding: 14px 16px; border-radius: 14px; background: var(--berry-soft); font-weight: 700; }

/* ---------- locked / toast / sparkles ---------- */
.locked {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 580px;
  margin: 24px auto;
  padding: 36px 32px;
  border-radius: var(--r);
  background: var(--paper);
  box-shadow: var(--shadow);
  text-align: center;
}
.locked p { margin: 0; }
.locked .hand { font-family: var(--font-hand); font-size: 28px; color: var(--berry); }
.toast {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 16px;
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 12px 14px 12px 22px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--sky);
  font-weight: 700;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.28);
}
.toast button {
  appearance: none;
  padding: 6px 14px;
  border: 0;
  border-radius: 999px;
  background: var(--gold-bright);
  color: #2A1E05;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}
.spark { position: fixed; z-index: 30; pointer-events: none; animation: spark 0.85s ease-out forwards; }
@keyframes spark {
  from { transform: translate(-50%, -50%) scale(0.5); opacity: 1; }
  to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.15) rotate(170deg); opacity: 0; }
}

/* ---------- wide screens: the jump list sits beside the lists and follows you down ---------- */
@media (min-width: 1000px) {
  .doc {
    max-width: 1140px;
    display: grid;
    grid-template-columns: 184px minmax(0, 1fr);
    grid-template-areas: "rail intro" "rail lists";
    column-gap: 32px;
    align-items: start;
  }
  .doc { padding-bottom: 0; }
  .intro { grid-area: intro; }
  .lists { grid-area: lists; padding-bottom: 140px; } /* inside the grid, so the jump column stays put to the very end */
  .jump {
    grid-area: rail;
    position: sticky;
    top: 20px;
    margin-top: -18px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 12px;
    padding: 14px 10px;
    border-radius: 18px;
    background: var(--paper);
    box-shadow: var(--shadow);
  }
  .jump-group { display: flex; flex-direction: column; gap: 2px; }
  .jump-label { display: block; margin: 0 0 4px 8px; font-family: var(--font-hand); font-weight: 700; font-size: 26px; line-height: 1; color: var(--berry); }
  .jump a { padding: 4px 10px 4px 6px; background: none; box-shadow: none; color: var(--ink-soft); font-weight: 700; overflow-wrap: anywhere; }
  .jump a:hover { background: var(--paper-2); color: var(--ink); }
  .jump a[aria-current] { background: color-mix(in srgb, var(--c) 16%, var(--paper)); color: var(--ink); font-weight: 800; }
  .jump .dot { width: 16px; height: 16px; }
}

/* ---------- phones ---------- */
@media (max-width: 640px) {
  body { font-size: 16px; }
  .top-inner { padding-bottom: 64px; }
  .person { padding: 18px 16px 14px; }
  .reveal { width: 100%; justify-content: center; }
  .row { flex-wrap: wrap; padding-left: 30px; }
  .row::before { left: 8px; }
  .row-body { flex-basis: 100%; }
  .row-actions { margin-left: auto; }
  .row.wrapped { padding-right: 66px; }
  .row.wrapped::after { right: 28px; }
  .bow { right: 8px; }
  .add-row .btn { padding-inline: 14px; }
  .group-title { font-size: 38px; }
  .two { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .lights .bulb { animation: none; }
  .btn { transition: none; }
  .person { transition: none; }
  .spark { display: none; }
}
