/* ============ Adventskalender – Gestaltung ============ */

:root {
  --night: #0b1a33;
  --night-2: #13284a;
  --pine: #1f4d3a;
  --berry: #b3262e;
  --gold: #e8c26a;
  --accent: #e8c26a;
  --cream: #fbf5e6;
  --paper: #fffaf0;
  --ink: #2a211c;
  --ink-soft: #6b5a4e;
  --frost: rgba(255, 248, 230, 0.92);
  --chrome: 200px; /* Platz für Kopf- und Fußzeile */
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  font-family: 'Lato', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--cream);
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(232, 194, 106, 0.14), transparent 70%),
    radial-gradient(ellipse 120% 80% at 50% 120%, #1d3a63, transparent 60%),
    linear-gradient(180deg, var(--night) 0%, #091428 100%);
  background-attachment: fixed;
  overflow-x: hidden;
}

body.modal-open { overflow: hidden; }

.snow {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

#app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  min-height: 100svh;
}

/* ---------- Kopfzeile ---------- */

.cal-header {
  text-align: center;
  padding: clamp(14px, 3vh, 28px) 16px clamp(10px, 2vh, 18px);
  max-width: 900px;
}

.cal-greeting {
  margin: 0;
  font-family: 'Great Vibes', 'Brush Script MT', cursive;
  font-size: clamp(30px, 5.2vw, 54px);
  line-height: 1.1;
  color: var(--accent);
  text-shadow: 0 2px 18px rgba(232, 194, 106, 0.35);
}

.cal-title {
  margin: 2px 0 0;
  font-family: 'Playfair Display', Georgia, serif;
  font-weight: 700;
  font-size: clamp(15px, 2vw, 20px);
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--cream);
  opacity: 0.92;
}

.cal-status {
  display: inline-block;
  margin: 12px 0 0;
  padding: 7px 16px;
  border-radius: 999px;
  font-size: clamp(13px, 1.6vw, 15px);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(232, 194, 106, 0.35);
  color: #fff3d6;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  min-height: 1em;
}
.cal-status:empty { visibility: hidden; }

.cal-footer {
  margin-top: auto;
  padding: 18px 16px 22px;
  font-family: 'Great Vibes', cursive;
  font-size: 24px;
  color: rgba(251, 245, 230, 0.7);
  text-align: center;
}
.cal-footer:empty { display: none; }

/* ---------- Kalenderbild mit Türen ---------- */

.board-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 0 16px;
}

.board {
  --gap: clamp(5px, 1.2vw, 16px);
  position: relative;
  width: min(1200px, 100%, calc((100vh - var(--chrome)) * 1.5));
  width: min(1200px, 100%, calc((100svh - var(--chrome)) * 1.5));
  aspect-ratio: 3 / 2;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(0, 1fr));
  gap: var(--gap);
  padding: calc(var(--gap) * 1.6);
  border-radius: 18px;
  background-color: #1d3a63;
  background-image: var(--bg-img, none);
  background-size: cover;
  background-position: center;
  box-shadow:
    0 0 0 5px rgba(232, 194, 106, 0.55),
    0 0 0 6px rgba(0, 0, 0, 0.5),
    0 0 0 12px rgba(122, 59, 46, 0.9),
    0 0 0 13px rgba(232, 194, 106, 0.35),
    0 30px 80px rgba(0, 0, 0, 0.6);
  margin: 14px 0;
}

@media (max-aspect-ratio: 1/1) {
  :root { --chrome: 230px; }
  .board {
    aspect-ratio: 2 / 3;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: repeat(6, minmax(0, 1fr));
    width: min(680px, 100%, calc((100vh - var(--chrome)) * 0.667));
    width: min(680px, 100%, calc((100svh - var(--chrome)) * 0.667));
    border-radius: 14px;
  }
}

/* Handy quer: lieber scrollen als winzige Türen */
@media (max-height: 520px) and (min-aspect-ratio: 1/1) {
  .board { width: min(1200px, 100%); }
}

@media (max-width: 480px) {
  .board {
    box-shadow:
      0 0 0 3px rgba(232, 194, 106, 0.55),
      0 0 0 7px rgba(122, 59, 46, 0.9),
      0 20px 50px rgba(0, 0, 0, 0.6);
  }
}

.slot {
  position: relative;
  display: flex;
  justify-content: var(--jx, center);
  align-items: var(--jy, center);
  min-width: 0;
  min-height: 0;
}

