/* Secret Santa — shared styles. No external assets; system fonts only. */

:root {
  --pine: #14452f;
  --pine-dark: #0d2f20;
  --pine-soft: #e3efe7;
  --cream: #fbf6ea;
  --card: #fffdf7;
  --red: #b3202a;
  --red-dark: #8f1a22;
  --gold: #c8963e;
  --gold-soft: #f5e8c8;
  --ink: #25201c;
  --muted: #5f564d;
  --line: #e6dccb;
  --ok: #1d6b3f;
  --radius: 16px;
  --serif: Georgia, "Iowan Old Style", "Palatino Linotype", Palatino, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  font-size: 18px;
  line-height: 1.5;
  color: var(--ink);
  background-color: var(--pine);
  background-image:
    radial-gradient(circle at 20px 30px, rgba(255,255,255,.20) 2px, transparent 3px),
    radial-gradient(circle at 70px 80px, rgba(255,255,255,.13) 1.5px, transparent 2.5px),
    radial-gradient(circle at 120px 20px, rgba(255,255,255,.16) 1px, transparent 2px),
    linear-gradient(180deg, var(--pine) 0%, var(--pine-dark) 100%);
  background-size: 150px 130px, 190px 170px, 110px 90px, 100% 100%;
  background-attachment: scroll, scroll, scroll, fixed;
}

.wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}
.wrap.wide { max-width: 780px; }

/* ---------- header ---------- */
.hero {
  text-align: center;
  color: var(--cream);
  padding: 22px 8px 20px;
}
.hero .emoji { font-size: 44px; line-height: 1; display: block; margin-bottom: 6px; }
.hero h1 {
  font-family: var(--serif);
  font-size: clamp(28px, 8vw, 40px);
  line-height: 1.15;
  margin: 0;
  font-weight: 700;
  letter-spacing: .01em;
}
.hero p {
  margin: 8px auto 0;
  max-width: 34ch;
  color: #d6e6dc;
  font-size: 17px;
}
.hero .badge {
  display: inline-block;
  margin-top: 10px;
  padding: 2px 12px;
  border: 1px solid var(--gold);
  color: var(--gold-soft);
  border-radius: 999px;
  font-size: 13px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

/* ---------- cards ---------- */
.card {
  position: relative;
  background: var(--card);
  border-radius: var(--radius);
  padding: 28px 20px 22px;
  margin: 0 0 16px;
  box-shadow: 0 6px 22px rgba(0,0,0,.28);
  overflow: hidden;
}
/* candy-cane ribbon along the top edge */
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 7px;
  background: repeating-linear-gradient(-45deg, var(--red) 0 10px, var(--cream) 10px 20px);
}
.card h2 {
  font-family: var(--serif);
  font-size: 24px;
  line-height: 1.2;
  margin: 0 0 6px;
  color: var(--pine);
}
.card h3 { font-family: var(--serif); font-size: 20px; margin: 0 0 6px; color: var(--pine); }
.card p { margin: 0 0 12px; }
.card p:last-child { margin-bottom: 0; }

.lead { font-size: 20px; }
.muted { color: var(--muted); }
.small { font-size: 15px; }
.center { text-align: center; }

/* ---------- forms ---------- */
label { display: block; font-weight: 600; margin: 0 0 6px; color: var(--pine-dark); }

input[type="text"], input[type="number"], textarea, select {
  display: block;
  width: 100%;
  min-height: 52px;
  padding: 10px 14px;
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 12px;
  appearance: none;
  -webkit-appearance: none;
}
select {
  padding-right: 38px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--pine) 50%),
    linear-gradient(135deg, var(--pine) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}
input[type="text"]:focus, input[type="number"]:focus, textarea:focus, select:focus { border-color: var(--pine); outline: none; box-shadow: 0 0 0 4px rgba(20,69,47,.18); }
input[readonly] { background: var(--cream); color: var(--muted); font-size: 15px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 10px 22px;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  border-radius: 12px;
  border: 2px solid transparent;
  color: #fff;
  background: var(--red);
  transition: background .15s, transform .1s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--red-dark); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .reveal:focus-visible, .switch:focus-visible, .banner button:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }
.btn.block { display: flex; width: 100%; font-size: 20px; min-height: 58px; }

