:root {
  --orange: #ff7518;
  --purple: #6a0dad;
  --dark: #1a1424;
  --dark2: #241a33;
  --text: #f2e9ff;
  --green: #3ddc84;
  --red: #ff5470;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  /* Basis-Hintergrundfarbe als Fallback, falls Bilder mal nicht laden.
     Die eigentlichen Hintergrundbilder liegen NICHT hier im Shorthand,
     sondern in body::before/::after (siehe unten) – Safari/WebKit hat einen
     bekannten Rendering-Bug, bei dem mehrere Hintergrundbilder mit
     gemischten background-attachment-Werten (scroll/fixed) im selben
     "background"-Shorthand auf einem flex+position:relative-Element
     überhaupt nicht gezeichnet werden (Ergebnis: komplett weißer
     Hintergrund, v.a. auf macOS/iOS Safari). Deshalb je EIN eigenes,
     einfaches Pseudo-Element pro Hintergrund-Layer. */
  background: #0d0714;
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Layer 1 (hinterste Ebene): großformatiger Vollbild-Hintergrund (Spukhaus,
   Friedhof, Mond) + radialer Farbverlauf. Eigenes Element mit
   position:fixed statt background-attachment:fixed im Shorthand – das
   funktioniert zuverlässig auch in Safari/WebKit. */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -3;
  background:
    url('assets/img/page-bg.svg') center bottom / cover no-repeat,
    radial-gradient(circle at 20% 20%, #2a1b3d, #0d0714 70%);
  pointer-events: none;
}

/* Layer 2: gekachelte, halbtransparente Struktur-Textur (scrollt normal
   mit der Seite mit, daher als einfaches, unabhängiges background-image
   direkt auf body – kein "fixed", also unproblematisch). */
body {
  background-image: url('assets/img/bg-texture.svg');
  background-repeat: repeat;
  background-size: 400px 400px;
  /* Die oben gesetzte Fallback-Farbe bleibt als background-color erhalten,
     da background-image die Farbe nicht überschreibt. */
}

/* Leicht wabernde Nebelschicht über dem gesamten Hintergrund für zusätzliche
   Gruselstimmung – rein dekorativ, blockiert keine Klicks (pointer-events none). */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 100%, rgba(74,58,104,0.35), transparent 60%);
  animation: fogDrift 18s ease-in-out infinite alternate;
}
@keyframes fogDrift {
  0% { opacity: 0.6; transform: translateX(-2%); }
  100% { opacity: 0.95; transform: translateX(2%); }
}

/* Schwebender Musik-Button (unten rechts, immer sichtbar) zum Starten/
   Stoppen der synthetischen Loop-Hintergrundmusik (assets/spooky-audio.js) */
.music-toggle {
  position: fixed;
  right: 1.2rem;
  bottom: 1.2rem;
  z-index: 100;
  background: var(--dark2);
  color: var(--text);
  border: 2px solid var(--orange);
  border-radius: 999px;
  padding: 0.6rem 1.1rem;
  font-size: 0.9rem;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.music-toggle:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 6px 22px rgba(255,117,24,0.4);
}
.music-toggle.playing {
  background: var(--orange);
  color: #1a1424;
  animation: musicPulse 1.6s ease-in-out infinite;
}
@keyframes musicPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,117,24,0.5); }
  50% { box-shadow: 0 0 0 10px rgba(255,117,24,0); }
}

a { color: var(--orange); }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background: rgba(0,0,0,0.4);
  border-bottom: 2px solid var(--orange);
  position: relative;
}
.topbar .brand {
  font-size: 1.4rem;
  font-weight: bold;
  text-decoration: none;
  color: var(--orange);
}
.topbar nav a, .topbar nav .link-btn {
  margin-left: 1rem;
  color: var(--text);
  text-decoration: none;
  background: none;
  border: none;
  font: inherit;
  cursor: pointer;
}
.topbar nav a:hover, .topbar nav .link-btn:hover { color: var(--orange); }
.inline-form { display: inline; }

