/* Tokens — see DESIGN.md */
:root {
  color-scheme: light;
  --bg: #FAFAF7;          /* page */
  --ink: #1A1D1B;         /* text */
  --muted: #56615B;
  --frost: #E3ECE6;       /* lines, hover */
  --band: #173F2F;        /* pine header band */
  --on-band: #FAFAF7;
  --link: #173F2F;        /* pine as text/marks */
  --selected: #173F2F;
  --on-selected: #FAFAF7;
  --cranberry: #B4202F;   /* main buttons only */
  --cranberry-hover: #9A1B28;
  --danger-text: #B4202F;
  --field: #FFFFFF;
  --field-line: #9AA7A0;
  --error-bg: #F7E4E6;
  --gold: #C99A2E;

  --font: "Bricolage Grotesque", ui-rounded, "Segoe UI", sans-serif;
  --fs-sm: 0.875rem;  /* 14 */
  --fs-base: 1rem;    /* 16 */
  --fs-md: 1.125rem;  /* 18 */
  --fs-lg: 1.375rem;  /* 22 */
  --fs-xl: 1.875rem;  /* 30 */
  --fs-hero: clamp(2.125rem, 7vw, 3.25rem);

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;
  --r-input: 6px;
  --r-btn: 10px;
}

/* Dark mode: follows the phone's setting unless the visitor picks one */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0E1512;
    --ink: #E8EEEA;
    --muted: #A3B1A9;
    --frost: #26342D;
    --band: #173F2F;
    --on-band: #F3F6F4;
    --link: #8CCBA8;
    --selected: #2F6E52;
    --on-selected: #FFFFFF;
    --cranberry: #C42B3C;
    --cranberry-hover: #D6404F;
    --danger-text: #FF8A95;
    --field: #16201B;
    --field-line: #4A5A52;
    --error-bg: #3A1A1F;
    --gold: #E2B84F;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0E1512;
  --ink: #E8EEEA;
  --muted: #A3B1A9;
  --frost: #26342D;
  --band: #173F2F;
  --on-band: #F3F6F4;
  --link: #8CCBA8;
  --selected: #2F6E52;
  --on-selected: #FFFFFF;
  --cranberry: #C42B3C;
  --cranberry-hover: #D6404F;
  --danger-text: #FF8A95;
  --field: #16201B;
  --field-line: #4A5A52;
  --error-bg: #3A1A1F;
  --gold: #E2B84F;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.5;
}
.wrap { width: 100%; max-width: 680px; margin: 0 auto; padding: 0 var(--s4); }
.wrap.wide { max-width: 980px; }

h1, h2, h3 { line-height: 1.15; margin: 0; font-weight: 800; }
p { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
a { color: var(--link); }

/* Header band */
.band { position: relative; background: var(--band); color: var(--on-band); padding: var(--s8) 0 var(--s6); }
.band h1 { font-size: var(--fs-hero); letter-spacing: -0.02em; }
.band .details { margin-top: var(--s3); font-size: var(--fs-md); white-space: pre-line; max-width: 34ch; opacity: 0.92; }
.band.slim { padding: var(--s5) 0; }
.band.slim h1 { font-size: var(--fs-xl); }
.band a { color: var(--on-band); }

/* Sections — rhythm varies on purpose */
.section { padding: var(--s6) 0; border-top: 1px solid var(--frost); scroll-margin-top: 52px; }
.section:first-child { border-top: 0; }
.section.tight { padding: var(--s5) 0; }
.section h2 { font-size: var(--fs-lg); margin-bottom: var(--s2); }
.section .lead { color: var(--muted); margin-bottom: var(--s4); }
.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }

