:root {
  --paper: #F3F4EF;
  --ink: #23302B;
  --ink-soft: #55645D;
  --accent: #5C8368; /* neutral default (sage) */
  --surface: #FFFFFF;
  --border: #D6D9D2;
  --divider: #E4E6E0;
  --danger: #B23B3B;
  --tag-fill: #EFE0BC;
  --tag-border: #C6A15B;
  --tag-string: #8B6B3D;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(35, 48, 43, 0.08), 0 1px 2px rgba(35, 48, 43, 0.06);
  --font-display: "Fredoka", ui-rounded, system-ui, sans-serif;
  --font-body: "Karla", system-ui, sans-serif;
  --font-hand: "Caveat", cursive;
}

.theme-junge { --accent: #4C7A97; }
.theme-maedchen { --accent: #C46A78; }
.theme-ueberraschung { --accent: #8E6FA8; }

/* Dark mode: folgt automatisch der Systemeinstellung, sofern niemand den
   Knopf im Header manuell benutzt hat (siehe script.js). Einmal manuell
   gewaehlt, gewinnt html[data-theme] unabhaengig vom System. */
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --paper: #1B211D;
    --ink: #EDEFEA;
    --ink-soft: #A9B4AC;
    --accent: #7FAE8C;
    --surface: #242B26;
    --border: #3A443C;
    --divider: #333C35;
    --danger: #E2827A;
    --tag-fill: #3E331D;
    --tag-border: #B78F4E;
    --tag-string: #C9A76B;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.45), 0 1px 2px rgba(0, 0, 0, 0.35);
  }
}

html[data-theme="dark"] {
  --paper: #1B211D;
  --ink: #EDEFEA;
  --ink-soft: #A9B4AC;
  --accent: #7FAE8C;
  --surface: #242B26;
  --border: #3A443C;
  --divider: #333C35;
  --danger: #E2827A;
  --tag-fill: #3E331D;
  --tag-border: #B78F4E;
  --tag-string: #C9A76B;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.45), 0 1px 2px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site-header {
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.theme-toggle {
  background: none;
  border: 2px solid var(--border);
  border-radius: 999px;
  width: 40px;
  height: 40px;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  flex-shrink: 0;
}
.theme-toggle:hover { border-color: var(--accent); }
.theme-toggle:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.15rem;
  color: var(--ink);
  text-decoration: none;
}

.brand-tag {
  width: 14px;
  height: 14px;
  background: var(--accent);
  border-radius: 4px 4px 4px 0;
  display: inline-block;
}

main {
  flex: 1;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 4rem;
}

h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2rem, 5vw, 2.75rem);
  line-height: 1.1;
  margin: 0 0 0.75rem;
}

h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.3rem;
  margin: 0 0 0.5rem;
}

h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  margin: 0.5rem 0 0.25rem;
}

.lede { font-size: 1.1rem; color: var(--ink-soft); max-width: 46ch; }
.muted { color: var(--ink-soft); font-size: 0.95rem; }

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  margin: 0 0 0.25rem;
}