/* Sandwich-/Hamburger-Menü-Button: standardmäßig ausgeblendet, wird per
   Media-Query auf schmalen Bildschirmen (Mobiltelefone) eingeblendet. */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  background: none;
  border: 2px solid var(--orange);
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
}
.nav-toggle-bar {
  display: block;
  width: 20px;
  height: 2px;
  margin: 0 auto;
  background: var(--orange);
  border-radius: 2px;
}

.container {
  flex: 1;
  max-width: 900px;
  margin: 0 auto;
  padding: 1.3rem 1rem;
  width: 100%;
}
.container.wide { max-width: 1140px; }

.hero { text-align: center; margin-bottom: 2rem; }
.hero h1 { font-size: 2.2rem; }
.subtitle { color: #d9c2ff; font-size: 1.1rem; }

/* Hero-Bereich mit Halloween-Nachtsilhouette */
.hero-banner {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 1.2rem;
  border: 1px solid #3a2a54;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
}
.hero-banner img {
  display: block;
  width: 100%;
  height: 260px;
  object-fit: cover;
}
.hero-banner .hero-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: linear-gradient(180deg, rgba(13,7,20,0.1), rgba(13,7,20,0.75));
  padding: 1rem;
}
.hero-banner h1 {
  margin: 0 0 0.4rem;
  font-size: 2.4rem;
  text-shadow: 0 0 12px rgba(255,117,24,0.6);
}
.hero-banner .subtitle { margin: 0; }

/* Icons */
.icon {
  display: inline-block;
  width: 1.4em;
  height: 1.4em;
  vertical-align: -0.28em;
  margin-right: 0.4em;
}
.icon-lg { width: 3rem; height: 3rem; margin: 0 auto 0.5rem; display: block; }
h1 .icon, h2 .icon { filter: drop-shadow(0 0 6px rgba(255,117,24,0.5)); }

.card { position: relative; overflow: hidden; }
.card.with-web::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 60px; height: 60px;
  background: url('assets/img/corner-web.svg') no-repeat;
  background-size: contain;
  opacity: 0.55;
  pointer-events: none;
  z-index: 0;
}
.card.with-web > * { position: relative; z-index: 1; }
.card.with-web h1,
.card.with-web h2 {
  padding-left: 2.6rem;
}

.card {
  background: var(--dark2);
  border: 1px solid #3a2a54;
  border-radius: 12px;
  padding: 1.3rem 1.6rem;
  margin-bottom: 1rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.card.narrow { max-width: 420px; margin-left: auto; margin-right: auto; }

.cta { text-align: center; margin-top: 1.2rem; }

.btn {
  display: inline-block;
  background: var(--orange);
  color: #1a1424;
  font-weight: bold;
  padding: 0.7rem 1.4rem;
  border-radius: 8px;
  text-decoration: none;
  border: none;
  cursor: pointer;
  margin: 0.3rem;
  position: relative;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  box-shadow: 0 0 0 rgba(255,117,24,0.0);
}
.btn:hover {
  background: #ff8f42;
  transform: translateY(-2px) rotate(-1deg);
  box-shadow: 0 6px 18px rgba(255,117,24,0.45);
}
.btn:active { transform: translateY(0) rotate(0deg); }
.btn-secondary { background: var(--purple); color: var(--text); }
.btn-secondary:hover { background: #7d1ed1; box-shadow: 0 6px 18px rgba(106,13,173,0.5); }
.btn-small { padding: 0.4rem 0.8rem; font-size: 0.85rem; }

/* Fledermaus-Divider */
.bat-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.2rem;
  margin: 0.6rem 0;
  opacity: 0.7;
}
.bat-divider img { width: 22px; height: 22px; }
.bat-divider img:nth-child(2) { animation: flutter 2.4s ease-in-out infinite; }
.bat-divider img:nth-child(1) { animation: flutter 2.1s ease-in-out infinite 0.3s; }
.bat-divider img:nth-child(3) { animation: flutter 2.7s ease-in-out infinite 0.6s; }
@keyframes flutter {
  0%, 100% { transform: translateY(0) scaleX(1); }
  50% { transform: translateY(-4px) scaleX(0.9); }
}

.form { display: flex; flex-direction: column; gap: 1rem; }
.form label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.95rem; }
.form input, .form select, .form textarea {
  padding: 0.6rem;
  border-radius: 6px;
  border: 1px solid #4c3766;
  background: #150f20;
  color: var(--text);
}
fieldset { border: none; padding: 0; display: flex; flex-direction: column; gap: 1rem; }
fieldset[disabled] { opacity: 0.6; }

