/* ==========================================================================
   Weihnachtsmodus (Test, Branch weihnachtsmodus) – siehe docs/weihnachtsmodus.md
   Nur Ebenen ueber/hinter der Seite, Layout und Inhalte bleiben unveraendert.
   Zustandsklassen am <html>:
     .xmas-an       Modus gewaehlt (Kopf-Skript in head.php, vor dem ersten Bild)
     .xmas-sichtbar Ebenen eingeblendet (assets/js/xmas.js, ein Bild spaeter)
     .xmas-auftakt  einmaliger Einschalt-Uebergang
   Alle Animationen nur mit transform und opacity.
   ========================================================================== */

/* ---------- Schalter in der Kopfleiste ---------- */
.xmas-schalter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(12, 22, 38, 0.12);
  background: none;
  color: var(--ink-2, #46536b);
  cursor: pointer;
  transition: color 0.3s ease, border-color 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}
.xmas-schalter svg {
  width: 18px;
  height: 18px;
  transition: transform 0.7s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.3s ease;
}
.xmas-schalter:hover svg,
.xmas-schalter:focus-visible svg { transform: rotate(60deg); }
.nav--dark .xmas-schalter { border-color: rgba(255, 255, 255, 0.2); color: #b9c4d8; }
.nav--dark .xmas-schalter:hover { color: #fff; }
html.xmas-an .xmas-schalter { color: #c8912f; border-color: rgba(200, 145, 47, 0.45); }
html.xmas-an .nav--dark .xmas-schalter { color: #f4cf86; border-color: rgba(244, 207, 134, 0.45); }
html.xmas-an .xmas-schalter svg { transform: rotate(60deg); }
/* Ohne JavaScript gibt es keinen Modus, also auch keinen Knopf */
html:not(.js) .xmas-schalter { display: none; }

/* ---------- Warmer Akzent: Punkt im Logo, Laser um die Kopfleiste ---------- */
html.xmas-an .nav__branddot { color: #e9b45a; }
html.xmas-an .nav__inner::before {
  background: conic-gradient(
    from var(--nav-angle),
    transparent 0turn 0.62turn,
    rgba(244, 207, 134, 0) 0.68turn,
    rgba(244, 207, 134, 0.5) 0.78turn,
    #f4cf86 0.85turn,
    #3fd6e8 0.92turn,
    transparent 0.995turn
  );
}

/* ---------- WebGL-Schnee ---------- */
.xmas-schnee {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 98;               /* unter der Kopfleiste (100) und allen Dialogen */
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.8s ease;
}
html.xmas-sichtbar .xmas-schnee { opacity: 1; }

/* ---------- Deko im ersten Bildschirm (Codex-Motive) ---------- */
.xmas-deko {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 100vh;
  height: 100svh;
  z-index: 97;
  overflow: hidden;
  pointer-events: none;
  contain: layout paint;
}
/* Rahmen = exakt die Breite der Kopfleiste (siehe .nav / .nav__inner):
   kein Motiv ragt seitlich ueber den Header hinaus */
.xmas-deko__rahmen {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  margin-inline: auto;
  width: min(var(--wrap, 1180px), calc(100% - 2 * clamp(0.9rem, 3vw, 2rem)));
}
.xmas-deko img {
  position: absolute;
  display: block;
  max-width: none;
  opacity: 0;
  transition: opacity 1.6s ease, transform 2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Lichterketten-Bokeh: reiner Hintergrundstreifen oben, volle Breite erlaubt */
.xmas-deko__bokeh {
  top: 0;
  left: 0;
  width: 100%;
  height: clamp(80px, 13vw, 190px);
  object-fit: cover;
  object-position: center top;
  transform: translateY(-14px) scale(1.04);
  -webkit-mask-image: linear-gradient(#000 35%, transparent);
  mask-image: linear-gradient(#000 35%, transparent);
}
html.xmas-sichtbar .xmas-deko__bokeh {
  opacity: 0.3;
  transform: translateY(0) scale(1.04);
  transition-delay: 0.15s;
}

/* Tannenzweig mit Lichtern, links oben unter der Kopfleiste */
.xmas-deko__zweig {
  top: 4px;
  left: 0;
  width: clamp(120px, 15vw, 230px);
  height: auto;
  transform-origin: 0 0;
  transform: translate(-18px, -18px) rotate(-4deg);
}
html.xmas-sichtbar .xmas-deko__zweig {
  opacity: 0.82;
  transform: translate(0, 0) rotate(0deg);
  transition-delay: 0.35s;
}

/* Glaskugel am Faden, rechts im Rahmen */
.xmas-deko__kugel {
  position: absolute;
  top: 0;
  right: 7%;
  width: clamp(44px, 4.6vw, 72px);
  transform-origin: 50% 0;
}
.xmas-deko__kugelbild {
  position: relative !important;
  width: 100%;
  height: auto;
  transform: translateY(-40%);
}
html.xmas-sichtbar .xmas-deko__kugelbild {
  opacity: 0.9;
  transform: translateY(0);
  transition-delay: 0.55s;
  transition-duration: 1.4s, 2.6s;
}

/* Feine Dauerbewegung: Kugel pendelt, Lichter atmen.
   Pausiert, sobald der erste Bildschirm weggescrollt ist (.xmas-ruhe). */
@keyframes xmas-pendeln { 0%, 100% { transform: rotate(2.2deg); } 50% { transform: rotate(-2.2deg); } }
@keyframes xmas-atmen { 0%, 100% { opacity: 0.3; } 50% { opacity: 0.18; } }
html.xmas-sichtbar .xmas-deko__kugel { animation: xmas-pendeln 7.5s ease-in-out 2.6s infinite; }
html.xmas-sichtbar .xmas-deko__bokeh { animation: xmas-atmen 9s ease-in-out 2s infinite; }
.xmas-deko.xmas-ruhe * { animation-play-state: paused !important; }

/* ---------- Deko in hellen Abschnitten (Codex-Motive, xmas.js hellBauen) ----------
   Ebene liegt im Abschnitt (der schon position:relative hat), Rahmen =
   Breite der Kopfleiste. Motive nur im Innenabstand oben/unten
   (--xh-oben / --xh-unten setzt das Skript), damit kein Text bedeckt wird.
   Auftritt, sobald der Abschnitt ins Bild kommt (.xmas-da); Dauerbewegung
   nur solange er sichtbar ist. */
.xmas-hell { display: none; }
html.xmas-an .xmas-hell {
  display: block;
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  contain: layout paint;
}
.xmas-hell__rahmen {
  position: absolute;
  inset: 0;
  margin-inline: auto;
  width: min(var(--wrap, 1180px), calc(100% - 2 * clamp(0.9rem, 3vw, 2rem)));
}
.xmas-hell img {
  position: absolute;
  display: block;
  max-width: none;
  height: auto;
  opacity: 0;
  transition: opacity 1.1s ease, transform 1.6s cubic-bezier(0.16, 1, 0.3, 1);
}
html.xmas-sichtbar .xmas-hell.xmas-da img { opacity: 1; transform: none; }
.xmas-hell:not(.xmas-da) * { animation-play-state: paused !important; }

/* Girlande: oben mittig im Innenabstand, schwingt ganz leicht */
.xmas-hell__girlande {
  position: absolute;
  top: 0;
  left: 50%;
  width: min(62%, 640px, calc((var(--xh-oben) - 16px) * 7));
  margin-left: calc(min(62%, 640px, calc((var(--xh-oben) - 16px) * 7)) / -2);
  transform-origin: 50% 0;
}
.xmas-hell__girlandenbild {
  position: relative !important;
  width: 100%;
  transform: translateY(-60%);
}
html.xmas-sichtbar .xmas-hell.xmas-da .xmas-hell__girlandenbild { transition-delay: 0.1s; }
@keyframes xmas-schwingen { 0%, 100% { transform: rotate(0.7deg); } 50% { transform: rotate(-0.7deg); } }
html.xmas-sichtbar .xmas-hell__girlande { animation: xmas-schwingen 8s ease-in-out 1.6s infinite; }

/* Sterne: schweben im oberen Innenabstand rechts und links */
.xmas-hell__stern { width: 34px; transform: translateY(14px) scale(0.6); }
.xmas-hell__stern--a { top: calc(var(--xh-oben) * 0.18); right: 4%; width: clamp(24px, 2.6vw, 38px); }
.xmas-hell__stern--b { top: calc(var(--xh-oben) * 0.52); right: 9%; width: clamp(16px, 1.6vw, 24px); }
.xmas-hell__stern--c { top: calc(var(--xh-oben) * 0.30); right: 15%; width: clamp(14px, 1.3vw, 20px); }
.xmas-hell__stern--d { top: calc(var(--xh-oben) * 0.36); left: 1%; width: clamp(18px, 1.9vw, 28px); }
/* Sterne neben dem Schneemann (unten) */
.xmas-hell__stern--e { bottom: calc(var(--xh-unten) * 0.62); right: calc(clamp(56px, 7.6vw, 104px) + 3%); width: clamp(14px, 1.3vw, 20px); }
.xmas-hell__stern--f { bottom: calc(var(--xh-unten) * 0.30); right: calc(clamp(56px, 7.6vw, 104px) + 8%); width: clamp(12px, 1.1vw, 17px); }
html.xmas-sichtbar .xmas-hell.xmas-da .xmas-hell__stern--b { transition-delay: 0.15s; }
html.xmas-sichtbar .xmas-hell.xmas-da .xmas-hell__stern--c { transition-delay: 0.3s; }
html.xmas-sichtbar .xmas-hell.xmas-da .xmas-hell__stern--d { transition-delay: 0.22s; }
html.xmas-sichtbar .xmas-hell.xmas-da .xmas-hell__stern--e { transition-delay: 0.55s; }
html.xmas-sichtbar .xmas-hell.xmas-da .xmas-hell__stern--f { transition-delay: 0.7s; }
/* Schweben: eigene Ebene (translate), damit es sich nicht mit dem Auftritt beisst */
@keyframes xmas-schweben {
  0%, 100% { translate: 0 0; rotate: -6deg; }
  50% { translate: 0 -7px; rotate: 6deg; }
}
html.xmas-sichtbar .xmas-hell__stern { animation: xmas-schweben 7s ease-in-out infinite; }
/* Mit Schwerelos-Physik (xmas.js) uebernimmt das Skript translate/rotate */
html.xmas-physik .xmas-hell__stern { animation: none !important; }
.xmas-hell__stern--b { animation-duration: 8.5s !important; animation-delay: -2s !important; }
.xmas-hell__stern--c { animation-duration: 6.2s !important; animation-delay: -4s !important; }
.xmas-hell__stern--d { animation-duration: 9s !important; animation-delay: -1s !important; }
.xmas-hell__stern--e { animation-duration: 7.6s !important; animation-delay: -3s !important; }
.xmas-hell__stern--f { animation-duration: 6.8s !important; animation-delay: -5s !important; }

/* Girlande v2: Schnur ueber die ganze Rahmenbreite, Teile einzeln */
.xmas-hell__kette {
  --sag: min(44px, calc(var(--xh-oben) * 0.32));
  --og: clamp(17px, 2.1vw, 30px);
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: var(--xh-oben);
}
.xmas-hell__schnur {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: var(--sag);
  overflow: visible;
  opacity: 0;
  transition: opacity 1s ease;
}
.xmas-hell__schnur path {
  fill: none;
  stroke: #d6a84e;
  stroke-width: 1.4;
  filter: drop-shadow(0 1px 1px rgba(120, 80, 20, 0.25));
}
.xmas-hell__pin {
  position: absolute;
  top: -3px;
  width: 7px;
  height: 7px;
  margin-left: -3.5px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff3cf, #d6a84e 55%, #8a6420);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  opacity: 0;
  transition: opacity 0.8s ease;
}
.xmas-hell__pin--links { left: 0; }
.xmas-hell__pin--rechts { left: 100%; }
html.xmas-sichtbar .xmas-hell.xmas-da .xmas-hell__schnur,
html.xmas-sichtbar .xmas-hell.xmas-da .xmas-hell__pin { opacity: 1; }
.xmas-hell__haenger {
  position: absolute;
  left: calc(var(--t) * 100%);
  top: calc(var(--sag) * var(--k) - 1px);
  width: var(--og);
  margin-left: calc(var(--og) / -2);
  padding-top: var(--faden);
  transform-origin: 50% 0;
}
.xmas-hell__haenger::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  width: 1px;
  height: calc(var(--faden) + 3px);
  background: linear-gradient(#d6a84e, rgba(214, 168, 78, 0.6));
  transform: scaleY(0);
  transform-origin: 50% 0;
  transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.xmas-hell .xmas-hell__haengerbild {
  position: relative !important;
  width: 100%;
  transform: translateY(-160%) scale(0.7);
  transition: opacity 0.5s ease, transform 1.1s cubic-bezier(0.34, 1.56, 0.64, 1);
  transition-delay: var(--verz);
}
html.xmas-sichtbar .xmas-hell.xmas-da .xmas-hell__haenger::before { transform: scaleY(1); transition-delay: var(--verz); }
@keyframes xmas-pendel-frei { 0%, 100% { rotate: 3deg; } 50% { rotate: -3deg; } }
html.xmas-sichtbar .xmas-hell__haenger { animation: xmas-pendel-frei var(--dauer) ease-in-out infinite; animation-delay: calc(var(--verz) * -3); }
html.xmas-physik .xmas-hell__haenger { animation: none !important; }
@media (max-width: 700px) {
  .xmas-hell__haenger:nth-child(2n+4) { display: none; }   /* am Handy jedes zweite Teil */
}

/* Figuren: xmas.js sucht je Abschnitt einen freien Platz an der Oberkante
   einer Karte (Endlage, nicht der Zwischenstand der Einflug-Animation) und
   setzt left/top/width/height. Der Kasten ist nur der sichtbare Teil, das
   Bild ist unten abgeschnitten: die Figur guckt ueber die Kante, auch bei
   durchscheinenden Karten scheint nichts durch.
   Sichtbar erst mit .xmas-sitzt (Karte ist angekommen); faehrt die Karte
   weg, duckt sich die Figur hinter die Kante. */
.xmas-hell__figur {
  position: absolute;
  overflow: hidden;
  transform-origin: 50% 100%;
}
.xmas-hell__figurbild {
  position: absolute !important;
  left: 0;
  top: 0;
  width: 100%;
  transform: translateY(100%);
  transform-origin: 50% 100%;
}
html.xmas-sichtbar .xmas-hell.xmas-da .xmas-hell__figurbild { transition-delay: 0.15s; transition-duration: 0.6s, 0.9s; }
html.xmas-sichtbar .xmas-hell.xmas-da:not(.xmas-sitzt) .xmas-hell__figurbild { opacity: 0; transform: translateY(100%); transition-delay: 0s; transition-duration: 0.25s, 0.4s; }
@keyframes xmas-wippen { 0%, 100% { transform: rotate(-2deg); } 50% { transform: rotate(2deg); } }
html.xmas-sichtbar .xmas-hell__figur { animation: xmas-wippen 6.2s ease-in-out 2s infinite; }
.xmas-hell__figur--haus, .xmas-hell__figur--tasse { animation-duration: 8s !important; }
html.xmas-sichtbar .xmas-hell.xmas-da:not(.xmas-sitzt) .xmas-hell__stern--frei { opacity: 0; transition-delay: 0s; }
/* Sterne neben der Figur (Position aus xmas.js) */
html.xmas-sichtbar .xmas-hell.xmas-da .xmas-hell__stern--frei { transition-delay: 0.6s; }
.xmas-hell__stern--frei + .xmas-hell__stern--frei { animation-duration: 8.3s !important; animation-delay: -3s !important; }

/* ---------- Knoepfe rechts (Kontaktleiste, Chat, Nach oben) ----------
   Farben der Knoepfe bleiben; nur Codex-Schneehauben obenauf und eine
   Mütze im ADence-Blau auf dem Chatknopf. Bild laedt erst mit xmas-an. */
html.xmas-an .rail__btn::before,
html.xmas-an .totop::before,
html.xmas-an .chatknopf::before {
  content: "";
  position: absolute;
  z-index: 2;
  pointer-events: none;
  background: url("../img/xmas/xmas-haube.webp") center / 100% 100% no-repeat;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.8s ease, transform 1s cubic-bezier(0.34, 1.56, 0.64, 1);
}
html.xmas-an .rail__btn::before,
html.xmas-an .totop::before {
  left: -5px;
  right: -5px;
  top: -10px;
  height: 23px;
}
html.xmas-an .rail__btn:nth-child(2n)::before { transform: translateY(-6px) scaleX(-1); }
html.xmas-an .chatknopf::before {
  background-image: url("../img/xmas/xmas-muetze.webp");
  width: 30px;
  height: 38px;
  top: -25px;
  right: -7px;
  transform: translateY(-6px) rotate(18deg);
  transform-origin: 50% 100%;
}
html.xmas-sichtbar .rail__btn::before,
html.xmas-sichtbar .totop::before { opacity: 1; transform: none; }
html.xmas-sichtbar .rail__btn:nth-child(2n)::before { transform: scaleX(-1); }
html.xmas-sichtbar .chatknopf::before { opacity: 1; transform: rotate(16deg); }
/* gestaffelt herabfallen */
html.xmas-sichtbar .rail__btn:nth-child(1)::before { transition-delay: 0.3s; }
html.xmas-sichtbar .rail__btn:nth-child(2)::before { transition-delay: 0.38s; }
html.xmas-sichtbar .rail__btn:nth-child(3)::before { transition-delay: 0.46s; }
html.xmas-sichtbar .rail__btn:nth-child(4)::before { transition-delay: 0.54s; }
html.xmas-sichtbar .rail__btn:nth-child(5)::before { transition-delay: 0.62s; }
html.xmas-sichtbar .rail__btn:nth-child(6)::before { transition-delay: 0.7s; }
html.xmas-sichtbar .rail__btn:nth-child(7)::before { transition-delay: 0.78s; }
/* Muetze wackelt beim Hover */
@keyframes xmas-muetze { 0%, 100% { transform: rotate(16deg); } 30% { transform: rotate(4deg); } 65% { transform: rotate(24deg); } }
html.xmas-sichtbar .chatknopf:hover::before { animation: xmas-muetze 0.7s ease; }

/* ---------- Einschalt-Uebergang: warmer Lichtlauf ueber die Kopfleiste ---------- */
.xmas-schimmer {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
}
.xmas-schimmer i {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 34%;
  background: linear-gradient(100deg,
    rgba(255, 220, 160, 0) 0%,
    rgba(255, 214, 150, 0.16) 35%,
    rgba(255, 244, 222, 0.42) 50%,
    rgba(255, 214, 150, 0.16) 65%,
    rgba(255, 220, 160, 0) 100%);
  transform: translateX(-110%) skewX(-18deg);
  opacity: 0;
  animation: xmas-schimmer 1.7s cubic-bezier(0.45, 0.05, 0.25, 1) 0.1s forwards;
}
@keyframes xmas-schimmer {
  0% { transform: translateX(-110%) skewX(-18deg); opacity: 0; }
  12% { opacity: 1; }
  85% { opacity: 1; }
  100% { transform: translateX(330%) skewX(-18deg); opacity: 0; }
}

/* ---------- Handy: Deko noch zurueckhaltender ---------- */
@media (max-width: 700px) {
  .xmas-deko__kugel { top: 26px; right: 26%; width: 34px; }
  html.xmas-sichtbar .xmas-deko__zweig { opacity: 0.7; }
}

/* ---------- Reduzierte Bewegung: alles steht, nichts laeuft ---------- */
@media (prefers-reduced-motion: reduce) {
  .xmas-schnee,
  .xmas-deko img,
  .xmas-schalter svg { transition: none !important; }
  html.xmas-sichtbar .xmas-deko__kugel,
  html.xmas-sichtbar .xmas-deko__bokeh,
  html.xmas-sichtbar .xmas-hell__girlande,
  html.xmas-sichtbar .xmas-hell__stern,
  html.xmas-sichtbar .xmas-hell__schneemann,
  html.xmas-sichtbar .xmas-hell__figur,
  html.xmas-sichtbar .xmas-hell__haenger { animation: none !important; }
  .xmas-hell__haenger::before { transition: none !important; }
  .xmas-hell img { transition: none !important; }
  .xmas-schimmer { display: none; }
}

/* Drucken: kein Schnee, keine Deko */
@media print {
  .xmas-schnee, .xmas-deko, .xmas-hell, .xmas-schalter { display: none !important; }
  html.xmas-an .rail__btn::before, html.xmas-an .totop::before, html.xmas-an .chatknopf::before { display: none !important; }
}