/* Buttons */
.btn {
  display: inline-block;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 1rem;
  padding: 0.8rem 1.5rem;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.btn-primary { background: var(--accent); color: #fff; box-shadow: var(--shadow); }
.btn-primary:hover { transform: translateY(-1px); }

.btn-secondary { background: transparent; color: var(--accent); border: 2px solid var(--accent); }

.btn-small { padding: 0.55rem 1rem; font-size: 0.9rem; background: var(--ink); color: var(--paper); }

/* Hero (landing) */
.hero { padding: 2rem 0 1rem; }

.hero-tag {
  width: 46px;
  height: 46px;
  background: var(--tag-fill);
  border: 2px solid var(--tag-border);
  border-radius: 6px 6px 6px 0;
  position: relative;
  margin-bottom: 1.5rem;
  transform: rotate(-8deg);
}

.tag-hole {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--paper);
  border: 2px solid var(--tag-string);
}

.steps { margin-top: 3rem; }
.steps ol {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(3, 1fr);
}
.steps p { margin: 0; color: var(--ink-soft); font-size: 0.92rem; }

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-family: var(--font-display);
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

@media (max-width: 640px) {
  .steps ol { grid-template-columns: 1fr; }
}

/* Cards */
.form-card, .created, .results-header, .empty {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.75rem;
  margin-top: 1.5rem;
}

.tag-card {
  background: var(--tag-fill);
  border: 2px solid var(--tag-border);
  border-radius: 10px 10px 10px 0;
  padding: 1.75rem 1.75rem 1.75rem 2.5rem;
  margin-top: 1.5rem;
  position: relative;
}
.tag-card .tag-hole { top: 18px; left: 14px; }
.tag-card-private { border-color: var(--accent); }

/* Forms */
form { display: flex; flex-direction: column; gap: 0.35rem; }

/* Honeypot fuer simple Spam-Bots: fuer Menschen und Screenreader unsichtbar,
   aber im DOM vorhanden (kein display:none - manche Bots pruefen das). */
.hp-field { position: absolute; left: -9999px; top: -9999px; height: 0; overflow: hidden; }
label { font-weight: 700; font-size: 0.92rem; margin-top: 0.75rem; }
.optional { font-weight: 400; color: var(--ink-soft); }

input[type="text"] {
  font-family: var(--font-body);
  font-size: 1rem;
  padding: 0.7rem 0.9rem;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--paper);
  color: var(--ink);
}
input[type="text"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.errors { color: var(--danger); padding-left: 1.2rem; }

.gender-fieldset {
  border: none;
  padding: 0;
  margin: 1rem 0 0.25rem;
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}
@media (min-width: 641px) {
  .gender-fieldset { flex-wrap: nowrap; }
}
.gender-fieldset legend { font-weight: 700; margin-bottom: 0.4rem; }

.gender-choice {
  position: relative;
  cursor: pointer;
  font-weight: 700;
  padding: 0.6rem 1rem;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: var(--paper);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.gender-choice input { position: absolute; opacity: 0; }

.gender-choice.gender-junge.is-checked { background: #4C7A97; border-color: #4C7A97; color: #fff; }
.gender-choice.gender-maedchen.is-checked { background: #C46A78; border-color: #C46A78; color: #fff; }
.gender-choice.gender-ueberraschung.is-checked { background: #8E6FA8; border-color: #8E6FA8; color: #fff; }
.gender-choice:has(input:focus-visible) { outline: 3px solid var(--ink); outline-offset: 2px; }

.link-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; }
.link-row input { flex: 1 1 100%; font-size: 0.85rem; padding: 0.6rem 0.7rem; }
.link-row .btn { flex: 1 1 auto; }

.confirm { padding: 1.5rem 0; }

.results-table table { width: 100%; border-collapse: collapse; margin-top: 0.5rem; }
.results-table th, .results-table td {
  text-align: left;
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid var(--divider);
}
.results-table th { font-family: var(--font-display); font-weight: 600; }

/* Tag wall — the signature element: size encodes vote count */
.tag-wall {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem 0.9rem;
  padding: 1.75rem;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-top: 1.5rem;
  align-items: flex-end;
}

.name-tag {
  font-family: var(--font-hand);
  font-weight: 700;
  color: var(--ink);
  background: var(--tag-fill);
  border: 2px solid var(--tag-border);
  border-radius: 8px 8px 8px 0;
  padding: 0.3rem 0.7rem 0.3rem 0.9rem;
  font-size: calc(1.15rem * var(--scale, 1));
  line-height: 1.3;
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  transform: rotate(calc((var(--scale, 1) * 3deg) - 4deg));
  box-shadow: 0 1px 3px rgba(35, 48, 43, 0.12);
}

.count-badge {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.6em;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 0.15em 0.55em;
}

.empty { text-align: center; color: var(--ink-soft); }

.site-footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--ink-soft);
  font-size: 0.85rem;
}

/* ---------------------------------------------------------------- */
/* Checkbox row (create form)                                       */
/* ---------------------------------------------------------------- */
.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin-top: 1.1rem;
  font-weight: 400;
  cursor: pointer;
}
.checkbox-row input { margin-top: 0.3rem; flex-shrink: 0; }
.checkbox-row .optional { display: block; font-size: 0.85rem; font-weight: 400; color: var(--ink-soft); margin-top: 0.15rem; }

/* ---------------------------------------------------------------- */
/* Wishlist                                                          */
/* ---------------------------------------------------------------- */
.wishlist, .wishlist-admin {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.75rem;
  margin-top: 1.5rem;
}

.wishlist-admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.wishlist-admin-header form { display: inline-flex; }

.wishlist-add-form {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0;
}
.wishlist-add-form input { flex: 1; min-width: 140px; margin-top: 0; }

.danger-zone { border: 2px solid var(--danger); }
.danger-zone h2 { color: var(--danger); }

.notice-banner {
  text-align: center;
  color: var(--ink-soft);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
}

.wishlist-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.wishlist-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border: 1.5px solid var(--divider);
  border-radius: 10px;
  flex-wrap: wrap;
}
.wishlist-item form { display: inline-flex; margin: 0; }
.wishlist-item.is-reserved { opacity: 0.6; }
.wishlist-item-info a { margin-left: 0.5rem; color: var(--accent); }