.door-btn {
  --r: 7px;
  position: relative;
  width: var(--w, 88%);
  height: var(--h, 88%);
  padding: 0;
  border: 0;
  background: none;
  border-radius: var(--r);
  cursor: pointer;
  perspective: 900px;
  -webkit-tap-highlight-color: transparent;
  font: inherit;
  color: inherit;
}
.door-btn.shape-arch { --r: 50% 50% 7px 7px / 34% 34% 7px 7px; }
.door-btn.shape-round { --r: 50%; }
.door-btn.locked { cursor: default; }
.door-btn.open { z-index: 2; }

.door-btn:focus-visible { outline: none; }
.door-btn:focus-visible .door-face { box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--berry); }

/* Die Öffnung hinter der Tür */
.hole {
  position: absolute;
  inset: 0;
  border-radius: var(--r);
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 40%, #6e2a24 0%, #3a1512 70%, #220b09 100%);
  box-shadow: inset 0 4px 14px rgba(0, 0, 0, 0.75), inset 0 0 0 1px rgba(0, 0, 0, 0.5);
}
.hole-img {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0;
  transition: opacity 0.4s ease 0.3s;
}
.door-btn.has-preview .hole-img { opacity: 1; }
.hole::after {
  content: '';
  position: absolute;
  inset: 0;
  box-shadow: inset 0 4px 14px rgba(0, 0, 0, 0.55);
  border-radius: inherit;
  pointer-events: none;
}
.hole-num {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: 'Playfair Display', Georgia, serif;
  font-weight: 700;
  font-size: clamp(16px, 2.6vw, 34px);
  color: var(--gold);
  text-shadow: 0 0 12px rgba(232, 194, 106, 0.6);
}
.hole-num::before {
  content: '✦';
  position: absolute;
  top: 12%;
  font-size: 0.55em;
  opacity: 0.8;
}
.door-btn.has-preview .hole-num { display: none; }

/* Die Tür selbst */
.door {
  position: absolute;
  inset: 0;
  transform-origin: left center;
  transform-style: preserve-3d;
  transition: transform 0.85s cubic-bezier(0.3, 0.7, 0.2, 1.04);
  border-radius: var(--r);
}
.door-btn.open .door { transform: rotateY(-112deg); }
.door-btn.waiting:hover .door { transform: rotateY(-14deg); }

.door-face,
.door-inside {
  position: absolute;
  inset: 0;
  border-radius: var(--r);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.door-face {
  background-color: #2a4a78;
  background-image: var(--bg-img, none);
  background-origin: border-box;
  background-repeat: no-repeat;
  border: 2px solid rgba(255, 244, 214, 0.88);
  box-shadow:
    0 3px 10px rgba(0, 0, 0, 0.45),
    inset 0 0 0 1px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  transition: box-shadow 0.3s ease, filter 0.3s ease;
}
.door-face::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0) 42%, rgba(0, 0, 0, 0.16));
  pointer-events: none;
}
.door-btn.locked .door-face { filter: saturate(0.92); }

