@font-face { font-family: Fraunces; src: url(/fonts/fraunces-latin-600-normal.woff2) format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: Fraunces; src: url(/fonts/fraunces-latin-400-italic.woff2) format('woff2'); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: Caveat; src: url(/fonts/caveat-latin-500-normal.woff2) format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: Caveat; src: url(/fonts/caveat-latin-700-normal.woff2) format('woff2'); font-weight: 700; font-display: swap; }

:root {
  /* --p: Jahreszeit, 0 = tiefer Herbst, 1 = Heiligabend im Schnee. Setzt app.js. */
  --p: 0;
  --pp: calc(var(--p) * 100%);
  --himmel-oben: color-mix(in oklab, #2b5180 var(--pp), #a4501f);
  --himmel-unten: color-mix(in oklab, #0b1730 var(--pp), #3a1a12);
  --gold: #eab461;
  --creme: #f7ecd9;
  --tinte: #3a1d14;
  --papier: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .22 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--creme);
  background: radial-gradient(120% 80% at 50% -10%, var(--himmel-oben), var(--himmel-unten) 70%) fixed, var(--himmel-unten);
  overflow-x: hidden;
}
[hidden] { display: none !important; }
.unsichtbar { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

#wetter { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; }
#schneedecke {
  position: fixed; left: -10%; right: -10%; bottom: 0; z-index: 0; pointer-events: none;
  height: calc(var(--p) * 56px);
  background: linear-gradient(#ffffff, #dfe9f7);
  border-radius: 50% 50% 0 0 / 40px 40px 0 0;
  box-shadow: 0 -4px 30px rgba(255, 255, 255, .25);
  transition: height 2s;
}

.dach { font: 700 1.7rem/1 Caveat, cursive; color: var(--gold); margin: 0 0 .3rem; }
h1, h2 { font-family: Fraunces, Georgia, serif; font-weight: 600; margin: 0; line-height: 1.05; }

/* --- Passwort --- */
.login { position: relative; z-index: 4; min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login .karte {
  width: min(100%, 380px); padding: 32px 28px 28px; text-align: center;
  background: var(--papier), var(--creme); color: var(--tinte);
  border-radius: 4px; transform: rotate(-1.5deg);
  box-shadow: 0 2px 0 rgba(0, 0, 0, .15), 0 24px 60px rgba(0, 0, 0, .45);
}
.login .dach { color: #b0521f; }
.login h1 { font-size: 1.6rem; margin-bottom: 22px; }
.login input {
  width: 100%; padding: 14px 16px; font: 500 1.5rem Caveat, cursive; text-align: center;
  border: 2px dashed rgba(58, 29, 20, .35); border-radius: 6px; background: rgba(255, 255, 255, .6); color: var(--tinte);
}
.login input:focus { outline: none; border-color: #b0521f; border-style: solid; }
.login button[type=submit] { margin-top: 14px; width: 100%; }
.login .meldung { min-height: 1.6em; margin: 12px 0 0; font: 500 1.3rem/1.2 Caveat, cursive; color: #9b2f26; }
.login .karte.falsch { animation: wackeln .5s; }

.knopf, .login button[type=submit] {
  display: inline-block; padding: 13px 26px; border: 0; border-radius: 999px;
  background: var(--gold); color: var(--tinte); font-weight: 700; text-decoration: none;
  box-shadow: 0 3px 0 #b07a2b, 0 10px 24px rgba(0, 0, 0, .3);
  transition: transform .15s;
}
.knopf:active, .login button[type=submit]:active { transform: translateY(2px); }

/* --- Kopf --- */
main { position: relative; z-index: 1; padding: max(28px, env(safe-area-inset-top)) 16px 120px; }
.kopf { text-align: center; margin: 12px auto 28px; }
.kopf h1 { font-size: clamp(2.6rem, 11vw, 4.6rem); text-shadow: 0 3px 20px rgba(0, 0, 0, .35); }
.unterzeile { font: 500 1.45rem/1.25 Caveat, cursive; margin: .6rem 0 0; min-height: 1.3em; opacity: .92; }

.ton {
  position: fixed; top: max(14px, env(safe-area-inset-top)); right: 14px; z-index: 6;
  width: 46px; height: 46px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .25);
  background: rgba(20, 10, 6, .35); backdrop-filter: blur(6px); display: grid; place-items: center;
}
.ton svg { width: 24px; height: 24px; fill: none; stroke: var(--creme); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ton svg path:first-child { fill: var(--creme); }
.ton .aus { display: none; }
.ton.stumm .aus { display: inline; }
.ton.stumm .welle { display: none; }

/* --- Kalender --- */
.kalender {
  display: grid; grid-template-columns: repeat(3, 1fr); grid-auto-flow: dense; gap: 14px;
  max-width: 520px; margin: 0 auto;
}
@media (min-width: 960px) {
  .kalender { grid-template-columns: repeat(9, 1fr); max-width: 1180px; gap: 16px; }
}

.tuer {
  position: relative; aspect-ratio: 1; padding: 0; border: 0; background: none;
  perspective: 900px; -webkit-tap-highlight-color: transparent;
}
.tuer.gross { grid-column: span 2; grid-row: span 2; aspect-ratio: auto; perspective: 2400px; }

/* Schnee auf der Kante, waechst mit der Jahreszeit */
.tuer::before {
  content: ''; position: absolute; z-index: 4; top: -6px; left: 3%; right: 3%; height: 12px; pointer-events: none;
  background: #fff; border-radius: 12px 12px 40% 40% / 10px 10px 6px 6px;
  box-shadow: 0 2px 3px rgba(0, 40, 80, .25);
  opacity: clamp(0, calc((var(--p) - .15) * 2.5), 1);
  transform: scaleY(clamp(.3, calc(var(--p) * 1.2), 1)); transform-origin: bottom;
}

.innen {
  position: absolute; inset: 0; border-radius: 6px; overflow: hidden;
  background: radial-gradient(circle at 50% 40%, #3b2016, #160a06);
  box-shadow: inset 0 4px 14px rgba(0, 0, 0, .8);
  display: grid; place-items: center;
}
.mini {
  width: 84%; background: #fffdf8; padding: 6% 6% 18%; border-radius: 2px;
  transform: rotate(var(--rot, -2deg)); box-shadow: 0 4px 12px rgba(0, 0, 0, .5);
}
.mini img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; background: #e8dccb; }
.zauber { padding: 10px; font: 500 1.05rem/1.15 Caveat, cursive; color: var(--creme); text-align: center; }
.tuer.gross .zauber { font-size: 1.5rem; }

.klappe {
  position: absolute; inset: 0; z-index: 2; transform-origin: left center; transform-style: preserve-3d;
  transition: transform 1.2s cubic-bezier(.25, 1.25, .45, 1);
}
.vorne, .hinten { position: absolute; inset: 0; border-radius: 6px; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.vorne {
  background: var(--papier), var(--farbe);
  display: grid; place-items: center; color: var(--zahl);
  box-shadow: 0 2px 0 rgba(0, 0, 0, .25), 0 8px 18px rgba(0, 0, 0, .35);
}
.vorne::after { content: ''; position: absolute; inset: 5px; border: 1.5px dashed currentColor; border-radius: 4px; opacity: .3; }
.hinten { transform: rotateY(180deg); background: var(--papier), color-mix(in oklab, var(--farbe) 45%, #4a2117); }

.zahl { font: 600 clamp(1.9rem, 9vw, 2.6rem)/1 Fraunces, Georgia, serif; }
.tuer.gross .zahl { font-size: clamp(4rem, 22vw, 6rem); }
@media (min-width: 960px) { .zahl { font-size: 2.3rem; } .tuer.gross .zahl { font-size: 5.5rem; } }
.vorne .klein { position: absolute; bottom: 12%; left: 0; right: 0; text-align: center; font: 500 1.25rem/1.1 Caveat, cursive; padding: 0 8px; }

.c0 { --farbe: #efe1c6; --zahl: #8e2a1f; }
.c1 { --farbe: #c99a69; --zahl: #3a1d14; }
.c2 { --farbe: #9b2f26; --zahl: #f7e8d0; }
.c3 { --farbe: #2f4d3d; --zahl: #efe1c6; }
.c4 { --farbe: #d59b3c; --zahl: #4a2117; }

.tuer.offen .klappe { transform: rotateY(-110deg); }
.tuer.gross.offen .klappe { transform: rotateY(-100deg); }
.tuer.offen { z-index: 2; }
.tuer.bereit .vorne { animation: leuchten 2.6s ease-in-out infinite; }
.tuer.wackelt { animation: wackeln .55s; }

@keyframes leuchten {
  50% { box-shadow: 0 2px 0 rgba(0, 0, 0, .25), 0 0 0 3px var(--gold), 0 0 28px 6px rgba(234, 180, 97, .55); }
}
@keyframes wackeln {
  20% { transform: rotate(-4deg); } 40% { transform: rotate(3.5deg); } 60% { transform: rotate(-2.5deg); } 80% { transform: rotate(1.5deg); }
}

/* --- Finale --- */
.finale { max-width: 640px; margin: 56px auto 0; text-align: center; }
.polaroid { margin: 0; background: #fffdf8; padding: 14px 14px 0; border-radius: 3px; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); color: var(--tinte); }
.polaroid figcaption { font: 500 1.6rem/1 Caveat, cursive; padding: 14px 0 18px; }
.gross-polaroid { max-width: 460px; margin: 0 auto; transform: rotate(-2deg); }
.bildknopf { display: block; width: 100%; padding: 0; border: 0; background: #e8dccb; }
.bildknopf img { display: block; width: 100%; height: auto; }
.gruss { margin: 40px auto 28px; font: 500 1.6rem/1.35 Caveat, cursive; text-align: left; max-width: 520px; }
.gruss p { margin: 0; white-space: pre-line; }
.gruss, .hinweis, .fuss, .unterzeile, .schlaf { text-shadow: 0 1px 8px rgba(0, 0, 0, .7); }
.gruss .signatur { text-align: right; font-weight: 700; font-size: 2rem; margin-top: 12px; color: var(--gold); }
.hinweis { font-size: .92rem; opacity: .8; margin: 18px auto 44px; max-width: 420px; }
.finale h2 { font-size: 1.8rem; margin-bottom: 18px; }
.galerie { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 6px; }
.galerie button { padding: 0; border: 0; background: rgba(255, 255, 255, .08); aspect-ratio: 1; border-radius: 3px; overflow: hidden; }
.galerie img { width: 100%; height: 100%; object-fit: cover; display: block; }

.schlaf { text-align: center; max-width: 480px; margin: 40px auto; }
.schlaf .gross { font: 500 2rem/1.2 Caveat, cursive; }

.fuss { text-align: center; margin-top: 60px; font: 500 1.25rem Caveat, cursive; opacity: .75; }

/* --- Toast --- */
.toast {
  position: fixed; left: 50%; bottom: max(26px, env(safe-area-inset-bottom)); z-index: 7;
  transform: translate(-50%, 140%); opacity: 0; transition: transform .35s, opacity .35s;
  background: var(--papier), var(--creme); color: var(--tinte); padding: 12px 22px; border-radius: 6px;
  font: 500 1.4rem/1.2 Caveat, cursive; box-shadow: 0 12px 30px rgba(0, 0, 0, .4); max-width: calc(100% - 32px); text-align: center;
}
.toast.zeigen { transform: translate(-50%, 0); opacity: 1; }

/* --- Lightbox --- */
.lightbox {
  width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 20px; border: 0;
  background: transparent; color: var(--creme);
}
.lightbox[open] { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; }
.lightbox::backdrop { background: rgba(12, 6, 4, .88); backdrop-filter: blur(6px); }
.lightbox .polaroid { max-width: min(100%, 900px); animation: auftauchen .45s cubic-bezier(.2, 1.3, .4, 1); }
.lightbox img { display: block; max-width: 100%; max-height: calc(100dvh - 210px); width: auto; height: auto; margin: 0 auto; background: #e8dccb; }
.lightbox figcaption { text-align: center; }
.lightbox .zu, .lightbox .pfeil {
  position: absolute; border: 0; background: rgba(255, 255, 255, .12); border-radius: 50%;
  width: 48px; height: 48px; font-size: 2rem; line-height: 1; display: grid; place-items: center;
}
.lightbox .zu { top: max(14px, env(safe-area-inset-top)); right: 14px; }
.lightbox .pfeil { top: 50%; transform: translateY(-50%); }
.lightbox .links { left: 10px; }
.lightbox .rechts { right: 10px; }
@keyframes auftauchen { from { transform: scale(.85) rotate(-4deg); opacity: 0; } }

/* --- Admin --- */
.admin {
  position: fixed; left: 10px; bottom: 10px; z-index: 8; display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  max-width: calc(100% - 20px); padding: 8px 10px; border-radius: 8px; font: 13px system-ui, sans-serif;
  background: rgba(0, 0, 0, .75); color: #fff;
}
.admin input, .admin button { font: inherit; padding: 4px 8px; border-radius: 4px; border: 1px solid #666; background: #222; color: #fff; }
#sim-info { opacity: .75; }

@media (prefers-reduced-motion: reduce) {
  .klappe { transition-duration: .01s; }
  .tuer.bereit .vorne, .tuer.wackelt, .lightbox .polaroid { animation: none; }
}
