/* Hochzeits-Adventskalender
   Idee: Jedes Türchen ist ein Umschlag mit Wachssiegel wie bei einer Hochzeitseinladung. */

:root {
  --night: #17233a;
  --night-2: #22324d;
  --paper: #e8ded5;
  --paper-shade: #d9ccc0;
  --paper-light: #f1e9e2;
  --wax: #8c1c2e;
  --wax-hi: #b23548;
  --wax-lo: #5c1120;
  --gold: #c8a45d;
  --frost: #a9b8cc;
  --ink: #17233a;

  --display: "Bodoni Moda", "Didot", "Bodoni 72", Georgia, serif;
  --script: "Ms Madi", "Segoe Script", cursive;
  --text: "Jost", "Futura", "Century Gothic", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(120% 60% at 50% 0%, var(--night-2), transparent 70%),
    var(--night);
  color: var(--paper);
  font-family: var(--text);
  font-weight: 300;
  font-size: 1rem;
  line-height: 1.5;
  overflow-x: clip; /* aufklappendes Papier am Rand erzeugt keine Querscroll-Leiste */
}

#snow { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }

.screen { position: relative; z-index: 1; margin: 0 auto; padding: 40px 16px 56px; }

button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

/* ---------- Login: eine Einladungskarte ---------- */

#login { min-height: 100dvh; display: grid; place-items: center; }

.card {
  width: min(100%, 360px);
  padding: 44px 32px 32px;
  background: var(--paper);
  color: var(--ink);
  border-radius: 4px;
  box-shadow: 0 30px 60px -20px rgba(5, 10, 20, 0.7);
  text-align: center;
  display: grid;
  gap: 18px;
  position: relative;
}
/* Prägerand wie bei Briefpapier */
.card::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(23, 35, 58, 0.18);
  border-radius: 2px;
  pointer-events: none;
}

.card h1 {
  font-family: var(--script);
  font-weight: 400;
  font-size: 3.1rem;
  line-height: 1.05;
  margin: 0;
  color: var(--ink);
}
.card .sub { margin: -6px 0 6px; color: rgba(23, 35, 58, 0.65); font-size: 0.95rem; }

.card input {
  font: inherit;
  font-weight: 400;
  text-align: center;
  letter-spacing: 0.08em;
  padding: 10px 4px;
  border: none;
  border-bottom: 1px solid rgba(23, 35, 58, 0.4);
  background: transparent;
  color: var(--ink);
  border-radius: 0;
}
.card input::placeholder { color: rgba(23, 35, 58, 0.45); letter-spacing: normal; }
.card input:focus { outline: none; border-bottom-color: var(--wax); box-shadow: 0 1px 0 var(--wax); }

.card button[type="submit"] {
  justify-self: center;
  border: none;
  border-radius: 999px;
  padding: 11px 34px;
  background: var(--wax);
  color: var(--paper-light);
  font-weight: 400;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.2s;
}
.card button[type="submit"]:hover { background: var(--wax-hi); }
.card button[type="submit"]:disabled { opacity: 0.7; cursor: progress; }

.error { color: var(--wax); min-height: 1.5em; margin: 0; font-size: 0.9rem; font-weight: 400; }

/* ---------- Kalender ---------- */

#calendar { max-width: 1240px; }
@media (min-width: 760px) { #calendar { padding-top: clamp(40px, 9vh, 110px); } }

header { text-align: center; margin-bottom: 36px; }
header h1 {
  font-family: var(--script);
  font-weight: 400;
  font-size: clamp(3.3rem, 13vw, 6.4rem);
  line-height: 1;
  margin: 0 0 14px;
  color: var(--paper);
  letter-spacing: -0.01em;
}
#status { margin: 0; color: var(--frost); font-size: 1.05rem; }

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-flow: dense;
  gap: 18px 12px;
  perspective: 1000px;
}
@media (min-width: 760px) {
  .grid { grid-template-columns: repeat(9, 1fr); gap: 22px 14px; }
}

