/* =========================================================
   Aktions-Overlay: zeigt beim Betreten der Startseite das Plakat
   zur naechsten Veranstaltung. Markup in index.njk, Logik in /js/aktion.js.
   Zum Entfernen einer Aktion reicht es, den Block in index.njk zu loeschen.
   ========================================================= */

/* Wichtig: .aktion setzt display, deshalb muss [hidden] hier ausdruecklich
   gewinnen. Ohne diese Regel waere das Overlay trotz hidden sichtbar. */
.aktion[hidden] { display: none; }

/* Sichtbar, sobald das hidden-Attribut faellt. WICHTIG: Die Sichtbarkeit wird
   nie animiert. In einem Hintergrund-Tab laufen weder requestAnimationFrame
   noch CSS-Animationen, eine Animation bliebe auf ihrem Startwert stehen, und
   ein Overlay mit opacity 0 wuerde die ganze Seite unsichtbar blockieren.
   Animiert wird deshalb nur die Skalierung der Box (siehe .aktion__box):
   steht die still, ist das Plakat lediglich 4 % kleiner, aber voll bedienbar. */
.aktion {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(32, 24, 10, .72);
  opacity: 1;
}

/* Klicks auf die Flaeche neben dem Bild schliessen (siehe aktion.js).
   Die dritte Breite im min() koppelt die Box an die verfuegbare Hoehe
   (Plakat-Seitenverhaeltnis 1170:1638 = 0.714). Sonst wuerde das Bild im
   Querformat zwar passen, aber mit hellen Raendern links und rechts stehen.
   Feste Breite statt max-width: im Grid waere die Box sonst "shrink to fit"
   und damit von der Intrinsic-Breite der gewaehlten srcset-Variante abhaengig. */
.aktion__box {
  position: relative;
  width: min(92vw, 560px, calc((100vh - 36px) * 0.714));   /* Fallback */
  width: min(92vw, 560px, calc((100dvh - 36px) * 0.714));  /* mit dynamischer Hoehe */
  animation: aktion-box-ein .25s var(--ease);
}

.aktion__img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

/* Schliessen-Knopf: sitzt auf der oberen rechten Ecke des Plakats. */
.aktion__close {
  position: absolute;
  top: -14px;
  right: -14px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--orange);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--orange-dark), var(--shadow-sm);
  transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
.aktion__close svg { width: 20px; height: 20px; pointer-events: none; }
.aktion__close:hover { transform: translateY(-2px); box-shadow: 0 6px 0 var(--orange-dark), var(--shadow-sm); }
.aktion__close:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--orange-dark); }
/* Fokusring nur bei echter Tastaturbedienung und in Weiss statt Gelb: auf dem
   abgedunkelten Hintergrund gut sichtbar, ohne wie ein Warnhinweis zu wirken.
   Bei Mausklick zeigt der Browser dank :focus-visible gar nichts an. */
.aktion__close:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

/* Ausblenden beim Schliessen (JS entfernt das Element danach). */
.aktion.is-closing { animation: none; opacity: 0; transition: opacity .2s var(--ease); }
.aktion.is-closing .aktion__box { animation: none; }

@keyframes aktion-box-ein { from { transform: scale(.96) } to { transform: none } }

/* Auf schmalen Geraeten den Knopf nach innen holen, damit er nicht abgeschnitten wird. */
@media (max-width: 420px) {
  .aktion { padding: 12px; }
  .aktion__close { top: 6px; right: 6px; width: 40px; height: 40px; }
}

/* Solange der Dialog offen ist, nicht dahinter scrollen. */
body.aktion-offen { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
  .aktion, .aktion__box { animation: none; }
  .aktion.is-closing { transition: none; }
  .aktion__close { transition: none; }
}
