/* ==========================================================================
   Weihnachtliches Design - Haupt-Stylesheet
   ========================================================================== */

:root {
  --font-serif: 'Playfair Display', Georgia, serif;
  --font-display: 'Cinzel Decorative', cursive, serif;
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Farbpalette - Edle, reduzierte Töne ohne überladene Farbverläufe */
  --bg-dark: #0a0e17;
  --gold-primary: #d4af37;
  --gold-light: #fef08a;
  --gold-dark: #996515;
  --gold-glow: rgba(212, 175, 55, 0.25);
  --crimson-red: #b91c32;
  --crimson-dark: #7a1221;
  --crimson-glow: rgba(185, 28, 50, 0.25);
  --pine-green: #165b33;
  --pine-light: #187d44;
  --snow-white: #f8fafc;
  --card-bg: #0f1624;
  --card-border: rgba(212, 175, 55, 0.22);
  --parchment-bg: #faf7f0;
  --parchment-text: #241d1a;
  --parchment-border: #d4af37;

  --shadow-luxe: 0 15px 35px rgba(0, 0, 0, 0.5);
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-full: 9999px;
  --transition: all 0.25s ease;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  min-height: 100vh;
  width: 100%;
  font-family: var(--font-sans);
  background: var(--bg-dark);
  color: var(--snow-white);
  overflow-x: hidden;
  position: relative;
}

/* -------------------------------------------------------------
   Schnee-Canvas (Hintergrund-Effekt)
   ------------------------------------------------------------- */
#snowCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

/* -------------------------------------------------------------
   Weihnachts-Lichterkette am oberen Rand
   ------------------------------------------------------------- */
.fairy-lights {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  display: flex;
  justify-content: space-around;
  pointer-events: none;
  z-index: 10;
  list-style: none;
  margin: 0;
  padding: 0;
  border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

.fairy-lights li {
  position: relative;
  width: 12px;
  height: 24px;
  border-radius: 50%;
  top: 6px;
  background: #f8fafc;
  animation-fill-mode: both;
  animation-iteration-count: infinite;
}

.fairy-lights li::before {
  content: "";
  position: absolute;
  top: -4px;
  left: 2px;
  width: 8px;
  height: 6px;
  border-radius: 2px;
  background: #2b303a;
}

.fairy-lights li:nth-child(4n+1) {
  background: #ff4757;
  box-shadow: 0 4px 20px #ff4757, 0 0 10px #ff4757;
  animation: twinkleRed 4.8s infinite ease-in-out;
}

.fairy-lights li:nth-child(4n+2) {
  background: #ffd32a;
  box-shadow: 0 4px 20px #ffd32a, 0 0 10px #ffd32a;
  animation: twinkleGold 5.4s infinite ease-in-out 0.9s;
}

.fairy-lights li:nth-child(4n+3) {
  background: #2ed573;
  box-shadow: 0 4px 20px #2ed573, 0 0 10px #2ed573;
  animation: twinkleGreen 5.0s infinite ease-in-out 1.8s;
}

.fairy-lights li:nth-child(4n+4) {
  background: #70a1ff;
  box-shadow: 0 4px 20px #70a1ff, 0 0 10px #70a1ff;
  animation: twinkleBlue 5.8s infinite ease-in-out 2.6s;
}

@keyframes twinkleRed {
  0%, 100% { opacity: 0.3; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.1); filter: brightness(1.4); }
}

@keyframes twinkleGold {
  0%, 100% { opacity: 0.4; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.15); filter: brightness(1.5); }
}

@keyframes twinkleGreen {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.1); filter: brightness(1.4); }
}

@keyframes twinkleBlue {
  0%, 100% { opacity: 0.4; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.12); filter: brightness(1.3); }
}

/* -------------------------------------------------------------
   Kopfleiste / Quick Controls
   ------------------------------------------------------------- */
.top-bar {
  position: absolute;
  top: 36px;
  right: 24px;
  z-index: 20;
  display: flex;
  gap: 12px;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(212, 175, 55, 0.3);
  color: var(--gold-light);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.15rem;
  backdrop-filter: blur(8px);
  transition: var(--transition);
}

.icon-btn:hover {
  background: rgba(212, 175, 55, 0.2);
  border-color: var(--gold-primary);
  transform: translateY(-2px);
  box-shadow: 0 0 15px var(--gold-glow);
}

/* -------------------------------------------------------------
   Haupt-Container
   ------------------------------------------------------------- */
.app-wrapper {
  position: relative;
  z-index: 5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 80px 20px 40px;
}

.hero-section {
  text-align: center;
  margin-bottom: 30px;
  animation: fadeInDown 1s ease-out;
}

.festive-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 18px;
  background: rgba(212, 175, 55, 0.12);
  border: 1px solid var(--gold-primary);
  border-radius: var(--radius-full);
  color: var(--gold-light);
  font-size: 0.85rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 18px;
  box-shadow: 0 0 20px rgba(212, 175, 55, 0.2);
}

.main-title {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 14px;
  color: #f8fafc;
  letter-spacing: 1px;
}

