/* =========================================================
   Design-System Familien-Wichteln
   Alle Farben, Abstände und Größen stehen als Variablen hier
   oben. Komponenten nutzen nur diese Variablen.
   ========================================================= */

:root {
  /* Farben */
  --bg: #f8f3ea;
  --bg-accent: #efe4d2;
  --surface: #ffffff;
  --surface-sunken: #fbf8f3;
  --text: #2b2320;
  --muted: #74675f;
  --border: #e6dacb;
  --border-strong: #98856f;  /* Feldrahmen, mind. 3:1 */
  --primary: #b3261e;        /* Weihnachtsrot: Hauptaktionen */
  --primary-hover: #93201a;
  --on-primary: #ffffff;
  --accent: #2f6b3f;         /* Tannengrün: Links, Erfolg */
  --gold: #c08a1e;           /* Deko */
  --danger-bg: #fde8e6;
  --danger-text: #8c1d17;
  --success-bg: #e5f2e8;
  --success-text: #24563a;
  --focus: #a87512;

  /* Schrift */
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.2rem;
  --text-xl: 1.5rem;
  --text-2xl: clamp(1.75rem, 6vw, 2.25rem);
  --text-reveal: clamp(1.9rem, 9vw, 2.6rem);

  /* Abstände (4er-Raster) */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;

  /* Formen */
  --radius-sm: 10px;
  --radius: 16px;
  --radius-pill: 999px;
  --shadow: 0 1px 2px rgba(60, 40, 20, 0.05), 0 8px 24px rgba(60, 40, 20, 0.07);
  --control-height: 46px;    /* gut tippbar auf dem Handy */
  --content-width: 560px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17130f;
    --bg-accent: #221b16;
    --surface: #241e1a;
    --surface-sunken: #1d1814;
    --text: #f2ebe4;
    --muted: #b3a69c;
    --border: #3a312b;
    --border-strong: #7a6a5c;
    --primary: #e0574d;
    --primary-hover: #ea6f66;
    --on-primary: #1b0f0d;
    --accent: #7cc690;
    --gold: #e0b252;
    --danger-bg: #3d1d1a;
    --danger-text: #ffb4ab;
    --success-bg: #1c3324;
    --success-text: #a6dcb5;
    --focus: #e0b252;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
  }
}

/* ---------- Grundlagen ---------- */

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.55;
  background-color: var(--bg);
  /* dezente Schneeflocken */
  background-image:
    radial-gradient(circle at 20% 30%, var(--bg-accent) 0 2px, transparent 3px),
    radial-gradient(circle at 70% 80%, var(--bg-accent) 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 85% 20%, var(--bg-accent) 0 2.5px, transparent 3.5px);
  background-size: 140px 140px, 90px 90px, 200px 200px;
}

main {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: var(--s-6) var(--s-4) var(--s-7);
}

h1, h2 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.2;
  text-wrap: balance;
}
h1 { font-size: var(--text-2xl); margin: 0; }
h2 { font-size: var(--text-lg); margin: 0 0 var(--s-4); text-align: center; }

p { margin: 0 0 var(--s-3); }
p:last-child { margin-bottom: 0; }

a { color: var(--accent); font-weight: 600; text-underline-offset: 3px; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---------- Kopfbereich ---------- */

.site-header {
  text-align: center;
  margin-bottom: var(--s-5);
}

.ornament {
  display: inline-grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: var(--s-3);
  font-size: 2rem;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--gold);
  box-shadow: var(--shadow);
}

.subtitle {
  color: var(--muted);
  margin: var(--s-2) 0 0;
  font-size: var(--text-lg);
}

.site-footer {
  text-align: center;
  color: var(--muted);
  font-size: var(--text-sm);
  margin-top: var(--s-6);
}

/* ---------- Karten ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--s-5);
  margin-bottom: var(--s-4);
}

/* kleine goldene Linie unter jeder Kartenüberschrift */
.card > h2::after,
.card-section > h2::after {
  content: "";
  display: block;
  width: 40px;
  height: 3px;
  margin: var(--s-2) auto 0;
  border-radius: var(--radius-pill);
  background: var(--gold);
}

.card-section + .card-section {
  margin-top: var(--s-5);
  padding-top: var(--s-5);
  border-top: 1px dashed var(--border);
}

.card-intro { text-align: center; color: var(--muted); }

.center { text-align: center; }

/* Leerer Zustand, z. B. "noch keine Wünsche" */
.empty {
  text-align: center;
  color: var(--muted);
  padding: var(--s-3) 0;
}
.empty-icon { display: block; font-size: 2rem; margin-bottom: var(--s-2); }

/* ---------- Partner-Enthüllung ---------- */

.hero {
  /* roter Streifen oben, folgt den runden Ecken */
  background:
    linear-gradient(var(--primary), var(--primary)) top / 100% 5px no-repeat,
    var(--surface);
}

.reveal {
  text-align: center;
  padding: var(--s-5) var(--s-4);
  border: 2px dashed var(--gold);
  border-radius: var(--radius);
  background: var(--surface-sunken);
}

