:root{
  --bg-main: #EAF5EF; /* Mint Pastell */
}

html, body{
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-main);
  overflow: hidden;
  font-family: Arial, Helvetica, sans-serif;
}

/* ======================================================
   LAYOUT: Desktop nebeneinander, Mobile untereinander
   ====================================================== */

.app{
  width: 100vw;
  height: 100vh;
  height: 100svh;
  height: 100dvh;
  display: flex;
  flex-direction: row; /* Bild links, Text rechts */
  flex-wrap: nowrap;
  align-items: stretch;
  background: transparent;
}

/* Links: Bühne */
.stage{
  position: relative;
  flex: 0 0 48%;
  width: 48%;
  max-width: 48vw;
  height: 100%;
  overflow: hidden;
  background: transparent;
}

/* Rechts: Chronik */
.chronicle{
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  background: transparent;
}

.chronicleInner{
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  padding: 18px 18px 18px 10px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  transition: opacity 160ms ease;
}

/* ======================================================
   Kopfzeile
   ====================================================== */

.metaRow{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 2px solid rgba(0,0,0,0.08);
}

.metaLabel{
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.2px;
  color: rgba(0,0,0,0.75);
  text-transform: uppercase;
}

/* Rechtscontainer für Buttons + Timer */
.metaRight{
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

/* Modus Buttons (Zufällig | Chronologisch) */
.modeSwitch{
  display: inline-flex;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(0,0,0,0.10);
}

.modeBtn{
  border: 0;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
  background: transparent;
  color: rgba(0,0,0,0.70);
  cursor: pointer;
}

.modeBtn.isActive{
  background: rgba(0,0,0,0.18);
  color: rgba(0,0,0,0.88);
}

.modeBtn:active{
  transform: translateY(1px);
}

/* Timer: schmaler Balken statt Text */
.metaTimer{
  position: relative;
  width: 150px;
  height: 6px;
  border-radius: 999px;
  background: rgba(0,0,0,0.14);
  overflow: hidden;
  cursor: default;

  /* Text unsichtbar, bleibt für Screenreader via aria-label */
  font-size: 0;
  line-height: 0;
}

/* Füllung */
.metaTimer.timerRun::before{
  content: "";
  position: absolute;
  inset: 0;
  width: 100%;
  transform: scaleX(0);
  transform-origin: left center;
  background: rgba(0,0,0,0.38);
  animation: timerFill var(--dur, 30000ms) linear forwards;
}

@keyframes timerFill{
  to { transform: scaleX(1); }
}

/* kleine Zahl nur beim Hover */
.metaTimer:hover::after{
  content: attr(data-sec) "s";
  position: absolute;
  right: 0;
  top: -26px;
  font-size: 12px;
  line-height: 1;
  padding: 6px 8px;
  border-radius: 10px;
  background: rgba(0,0,0,0.78);
  color: #fff;
  white-space: nowrap;
}

/* ======================================================
   Chronik Text
   ====================================================== */

.date{
  margin: 14px 0 10px 0;
  font-size: 28px;
  font-weight: 900;
  line-height: 1.05;
}

.text{
  flex: 1;
  min-height: 0;
  overflow: auto;
  font-size: 17px;
  line-height: 1.38;
  padding-right: 6px;
  white-space: pre-wrap;
}

/* Fade beim Wechsel */
.chronicleInner.swapFade{
  opacity: 0;
}

/* ======================================================
   Szene Layering
   ====================================================== */

.sceneLayers{
  position: absolute;
  inset: 0;
}

/* Standard für alle Ebenen */
.layer{
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center center;
  pointer-events: none;
}

/* =========================
   Ebenen + Animationen final
   ========================= */

/* kl-storch hinter dem Turm + links rechts schieben */
img[src*="kl-storch"]{
  z-index: 0;
  animation: klStorchSlide 5.8s ease-in-out infinite;
  will-change: transform;
}

@keyframes klStorchSlide{
  0%   { transform: translateX(-4px); }
  50%  { transform: translateX(4px); }
  100% { transform: translateX(-4px); }
}

/* Turm */
img[src*="turm"]{
  z-index: 1;
}

/* Hauptstorch (ohne kl-storch) */
img[src*="storch"]:not([src*="kl-storch"]){
  z-index: 3;
}

/* Hand hinter dem Storch, leicht hoch runter */
img[src*="hand"]{
  z-index: 2;
  animation: handFloat 3.6s ease-in-out infinite;
  will-change: transform;
}

@keyframes handFloat{
  0%   { transform: translateY(-3px); }
  50%  { transform: translateY(3px); }
  100% { transform: translateY(-3px); }
}

/* Mund vor dem Körper */
img[src*="mund"]{
  z-index: 4;
}

/* Augen vor dem Mund */
img[src*="augen"]{
  z-index: 5;
}

/* Wappen vor dem Storch + minimal mitschwingen */
img[src*="wappen"]{
  z-index: 6;
  transform-origin: 50% 8%;
  animation: wappenSway 6.8s ease-in-out infinite;
  will-change: transform;
}

@keyframes wappenSway{
  0%   { transform: translateY(0) rotate(-0.7deg); }
  50%  { transform: translateY(1px) rotate(0.7deg); }
  100% { transform: translateY(0) rotate(-0.7deg); }
}

/* Augen: Sichtbarkeit (Blinzeln via JS) */
#eyesOpen{ opacity: 1; }
#eyesClosed{ opacity: 0; }

.eyeClosed{ opacity: 1 !important; }
.eyeOpenHidden{ opacity: 0 !important; }

/* Mund: Default nur "zu" */
#mouthOpen{ opacity: 0; }
#mouthHalf{ opacity: 0; }
#mouthClosed{ opacity: 1; }

/* Mund Zustände (werden per JS auf .sceneLayers gesetzt) */
.sceneLayers.mouth-zu   #mouthClosed{ opacity: 1; }
.sceneLayers.mouth-zu   #mouthHalf,
.sceneLayers.mouth-zu   #mouthOpen{ opacity: 0; }

.sceneLayers.mouth-halb #mouthHalf{ opacity: 1; }
.sceneLayers.mouth-halb #mouthClosed,
.sceneLayers.mouth-halb #mouthOpen{ opacity: 0; }

.sceneLayers.mouth-auf  #mouthOpen{ opacity: 1; }
.sceneLayers.mouth-auf  #mouthHalf,
.sceneLayers.mouth-auf  #mouthClosed{ opacity: 0; }

/* ======================================================
   Mobile: Bild oben, Text unten
   ====================================================== */

@media (max-width: 900px){
  html, body{ overflow: hidden; }

  .app{
    flex-direction: column;
  }

  .stage{
    flex: 0 0 auto;
    width: 100%;
    max-width: none;
    height: 58svh;
    height: 58dvh;
  }

  .chronicle{
    width: 100%;
    height: auto;
    flex: 1 1 auto;
    min-height: 0;
  }

  .date{ font-size: 24px; }
  .text{ font-size: 16px; }

  /* Mobile: etwas ruhiger */
  img[src*="wappen"]{ animation-duration: 8.5s; }
  img[src*="hand"]{ animation-duration: 4.6s; }
  img[src*="kl-storch"]{ animation-duration: 7.2s; }
}

/* Mobile Kopfzeile: Buttons + Balken passen sauber */
@media (max-width: 520px){
  .metaRow{
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .metaRight{
    width: 100%;
    justify-content: space-between;
    gap: 8px;
    margin-top: 6px;
  }

  .metaTimer{
    width: 46%;
    min-width: 120px;
  }
}