.subtitle {
  font-size: clamp(1rem, 2vw, 1.2rem);
  color: rgba(248, 250, 252, 0.75);
  max-width: 540px;
  margin: 0 auto;
  line-height: 1.6;
}

/* -------------------------------------------------------------
   Geschenk / Eingabekarte
   ------------------------------------------------------------- */
.card-container {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
}

.festive-card {
  position: relative;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 36px 30px;
  box-shadow: var(--shadow-luxe);
  transition: var(--transition);
  overflow: hidden;
}

/* Deko-Linie */
.ribbon-ornament {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100px;
  height: 3px;
  background: var(--gold-primary);
  opacity: 0.8;
  border-radius: 0 0 3px 3px;
}

.card-inner-header {
  text-align: center;
  margin-bottom: 28px;
}

.gift-icon-wrapper {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(185, 28, 50, 0.12);
  border: 1px solid rgba(212, 175, 55, 0.35);
  font-size: 2rem;
  color: var(--gold-primary);
  margin-bottom: 12px;
  animation: floatGift 5s ease-in-out infinite;
}

.gift-icon-wrapper i {
  color: var(--gold-primary);
}

@keyframes floatGift {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.form-group {
  margin-bottom: 22px;
  text-align: left;
}

.form-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--gold-primary);
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

/* Icon bei der Code-Eingabe */
.input-icon {
  position: absolute;
  left: 18px;
  font-size: 1.15rem;
  color: var(--gold-primary);
  pointer-events: none;
  transition: color 0.2s ease, opacity 0.25s ease, transform 0.25s ease;
  z-index: 2;
}

/* Beim Hovern wird das Icon grau */
.input-wrapper:hover .input-icon,
.input-wrapper:hover .input-icon i {
  color: #94a3b8;
}

/* Verschwindet wenn man tippt */
.input-wrapper.has-value .input-icon {
  opacity: 0;
  transform: scale(0.6);
  pointer-events: none;
}

.code-input {
  width: 100%;
  padding: 16px 16px 16px 48px;
  font-family: var(--font-sans);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #ffffff;
  background: #090e18;
  border: 1px solid rgba(212, 175, 55, 0.35);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color 0.2s ease, padding-left 0.25s ease, box-shadow 0.2s ease;
}

/* Sanfte Anpassung des Einzugs wenn das Icon verschwunden ist */
.input-wrapper.has-value .code-input {
  padding-left: 20px;
}

.code-input::placeholder {
  color: rgba(255, 255, 255, 0.3);
  letter-spacing: 1px;
  text-transform: none;
  font-size: 0.95rem;
  font-weight: 400;
}

.code-input:focus {
  border-color: var(--gold-primary);
  box-shadow: 0 0 15px rgba(212, 175, 55, 0.15);
}

/* Hochwertiger Button mit sauberem Vollton statt Farbverlauf */
.btn-festive {
  width: 100%;
  padding: 16px 28px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  background: var(--crimson-red);
  color: #ffffff;
  font-family: var(--font-sans);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.btn-festive:hover {
  background: #c8233a;
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(185, 28, 50, 0.35);
}

.btn-festive:active {
  transform: translateY(0);
}

.btn-festive:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Fehlermeldung */
.error-box {
  display: none;
  margin-top: 18px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: rgba(196, 30, 58, 0.2);
  border: 1px solid var(--crimson-red);
  color: #ffccd5;
  font-size: 0.95rem;
  text-align: center;
  animation: shake 0.4s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

/* -------------------------------------------------------------
   Weihnachtsbrief / Enthüllte Botschaft (Parchment Card)
   ------------------------------------------------------------- */
.message-reveal-container {
  display: none;
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
  animation: unfoldLetter 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes unfoldLetter {
  0% {
    opacity: 0;
    transform: scale(0.85) rotateX(20deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotateX(0deg);
  }
}

.parchment-letter {
  position: relative;
  background: var(--parchment-bg);
  color: var(--parchment-text);
  border: 2px solid var(--parchment-border);
  border-radius: var(--radius-lg);
  padding: 44px 36px 36px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.7), 0 0 50px rgba(212, 175, 55, 0.4);
  overflow: hidden;
}

/* Goldene Zierecken */
.parchment-letter::before,
.parchment-letter::after {
  content: "✦";
  position: absolute;
  font-size: 1.5rem;
  color: var(--gold-primary);
}
.parchment-letter::before { top: 12px; left: 16px; }
.parchment-letter::after { top: 12px; right: 16px; }

.parchment-inner-border {
  border: 1px dashed rgba(212, 175, 55, 0.4);
  border-radius: calc(var(--radius-lg) - 6px);
  padding: 24px 20px;
  background: #ffffff;
}

.letter-header {
  text-align: center;
  margin-bottom: 24px;
}

.wax-seal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #8b1528;
  color: #fef08a;
  font-size: 1.6rem;
  box-shadow: 0 4px 12px rgba(128, 18, 36, 0.35);
  margin-bottom: 12px;
  border: 2px solid #580c18;
}

.letter-recipient {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  color: var(--crimson-dark);
  font-style: italic;
  margin-bottom: 6px;
}

.letter-title {
  font-family: var(--font-serif);
  font-size: clamp(1.6rem, 3.5vw, 2.2rem);
  font-weight: 700;
  color: #1a1a1a;
  line-height: 1.3;
}

.gold-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 18px auto;
  color: var(--gold-primary);
  font-size: 1rem;
}

.gold-divider::before,
.gold-divider::after {
  content: "";
  height: 1px;
  width: 60px;
  background: rgba(212, 175, 55, 0.4);
}

.letter-body {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  line-height: 1.8;
  color: #2c2523;
  margin-bottom: 28px;
  white-space: pre-line;
  text-align: left;
}

.letter-footer {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 20px;
  border-top: 1px solid rgba(212, 175, 55, 0.3);
  padding-top: 20px;
}

.letter-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-secondary {
  padding: 12px 22px;
  background: #f1ebd9;
  border: 1px solid var(--gold-primary);
  border-radius: var(--radius-md);
  color: var(--parchment-text);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-secondary:hover {
  background: var(--gold-primary);
  color: #ffffff;
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(212, 175, 55, 0.3);
}

.code-badge-info {
  text-align: center;
  font-size: 0.85rem;
  color: #7a6e65;
}

.code-badge-info span {
  font-family: monospace;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.05);
  padding: 2px 6px;
  border-radius: 4px;
}

/* -------------------------------------------------------------
   Konfetti-Canvas
   ------------------------------------------------------------- */
#confettiCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
}