/* Ein Päckchen: Foto in Seidenpapier, mit Samtband, Schleife und Kraftpapier-Anhänger */
.door {
  --ribbon: #9c2f3e;
  --ribbon-hi: #b8475a;
  --ribbon-lo: #6e1d2b;
  --tissue: #f4efe9;
  --tissue-2: #e9e1d8;
  --kraft: #dcbc85;
  --kraft-ink: #2e1d0e;
  --rb: 13%; /* Bandbreite */
  container-type: inline-size;
  position: relative;
  aspect-ratio: 1;
  padding: 0;
  border: none;
  border-radius: 3px;
  background: var(--tissue-2);
  box-shadow: 0 10px 18px -10px rgba(0, 0, 0, 0.6);
  cursor: pointer;
  perspective: 600px;
}
.door.big { grid-column: span 2; grid-row: span 2; --rb: 9%; --ribbon: #c8a45d; --ribbon-hi: #e6c987; --ribbon-lo: #8a6a2c; }

/* Foto im Inneren, mit schmalem Papierrand */
.door .photo {
  position: absolute;
  inset: 4%;
  border-radius: 1px;
  background: var(--tissue-2) 50% 30% / cover no-repeat;
  opacity: 0;
  transition: opacity 0.6s 0.55s;
}

/* Seidenpapier in zwei Hälften, die beim Öffnen nach außen aufschlagen */
.door .paper {
  position: absolute;
  top: 0; bottom: 0;
  width: 50%;
  background:
    repeating-linear-gradient(112deg, transparent 0 14px, rgba(120, 95, 75, 0.05) 14px 15px, transparent 15px 31px),
    repeating-linear-gradient(64deg, transparent 0 22px, rgba(255, 255, 255, 0.5) 22px 23px, transparent 23px 41px),
    linear-gradient(160deg, var(--tissue), var(--tissue-2));
  transition: transform 0.8s cubic-bezier(.5, 0, .2, 1) 0.35s, opacity 0.4s 0.8s;
  backface-visibility: hidden;
}
.door .paper.l { left: 0; border-radius: 3px 0 0 3px; transform-origin: 0 50%; box-shadow: inset -1px 0 0 rgba(120, 95, 75, 0.12); }
.door .paper.r { right: 0; border-radius: 0 3px 3px 0; transform-origin: 100% 50%; }

/* Samtband über Kreuz */
.door .rib {
  position: absolute;
  background: linear-gradient(90deg, var(--ribbon-lo), var(--ribbon) 25%, var(--ribbon-hi) 50%, var(--ribbon) 75%, var(--ribbon-lo));
  transition: transform 0.55s cubic-bezier(.5, 0, .8, .4) 0.15s, opacity 0.3s 0.4s;
}
.door .rib.v { left: calc(50% - var(--rb) / 2); width: var(--rb); top: 0; bottom: 0; }
.door .rib.h {
  top: calc(50% - var(--rb) / 2); height: var(--rb); left: 0; right: 0;
  background: linear-gradient(180deg, var(--ribbon-lo), var(--ribbon) 25%, var(--ribbon-hi) 50%, var(--ribbon) 75%, var(--ribbon-lo));
}

/* Schleife: zwei Schlaufen, zwei Enden, ein Knoten */
.door .bow { position: absolute; left: 50%; top: 50%; width: 0; height: 0; transition: transform 0.4s ease-in, opacity 0.3s 0.1s; }
.door .loop {
  position: absolute;
  width: 30cqi; height: 19cqi;
  top: -9.5cqi;
  border: 4.2cqi solid var(--ribbon);
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}
.door .loop.l { right: -1cqi; transform: rotate(-22deg); transform-origin: 100% 50%; border-right-color: var(--ribbon-lo); }
.door .loop.r { left: -1cqi; transform: rotate(22deg); transform-origin: 0 50%; border-left-color: var(--ribbon-lo); }
.door .tail {
  position: absolute; top: 2cqi;
  width: 6cqi; height: 20cqi;
  background: linear-gradient(90deg, var(--ribbon-lo), var(--ribbon));
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 82%, 0 100%);
}
.door .tail.l { right: 0; transform: rotate(24deg); transform-origin: 100% 0; }
.door .tail.r { left: 0; transform: rotate(-24deg); transform-origin: 0 0; }
.door .knot {
  position: absolute; left: -5cqi; top: -5cqi;
  width: 10cqi; height: 10cqi;
  border-radius: 30%;
  background: radial-gradient(circle at 40% 35%, var(--ribbon-hi), var(--ribbon) 60%, var(--ribbon-lo));
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
.door.big .loop { border-width: 3cqi; }

/* Kraftpapier-Anhänger mit Nummer */
.door .tag {
  position: absolute;
  right: 5%; bottom: 7%;
  width: 44%; height: 29%;
  display: grid; place-items: center;
  padding-left: 11%;
  background: var(--kraft);
  clip-path: polygon(20% 0, 100% 0, 100% 100%, 20% 100%, 0 50%);
  font-family: var(--display);
  font-style: normal;
  font-weight: 700;
  font-size: 19cqi;
  font-variant-numeric: lining-nums;
  line-height: 1;
  color: var(--kraft-ink);
  transform: rotate(var(--tilt, -6deg));
  transform-origin: 6% 50%;
  transition: transform 0.6s cubic-bezier(.6, 0, .8, .5), opacity 0.4s 0.2s;
}
/* Loch im Anhänger */
.door .tag::before {
  content: "";
  position: absolute; left: 9%; top: calc(50% - 4cqi);
  width: 8cqi; height: 8cqi; border-radius: 50%;
  background: var(--tissue-2);
  box-shadow: inset 0 0 0 1px rgba(74, 52, 32, 0.4);
}
.door.big .tag { width: 32%; height: 21%; padding-left: 7%; font-size: 13cqi; background: #e6cc96; }
.door.big .tag::before { width: 5cqi; height: 5cqi; top: calc(50% - 2.5cqi); }

/* Noch nicht dran: gedämpft */
.door.locked { cursor: default; filter: saturate(0.3) brightness(0.72); box-shadow: none; }

/* Heute dran: Anhänger schaukelt, feiner Goldrand */
.door.today { box-shadow: 0 0 0 2px var(--gold), 0 10px 18px -10px rgba(0, 0, 0, 0.6); }
.door.today .tag { animation: swing 2.8s ease-in-out infinite; }
@keyframes swing {
  0%, 100% { transform: rotate(-9deg); }
  50% { transform: rotate(5deg); }
}

/* Öffnen: Schleife löst sich, Band rutscht weg, Anhänger fällt, Papier schlägt auf */
.door.opened .bow { transform: scale(0.4) rotate(40deg); opacity: 0; }
.door.opened .rib.v { transform: translateY(115%); opacity: 0; }
.door.opened .rib.h { transform: translateX(115%); opacity: 0; }
.door.opened .tag { transform: translateY(60%) rotate(35deg); opacity: 0; animation: none; }
.door.opened .paper.l { transform: rotateY(-115deg); opacity: 0; }
.door.opened .paper.r { transform: rotateY(115deg); opacity: 0; }
.door.opened .photo { opacity: 1; }
.door.opened { box-shadow: 0 10px 18px -10px rgba(0, 0, 0, 0.6); }

/* Bereits geöffnete Türchen ohne Animation anzeigen */
.door.instant, .door.instant * { transition: none !important; }

footer { text-align: center; margin-top: 44px; }
button.link {
  background: none;
  border: none;
  color: var(--frost);
  font-size: 0.9rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* ---------- Lightbox ---------- */

.lightbox {
  position: fixed; inset: 0; z-index: 10;
  background: rgba(12, 19, 33, 0.94);
  display: grid; place-items: center;
  padding: 16px;
}
.lightbox figure { margin: 0; max-width: min(100%, 1100px); text-align: center; }
.lightbox img {
  display: block;
  max-width: 100%;
  max-height: 78dvh;
  margin: 0 auto;
  padding: clamp(6px, 1.2vw, 12px);
  background: var(--paper-light);
  border-radius: 2px;
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.8);
}
.lightbox figcaption { margin-top: 18px; display: grid; gap: 2px; }
.lightbox .day { font-family: var(--script); color: var(--paper); font-size: clamp(1.8rem, 6vw, 2.4rem); line-height: 1.1; }
.lightbox .caption { font-family: var(--display); font-style: italic; font-size: clamp(1.2rem, 3.4vw, 1.6rem); color: var(--paper); }
.lightbox .close {
  position: absolute; top: 10px; right: 12px;
  background: none; border: none;
  color: var(--paper); font-size: 2.2rem; line-height: 1; padding: 6px 10px; cursor: pointer;
}

.toast {
  position: fixed; left: 50%; bottom: 24px;
  transform: translateX(-50%) translateY(16px);
  background: var(--paper); color: var(--ink);
  padding: 10px 20px; border-radius: 999px;
  font-weight: 400;
  opacity: 0; transition: opacity .25s, transform .25s;
  z-index: 20; pointer-events: none;
  max-width: calc(100% - 32px);
  box-shadow: 0 10px 30px -10px rgba(0,0,0,.6);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  .door *, .toast { transition: none !important; }
  .door.today .tag { animation: none; }
}

/* ---------- Türchen 24: Rubbelbild ---------- */

.reveal {
  position: fixed; inset: 0; z-index: 12;
  background: radial-gradient(80% 60% at 50% 40%, #22324d, rgba(12, 19, 33, 0.98));
  display: grid; place-items: center;
  padding: 56px 16px 24px;
  overflow-y: auto;
}
.reveal-inner { display: grid; justify-items: center; gap: 14px; text-align: center; }

.scratch {
  position: relative;
  border: clamp(6px, 1.2vw, 12px) solid var(--paper-light);
  border-radius: 2px;
  background: var(--paper);
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.8);
  transition: box-shadow 1.6s ease;
  line-height: 0;
}
.scratch img {
  display: block;
  max-width: min(100%, calc(100vw - 56px));
  max-height: 66dvh;
  width: auto; height: auto;
  visibility: hidden;
}
.scratch.ready img { visibility: visible; }
.scratch canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  touch-action: none;
  cursor: grab;
  transition: opacity 1.2s ease;
}
.scratch.done canvas { opacity: 0; pointer-events: none; }
.scratch.done { box-shadow: 0 0 0 1px rgba(200, 164, 93, 0.5), 0 0 70px -10px rgba(200, 164, 93, 0.55), 0 30px 60px -20px rgba(0, 0, 0, 0.8); }

.reveal-hint { margin: 4px 0 0; color: var(--frost); transition: opacity .4s; }
.reveal-hint.started, .reveal.done .reveal-hint { opacity: 0; }
.reveal-caption {
  margin: 0;
  font-family: var(--display); font-style: italic;
  font-size: clamp(1.3rem, 4vw, 1.9rem);
  color: var(--paper);
  opacity: 0; transition: opacity 1s 0.9s;
}
.reveal-caption:empty { display: none; }
.reveal.done .reveal-caption { opacity: 1; }
.reveal.done #reveal-all { visibility: hidden; }
.reveal .close {
  position: absolute; top: 10px; right: 12px;
  background: none; border: none;
  color: var(--paper); font-size: 2.2rem; line-height: 1; padding: 6px 10px; cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  .scratch, .scratch canvas, .reveal-caption, .reveal-hint { transition: none !important; }
}

/* Nach dem Auspacken: Band, Papier und Anhänger ganz entfernen (sonst ragen sie unsichtbar über den Rand) */
.door.unwrapped .paper, .door.unwrapped .rib, .door.unwrapped .bow, .door.unwrapped .tag { display: none; }