/* Buttons */
button { font: inherit; color: inherit; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 44px; padding: 0 var(--s4);
  border-radius: var(--r-btn); border: 1.5px solid transparent;
  font-weight: 600; cursor: pointer; text-decoration: none;
  transition: background-color 150ms ease-out, color 150ms ease-out, border-color 150ms ease-out;
}
.btn-main { background: var(--cranberry); color: #fff; }
.btn-main:hover { background: var(--cranberry-hover); }
.btn-line { background: transparent; border-color: var(--ink); }
.btn-line:hover { background: var(--frost); }
.btn-text { background: none; border: 0; padding: 0 var(--s1); min-height: 44px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-weight: 600; }
.btn-text.danger { color: var(--danger-text); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-block { width: 100%; }
:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; }
.band :focus-visible { outline-color: var(--on-band); }

/* Forms */
label { display: block; font-weight: 600; margin-bottom: var(--s2); }
input[type="text"], input[type="password"], input[type="tel"], textarea, select {
  width: 100%; font: inherit; color: var(--ink); background: var(--field);
  border: 1.5px solid var(--field-line); border-radius: var(--r-input);
  padding: var(--s3); min-height: 44px;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--link); outline: none; box-shadow: 0 0 0 2px var(--frost); }
.field { margin-bottom: var(--s4); }
.pin-input { font-size: var(--fs-xl); letter-spacing: 0.4em; text-align: center; max-width: 220px; }
.row { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; }

/* Messages */
.msg { padding: var(--s3) var(--s4); border-left: 4px solid var(--link); background: var(--frost); margin-bottom: var(--s4); }
.msg.error { border-left-color: var(--danger-text); background: var(--error-bg); }
.saved { color: var(--link); font-weight: 600; font-size: var(--fs-sm); }

/* Name picker */
.names { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--frost); }
.names li { border-bottom: 1px solid var(--frost); }
.names button {
  width: 100%; min-height: 56px; display: flex; justify-content: space-between; align-items: center;
  background: none; border: 0; padding: 0 var(--s2); font-size: var(--fs-md); font-weight: 600; cursor: pointer; text-align: left;
}
.names button:hover { background: var(--frost); }
.names .arrow { color: var(--muted); font-weight: 400; }

/* Arrival choice */
.choice { display: inline-flex; border: 1.5px solid var(--selected); border-radius: var(--r-btn); overflow: hidden; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice label {
  margin: 0; min-height: 48px; min-width: 120px; padding: 0 var(--s5);
  display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: var(--fs-md);
  transition: background-color 150ms ease-out, color 150ms ease-out;
}
.choice input + label ~ label { border-left: 1.5px solid var(--selected); }
.choice input:checked + label { background: var(--selected); color: var(--on-selected); }
.choice input:focus-visible + label { outline: 3px solid var(--cranberry); outline-offset: -3px; }

/* Food list */
.items { list-style: none; margin: 0; padding: 0; }
.items li {
  display: flex; justify-content: space-between; align-items: center; gap: var(--s3);
  padding: var(--s3) 0; border-bottom: 1px solid var(--frost);
}
.items li.mine { border-left: 4px solid var(--link); padding-left: var(--s3); }
.items .name { font-weight: 600; }
.items .who { color: var(--muted); font-size: var(--fs-sm); }
.items .yours { color: var(--link); font-size: var(--fs-sm); font-weight: 700; }

/* Secret Santa reveal */
.reveal { margin: var(--s4) 0; padding: var(--s5); background: var(--band); color: var(--on-band); border-radius: var(--r-btn); }
.reveal .big { font-size: var(--fs-xl); font-weight: 800; margin: var(--s1) 0 var(--s3); }
.reveal .ideas { white-space: pre-line; }

.footer-note { padding: var(--s6) 0 var(--s8); }

/* Admin */
.admin-nav { position: sticky; top: 0; z-index: 5; background: var(--bg); border-bottom: 1px solid var(--frost); }
.admin-nav .wrap { display: flex; gap: var(--s1); overflow-x: auto; }
.admin-nav a { padding: var(--s3) var(--s3); min-height: 44px; display: inline-flex; align-items: center; font-weight: 600; white-space: nowrap; text-decoration: none; color: var(--ink); }
.admin-nav a:hover { background: var(--frost); }

.glist { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--frost); }
.glist > li { padding: var(--s4) 0; border-bottom: 1px solid var(--frost); display: grid; gap: var(--s3); grid-template-columns: 1fr; }
.glist .top { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s3); flex-wrap: wrap; }
.glist .gname { font-size: var(--fs-md); font-weight: 700; }
.glist .meta { color: var(--muted); font-size: var(--fs-sm); }
.toggles { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); align-items: center; }
.check { display: inline-flex; align-items: center; gap: var(--s2); margin: 0; font-weight: 600; min-height: 44px; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--selected); }
.toggles select { width: auto; min-width: 170px; }
.lock-bar { display: flex; flex-wrap: wrap; gap: var(--s4); align-items: center; justify-content: space-between; }
.lock-bar > div { flex: 1 1 260px; }
.lock-bar h2 { margin-bottom: var(--s1); }
.lock-bar.is-locked { border-left: 4px solid var(--danger-text); padding-left: var(--s4); }