/* -------------------------------------------------------------
   Footer
   ------------------------------------------------------------- */
.app-footer {
  margin-top: 40px;
  text-align: center;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.admin-link {
  color: var(--gold-primary);
  text-decoration: none;
  font-size: 0.85rem;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(212, 175, 55, 0.2);
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.admin-link:hover {
  background: rgba(212, 175, 55, 0.15);
  color: var(--gold-light);
  border-color: var(--gold-primary);
}

.footer-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* -------------------------------------------------------------
   Impressum / Rechtliche Seiten
   ------------------------------------------------------------- */
.legal-card {
  max-width: 680px;
  margin: 0 auto;
  text-align: left;
}

.legal-section {
  margin-bottom: 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding-bottom: 18px;
}

.legal-section:last-of-type {
  border-bottom: none;
  padding-bottom: 0;
}

.legal-section h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--gold-primary);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.legal-section p,
.legal-section address {
  font-size: 0.92rem;
  color: rgba(248, 250, 252, 0.8);
  line-height: 1.7;
  font-style: normal;
  margin-bottom: 6px;
}

.legal-section a {
  color: var(--gold-primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.legal-section a:hover {
  color: var(--gold-light);
}

.legal-back-bar {
  margin-top: 28px;
  display: flex;
  justify-content: center;
}

/* -------------------------------------------------------------
   Toast Benachrichtigungen
   ------------------------------------------------------------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--gold-primary);
  color: #ffffff;
  padding: 12px 24px;
  border-radius: var(--radius-full);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 20px var(--gold-glow);
  z-index: 100;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 10px;
  backdrop-filter: blur(8px);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.35s ease;
  opacity: 0;
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* -------------------------------------------------------------
   Responsive Optimierungen (Handy- & Tablet-Optimierung)
   ------------------------------------------------------------- */
@media (max-width: 600px) {
  .app-wrapper {
    padding: 50px 14px 24px;
    padding-top: calc(44px + env(safe-area-inset-top));
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }
  .top-bar {
    top: 20px;
    right: 16px;
  }
  .icon-btn {
    width: 40px;
    height: 40px;
  }
  .main-title {
    font-size: 2.1rem;
    margin-bottom: 10px;
  }
  .subtitle {
    font-size: 0.95rem;
    padding: 0 8px;
  }
  .festive-card {
    padding: 24px 16px;
    border-radius: 16px;
  }
  .card-inner-header {
    margin-bottom: 20px;
  }
  .gift-icon-wrapper {
    width: 68px;
    height: 68px;
    font-size: 1.8rem;
    margin-bottom: 8px;
  }
  .card-title {
    font-size: 1.2rem;
  }
  .code-input {
    font-size: 1.1rem;
    padding: 14px 14px 14px 44px;
    min-height: 50px;
  }
  .btn-festive {
    padding: 14px 20px;
    font-size: 1.05rem;
    min-height: 52px;
  }
  .parchment-letter {
    padding: 24px 14px 20px;
    border-radius: 16px;
  }
  .parchment-inner-border {
    padding: 16px 12px;
  }
  .wax-seal {
    width: 52px;
    height: 52px;
    font-size: 1.4rem;
  }
  .letter-title {
    font-size: 1.5rem;
  }
  .letter-body {
    font-size: 1.05rem;
    line-height: 1.7;
    margin-bottom: 20px;
  }
  .letter-actions {
    flex-direction: column;
    width: 100%;
  }
  .btn-secondary {
    width: 100%;
    justify-content: center;
    min-height: 46px;
    font-size: 0.95rem;
  }
  .fairy-lights li:nth-child(even) {
    display: none;
  }
}
