:root {
  --door: #b3202a;
  --cream: #fff6e5;
  --ink: #1d1a17;
  --night: #0f1d2b;
  --gold: #e8b64c;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--cream);
  background: var(--night);
  -webkit-font-smoothing: antialiased;
}

.backdrop {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(232, 182, 76, .18), transparent 55%),
    radial-gradient(ellipse at 90% 100%, rgba(179, 32, 42, .25), transparent 60%),
    linear-gradient(180deg, #13263a 0%, #0b1622 100%);
  background-size: cover;
  background-position: center;
}

.backdrop.has-image::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, .35), rgba(0, 0, 0, .15) 40%, rgba(0, 0, 0, .45));
}

/* ---------- sneeuw ---------- */
.snow { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.flake {
  position: absolute;
  top: -10px;
  border-radius: 50%;
  background: #fff;
  opacity: .7;
  animation: fall linear infinite;
}
@keyframes fall {
  to { transform: translate3d(var(--drift, 20px), 105vh, 0); }
}
@media (prefers-reduced-motion: reduce) { .snow { display: none; } }

/* ---------- layout ---------- */
.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: clamp(20px, 5vw, 56px) clamp(14px, 4vw, 32px) 64px;
}

.hero { text-align: center; margin-bottom: clamp(20px, 4vw, 40px); }
.hero h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 6vw, 3.6rem);
  line-height: 1.05;
  margin: 0;
  text-wrap: balance;
  text-shadow: 0 2px 18px rgba(0, 0, 0, .45);
}
.hello { margin: 0 0 8px; color: var(--gold); font-weight: 600; letter-spacing: .04em; }
.subtitle { margin: 12px auto 0; max-width: 60ch; opacity: .9; text-wrap: pretty; white-space: pre-line; }
.subtitle:empty, .hello:empty { display: none; }

.preview-banner {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--gold);
  color: var(--ink);
  text-align: center;
  padding: 8px 12px;
  font-weight: 600;
  font-size: .9rem;
}
.preview-banner a { color: inherit; }

/* ---------- vakjes ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(78px, 18vw, 130px), 1fr));
  grid-auto-flow: dense;
  gap: clamp(8px, 1.6vw, 16px);
  perspective: 1200px;
}

.door {
  position: relative;
  aspect-ratio: 1;
  border: 0;
  padding: 0;
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.door.big { grid-column: span 2; grid-row: span 2; }

.door-inside {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  background: rgba(10, 16, 24, .72);
  border: 1px solid rgba(255, 246, 229, .18);
  display: grid;
  place-items: center;
  font-size: clamp(1.4rem, 4vw, 2rem);
}

.door-front {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  background: var(--door);
  background-image: linear-gradient(145deg, rgba(255, 255, 255, .16), rgba(0, 0, 0, .18));
  box-shadow: 0 6px 18px rgba(0, 0, 0, .35), inset 0 0 0 1px rgba(255, 255, 255, .12);
  display: grid;
  place-items: center;
  transform-origin: left center;
  transition: transform .7s cubic-bezier(.3, .7, .2, 1), filter .2s;
  backface-visibility: hidden;
}
.door-front::before {
  content: "";
  position: absolute;
  inset: 7px;
  border: 2px dashed rgba(255, 246, 229, .35);
  border-radius: calc(var(--radius) - 6px);
}

.door-number {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  font-size: clamp(1.6rem, 5vw, 2.6rem);
  color: var(--cream);
  text-shadow: 0 2px 6px rgba(0, 0, 0, .35);
  font-variant-numeric: tabular-nums;
}
.door.big .door-number { font-size: clamp(2.6rem, 9vw, 4.6rem); }

.door:hover .door-front, .door:focus-visible .door-front { filter: brightness(1.08); }
.door:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

.door.locked { cursor: default; }
.door.locked .door-front { filter: saturate(.55) brightness(.75); }
.door.locked .door-front::after {
  content: "🔒";
  position: absolute;
  right: 10px;
  bottom: 8px;
  font-size: .85rem;
  opacity: .8;
}

.door.today .door-front {
  box-shadow: 0 0 0 3px var(--gold), 0 0 26px rgba(232, 182, 76, .65);
  animation: glow 2.4s ease-in-out infinite;
}
@keyframes glow {
  50% { box-shadow: 0 0 0 3px var(--gold), 0 0 40px rgba(232, 182, 76, .9); }
}

.door.opened .door-front { transform: rotateY(-108deg); }
.door.opened .door-inside { color: var(--gold); }

@media (prefers-reduced-motion: reduce) {
  .door-front { transition: none; }
  .door.today .door-front { animation: none; }
}

/* ---------- modal ---------- */
.modal {
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  border: 0;
  border-radius: 20px;
  padding: 28px 24px 24px;
  background: var(--cream);
  color: var(--ink);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .5);
}
.modal::backdrop { background: rgba(5, 10, 16, .65); backdrop-filter: blur(3px); }
.modal[open] { animation: pop .35s cubic-bezier(.3, .7, .2, 1.2); }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }

.modal-close-form { position: absolute; top: 8px; right: 8px; margin: 0; }
.modal-close {
  width: 40px; height: 40px;
  border: 0; border-radius: 50%;
  background: transparent;
  font-size: 1.8rem; line-height: 1;
  color: var(--ink);
  cursor: pointer;
}
.modal-close:hover { background: rgba(0, 0, 0, .07); }

.modal-day {
  margin: 0 0 14px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--door);
}
.modal-body img {
  display: block;
  width: 100%;
  max-height: 60vh;
  object-fit: contain;
  border-radius: 12px;
  background: #00000010;
  margin-bottom: 16px;
}
.modal-text { white-space: pre-wrap; line-height: 1.55; font-size: 1.05rem; margin: 0 0 16px; overflow-wrap: anywhere; }
.modal-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: 999px;
  background: var(--door);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.modal-link:hover { filter: brightness(1.1); }
.modal-empty { opacity: .65; font-style: italic; }

/* ---------- meldingen ---------- */
.message { text-align: center; margin-top: 18vh; }
.message h1 { font-family: Georgia, serif; font-size: clamp(1.8rem, 5vw, 2.8rem); margin: 0 0 12px; }
.message p { opacity: .85; max-width: 46ch; margin: 0 auto; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  background: rgba(10, 16, 24, .92);
  color: var(--cream);
  padding: 12px 18px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  max-width: calc(100vw - 32px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
