/* ===== Theme ===== */
:root {
  --red: #b3262e;
  --red-dark: #7f1a20;
  --green: #1f5f3f;
  --green-dark: #123826;
  --green-deep: #0c2a1c;
  --cream: #fbf5e9;
  --cream-dark: #eadfc8;
  --gold: #d9ad45;
  --gold-light: #f3d27a;
  --ink: #2a1a14;

  --radius: 14px;
  --gap: 10px;
  --font-head: "Fraunces", Georgia, serif;
  --font-body: "Nunito", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--cream);
  background:
    radial-gradient(ellipse at 50% -10%, #2c7a52 0%, transparent 60%),
    radial-gradient(circle at 20% 80%, rgba(179, 38, 46, .18) 0%, transparent 45%),
    var(--green-deep);
  background-attachment: fixed;
  overflow-x: hidden;
}

button { font: inherit; color: inherit; }

/* ===== Canvas-Ebenen ===== */
#snow, #confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
#snow { z-index: 0; }
#confetti { z-index: 60; }

/* ===== Lichterkette ===== */
.lights {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-around;
  height: 46px;
  padding: 0 4px;
  overflow: hidden;
}
.lights::before {
  /* das Kabel */
  content: "";
  position: absolute;
  left: -5%;
  right: -5%;
  top: -22px;
  height: 40px;
  border-bottom: 2px solid #0a1f14;
  border-radius: 0 0 50% 50% / 0 0 100% 100%;
}
.bulb {
  position: relative;
  width: 11px;
  height: 18px;
  margin-top: var(--drop, 14px);
  border-radius: 50% 50% 50% 50% / 40% 40% 60% 60%;
  background: var(--bulb);
  box-shadow: 0 2px 14px 3px var(--bulb);
  animation: twinkle var(--speed, 1.6s) ease-in-out infinite alternate;
  animation-delay: var(--delay, 0s);
}
.bulb::before {
  content: "";
  position: absolute;
  top: -5px;
  left: 2px;
  width: 7px;
  height: 6px;
  border-radius: 2px;
  background: #24322a;
}
@keyframes twinkle {
  0%, 35% { opacity: 1; box-shadow: 0 2px 16px 4px var(--bulb); }
  100% { opacity: .35; box-shadow: 0 0 2px 0 var(--bulb); }
}

/* ===== Kopfbereich ===== */
.hero {
  position: relative;
  z-index: 2;
  max-width: 640px;
  margin: 0 auto;
  padding: 12px 16px 8px;
  text-align: center;
}
.hero__kicker {
  margin: 0;
  font-weight: 800;
  font-size: .8rem;
  letter-spacing: .25em;
  text-transform: uppercase;
  color: var(--gold-light);
}
.hero__title {
  margin: .2em 0 .25em;
  font-family: var(--font-head);
  font-weight: 800;
  font-size: clamp(2rem, 9vw, 3.2rem);
  line-height: 1.05;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .25);
}
.hero__message {
  margin: 0 auto;
  max-width: 34em;
  font-size: 1.02rem;
  line-height: 1.5;
  color: var(--cream-dark);
  white-space: pre-line;
}
.hero__message:empty { display: none; }