.alert { padding: 0.8rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.alert-success { background: rgba(61,220,132,0.15); border: 1px solid var(--green); color: var(--green); }
.alert-error { background: rgba(255,84,112,0.15); border: 1px solid var(--red); color: var(--red); }

.guest-table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
.guest-table th, .guest-table td {
  padding: 0.7rem 0.8rem;
  border-bottom: 1px solid #3a2a54;
  text-align: left;
  font-size: 0.9rem;
  vertical-align: top;
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-width: 220px;
}
.guest-table th {
  color: var(--orange);
  white-space: nowrap;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.guest-table tbody tr:hover { background: rgba(255,117,24,0.06); }
.guest-table tbody tr:last-child td { border-bottom: none; }

/* Scrollbarer Wrapper, damit breite Tabellen die Karte nie sprengen */
.table-scroll {
  overflow-x: auto;
  margin-top: 1rem;
  border-radius: 10px;
  -webkit-overflow-scrolling: touch;
}
.table-scroll .guest-table {
  margin-top: 0;
  min-width: 640px;
}
.table-scroll::-webkit-scrollbar { height: 8px; }
.table-scroll::-webkit-scrollbar-thumb { background: #4c3766; border-radius: 4px; }
.table-scroll::-webkit-scrollbar-track { background: transparent; }

/* Zusammenfassung über der Gästeliste (z.B. "12 Zusagen von 20 Rückmeldungen") */
.guest-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.8rem;
}
.guest-summary .status-badge { font-size: 0.9rem; padding: 0.35rem 0.8rem; }

/* -----------------------------------------------------------------------
   Gästeliste auf Mobiltelefonen: die klassische Tabelle wird ab 640px
   Breite in gestapelte "Karten" umgewandelt, damit KEIN horizontales
   Scrollen mehr nötig ist. Jede Zelle bekommt über data-label ihre
   Spaltenüberschrift als Pseudo-Label vorangestellt (siehe guests.php /
   index.php, wo jedes <td> ein data-label="..." Attribut trägt).
   ----------------------------------------------------------------------- */
@media (max-width: 640px) {
  .table-scroll { overflow-x: visible; }
  .table-scroll .guest-table { min-width: 0; }
  .guest-table thead { display: none; }
  .guest-table, .guest-table tbody, .guest-table tr, .guest-table td { display: block; width: 100%; }
  .guest-table tr {
    margin-bottom: 0.9rem;
    border: 1px solid #3a2a54;
    border-radius: 10px;
    padding: 0.6rem 0.8rem;
    background: rgba(255,255,255,0.02);
  }
  .guest-table tr:last-child { margin-bottom: 0; }
  .guest-table td {
    border-bottom: none;
    padding: 0.35rem 0;
    max-width: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }
  /* Avatar-Zelle (ohne data-label) bekommt Name automatisch daneben */
  .guest-table td:first-child { padding-top: 0; }
  .guest-table td[data-label]::before {
    content: attr(data-label);
    flex: 0 0 auto;
    min-width: 90px;
    color: var(--orange);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
  }
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}
.status-badge.yes { background: rgba(61,220,132,0.18); color: var(--green); }
.status-badge.no { background: rgba(255,84,112,0.18); color: var(--red); }
.status-badge.maybe { background: rgba(255,117,24,0.18); color: var(--orange); }
.status-badge.pending { background: rgba(242,233,255,0.12); color: var(--text); }

.actions-cell { display: flex; flex-wrap: wrap; gap: 0.4rem; }

@media (max-width: 640px) {
  .container { padding: 1rem 0.75rem; }
  .card { padding: 1.1rem 1.1rem; margin-bottom: 0.8rem; }
  .card.with-web h1, .card.with-web h2 { padding-left: 2.2rem; font-size: 1.3rem; }
  .hero-banner img { height: 180px; }
  .hero-banner h1 { font-size: 1.6rem; }

  /* Sandwich-Menü aktivieren: Hamburger-Button einblenden, Navigation als
     ausklappbares Dropdown unter der Topbar verstecken/anzeigen. */
  .nav-toggle { display: flex; }
  .topbar nav {
    display: none;
    flex-direction: column;
    align-items: stretch;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #1a1424;
    border-bottom: 2px solid var(--orange);
    box-shadow: 0 8px 20px rgba(0,0,0,0.5);
    padding: 0.5rem 1rem 1rem;
    z-index: 20;
  }
  .topbar nav.open { display: flex; }
  .topbar nav a, .topbar nav .link-btn {
    margin-left: 0;
    padding: 0.7rem 0.2rem;
    border-bottom: 1px solid #3a2a54;
    width: 100%;
    text-align: left;
  }
  .topbar nav a:last-child, .topbar nav form:last-child .link-btn { border-bottom: none; }
  .topbar nav .inline-form { display: block; width: 100%; }
}

footer {
  text-align: center;
  padding: 1rem;
  font-size: 0.85rem;
  color: #b9a4d9;
  border-top: 1px solid #3a2a54;
}

/* -----------------------------------------------------------------------
   Avatare (Profilbilder) – werden konsistent im Header, in Gästeliste,
   Admin-Tabelle, Galerie und auf der Account-Seite verwendet.
   ----------------------------------------------------------------------- */
.avatar {
  border-radius: 50%;
  object-fit: cover;
  background: var(--dark2);
  border: 2px solid var(--orange);
  flex-shrink: 0;
}
.avatar-nav { width: 28px; height: 28px; margin-right: 0.4rem; vertical-align: middle; }
.avatar-sm { width: 32px; height: 32px; }
.avatar-xs { width: 20px; height: 20px; vertical-align: middle; margin-right: 0.3rem; }
.avatar-lg { width: 96px; height: 96px; border-width: 3px; }

.nav-avatar-link { display: inline-flex; align-items: center; }

/* -----------------------------------------------------------------------
   Account-Seite (account.php)
   ----------------------------------------------------------------------- */
.account-avatar-block {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.card-section {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid #3a2a54;
}
.card-section h2 { margin-top: 0; font-size: 1.15rem; }

/* -----------------------------------------------------------------------
   Mitbringsel- & Kostüm-Übersicht (contributions.php / costumes.php)
   ----------------------------------------------------------------------- */
.contribution-list { list-style: none; padding: 0; margin: 0.8rem 0 0; }
.contribution-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid #3a2a54;
}
.contribution-list li:last-child { border-bottom: none; }

/* -----------------------------------------------------------------------
   Foto-Diagnose (diagnose-photo.php, admin-only)
   ----------------------------------------------------------------------- */
.diagnose-list { list-style: none; padding: 0; margin: 0.8rem 0 0; }
.diagnose-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid #3a2a54;
  word-break: break-word;
}
.diagnose-list li:last-child { border-bottom: none; }
.diagnose-list code {
  background: #241638;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.85rem;
  word-break: break-all;
}
.diagnose-table { width: 100%; border-collapse: collapse; margin-top: 0.8rem; font-size: 0.9rem; }
.diagnose-table th, .diagnose-table td {
  text-align: left;
  padding: 0.5rem;
  border-bottom: 1px solid #3a2a54;
}

.hint { color: #b9a4d9; font-size: 0.9rem; }

.checkbox-label { display: flex; align-items: center; gap: 0.5rem; font-weight: normal; }
.checkbox-label input[type="checkbox"] { width: auto; }

.danger-zone {
  border: 1px solid var(--red);
  border-radius: 10px;
  padding: 1.2rem;
  background: rgba(255, 84, 112, 0.06);
}
.danger-zone h2 { color: var(--red); }

.btn-danger {
  background: var(--red);
  color: #1a1424;
}
.btn-danger:hover { background: #ff7a95; }

.btn-small { padding: 0.4rem 0.8rem; font-size: 0.85rem; }

/* -----------------------------------------------------------------------
   Fotogalerie (gallery.php)
   ----------------------------------------------------------------------- */
.gallery-grid-section { margin-top: 1.5rem; }

.gallery-grid {
  display: grid;
  /* Kleinere, gleichgroße quadratische Kacheln (wie in der iPhone-
     "Fotos"-App) statt weniger, großer Vorschaubilder – dadurch passen
     deutlich mehr Fotos auf einen Blick auf den Bildschirm. */
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 0.4rem;
}

.gallery-item {
  margin: 0;
  background: var(--dark2);
  border: 1px solid #3a2a54;
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
/* Vorschau-Button (klickbar zum Öffnen der Lightbox) – als <button>
   statt direktem <img>-Klick, damit es per Tastatur/Screenreader
   bedienbar bleibt und keine eigene Formularsemantik benötigt.
   WICHTIG: Das quadratische Seitenverhältnis wird bewusst auf dem BUTTON
   selbst erzeugt (aspect-ratio + position:relative), NICHT auf dem <img>
   darin – manche WebKit-Versionen (Safari/iOS) berechnen "aspect-ratio"
   auf einem <img> innerhalb eines <button> fehlerhaft bzw. ignorieren es
   in Kombination mit CSS-Grid, wodurch die Fotos statt quadratisch als
   überlangen, verzerrten Streifen über die volle Bildschirmhöhe
   dargestellt wurden. Die robuste Lösung: der Button bekommt ein festes
   1:1-Seitenverhältnis, das Bild wird per position:absolute EXAKT
   hineingelegt (inset:0) – das funktioniert zuverlässig, unabhängig von
   Verschachtelung oder Grid-Kontext. */
.gallery-thumb-btn {
  display: block;
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  padding: 0;
  border: none;
  background: #1a1128;
  cursor: pointer;
  overflow: hidden;
}
.gallery-thumb-btn > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.gallery-item figcaption {
  padding: 0.35rem 0.5rem;
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem;
}
.gallery-item figcaption .avatar-xs { width: 18px; height: 18px; }
.gallery-delete { padding: 0 0.5rem 0.4rem; }
.gallery-delete .link-btn { color: var(--red); font-size: 0.75rem; }

/* Hinweistext, der ein kaputtes/nicht ladbares Foto ersetzt (siehe
   assets/img-fallback.js), damit statt eines verzerrten "kaputtes Bild"-
   Icons ein sauberer, verständlicher Platzhalter erscheint. */
.gallery-broken-notice {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0.5rem;
  font-size: 0.65rem;
  color: #b9a4d9;
  background: rgba(255,255,255,0.03);
}

@media (max-width: 640px) {
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 0.25rem; }
}

/* -----------------------------------------------------------------------
   Foto-Lightbox (Vollbild-Ansicht mit Durchblättern/Download)
   ----------------------------------------------------------------------- */
.gallery-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(10, 5, 20, 0.94);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.gallery-lightbox[hidden] { display: none; }

.gallery-lightbox-content {
  max-width: min(90vw, 900px);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
}
.gallery-lightbox-content img {
  max-width: 100%;
  max-height: 75vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}
.gallery-lightbox-info {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: #e8dcff;
  font-size: 0.9rem;
  flex-wrap: wrap;
  justify-content: center;
}

.gallery-lightbox-close,
.gallery-lightbox-prev,
.gallery-lightbox-next {
  position: fixed;
  background: rgba(255,255,255,0.08);
  border: none;
  color: #fff;
  font-size: 1.6rem;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gallery-lightbox-close:hover,
.gallery-lightbox-prev:hover,
.gallery-lightbox-next:hover { background: rgba(255,255,255,0.18); }

.gallery-lightbox-close { top: 1rem; right: 1rem; }
.gallery-lightbox-prev { left: 1rem; top: 50%; transform: translateY(-50%); }
.gallery-lightbox-next { right: 1rem; top: 50%; transform: translateY(-50%); }

@media (max-width: 640px) {
  .gallery-lightbox-close, .gallery-lightbox-prev, .gallery-lightbox-next {
    width: 40px; height: 40px; font-size: 1.3rem;
  }
}