.reveal-label {
  font-size: var(--text-sm);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0;
}

.partner {
  font-family: var(--font-display);
  font-size: var(--text-reveal);
  font-weight: 700;
  line-height: 1.15;
  color: var(--primary);
  margin: var(--s-1) 0;
  overflow-wrap: anywhere;
}

.reveal .muted { margin: 0; font-size: var(--text-sm); }

/* ---------- Infos als Chips ---------- */

.info-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-2);
}
.info-list p {
  margin: 0;
  padding: var(--s-3) var(--s-4);
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  text-align: center;
  overflow-wrap: anywhere;
}
.info-label {
  display: block;
  font-size: var(--text-sm);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.info-value { display: block; font-weight: 600; }

/* ---------- Listen ---------- */

ul.list { list-style: none; padding: 0; margin: 0; }
ul.list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2) var(--s-3);
  padding: var(--s-3) 0;
  border-bottom: 1px solid var(--border);
}
ul.list li:last-child { border-bottom: 0; }
ul.list li .grow { flex: 1 1 140px; min-width: 0; overflow-wrap: anywhere; }
ul.list a { white-space: nowrap; }

/* Admin-Teilnehmer: auf dem Handy Name oben, Buttons darunter.
   Beschriftungen brechen nicht um, ein dritter Button rutscht lieber in eine eigene Zeile. */
@media (max-width: 479px) {
  ul.list.stacked li .grow { flex-basis: 100%; }
  ul.list.stacked li button { flex: 1 1 auto; white-space: nowrap; }
}

/* ---------- Formulare ---------- */

input, select, textarea {
  font: inherit;
  font-size: max(16px, 1rem);  /* verhindert Zoom auf dem iPhone */
  color: inherit;
  background: var(--surface-sunken);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  width: 100%;
  min-height: var(--control-height);
}
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input:focus, select:focus, textarea:focus { border-color: var(--focus); }

/* Felder untereinander, Button darunter zentriert */
form.row {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  margin-top: var(--s-4);
}
form.row button { align-self: center; width: 100%; max-width: 320px; margin-top: var(--s-1); }

.field { display: block; margin-bottom: var(--s-4); }
.field > span {
  display: block;
  font-weight: 600;
  font-size: var(--text-sm);
  margin-bottom: var(--s-1);
}

.form-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-2);
}

/* ---------- Buttons ---------- */

button {
  font: inherit;
  font-weight: 600;
  border: 0;
  border-radius: var(--radius-pill);
  min-height: var(--control-height);
  padding: 10px 22px;
  background: var(--primary);
  color: var(--on-primary);
  cursor: pointer;
  transition: background-color 0.15s, transform 0.1s;
}
button:hover { background: var(--primary-hover); }
button:active { transform: translateY(1px); }

button.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
button.secondary:hover { background: var(--surface-sunken); border-color: var(--muted); }

/* Löschen, Entfernen, Zurücksetzen */
button.danger { color: var(--danger-text); }
button.danger:hover { background: var(--danger-bg); border-color: var(--danger-text); }

button.small {
  min-height: 44px;
  padding: 6px 14px;
  font-size: var(--text-sm);
}

button.wide { width: 100%; max-width: 320px; }

.actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-2);
  margin-top: var(--s-4);
}

/* ---------- Hinweise ---------- */

.error {
  background: var(--danger-bg);
  color: var(--danger-text);
  border-radius: var(--radius-sm);
  padding: var(--s-3) var(--s-4);
  margin-bottom: var(--s-4);
  text-align: center;
}

.saved { color: var(--success-text); font-weight: 600; }

/* Hinweis nach "Neuer Link": volle Breite, langer Link darf umbrechen */
.fresh-link { flex-basis: 100%; margin: 0; font-size: var(--text-sm); overflow-wrap: anywhere; }
.fresh-link code { font-weight: 400; user-select: all; }

.count {
  display: inline-block;
  margin-left: var(--s-1);
  font-size: var(--text-sm);
  padding: 0 8px;
  border-radius: var(--radius-pill);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
}

/* Status-Plakette "Link geöffnet" in der Admin-Teilnehmerliste */
.count.opened {
  background: var(--success-bg);
  border-color: transparent;
  color: var(--success-text);
}

.badge {
  display: inline-block;
  font-size: var(--text-sm);
  font-weight: 600;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  background: var(--success-bg);
  color: var(--success-text);
}

/* ---------- Größere Bildschirme ---------- */

@media (min-width: 600px) {
  main { padding-top: var(--s-7); }
  .card { padding: var(--s-6); }
  button.small { min-height: 36px; }
  /* Budget und Datum nebeneinander, Hinweis darunter über volle Breite */
  .info-list { grid-template-columns: 1fr 1fr; }
  #info-note,
  #info-budget:has(+ #info-date.hidden),
  #info-budget.hidden + #info-date { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  button { transition: none; }
}

/* ---------- Geschenk zum Auspacken (Idee 11) ---------- */

.hero { position: relative; overflow: hidden; }

.gift-box { text-align: center; }

