html { scroll-behavior: smooth; }
body { font-family: 'Nunito', system-ui, sans-serif; }

/* ------------------------------------------------------------------
   Sichtbarer Tastaturfokus - Grundregel fuer die ganze Seite.
   :where() hat Spezifitaet 0, jede eigene Regel weiter unten sticht sie
   also weiterhin. Der Rahmen ist absichtlich fast schwarz; nur auf den
   beiden dunklen Flaechen (Fusszeile, Cookie-Banner) wird er hell -
   eine einzige Farbe schafft 3:1 gegen cream UND forest nicht.
   ------------------------------------------------------------------ */
:where(a, button, summary, input, select, textarea, [tabindex]):focus-visible {
  outline: 3px solid #1F1A14;
  outline-offset: 2px;
}
:where(footer, #cookie-banner) :where(a, button, summary, input, select, textarea, [tabindex]):focus-visible {
  outline-color: #FBF7F0;
}

@keyframes fadeInUp {
  0%   { opacity: 0; transform: translateY(24px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* Fade-in-up beim Scrollen – Startzustand NUR wenn JS aktiv ist */
.js .reveal { opacity: 0; transform: translateY(24px); }
.js .reveal.is-visible { animation: fadeInUp 0.7s ease-out forwards; }

/* Fehlerhafte Formularfelder.
   Der rote Rand haengt bewusst an aria-invalid und nicht an einer
   Tailwind-Klasse: welche von zwei border-*-Klassen gewinnt, entscheidet sonst
   die Reihenfolge im erzeugten Stylesheet - und die ist nichts, worauf man sich
   festlegen kann. So koennen sichtbarer Zustand und vorgelesener Zustand auch
   gar nicht auseinanderlaufen. Spezifitaet (1,1,0) schlaegt jede Utility-Klasse,
   !important ist deshalb nicht noetig. */
#kontakt-formular [aria-invalid="true"] {
  border-color: #B3261E;
  border-width: 2px;
}

/* "Mehr erfahren" – gestyltes <details> */
details > summary { list-style: none; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }
details[open] .chevron { transform: rotate(180deg); }
.chevron { transition: transform 0.25s ease; }

/* Affiliate Logos */
.affiliate-logo {
  filter: grayscale(100%) brightness(1.1);
  transition: filter 0.3s ease;
}
.affiliate-logo:hover {
  filter: grayscale(0%) brightness(1);
}

/* Barrierefreiheit: Animationen reduzieren -> Inhalt sofort sichtbar */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .reveal { opacity: 1 !important; transform: none !important; animation: none !important; }
  .btn-story, .btn-play-game, .spiel-wiki, .paw-bg-1, .paw-bg-2, .paw-bg-3, #anniversary-info-box {
    animation: none !important;
    transform: none !important;
  }
}

.btn-story {
  display: flex;
  align-items: center;
  gap: 8px;
  /* War #6f9e5f: weisse Schrift darauf kam nur auf 3,12:1. #588049 ist derselbe
     Gruenton wie --tree-2 in der Galerie und traegt Weiss mit 4,57:1. */
  background-color: #588049;
  color: #ffffff;
  font-weight: bold;
  text-decoration: none;
  padding: 10px 18px;
  border-radius: 30px;
  font-size: 14px;
  white-space: nowrap;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  transition: all 0.3s ease;
  animation: pulse-button 2.5s infinite;
}

.btn-story:hover {
  transform: translateY(-2px) scale(1.02);
  background-color: #46683a;
  box-shadow: 0 6px 12px rgba(0,0,0,0.15);
  animation: none; 
}

.btn-story svg {
  margin-top: -1px;
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .btn-story {
    gap: 6px;
    padding: 8px 14px;
    font-size: 13px;
  }
  .btn-story svg {
    width: 16px;
    height: 16px;
  }
}

@keyframes pulse-button {
  0% { box-shadow: 0 0 0 0 rgba(111, 158, 95, 0.5); }
  70% { box-shadow: 0 0 0 10px rgba(111, 158, 95, 0); }
  100% { box-shadow: 0 0 0 0 rgba(111, 158, 95, 0); }
}