.btn-reserve { background: var(--accent); color: #fff; }
.btn-danger { background: transparent; color: var(--danger); border: 1.5px solid var(--danger); }

/* ---------------------------------------------------------------- */
/* Admin dashboard                                                   */
/* ---------------------------------------------------------------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin: 1.25rem 0;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  text-align: center;
}
.stat-num {
  display: block;
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 600;
  color: var(--accent);
}
.stat-label { display: block; font-size: 0.85rem; color: var(--ink-soft); margin-top: 0.25rem; }

@media (max-width: 640px) {
  .stat-grid { grid-template-columns: 1fr; }
}

.views-breakdown, .admin-projects table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.views-breakdown th, .views-breakdown td,
.admin-projects th, .admin-projects td {
  text-align: left;
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--divider);
}
.admin-projects { margin-top: 1.5rem; }
.table-scroll { overflow-x: auto; }

.pill {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15em 0.6em;
  border-radius: 999px;
}
.pill-on { background: var(--accent); color: #fff; }
.pill-off { background: var(--divider); color: var(--ink-soft); }

/* ---------------------------------------------------------------- */
/* Footer links + cookie banner                                      */
/* ---------------------------------------------------------------- */
.footer-links { margin-top: 0.4rem; font-size: 0.8rem; }
.footer-links a { color: var(--ink-soft); }
.link-button {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  color: var(--ink-soft);
  text-decoration: underline;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.8rem;
}

.cookie-banner {
  position: fixed;
  left: 1rem;
  right: 1rem;
  bottom: 1rem;
  max-width: 640px;
  margin: 0 auto;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
  padding: 1.25rem 1.5rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}
.cookie-banner[hidden] { display: none; }
.cookie-banner-text p { margin: 0 0 0.4rem; font-size: 0.88rem; color: var(--ink-soft); }
.cookie-banner-text p:first-child { color: var(--ink); margin-bottom: 0.3rem; }
.cookie-banner-text a { color: var(--accent); }
.cookie-banner-actions { display: flex; gap: 0.6rem; justify-content: flex-end; flex-wrap: wrap; }

/* ---------------------------------------------------------------- */
/* Gender-reveal balloon                                             */
/* ---------------------------------------------------------------- */
.balloon-reveal {
  position: relative;
  text-align: center;
  margin: 2rem 0 1rem;
  min-height: 260px;
}

.balloon {
  appearance: none;
  -webkit-appearance: none;
  display: block;
  width: 150px;
  height: 180px;
  margin: 0 auto;
  padding: 0;
  background: var(--tag-fill);
  border: 3px solid var(--tag-border);
  border-radius: 50% 50% 50% 50% / 58% 58% 42% 42%;
  cursor: pointer;
  position: relative;
  box-shadow: var(--shadow);
  animation: balloon-float 3.4s ease-in-out infinite;
}
.balloon::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -10px;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 10px solid var(--tag-border);
  transform: translateX(-50%);
}
.balloon::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -46px;
  width: 3px;
  height: 46px;
  background: var(--tag-string);
  transform: translateX(-50%);
}
.balloon-shine {
  position: absolute;
  top: 16%;
  left: 24%;
  width: 30px;
  height: 40px;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 50%;
  transform: rotate(-20deg);
}
.balloon:hover { transform: translateY(-4px) scale(1.03); }
.balloon:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.balloon.is-popping { animation: balloon-pop 0.38s ease forwards; cursor: default; }

@keyframes balloon-float {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-10px) rotate(2deg); }
}
@keyframes balloon-pop {
  0% { transform: scale(1); opacity: 1; }
  60% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.2); opacity: 0; }
}

.balloon-hint { margin: 3.6rem 0 0; font-size: 0.9rem; color: var(--ink-soft); }

.balloon-result {
  margin-top: 0.5rem;
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.balloon-result.is-visible { opacity: 1; transform: scale(1); }
.balloon-result .reveal-text {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--accent);
  margin: 0;
}

.confetti-burst { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.confetti-piece {
  position: absolute;
  top: 36%;
  left: 50%;
  width: var(--size, 10px);
  height: calc(var(--size, 10px) * 0.4);
  border-radius: var(--piece-radius, 2px);
  transform: translate(-50%, -50%) rotate(var(--rot, 0deg));
  animation: confetti-fly var(--duration, 1.9s) cubic-bezier(0.16, 1, 0.3, 1) forwards;
  animation-delay: var(--delay, 0s);
}
@keyframes confetti-fly {
  0% {
    transform: translate(-50%, -50%) rotate(var(--rot, 0deg));
    opacity: 1;
  }
  32% {
    transform: translate(calc(-50% + var(--dx, 0px)), calc(-50% + var(--dy, 0px))) rotate(var(--rot-mid, 140deg));
    opacity: 1;
  }
  78% {
    transform: translate(calc(-50% + var(--dx-final, 0px)), calc(-50% + var(--dy-final, 0px))) rotate(var(--rot-end, 360deg));
    opacity: 1;
  }
  100% {
    transform: translate(calc(-50% + var(--dx-final, 0px)), calc(-50% + var(--dy-final, 0px))) rotate(var(--rot-end, 360deg));
    opacity: 0;
  }
}

.external-wishlist-link { margin: 0.75rem 0 0; font-weight: 700; }
.external-wishlist-link a { color: var(--accent); }