/* ===== Countdown ===== */
.countdown {
  display: inline-block;
  margin: 18px auto 6px;
  padding: 10px 14px 12px;
  border: 1px solid rgba(217, 173, 69, .45);
  border-radius: var(--radius);
  background: rgba(12, 42, 28, .55);
  backdrop-filter: blur(4px);
}
.countdown__label {
  margin: 0 0 6px;
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--gold-light);
}
.countdown__units { display: flex; gap: 8px; justify-content: center; }
.countdown__unit {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 54px;
  padding: 6px 4px 4px;
  border-radius: 10px;
  background: var(--red);
  box-shadow: inset 0 -3px 0 var(--red-dark);
}
.countdown__unit span {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 1.5rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.countdown__unit small { font-size: .7rem; opacity: .85; }
.countdown--done .countdown__units { display: none; }
.countdown--done .countdown__label { margin: 0; font-size: 1rem; letter-spacing: .05em; }

/* ===== Raster ===== */
main {
  position: relative;
  z-index: 2;
  max-width: 820px;
  margin: 0 auto;
  padding: 16px 16px 8px;
}
.grid {
  --cols: 4;
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  grid-auto-rows: calc((min(100vw, 820px) - 32px - (var(--cols) - 1) * var(--gap)) / var(--cols));
  grid-auto-flow: dense;
  gap: var(--gap);
}
@media (min-width: 640px) {
  :root { --gap: 14px; }
  .grid { --cols: 6; }
}

/* ===== Türchen ===== */
.door {
  position: relative;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  perspective: 900px;
  -webkit-tap-highlight-color: transparent;
}
.door--wide { grid-column: span 2; }
.door--tall { grid-row: span 2; }
.door--big { grid-column: span 2; grid-row: span 2; }

/* Innenraum hinter der Tür */
.door__inside {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 50% 40%, rgba(243, 210, 122, .35), transparent 70%),
    #1a0f0c;
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .4), inset 0 6px 18px rgba(0, 0, 0, .6);
  overflow: hidden;
}
.door__inside span {
  font-size: clamp(1.4rem, 7vw, 2.4rem);
  filter: drop-shadow(0 0 10px rgba(243, 210, 122, .8));
  transform: scale(.6);
  opacity: 0;
  transition: transform .6s .35s cubic-bezier(.2, 1.6, .4, 1), opacity .4s .35s;
}
.door.is-open .door__inside span { transform: scale(1); opacity: 1; }

/* Die Tür selbst – 3D */
.door__panel {
  position: absolute;
  inset: 0;
  transform-origin: left center;
  transform-style: preserve-3d;
  transition: transform .9s cubic-bezier(.3, .1, .2, 1);
}
.door.is-open .door__panel { transform: rotateY(-118deg); }

.door__face {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.door__front {
  display: grid;
  place-items: center;
  background: var(--c);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, .12),
    inset 0 -4px 0 rgba(0, 0, 0, .18),
    0 6px 14px rgba(0, 0, 0, .35);
  overflow: hidden;
}
/* Deko: gestrichelter Rand + Muster */
.door__front::before {
  content: "";
  position: absolute;
  inset: 6px;
  border: 2px dashed var(--line, rgba(217, 173, 69, .6));
  border-radius: calc(var(--radius) - 5px);
}
.door__front::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, .09) 1.5px, transparent 1.5px);
  background-size: 14px 14px;
}
.door__back {
  background: var(--c-dark);
  transform: rotateY(180deg);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .25);
}
.door__num {
  position: relative;
  z-index: 1;
  font-family: var(--font-head);
  font-weight: 800;
  font-size: clamp(1.4rem, 7vw, 2.1rem);
  color: var(--num, var(--gold-light));
  text-shadow: 0 2px 0 rgba(0, 0, 0, .25);
}
.door--big .door__num { font-size: clamp(2.4rem, 13vw, 3.6rem); }
.door--wide .door__num, .door--tall .door__num { font-size: clamp(1.8rem, 9vw, 2.6rem); }

/* Farbvarianten */
.door[data-color="red"]   { --c: var(--red);   --c-dark: var(--red-dark); }
.door[data-color="green"] { --c: var(--green); --c-dark: var(--green-dark); }
.door[data-color="cream"] { --c: var(--cream); --c-dark: var(--cream-dark); --num: var(--red); --line: rgba(179, 38, 46, .45); }
.door[data-color="gold"]  { --c: var(--gold);  --c-dark: #a9822b; --num: var(--cream); --line: rgba(255, 255, 255, .6); }

/* Heutiges Türchen leuchtet */
.door.is-today:not(.is-open) .door__front {
  animation: glow 2s ease-in-out infinite alternate;
}
@keyframes glow {
  from { box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .12), 0 0 0 0 rgba(243, 210, 122, 0); }
  to   { box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .25), 0 0 22px 4px rgba(243, 210, 122, .75); }
}

