@font-face {
  font-family: "Montserrat";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url(fonts/montserrat-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+20A0-20AB, U+20AD-20C0, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Montserrat";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url(fonts/montserrat-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212;
}

:root {
  --atlantis: #93BD32;
  --atlantis-dunkel: #6E9424;
  --mine-shaft: #2C3039;
  --grund: #EEF5E0;
  --text: #2C3039;
  --text-leise: #5A606B;
  --radius: 4px;
  /* Kalenderbreite: so groß wie möglich, aber 4 Reihen passen in die Fensterhöhe */
  --kalender-breite: min(100%, 1500px, max(560px, calc((100svh - 190px) * 1.5)));
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; overflow-x: clip; }
body {
  margin: 0;
  font-family: "Montserrat", Arial, sans-serif;
  font-weight: 400;
  color: var(--text);
  background: #DCE7F1;
  line-height: 1.5;
  padding: 0 16px 32px;
  min-height: 100svh;
}
/* Winterbild füllt immer das ganze Fenster und skaliert mit (fixe Ebene statt
   background-attachment: fixed, das auf iOS nicht zuverlässig funktioniert). */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1;
  background: url(img/hintergrund.webp) center 70% / cover no-repeat, #DCE7F1;
}
a { color: var(--atlantis-dunkel); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Kopf ---------- */
.kopf {
  position: relative;
  text-align: center; padding: clamp(20px, 4vh, 40px) 0 clamp(14px, 2.5vh, 24px);
  text-shadow: 0 0 12px rgba(255,255,255,.95), 0 0 2px rgba(255,255,255,.9);
}
.signet {
  position: absolute; left: 0; top: clamp(12px, 2.5vh, 28px);
  width: clamp(48px, 5vw, 84px); line-height: 0;
  filter: drop-shadow(0 4px 10px rgba(30,40,60,.25));
}
.signet img { width: 100%; height: auto; }
@media (max-width: 600px) { .kopf { padding-top: 72px; } .signet { top: 12px; width: 48px; } }
.kopf h1 { font-weight: 800; font-size: clamp(1.6rem, 4.5vw, 2.4rem); margin: 0 0 6px; letter-spacing: -0.01em; }
.unterzeile { font-weight: 800; font-size: clamp(1rem, 2.6vw, 1.35rem); margin: 0 0 14px; }
.countdown { margin: 0; font-size: 1.05rem; }
.countdown strong { color: var(--atlantis-dunkel); font-weight: 800; }
.hinweis { margin: 2px 0 0; font-size: .88rem; color: var(--text-leise); }

/* ---------- Raster ---------- */
.raster {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  /* Skaliert mit dem Fenster: so breit wie möglich, aber 4 Reihen passen in die Höhe */
  width: var(--kalender-breite);
  margin: 0 auto;
  position: relative; isolation: isolate;
}
/* Leichter Schatten hinter dem ganzen Kalender */
.raster::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  box-shadow: 0 6px 14px rgba(20,30,50,.22), 0 26px 60px rgba(20,30,50,.35);
}
@media (max-width: 760px) { :root { --kalender-breite: 100%; } .raster { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 440px) { .raster { grid-template-columns: repeat(2, 1fr); } }

.kachel {
  position: relative;
  aspect-ratio: 1;
  border: 0;
  padding: 0;
  margin: 0;
  background: color-mix(in srgb, var(--kachel) 55%, #000);
  cursor: pointer;
  perspective: 1400px;
  container-type: inline-size;
  font: inherit;
  color: #fff;
  -webkit-tap-highlight-color: transparent;
}
.kachel:focus-visible { outline: 3px solid var(--mine-shaft); outline-offset: 2px; z-index: 2; }

/* Innenseite: sichtbar, wenn die Tür aufschwingt */
.innen {
  position: absolute; inset: 0;
  display: grid; place-content: center; text-align: center; gap: 2cqi;
  color: var(--mine-shaft);
  background:
    radial-gradient(circle at 50% 40%, #fff 0, #F4F8EC 70%),
    #fff;
  box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--kachel) 70%, #000), inset 6px 6px 18px rgba(0,0,0,.18);
}
/* Innenseite: Spruch + Hinweis auf den Tipp. Rechts mehr Abstand, weil dort die offene Tür
   des rechten Nachbarn ein Stück hereinragt. */
.innen { place-content: safe center start; text-align: left; gap: 5cqi; padding: 8cqi 9cqi; overflow: hidden; grid-template-columns: minmax(0, 1fr); }
.innen-spruch {
  /* Größe setzt app.js je Spruch (sprueheEinpassen), so groß wie es passt */
  font-weight: 800; font-size: var(--spruch-groesse, 8cqi); line-height: 1.18; letter-spacing: -.01em;
  hyphens: var(--spruch-trennung, manual); -webkit-hyphens: var(--spruch-trennung, manual); min-width: 0; max-width: 100%;
}
.innen-hinweis {
  justify-self: start;
  font-size: max(5.4cqi, 8px); font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: #fff; background: var(--atlantis-dunkel); padding: 1.6cqi 3.6cqi; border-radius: 99px; white-space: nowrap;
}
.innen-hinweis::after { content: " →"; }
.kachel.offen:hover .innen-hinweis { background: var(--mine-shaft); }

/* Die Tür: Vorder- und Rückseite, Scharnier links */
.tuer {
  position: absolute; inset: 0;
  transform-origin: left center;
  transform-style: preserve-3d;
  transition: transform .7s cubic-bezier(.2,.9,.25,1);
}
.vorne, .hinten { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.vorne { background: var(--kachel); }
.hinten {
  transform: rotateY(180deg);
  background:
    linear-gradient(90deg, rgba(0,0,0,.25), rgba(0,0,0,0) 40%),
    color-mix(in srgb, var(--kachel) 75%, #000);
}
.zahl {
  position: absolute; top: 6cqi; right: 8cqi;
  font-weight: 800; font-size: 25cqi; line-height: 1;
}
.motiv {
  position: absolute; left: 6cqi; bottom: 6cqi;
  width: 60cqi; height: 60cqi;
}
.motiv .k { fill: var(--kachel); }
.motiv .k-s { stroke: var(--kachel); }

/* Zustände */
.kachel.offen { z-index: 1; }
.kachel.offen .tuer { transform: rotateY(-93deg); }
.kachel.offen:hover .tuer, .kachel.offen:focus-visible .tuer { transform: rotateY(-86deg); }
.kachel.heute .vorne::after {
  content: ""; position: absolute; inset: 0;
  box-shadow: inset 0 0 0 4px #fff;
  animation: puls 1.8s ease-in-out infinite;
}
.kachel.heute:not(.offen):hover .tuer,
.kachel.vergangen:not(.offen):hover .tuer { transform: rotateY(-14deg); }
.kachel.gesperrt { cursor: not-allowed; }
/* Sofortiges Feedback beim Drücken */
.kachel:active:not(.gesperrt) .vorne { filter: brightness(1.12); }
.kachel:not(.gesperrt):not(.offen):active .tuer { transform: rotateY(-8deg) scale(.98); transition-duration: .08s; }
.kachel.oeffnet { z-index: 3; }
.kachel.oeffnet .tuer { transform: rotateY(-93deg); }
.kachel.wackelt .tuer { animation: wackeln .45s ease; }

@keyframes puls { 50% { box-shadow: inset 0 0 0 4px rgba(255,255,255,.35); } }
@keyframes wackeln {
  20% { transform: translateX(-4px); } 40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); } 80% { transform: translateX(2px); }
}

/* ---------- Testleiste + Meldungen ---------- */
.testleiste {
  margin: 0 -16px; padding: 8px 16px;
  background: var(--mine-shaft); color: #fff; font-size: .88rem;
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center;
}
.testleiste input { font: inherit; padding: 2px 6px; border-radius: var(--radius); border: 0; }
.testleiste a { color: var(--atlantis); }

.meldung {
  max-width: 900px; margin: 16px auto 0; padding: 10px 14px;
  background: #fff; border-left: 4px solid var(--atlantis); border-radius: var(--radius);
}

.toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom));
  transform: translate(-50%, 20px); opacity: 0;
  background: var(--mine-shaft); color: #fff;
  padding: 12px 18px; border-radius: 6px; font-size: .95rem;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  transition: opacity .25s, transform .25s; pointer-events: none; z-index: 50;
  max-width: calc(100vw - 32px); text-align: center;
}
.toast.sichtbar { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Dialog ---------- */
.dialog {
  border: 0; border-radius: 16px; padding: 0; overflow: hidden;
  width: min(600px, calc(100vw - 32px));
  max-height: calc(100svh - 32px); overflow-y: auto;
  color: var(--text); font-family: inherit; background: #fff;
  box-shadow: 0 30px 80px rgba(20,25,35,.45), 0 0 0 1px rgba(255,255,255,.4);
}
.dialog:focus { outline: none; }
.dialog[open] { animation: aufklappen .55s cubic-bezier(.2,1.2,.3,1); }
.dialog::backdrop { background: rgba(30,34,42,.55); backdrop-filter: blur(4px); animation: einblenden .3s; }
@keyframes aufklappen { from { opacity: 0; transform: translateY(30px) scale(.85) rotate(-2deg); } to { opacity: 1; transform: none; } }
@keyframes einblenden { from { opacity: 0; } }
@keyframes hochkommen { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* Farbband oben in der Farbe des Türchens, mit großem Motiv */
.dlg-band {
  position: relative; overflow: hidden;
  display: flex; align-items: flex-end; gap: 16px;
  padding: 22px 26px 18px; min-height: 120px;
  color: #fff; background:
    radial-gradient(circle at 85% 20%, rgba(255,255,255,.22), transparent 55%),
    repeating-linear-gradient(135deg, rgba(255,255,255,.05) 0 12px, transparent 12px 24px),
    var(--dlg-farbe, var(--atlantis));
}
.dlg-nr { font-weight: 800; font-size: 5.2rem; line-height: .8; letter-spacing: -.01em; color: #fff; filter: url(#outline-white-3); padding: 4px; }
.dlg-meta { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding-bottom: 2px; position: relative; z-index: 1; }
.dlg-tag { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; opacity: .95; }
.dlg-platzhalter { font-size: .68rem; font-weight: 700; background: #FFE8A3; color: #6B5200; padding: 1px 8px; border-radius: 99px; }
.dlg-motiv { position: absolute; right: -18px; bottom: -26px; width: 160px; height: 160px; opacity: .28; transform: rotate(-10deg); pointer-events: none; }
.dlg-motiv .motiv { position: static; width: 100%; height: 100%; }
.dlg-motiv .k { fill: var(--dlg-farbe); }
.dlg-motiv .k-s { stroke: var(--dlg-farbe); }
.schliessen {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  width: 36px; height: 36px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(255,255,255,.22); color: #fff; font-size: 1.5rem; line-height: 1;
  display: grid; place-items: center; transition: background .2s, transform .2s;
}
.schliessen:hover { background: rgba(255,255,255,.38); transform: rotate(90deg); }
.schliessen:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.dlg-inhalt { padding: 26px 26px 24px; }
.spruch {
  position: relative; margin: 0 0 18px; padding-top: 20px;
  font-weight: 700; font-size: clamp(1rem, 2.2vw, 1.15rem); line-height: 1.4; color: var(--text-leise);
}
.spruch::before {
  content: "„"; position: absolute; left: -2px; top: -50px;
  font-size: 4.5rem; line-height: 1; color: var(--atlantis); opacity: .35; pointer-events: none;
}
.tipp {
  position: relative; background: var(--mine-shaft); color: #fff;
  border-radius: 12px; padding: 20px 22px 20px 66px;
}
.tipp-icon {
  position: absolute; left: 16px; top: 16px; width: 32px; height: 32px; border-radius: 50%;
  background: var(--atlantis); display: grid; place-items: center;
}
.tipp-icon svg { width: 18px; height: 18px; }
.tipp-kopf { font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--atlantis); margin: 0 0 4px; }
.tipp p { margin: 0; }
.tipp p + p { color: #fff; font-size: clamp(1.05rem, 2.3vw, 1.25rem); font-weight: 600; line-height: 1.45; }
.dlg-aktionen { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.dlg-teilen {
  display: inline-flex; align-items: center; gap: 8px;
  background: none; border: 2px solid var(--atlantis); color: var(--atlantis-dunkel);
  font: inherit; font-weight: 700; font-size: .88rem; padding: 7px 14px; border-radius: 99px; cursor: pointer;
  transition: background .2s, color .2s;
}
.dlg-teilen:hover { background: var(--atlantis); color: var(--mine-shaft); }
.dlg-teilen svg { width: 16px; height: 16px; }
.dialog[open] .dlg-nr { animation: hochkommen .5s .15s both; }
.dialog[open] .spruch { animation: hochkommen .5s .25s both; }
.dialog[open] .tipp { animation: hochkommen .5s .4s both; }
.dialog[open] .dlg-aktionen { animation: hochkommen .5s .5s both; }
#dlg-bild { width: 100%; border-radius: 8px; margin-top: 16px; }
.dlg-link, .anmeldung button {
  display: inline-block; margin-top: 14px;
  background: var(--atlantis); color: var(--mine-shaft);
  font: inherit; font-weight: 700; text-decoration: none;
  padding: 10px 18px; border: 0; border-radius: var(--radius); cursor: pointer;
}
.dlg-link:hover, .anmeldung button:hover { background: var(--atlantis-dunkel); color: #fff; }

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

/* ---------- Anmeldung ---------- */
.anmeldung {
  width: var(--kalender-breite); box-sizing: border-box; margin: 36px auto 0; padding: 20px 22px;
  background: rgba(255,255,255,.94); color: var(--text); border-radius: 12px;
  box-shadow: 0 10px 30px rgba(30,40,60,.18);
  backdrop-filter: blur(6px);
}
.anmeldung h2 { font-weight: 800; margin: 0 0 2px; font-size: 1.1rem; }
.anmeldung p { margin: 0 0 12px; font-size: .9rem; color: var(--text-leise); }
.anmeldung a { color: var(--atlantis-dunkel); }
.feldzeile { display: flex; gap: 8px; flex-wrap: wrap; }
.feldzeile input {
  flex: 1 1 220px; min-width: 0; font: inherit; font-size: .95rem; padding: 8px 12px;
  border: 1.5px solid #D5DAE0; border-radius: var(--radius); background: #fff;
}
.feldzeile input:focus { outline: none; border-color: var(--atlantis); box-shadow: 0 0 0 3px rgba(147,189,50,.25); }
.anmeldung .feldzeile button { margin-top: 0; padding: 8px 16px; font-size: .95rem; }
.einwilligung { display: flex; gap: 8px; align-items: flex-start; margin-top: 10px; font-size: .72rem; line-height: 1.45; color: var(--text-leise); }
.einwilligung input { margin-top: 2px; accent-color: var(--atlantis); width: 15px; height: 15px; flex: none; }
.honig { position: absolute; left: -9999px; }
.anmeldung .formstatus { margin: 8px 0 0; font-weight: 600; min-height: 0; font-size: .85rem; }
.anmeldung .formstatus:empty { display: none; }
.formstatus.ok { color: var(--atlantis-dunkel) !important; }
.formstatus.fehler { color: #B0381A !important; }

.fuss { text-align: center; margin-top: 32px; font-size: .82rem; color: var(--text-leise); }
.fuss p { margin: 2px 0; }
.entwurf { font-style: italic; }

@media (prefers-reduced-motion: reduce) {
  .tuer, .dialog[open], .toast { transition: none; animation: none; }
  .dialog[open] * { animation: none !important; }
  .schnee { display: none; }
  .kachel.heute .vorne::after { animation: none; }
}

/* ---------- Einfache Seiten (Abmelden, Dev-Postfach) ---------- */
.einfachseite { max-width: 900px; margin: 40px auto; background: #fff; padding: 28px; border-radius: 6px; border-top: 8px solid var(--atlantis); }
.einfachseite h1 { font-weight: 800; font-size: 1.5rem; margin: 0 0 12px; }
.einfachseite h2 { font-weight: 800; font-size: 1.1rem; margin: 28px 0 8px; }
.einfachseite button {
  background: var(--atlantis); color: var(--mine-shaft); font: inherit; font-weight: 700;
  padding: 10px 18px; border: 0; border-radius: var(--radius); cursor: pointer;
}
.einfachseite button.leise { background: #E2E5EA; font-weight: 600; padding: 6px 12px; margin-top: 8px; }
.einfachseite input[type=date] { font: inherit; padding: 6px 8px; margin: 0 8px; }
.dev-hinweis { background: #FFF6D6; padding: 8px 12px; border-radius: var(--radius); font-size: .9rem; }
.dev-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tabelle { overflow-x: auto; }
.einfachseite table { border-collapse: collapse; width: 100%; font-size: .88rem; }
.einfachseite th, .einfachseite td { text-align: left; padding: 6px 8px; border-bottom: 1px solid #E2E5EA; }
.einfachseite pre { background: var(--grund); padding: 12px; border-radius: var(--radius); overflow-x: auto; }
.mailkopf { font-size: .88rem; background: var(--grund); padding: 10px 12px; border-radius: var(--radius); word-break: break-all; }
.mailvorschau { width: 100%; height: 520px; border: 1px solid #E2E5EA; border-radius: var(--radius); }

.filterdefs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ---------- Hund, der links hinter dem Kalender hervorschaut ---------- */
.buehne { position: relative; width: var(--kalender-breite); margin: 0 auto; isolation: isolate; }
.buehne .raster { z-index: 1; }
.hund {
  position: absolute; z-index: 0; pointer-events: none;
  left: 0; bottom: 2%;
  height: 50%; width: auto; max-width: none;
  /* gespiegelt: Kopf schaut nach links um die Ecke, Körper steckt hinter dem Kalender */
  transform-origin: 50% 100%;
  transform: translateX(-82%) scaleX(-1) rotate(-6deg);
  animation: hervorschauen 1.1s cubic-bezier(.3,1.4,.5,1) .8s both;
}
@keyframes hervorschauen {
  from { transform: translateX(-10%) scaleX(-1) rotate(0deg); }
  to   { transform: translateX(-82%) scaleX(-1) rotate(-6deg); }
}
/* zu wenig Platz neben dem Kalender: Hund ausblenden */
@media (max-width: 760px) { .hund { display: none; } }
@media (prefers-reduced-motion: reduce) { .hund { animation: none; } }

/* ---------- Unnützes Wissen: Bogen + Link ---------- */
.dlg-bogen { margin: 14px 2px 0; font-weight: 700; font-size: 1.02rem; color: var(--mine-shaft); }
.dlg-aktionen { align-items: center; flex-wrap: wrap; }
.dlg-aktionen .dlg-link { margin: 0 auto 0 0; border-radius: 99px; padding: 10px 18px; }
.kachel.rechts-offen .innen { padding-right: 19cqi; }
.dlg-aktionen .dlg-link { color: #fff; }