.spin-tag {
  display: inline-block; margin-left: var(--s2); padding: 1px var(--s2); vertical-align: middle;
  font-size: var(--fs-sm); font-weight: 700; border-radius: var(--r-input);
  color: var(--muted); border: 1.5px solid var(--field-line);
}
.spin-tag.done { color: var(--on-selected); background: var(--selected); border-color: var(--selected); }
.flag { font-size: var(--fs-sm); font-weight: 700; color: var(--danger-text); }

.counts { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); margin-bottom: var(--s4); color: var(--muted); }
.counts b { color: var(--ink); }

.ilist { list-style: none; margin: 0 0 var(--s5); padding: 0; border-top: 1px solid var(--frost); }
.ilist li { display: grid; grid-template-columns: 1fr; gap: var(--s2); padding: var(--s3) 0; border-bottom: 1px solid var(--frost); }
.ilist .iname { font-weight: 600; }

@media (min-width: 720px) {
  .glist > li { grid-template-columns: 220px 1fr; align-items: center; }
  .ilist li { grid-template-columns: 1fr 220px auto; align-items: center; }
}

/* Theme switch (top-right of the header band) */
.theme-toggle {
  position: absolute; top: var(--s3); right: var(--s3);
  display: inline-flex; align-items: center; gap: var(--s2);
  min-height: 44px; padding: 0 var(--s3);
  background: transparent; color: var(--on-band);
  border: 1.5px solid rgba(255, 255, 255, 0.35); border-radius: 999px;
  font-size: var(--fs-sm); font-weight: 600; cursor: pointer;
}
.theme-toggle:hover { border-color: var(--on-band); }
.theme-toggle svg { width: 18px; height: 18px; }
.band.slim .theme-toggle { position: static; }

/* Secret Santa reel — names fall down and land on your person */
.reel {
  --row: 68px;
  position: relative; height: calc(var(--row) * 3); overflow: hidden;
  margin: var(--s4) 0 var(--s3);
  background: var(--band); color: var(--on-band); border-radius: var(--r-btn);
}
.reel-strip { list-style: none; margin: 0; padding: 0; will-change: transform; }
.reel-strip li {
  height: var(--row); display: flex; align-items: center; justify-content: center; padding: 0 var(--s4);
  font-size: clamp(1.5rem, 7vw, 2.125rem); font-weight: 800; letter-spacing: -0.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* dim the row above and below; frame the middle one */
.reel::before, .reel::after {
  content: ""; position: absolute; left: 0; right: 0; height: var(--row); z-index: 1; pointer-events: none;
  background: var(--band); opacity: 0.72;
}
.reel::before { top: 0; border-bottom: 2px solid var(--gold); }
.reel::after { bottom: 0; border-top: 2px solid var(--gold); }
.reel.landed .reel-strip li.target { color: var(--gold); transform: scale(1.08); transition: transform 250ms ease-out, color 250ms ease-out; }
.reel-caption { text-align: center; font-weight: 600; color: var(--muted); min-height: 1.5em; }

.match-card { margin-top: var(--s4); padding: var(--s5); border: 2px solid var(--gold); border-radius: var(--r-btn); }
.match-card .big { font-size: var(--fs-xl); font-weight: 800; margin: var(--s1) 0 var(--s3); }
.match-card .ideas { white-space: pre-line; }
.fade-in { animation: fade-in 300ms ease-out both; }
@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 50; }
.confetti i { position: absolute; top: -24px; display: block; border-radius: 2px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
