/* Weihnachtsgruß – Low-Poly-Winternacht
   Zustände am <html>-Element:
     (ohne Klasse)   kein JavaScript → statischer Gruß
     .js             Szene wird vorbereitet (dunkle Abdeckung)
     .is-webgl       3D-Szene läuft; Gruß nur für Screenreader, Absender schwebt unter dem 3D-Text
     .is-running     Einblenden abgeschlossen bzw. gestartet
     .no-webgl       statischer Fallback (CSS-Verlauf mit HTML-Gruß)
     .html-greeting  WebGL läuft, aber 3D-Schrift fehlt → HTML-Gruß sichtbar */

@font-face {
  font-family: 'Playfair Display';
  src: url('../fonts/playfair-display-700.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Playfair Display';
  src: url('../fonts/playfair-display-400-italic.woff2') format('woff2');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

:root {
  --night: #0b1b3a;
  --dusk: #1e3a5f;
  --snow: #f4f8ff;
  --gold: #ffc857;
  --red: #c8102e;
  --fir: #2e7d5b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--night);
  color: var(--snow);
  font-family: 'Playfair Display', Georgia, 'Times New Roman', serif;
}

/* ---------- Gruß (Fallback-Darstellung als Standard) ---------- */
.greeting {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 1.25rem 18vh;
  text-align: center;
  z-index: 2;
}
.greeting h1 {
  margin: 0;
  font-weight: 700;
  font-size: clamp(2.6rem, 9vw, 6rem);
  line-height: 1.1;
  color: var(--gold);
  text-shadow: 0 0 0.35em rgba(255, 200, 87, 0.45), 0 0.06em 0 #8a5a00;
}
.sender {
  margin: 0.8rem 0 0;
  font-style: italic;
  font-weight: 400;
  font-size: clamp(1.05rem, 2.6vw, 1.5rem);
  letter-spacing: 0.04em;
  color: var(--snow);
  text-shadow: 0 1px 6px rgba(11, 27, 58, 0.9);
}

/* statischer Hintergrund: Verlauf, Sterne, Mond, Schneehügel */
.fallback-art {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(1.5px 1.5px at 12% 18%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 27% 8%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 41% 22%, #fff7e0 50%, transparent 51%),
    radial-gradient(1px 1px at 55% 12%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 68% 28%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 83% 9%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 91% 31%, #fff7e0 50%, transparent 51%),
    radial-gradient(1px 1px at 6% 37%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 35% 40%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 76% 44%, #fff 50%, transparent 51%),
    linear-gradient(to bottom, var(--night) 0%, var(--night) 25%, var(--dusk) 75%);
}
.fallback-moon {
  position: absolute;
  top: 9%;
  left: 14%;
  width: clamp(3rem, 8vw, 5.5rem);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 38%, #fff, #dfe8f7 70%);
  box-shadow: 0 0 3rem 1rem rgba(207, 224, 255, 0.25);
}
.fallback-hills {
  position: absolute;
  left: -20%;
  right: -20%;
  bottom: -32vh;
  height: 55vh;
  border-radius: 50% 50% 0 0;
  background: linear-gradient(to bottom, var(--snow), #c9d7ee);
  box-shadow: -30vw -4vh 0 -2vh #dbe5f5, 30vw -6vh 0 -3vh #d3dfef;
}

/* Abdeckung zum Einblenden aus Dunkel */
#fade {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: var(--night);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
}
.js:not(.no-webgl) #fade {
  opacity: 1;
  visibility: visible;
}
.js.is-running #fade {
  opacity: 0;
  visibility: hidden;
  transition: opacity 1s ease-out, visibility 0s linear 1s;
}

/* ---------- 3D-Szene ---------- */
#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: none;
  touch-action: pan-y;
}
.is-webgl #scene { display: block; }
.is-webgl .fallback-art { display: none; }

/* Gruß bleibt für Screenreader im Dokument, sichtbar ist der 3D-Schriftzug */
.visually-hidden,
.is-webgl:not(.html-greeting) .greeting h1 {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.is-webgl .greeting {
  pointer-events: none;
  padding-bottom: 30vh;
}
/* Absender: per JavaScript unter den 3D-Schriftzug gesetzt, erscheint ab 5 s */
.is-webgl:not(.html-greeting) .sender {
  position: fixed;
  left: 0;
  top: 0;
  margin: 0;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 1.4s ease-out;
}
.is-webgl .sender.is-visible { opacity: 1; }
.is-webgl.html-greeting .sender { opacity: 1; }

/* ---------- Bedienelement „Animation anhalten“ ---------- */
.pause {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.9rem;
  border: 1px solid rgba(244, 248, 255, 0.35);
  border-radius: 999px;
  background: rgba(11, 27, 58, 0.55);
  color: var(--snow);
  font: 0.85rem/1 system-ui, sans-serif;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
}
.pause:hover, .pause:focus-visible { opacity: 1; }
.pause:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.pause[hidden], .no-webgl .pause { display: none; }
.pause .icon {
  width: 0.7rem;
  height: 0.8rem;
  border-left: 0.22rem solid currentColor;
  border-right: 0.22rem solid currentColor;
}
.pause[aria-pressed='true'] .icon {
  border: 0;
  width: 0;
  height: 0;
  border-left: 0.7rem solid currentColor;
  border-top: 0.42rem solid transparent;
  border-bottom: 0.42rem solid transparent;
}
/* auf kleinen Bildschirmen nur das Symbol, Text bleibt für Screenreader */
@media (max-width: 600px) {
  .pause .label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  .pause { padding: 0.7rem; }
}

@media (prefers-reduced-motion: reduce) {
  .js.is-running #fade, .is-webgl .sender { transition: none; }
}