/* ==================== Spiel-Abschnitt Animationen ==================== */

@keyframes floatPaw {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-12px) rotate(6deg);
  }
}

@keyframes floatPawAlt {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-8px) rotate(-8deg);
  }
}

.paw-bg-1 {
  animation: floatPaw 6s ease-in-out infinite;
}

.paw-bg-2 {
  animation: floatPawAlt 8s ease-in-out 1s infinite;
}

.paw-bg-3 {
  animation: floatPaw 7s ease-in-out 2s infinite;
}

/* Spiel-Button mit dezentem Puls */
.btn-play-game {
  box-shadow: 0 4px 14px rgba(74, 93, 78, 0.3);
  animation: pulse-play 3s infinite;
}

.btn-play-game:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 8px 22px rgba(74, 93, 78, 0.4);
  animation: none;
}

@keyframes pulse-play {
  0% { box-shadow: 0 0 0 0 rgba(74, 93, 78, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(74, 93, 78, 0); }
  100% { box-shadow: 0 0 0 0 rgba(74, 93, 78, 0); }
}

@keyframes spiel-wiki-idle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

.spiel-wiki {
  display: grid;
  justify-items: center;
  gap: 4px;
  min-width: 44px;
  min-height: 44px;
  text-decoration: none;
  animation: spiel-wiki-idle 2.4s ease-in-out infinite;
}
.spiel-wiki canvas { display: block; }
.spiel-wiki-label {
  padding: 4px 8px;
  border: 2px solid #3B352E;
  border-radius: 999px;
  color: #3B352E;
  background: #fffdf8;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
}
.spiel-wiki:hover {
  animation: none;
  transform: translateY(-4px) scale(1.08);
}
.spiel-wiki:focus-visible { outline: 3px solid #845C3E; outline-offset: 4px; }

/* Weiches Einblenden der aufklappbaren Infobox */
#anniversary-info-box:not(.hidden) {
  animation: fadeInDown 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes fadeInDown {
  0% {
    opacity: 0;
    transform: translateY(-8px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ========================================================================
   Jubiläumsbrief – responsives Pergament-Overlay
   Die Fläche bleibt HTML/CSS, damit sie auf kleinen Bildschirmen scharf und
   scrollbar bleibt. Alegreya gibt dem Brief den alten Buchcharakter; Buttons
   und Bedienhinweise bleiben in der vorhandenen UI-Schrift.
   ======================================================================== */
#anniversary-info-box.anniversary-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: max(16px, env(safe-area-inset-top))
           max(16px, env(safe-area-inset-right))
           max(16px, env(safe-area-inset-bottom))
           max(16px, env(safe-area-inset-left));
  overflow: hidden;
  background: rgba(33, 45, 36, 0.74);
  backdrop-filter: blur(2px);
}
#anniversary-info-box.anniversary-overlay.hidden {
  display: none !important;
}
#anniversary-info-box.anniversary-overlay:not(.hidden) {
  animation: anniversaryOverlayIn 180ms ease-out both;
}

@keyframes anniversaryOverlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.anniversary-letter {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(92vw, 900px);
  max-height: min(80dvh, 574px);
  height: min(80dvh, 574px);
  min-height: 0;
  overflow: hidden;
  isolation: isolate;
  color: #5a3b25;
  background:
    radial-gradient(ellipse at 4% 50%, rgba(174, 122, 43, .17), transparent 25%),
    radial-gradient(ellipse at 96% 48%, rgba(174, 122, 43, .15), transparent 24%),
    radial-gradient(circle at 18% 18%, rgba(255, 255, 248, .74), transparent 30%),
    radial-gradient(circle at 84% 72%, rgba(202, 158, 84, .13), transparent 38%),
    repeating-linear-gradient(7deg, rgba(144, 102, 48, .022) 0 1px, transparent 1px 17px),
    linear-gradient(135deg, #f8efd9 0%, #f4e7c9 50%, #ead6aa 100%);
  border: 2px solid rgba(147, 116, 76, .68);
  border-radius: 24px 22px 28px 20px;
  box-shadow: 0 24px 65px rgba(15, 24, 17, .48), inset 0 0 45px rgba(137, 94, 35, .15);
}
.anniversary-letter::before,
.anniversary-letter::after {
  content: '';
  position: absolute;
  z-index: 0;
  left: 4%;
  right: 4%;
  height: 38px;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 249, 211, .96), rgba(198, 145, 58, .45));
  border: 1px solid rgba(139, 108, 65, .46);
  border-radius: 50% 48% 42% 45%;
  box-shadow: 0 4px 8px rgba(108, 71, 26, .20), inset 0 -7px 10px rgba(142, 91, 22, .14);
}
.anniversary-letter::before {
  top: -20px;
  transform: rotate(-.7deg);
}
.anniversary-letter::after {
  bottom: -20px;
  transform: rotate(.6deg);
}
.anniversary-letter-head,
.anniversary-letter-body {
  position: relative;
  z-index: 1;
}
.anniversary-letter-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: clamp(28px, 3.2vw, 40px) clamp(22px, 5vw, 58px) clamp(6px, 1.1vw, 14px);
}
.anniversary-letter-title {
  min-width: 0;
  margin: 0;
  color: #65401f;
  font-family: 'Alegreya', Georgia, serif;
  font-size: clamp(1.45rem, 3.1vw, 2.25rem);
  font-weight: 700;
  line-height: 1.12;
}
.anniversary-letter-title span:first-child { margin-right: .35em; }
.anniversary-letter-close {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  justify-self: end;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #fffaf0;
  background: #c8452f;
  box-shadow: 0 3px 0 #8f2c1d;
  font-family: 'Nunito', system-ui, sans-serif;
  font-size: 2rem;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  transition: transform .16s ease, filter .16s ease;
}
.anniversary-letter-close:hover,
.anniversary-letter-close:focus-visible { filter: brightness(1.08); transform: scale(1.04); }
.anniversary-letter-close:focus-visible { outline: 3px solid #7c531c; outline-offset: 3px; }
.anniversary-letter-close:active { transform: translateY(2px); box-shadow: 0 1px 0 #8f2c1d; }
.anniversary-letter-body {
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
  padding: 0 clamp(22px, 5vw, 58px) clamp(20px, 2vw, 28px);
  color: #5a3b25;
  font-family: 'Alegreya', Georgia, serif;
  font-size: clamp(1rem, 1.25vw, 1.125rem);
  font-weight: 400;
  line-height: 1.35;
  text-wrap: pretty;
}
.anniversary-letter-body::-webkit-scrollbar { display: none; }
.anniversary-letter-body p { margin: 0 0 .5rem; }
.anniversary-letter-body p:first-child { font-weight: 700; }
.anniversary-letter-body strong { font-weight: 700; }
.anniversary-letter-final {
  margin-bottom: 0 !important;
  /* Dunkler als das Grün der Lobby (#39723e): das kam am unteren Pergamentrand nur auf
     rund 4 : 1 und damit unter die 4,5 : 1 für Fließtext (Abschnitt 3.2). */
  color: #2e6133;
  font-weight: 700;
}

@media (max-width: 640px), (max-height: 480px) {
  #anniversary-info-box.anniversary-overlay {
    padding: max(10px, env(safe-area-inset-top))
             max(10px, env(safe-area-inset-right))
             max(10px, env(safe-area-inset-bottom))
             max(10px, env(safe-area-inset-left));
  }
  .anniversary-letter {
    width: min(94vw, 900px);
    max-height: 88dvh;
    height: auto;
    border-radius: 18px 16px 20px 15px;
  }
  .anniversary-letter-head {
    gap: 8px;
    padding: 30px 18px 5px;
  }
  .anniversary-letter-title { font-size: clamp(1.3rem, 5.5vw, 1.75rem); }
  .anniversary-letter-body {
    padding: 0 18px 28px;
    font-size: clamp(14px, 2.2vmin, 18px);
    line-height: 1.45;
  }
  .anniversary-letter-body p { margin-bottom: .7rem; }
}

@media (prefers-reduced-motion: reduce) {
  #anniversary-info-box.anniversary-overlay:not(.hidden),
  .anniversary-letter-close { animation: none; transition: none; }
}