.door-num {
  position: absolute;
  inset: 0;
  margin: auto;
  width: fit-content;
  height: fit-content;
  min-width: 1.9em;
  padding: 0.18em 0.45em 0.22em;
  border-radius: 999px;
  font-family: 'Playfair Display', Georgia, serif;
  font-weight: 700;
  font-size: clamp(14px, 2.1vw, 28px);
  line-height: 1;
  text-align: center;
  color: #fff8e7;
  background: rgba(10, 24, 44, 0.55);
  border: 1px solid rgba(255, 244, 214, 0.45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.door-inside {
  transform: rotateY(180deg);
  background:
    repeating-linear-gradient(45deg, rgba(179, 38, 46, 0.07) 0 6px, transparent 6px 12px),
    linear-gradient(90deg, #efe3c8, var(--paper));
  border: 2px solid rgba(255, 244, 214, 0.9);
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.25);
}

/* Heiligabend: goldene Tür */
.door-btn.big-day .door-face { border: 3px solid var(--gold); }
.door-btn.big-day .door-num {
  background: linear-gradient(135deg, #f3d488, #c79a3a);
  color: #3a2208;
  text-shadow: none;
  border-color: rgba(255, 255, 255, 0.6);
}

/* Heutiges Türchen leuchtet */
.door-btn.today .door-face { animation: leuchten 2.4s ease-in-out infinite; }
@keyframes leuchten {
  0%, 100% { box-shadow: 0 3px 10px rgba(0, 0, 0, 0.45), 0 0 0 0 rgba(232, 194, 106, 0); }
  50% { box-shadow: 0 3px 10px rgba(0, 0, 0, 0.45), 0 0 18px 4px rgba(255, 214, 120, 0.85); }
}

/* Gesperrt: kurz wackeln */
.door-btn.shake { animation: wackeln 0.45s ease; }
@keyframes wackeln {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px) rotate(-1.5deg); }
  40% { transform: translateX(5px) rotate(1.5deg); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

@media (hover: none) {
  .door-btn.waiting:hover .door { transform: none; }
}

/* ---------- Hinweis-Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  max-width: calc(100% - 32px);
  padding: 12px 20px;
  border-radius: 14px;
  background: rgba(20, 34, 58, 0.94);
  border: 1px solid rgba(232, 194, 106, 0.5);
  color: var(--cream);
  font-size: 15px;
  text-align: center;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 20;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Tagesinhalt (Modal) ---------- */

.day-modal {
  width: min(760px, calc(100% - 24px));
  max-height: calc(100svh - 24px);
  padding: 0;
  border: 0;
  border-radius: 20px;
  background: transparent;
  color: var(--ink);
  overflow: visible;
}
.day-modal::backdrop {
  background: rgba(5, 12, 24, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.day-modal[open] { animation: aufklappen 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.15); }
@keyframes aufklappen {
  from { opacity: 0; transform: scale(0.9) translateY(10px); }
  to { opacity: 1; transform: none; }
}

.modal-card {
  position: relative;
  max-height: calc(100svh - 24px);
  overflow-y: auto;
  padding: clamp(20px, 4vw, 36px) clamp(16px, 4vw, 36px) clamp(22px, 4vw, 32px);
  border-radius: 20px;
  background:
    radial-gradient(circle at 100% 0%, rgba(232, 194, 106, 0.22), transparent 40%),
    radial-gradient(circle at 0% 100%, rgba(179, 38, 46, 0.08), transparent 45%),
    var(--paper);
  border: 3px solid var(--gold);
  box-shadow: 0 0 0 6px rgba(179, 38, 46, 0.85), 0 30px 80px rgba(0, 0, 0, 0.55);
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(42, 33, 28, 0.08);
  color: var(--ink);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}
.modal-close:hover { background: rgba(42, 33, 28, 0.16); }

.modal-date {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--berry);
  text-align: center;
}
.modal-title {
  margin: 6px 40px 18px;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: clamp(24px, 4.4vw, 36px);
  line-height: 1.15;
  text-align: center;
  color: var(--ink);
}
.modal-body { display: grid; gap: 18px; }
.modal-loading { text-align: center; font-size: 34px; padding: 40px 0; animation: pulsieren 1s ease-in-out infinite; }
@keyframes pulsieren { 50% { opacity: 0.3; } }

.modal-text {
  margin: 0;
  font-size: clamp(16px, 2.1vw, 18px);
  line-height: 1.6;
  white-space: pre-line;
  color: var(--ink);
  text-align: center;
}

.modal-video,
.modal-embed {
  width: 100%;
  border-radius: 12px;
  background: #000;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
.modal-video { max-height: 65svh; display: block; }
.modal-embed { aspect-ratio: 16 / 9; overflow: hidden; }
.modal-embed iframe { width: 100%; height: 100%; border: 0; display: block; }

.modal-link {
  justify-self: center;
  padding: 10px 22px;
  border-radius: 999px;
  background: var(--berry);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
}

/* Bildergalerie */
.gallery { position: relative; }
.gallery-track {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  border-radius: 12px;
  background: #efe5cf;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}
.gallery-track::-webkit-scrollbar { display: none; }
.gallery-item {
  flex: 0 0 100%;
  margin: 0;
  scroll-snap-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.gallery-item img {
  display: block;
  width: 100%;
  max-height: 62svh;
  object-fit: contain;
}
.gallery-item figcaption {
  padding: 8px 12px 10px;
  font-size: 14px;
  color: var(--ink-soft);
  text-align: center;
}
.gallery-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 250, 240, 0.92);
  color: var(--ink);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}
.gallery-btn.prev { left: 10px; }
.gallery-btn.next { right: 10px; }
.gallery-btn:disabled { opacity: 0; pointer-events: none; }
.gallery-dots { display: flex; justify-content: center; gap: 8px; margin-top: 10px; }
.dot {
  width: 9px;
  height: 9px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(42, 33, 28, 0.25);
  cursor: pointer;
}
.dot.active { background: var(--berry); }

@media (hover: none) {
  .gallery-btn { display: none; }
}

/* ---------- Neutrale Seiten (Start / 404 / nicht gefunden) ---------- */

.center-note {
  margin: auto;
  padding: 40px 16px;
  text-align: center;
  max-width: 640px;
}
.center-note .tree {
  font-size: 64px;
  display: block;
  margin-bottom: 8px;
  filter: drop-shadow(0 0 18px rgba(232, 194, 106, 0.4));
}

@media (prefers-reduced-motion: reduce) {
  .door, .hole-img, .toast { transition: none; }
  .door-btn.today .door-face, .day-modal[open], .modal-loading { animation: none; }
}