.btn.secondary { background: #fff; color: var(--pine); border-color: var(--pine); }
.btn.secondary:hover { background: var(--pine-soft); }
.btn.green { background: var(--pine); }
.btn.green:hover { background: var(--pine-dark); }
.btn.danger { background: #fff; color: var(--red); border-color: var(--red); }
.btn.danger:hover { background: #fbeaec; }
.btn.small { min-height: 40px; padding: 6px 14px; font-size: 15px; border-radius: 10px; }

.row { display: flex; flex-wrap: wrap; gap: 10px; }
.row > * { flex: 0 0 auto; }
.row.grow > * { flex: 1 1 auto; }

.stack > * + * { margin-top: 14px; }

/* ---------- messages ---------- */
.error, .notice {
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 16px;
  margin-top: 14px;
}
.error { background: #fdecee; color: #7d1219; border: 1px solid #efb4ba; }
.notice { background: var(--gold-soft); color: #5a4217; border: 1px solid #e4cb92; }

.spinner {
  width: 34px; height: 34px;
  margin: 12px auto;
  border: 4px solid var(--pine-soft);
  border-top-color: var(--pine);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.pill {
  display: inline-block;
  padding: 2px 12px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  background: var(--pine-soft);
  color: var(--pine);
}
.pill.red { background: #fbe0e3; color: var(--red-dark); }
.pill.gold { background: var(--gold-soft); color: #6b4c12; }

/* ---------- me.html reveal ---------- */
.big-icon { font-size: 56px; line-height: 1; margin-bottom: 8px; }
.recipient-name {
  font-family: var(--serif);
  font-size: clamp(34px, 11vw, 52px);
  line-height: 1.1;
  color: var(--red);
  margin: 6px 0 4px;
  overflow-wrap: anywhere;
}
.reveal {
  display: block;
  width: 100%;
  margin: 16px 0 6px;
  padding: 30px 16px;
  font: inherit;
  cursor: pointer;
  text-align: center;
  color: var(--pine-dark);
  border: 3px dashed var(--gold);
  border-radius: var(--radius);
  background: var(--gold-soft);
  -webkit-tap-highlight-color: transparent;
}
.reveal .gift { display: block; font-size: 64px; line-height: 1.1; }
.reveal .tap { display: block; font-size: 22px; font-weight: 700; margin-top: 6px; }
.reveal .sub { display: block; font-size: 15px; color: var(--muted); margin-top: 4px; }
.revealed {
  text-align: center;
  margin: 16px 0 6px;
  padding: 22px 12px;
  border: 3px solid var(--gold);
  border-radius: var(--radius);
  background: #fff;
  animation: pop .4s ease-out;
}
@keyframes pop { from { transform: scale(.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.linkbox { margin-top: 14px; }

/* ---------- admin ---------- */
.list { list-style: none; margin: 12px 0 0; padding: 0; }
.list > li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.list > li:first-child { border-top: 0; }
.list .name { flex: 1 1 140px; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.list .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.list .edit-input { flex: 1 1 160px; min-height: 44px; }
.list .pair-arrow { color: var(--gold); font-weight: 700; }

.pairs-list > li { font-size: 19px; }
.pairs-list .to { color: var(--red); font-weight: 700; }

.switch {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
  font: inherit;
  font-weight: 700;
  color: var(--pine-dark);
  background: none;
  border: 0;
  cursor: pointer;
}
.switch[disabled] { opacity: .55; cursor: not-allowed; }
.switch .track {
  position: relative;
  width: 58px; height: 32px;
  border-radius: 999px;
  background: #b9b1a4;
  transition: background .2s;
  flex: none;
}
.switch .track::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.35);
  transition: transform .2s;
}
.switch[aria-checked="true"] .track { background: var(--ok); }
.switch[aria-checked="true"] .track::after { transform: translateX(26px); }

.add-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.add-row input { flex: 1 1 180px; }

.pair-form { display: grid; gap: 10px; margin-top: 12px; }
@media (min-width: 640px) {
  .pair-form { grid-template-columns: 1fr 1fr auto; align-items: end; }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  padding: 12px 20px;
  background: var(--pine-dark);
  color: var(--cream);
  border: 1px solid var(--gold);
  border-radius: 999px;
  box-shadow: 0 6px 20px rgba(0,0,0,.35);
  font-size: 16px;
  z-index: 50;
}

.banner {
  position: sticky;
  top: 8px;
  z-index: 40;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin: 0 0 16px;
  padding: 14px 16px;
  background: #fdecee;
  color: #7d1219;
  border: 2px solid var(--red);
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(0,0,0,.3);
}
.banner .msg { flex: 1; font-weight: 600; overflow-wrap: anywhere; }
.banner button {
  flex: none; border: 0; background: none; font-size: 26px; line-height: 1; cursor: pointer; color: inherit; padding: 0 4px;
}

dialog {
  width: calc(100vw - 32px);
  max-width: 440px;
  padding: 24px 20px 20px;
  border: 0;
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 14px 50px rgba(0,0,0,.5);
}
dialog::backdrop { background: rgba(8, 30, 20, .65); }
dialog h3 { font-family: var(--serif); font-size: 24px; margin: 0 0 8px; color: var(--pine); }
dialog p { margin: 0 0 18px; }
dialog .row { justify-content: flex-end; }

.footer { text-align: center; color: #b9d0c3; font-size: 14px; margin-top: 8px; }
.footer a { color: var(--gold-soft); }

.stat-row { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }
.stat-big { font-family: var(--serif); font-size: 40px; line-height: 1; color: var(--pine); }

/* ---------- v2: gift ideas + budget ---------- */
textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.4;
}
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
.field { margin-top: 16px; }
.optional { font-weight: 400; color: var(--muted); }
.counter { font-size: 14px; color: var(--muted); text-align: right; margin-top: 4px; }
.counter.near { color: var(--red-dark); font-weight: 700; }
.hint { font-size: 15px; color: var(--muted); margin: 0 0 8px; }

fieldset.chips-field { border: 0; padding: 0; margin: 16px 0 0; min-width: 0; }
.chips-field legend { font-weight: 600; color: var(--pine-dark); padding: 0; margin: 0 0 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip { position: relative; display: block; margin: 0; flex: 1 1 72px; font-weight: 700; }
.chip input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.chip span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  min-width: 72px;
  padding: 8px 16px;
  font-size: 20px;
  text-align: center;
  color: var(--pine);
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 12px;
  transition: background .15s, border-color .15s;
}
.chip.wide { flex: 2 1 160px; }
.chip.wide span { font-size: 17px; }
.chip:hover span { border-color: var(--pine); }
.chip input:checked + span { background: var(--pine); border-color: var(--pine); color: #fff; }
.chip input:checked + span::before { content: "\2713"; margin-right: 6px; }
.chip input:focus-visible + span { outline: 3px solid var(--gold); outline-offset: 2px; }

.budget-banner {
  margin: 0 0 16px;
  padding: 14px 16px;
  text-align: center;
  font-family: var(--serif);
  font-size: 24px;
  line-height: 1.2;
  color: #5a4217;
  background: var(--gold-soft);
  border: 2px solid var(--gold);
  border-radius: var(--radius);
  box-shadow: 0 6px 22px rgba(0,0,0,.2);
}
.budget-banner strong { font-size: 1.5em; color: var(--pine); }
.budget-banner.unset {
  font-family: var(--sans);
  font-size: 17px;
  color: var(--muted);
  background: var(--card);
  border-style: dashed;
}

.save-status { font-weight: 700; color: var(--ok); margin-top: 10px; }

.ideas-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.revealed .ideas {
  margin-top: 16px;
  padding: 14px;
  text-align: left;
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.revealed .ideas h3 { margin: 0 0 6px; font-family: var(--serif); font-size: 18px; color: var(--pine); overflow-wrap: anywhere; }
.revealed .ideas .none { color: var(--muted); font-style: italic; }

.tally { list-style: none; margin: 12px 0 0; padding: 0; }
.tally li { display: grid; grid-template-columns: 7.5em 1fr 2.5em; align-items: center; gap: 10px; padding: 4px 0; }
.tally .bar-label { font-weight: 600; }
.tally .bar-track { height: 18px; background: var(--pine-soft); border-radius: 999px; overflow: hidden; }
.tally .bar-fill { height: 100%; width: 0; background: var(--pine); border-radius: 999px; transition: width .3s; }
.tally .bar-count { text-align: right; font-weight: 700; color: var(--pine); }
.budget-facts { margin-top: 14px; }
.budget-facts p { margin: 0 0 4px; }
.budget-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-top: 14px; }
.budget-form .amount { flex: 1 1 140px; }
.amount-wrap { position: relative; }
.amount-wrap::before { content: "$"; position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-weight: 700; color: var(--muted); }
.amount-wrap input { padding-left: 30px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (min-width: 640px) {
  .card { padding: 30px 28px 26px; }
}