.gift {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-1);
  width: 100%;
  min-height: 0;
  padding: var(--s-5) var(--s-4);
  border: 2px dashed var(--gold);
  border-radius: var(--radius);
  background: var(--surface-sunken);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.gift:hover { background: var(--surface-sunken); border-color: var(--primary); }
.gift:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

.gift-art { width: 132px; height: 132px; overflow: visible; }
.gift-paper { fill: var(--primary); }
.gift-paper-lid { filter: brightness(1.08); }
.gift-ribbon, .gift-bow { fill: var(--gold); }

.gift-lid { transform-box: fill-box; transform-origin: 50% 100%; }
.gift-art { animation: gift-wiggle 2.8s ease-in-out infinite; }

.gift-cta {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--primary);
}

.gift.opening .gift-art { animation: none; }
.gift.opening .gift-lid { animation: gift-lid-pop 0.6s ease-in forwards; }
.gift.opening .gift-body { animation: gift-shake 0.3s ease-in-out; }

@keyframes gift-wiggle {
  0%, 80%, 100% { transform: rotate(0); }
  85% { transform: rotate(-4deg); }
  90% { transform: rotate(4deg); }
  95% { transform: rotate(-2deg); }
}
@keyframes gift-shake {
  0%, 100% { transform: translateX(0); }
  33% { transform: translateX(-3px); }
  66% { transform: translateX(3px); }
}
@keyframes gift-lid-pop {
  to { transform: translateY(-70px) rotate(-25deg); opacity: 0; }
}

.confetti { position: absolute; left: 50%; top: 45%; pointer-events: none; }
.confetti span {
  position: absolute;
  width: 8px;
  height: 12px;
  border-radius: 2px;
  opacity: 0;
  animation: confetti-fly 1.2s ease-out forwards;
}
@keyframes confetti-fly {
  0% { transform: translate(0, 0) rotate(0); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translate(var(--x), calc(var(--y) + 160px)) rotate(var(--r)); opacity: 0; }
}

.fade-in { animation: fade-in 0.5s ease-out; }
@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.partner:focus { outline: none; }

.again { margin: var(--s-3) 0 0; }
.link-button {
  min-height: 0;
  padding: var(--s-1) var(--s-2);
  background: none;
  border: 0;
  color: var(--accent);
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link-button:hover { background: none; color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  .gift-art, .gift.opening .gift-lid, .gift.opening .gift-body { animation: none; }
  .confetti { display: none; }
  .fade-in { animation: fade-in-plain 0.4s ease-out; }
  @keyframes fade-in-plain { from { opacity: 0; } to { opacity: 1; } }
}

/* ---------- Countdown bis zur Bescherung (Idee 10) ---------- */

.countdown {
  margin: 0 0 var(--s-4);
  padding: var(--s-3) var(--s-4);
  text-align: center;
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  line-height: 1.25;
  color: var(--primary);
  background: var(--surface);
  border: 2px solid var(--gold);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-variant-numeric: tabular-nums;
}
.countdown.today { background: var(--success-bg); border-color: var(--accent); color: var(--success-text); }

/* ---------- Anti-Wunschliste (Idee 4) ---------- */

#dislikes-form textarea { text-align: left; }
#dislikes-form .saved { width: 100%; margin: 0; }

.dislikes {
  margin-top: var(--s-4);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--radius-sm);
  background: var(--danger-bg);
  color: var(--danger-text);
}
.dislikes-label {
  margin: 0 0 var(--s-1);
  font-size: var(--text-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.dislikes-text { margin: 0; white-space: pre-line; overflow-wrap: anywhere; }

/* ---------- Anonyme Fragen (Idee 3) ---------- */

.qa-list li { display: block; }
.qa-question { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.qa-answer { margin: var(--s-1) 0 0; overflow-wrap: anywhere; }
.qa-answer-form { margin-top: var(--s-2); }

/* ---------- Hinweise vom Wichtel (Idee 13) ---------- */

ol.hint-list { list-style: none; padding: 0; margin: 0; counter-reset: hint; }
ol.hint-list li {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) 0;
  border-bottom: 1px solid var(--border);
  counter-increment: hint;
  overflow-wrap: anywhere;
}
ol.hint-list li:last-child { border-bottom: 0; }
ol.hint-list li::before {
  content: counter(hint);
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-sunken);
  border: 1px solid var(--gold);
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: 700;
}
#hint-sent { margin: var(--s-4) 0 0; }

/* ---------- Funktionen ein-/ausschalten (Admin) ---------- */
.toggles { display: flex; flex-direction: column; gap: var(--s-2); margin-top: var(--s-4); }
.toggle {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  padding: var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  cursor: pointer;
}
.toggle input[type="checkbox"] {
  width: 22px;
  height: 22px;
  min-height: 0;
  padding: 0;
  margin: 2px 0 0;
  flex: none;
  accent-color: var(--primary);
  cursor: pointer;
}
.toggle span { display: flex; flex-direction: column; gap: 2px; }
.toggle small { color: var(--muted); font-size: var(--text-sm); }
.toggle:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