/* Gesperrt: Wackeln beim Antippen */
.door.shake { animation: shake .45s; }
@keyframes shake {
  20% { transform: translateX(-5px) rotate(-2deg); }
  40% { transform: translateX(5px) rotate(2deg); }
  60% { transform: translateX(-3px) rotate(-1deg); }
  80% { transform: translateX(3px); }
}
.door:focus-visible { outline: 3px solid var(--gold-light); outline-offset: 3px; border-radius: var(--radius); }

/* ===== Footer & Bedienelemente ===== */
.footer {
  position: relative;
  z-index: 2;
  padding: 24px 16px 90px;
  text-align: center;
  font-size: .85rem;
  color: rgba(251, 245, 233, .55);
}
.controls {
  position: fixed;
  z-index: 40;
  right: 14px;
  bottom: calc(14px + env(safe-area-inset-bottom));
  display: flex;
  gap: 10px;
}
.control {
  width: 46px;
  height: 46px;
  border: 2px solid var(--gold);
  border-radius: 50%;
  background: var(--red);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .4);
  transition: transform .15s, opacity .2s;
}
.control:active { transform: scale(.92); }
.control[aria-pressed="false"] { opacity: .55; background: var(--green-dark); }

/* ===== Toast ===== */
.toast {
  position: fixed;
  z-index: 70;
  left: 50%;
  bottom: calc(76px + env(safe-area-inset-bottom));
  max-width: calc(100vw - 32px);
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--cream);
  color: var(--ink);
  font-weight: 700;
  text-align: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .4);
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  transition: transform .3s, opacity .3s;
}
.toast.is-visible { transform: translate(-50%, 0); opacity: 1; }

/* ===== Modal ===== */
.modal {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
}
.modal[hidden] { display: none; }
.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 20, 13, .75);
  backdrop-filter: blur(3px);
  animation: fade .3s;
}
.modal__card {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 26px 20px 22px;
  border-radius: 20px;
  background: var(--cream);
  color: var(--ink);
  box-shadow: 0 0 0 4px var(--gold), 0 0 0 9px var(--red), 0 20px 50px rgba(0, 0, 0, .6);
  animation: pop .45s cubic-bezier(.2, 1.4, .4, 1);
}
.modal__close {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--red);
  font-size: 1.9rem;
  line-height: 1;
  cursor: pointer;
}
.modal__day {
  margin: 0;
  font-weight: 800;
  font-size: .78rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--green);
}
.modal__title {
  margin: .2em 2rem .5em 0;
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 1.7rem;
  line-height: 1.15;
  color: var(--red);
}
.modal__title:empty { display: none; }
.modal__body { font-size: 1.02rem; line-height: 1.55; }
.modal__body > * + * { margin-top: 14px; }
.modal__body p { margin: 0; white-space: pre-line; }
.modal__body img,
.modal__body video {
  display: block;
  width: 100%;
  max-height: 60vh;
  object-fit: contain;
  border-radius: 12px;
  background: var(--cream-dark);
}
.embed {
  position: relative;
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
}
.embed--video { aspect-ratio: 16 / 9; }
.embed--spotify { height: 152px; background: transparent; }
.embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: 999px;
  background: var(--green);
  color: var(--cream);
  font-weight: 800;
  text-decoration: none;
  box-shadow: inset 0 -3px 0 var(--green-dark);
}
.link-btn:active { transform: translateY(1px); }
.modal__loading { text-align: center; color: var(--green); font-weight: 700; }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.85) translateY(20px); } }

/* ===== Reduzierte Bewegung ===== */
@media (prefers-reduced-motion: reduce) {
  .bulb { animation: none; }
  .door__panel { transition-duration: .01s; }
  .door.is-today:not(.is-open) .door__front { animation: none; box-shadow: 0 0 18px 3px rgba(243, 210, 122, .7); }
  .modal__card, .modal__backdrop { animation: none; }
  .door.shake { animation: none; }
}

.link-small { display: inline-block; font-size: .9rem; font-weight: 700; color: var(--green); }
