/* ===========================================================
   Bilder entdecken: Galerie und Detailansicht.
   Verwendet die Variablen und Komponenten aus style.css; nur auf /bilder/ geladen.
   Alle Bilder werden vollständig gezeigt (kein Zuschneiden, kein object-fit: cover).
   =========================================================== */

.bilder-gruppe { scroll-margin-top: 4.5rem; }

/* ---------- Raster ---------- */
.bilder-raster {
  list-style: none;
  margin: 1.6rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 2.2rem 1.6rem;
  align-items: start;
}
@media (min-width: 520px) { .bilder-raster { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 860px) { .bilder-raster { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.bild-kachel { display: block; color: var(--text); text-decoration: none; }
.bild-flaeche { display: block; background: var(--grün-blass); border-radius: 4px; overflow: hidden; }
.bild-flaeche img { width: 100%; height: auto; }
.bild-titel {
  display: block;
  margin-top: 0.7rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.12rem;
  line-height: 1.3;
  color: var(--dunkel);
}
.bild-hinweis { display: block; margin-top: 0.15rem; font-size: 0.85rem; color: #3b5964; }
.bild-kachel:hover .bild-titel,
.bild-kachel:focus-visible .bild-titel { text-decoration: underline; text-underline-offset: 3px; }
.bild-kachel:focus-visible { outline-offset: 4px; border-radius: 4px; }

/* ---------- Detailansicht (Dialog) ---------- */
body:has(dialog.bild-dialog[open]) { overflow: hidden; }

dialog.bild-dialog {
  border: 0;
  border-radius: 14px;
  padding: 0;
  width: min(1100px, 96vw);
  max-width: none;
  height: min(860px, calc(100vh - 1.5rem));
  height: min(860px, calc(100dvh - 1.5rem));
  max-height: none;
  background: var(--creme);
  color: var(--text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}
dialog.bild-dialog::backdrop { background: rgba(20, 32, 38, 0.74); }
dialog.bild-dialog[open] { display: block; }

.bild-dialog-innen { display: flex; flex-direction: column; height: 100%; }

.bild-dialog-kopf,
.bild-dialog-fuss {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.6rem 0.9rem;
  background: var(--weiss);
}
.bild-dialog-kopf { border-bottom: 1px solid var(--rand); }
.bild-dialog-fuss { border-top: 1px solid var(--rand); }
.bild-dialog-aktionen { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 0.5rem; }
.bild-dialog-position { margin: 0; font-weight: 600; font-size: 0.95rem; color: var(--dunkel); }

.bild-knopf {
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.2;
  min-height: 44px;
  padding: 0.55rem 1.1rem;
  border-radius: 30px;
  border: 2px solid var(--dunkel);
  background: var(--dunkel);
  color: var(--weiss);
  cursor: pointer;
}
.bild-knopf:hover { background: #1c2731; border-color: #1c2731; }
.bild-knopf-leise { background: transparent; color: var(--dunkel); }
.bild-knopf-leise:hover { background: var(--grün-blass); border-color: var(--dunkel); }
.bild-dialog-fuss .bild-knopf { flex: 1 1 0; max-width: 16rem; }
.bild-dialog-fuss .bild-knopf:last-child { margin-left: auto; }

.bild-dialog-inhalt {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 1rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: 1.2rem;
}
.bild-dialog-bild { margin: 0; display: flex; flex-direction: column; align-items: center; }
.bild-dialog-flaeche { width: 100%; display: flex; justify-content: center; }
.bild-dialog-flaeche picture { display: block; max-width: 100%; }
.bild-dialog-flaeche img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 52vh;
  max-height: 52dvh;
}

.bild-dialog-text h2 { margin-top: 0; font-size: clamp(1.4rem, 3vw, 1.8rem); }
.bild-dialog-text h2:focus { outline: none; }
.bild-dialog-absaetze p { font-size: 1.05rem; line-height: 1.65; }
.bild-dialog-nachweis { font-size: 0.82rem; color: #55656c; }

/* Scrollbereiche, die per Tastatur erreichbar sind */
.bild-dialog-inhalt:focus-visible,
.bild-dialog-text:focus-visible { outline: 3px solid var(--gold); outline-offset: -3px; }

@media (min-width: 800px) {
  .bild-dialog-inhalt { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); overflow: hidden; align-content: stretch; gap: 1.6rem; padding: 1.2rem 1.4rem; }
  .bild-dialog-bild { min-height: 0; justify-content: flex-start; }
  .bild-dialog-flaeche { flex: 0 1 auto; min-height: 0; }
  .bild-dialog-flaeche img { max-height: calc(100vh - 12.5rem); max-height: min(680px, calc(100dvh - 12.5rem)); }
  .bild-dialog-text { min-height: 0; overflow: auto; padding-right: 0.4rem; }
}

/* Vergrößerte Ansicht: das Bild in voller Dialogbreite, vollständig und unverzerrt, mit Scrollen */
dialog.bild-dialog.vergroessert .bild-dialog-inhalt { display: block; overflow: auto; padding: 0.6rem; }
dialog.bild-dialog.vergroessert .bild-dialog-text { display: none; }
dialog.bild-dialog.vergroessert .bild-dialog-bild { display: block; }
dialog.bild-dialog.vergroessert .bild-dialog-flaeche img { width: 100%; max-height: none; }

@media (max-width: 420px) {
  .bild-knopf { padding: 0.5rem 0.8rem; font-size: 0.88rem; }
  .bild-dialog-kopf, .bild-dialog-fuss { padding: 0.5rem 0.6rem; }
}

/* ---------- Startseite: "Ein erster Blick" ---------- */
.bild-teaser-reihe {
  list-style: none;
  margin: 1.4rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
  align-items: start;
}
.bild-teaser { display: block; color: var(--text); text-decoration: none; }
.bild-teaser .bild-titel { font-size: 0.88rem; margin-top: 0.5rem; }
.bild-teaser:hover .bild-titel,
.bild-teaser:focus-visible .bild-titel { text-decoration: underline; text-underline-offset: 3px; }
@media (min-width: 620px) {
  .bild-teaser-reihe { gap: 1.6rem; }
  .bild-teaser .bild-titel { font-size: 1.12rem; margin-top: 0.7rem; }
}

/* Überschrift nur für Screenreader */
.nur-vorlesen { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- Triptychen ---------- */
.triptychon-block + .triptychon-block { margin-top: 2.2rem; }
.triptychon-block h3 { margin-top: 1.4rem; }
.triptychon {
  list-style: none;
  margin: 0.8rem 0 0;
  padding: 0;
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
}
/* Breite im Verhältnis der Bildformate: so haben alle drei Bilder dieselbe Höhe, ohne Beschnitt */
.triptychon li { flex: var(--a, 1) 1 0; min-width: 0; }
.tri-panel { display: block; background: var(--grün-blass); border-radius: 4px; overflow: hidden; line-height: 0; }
.tri-panel img { width: 100%; height: auto; }
.tri-panel:focus-visible { outline-offset: 3px; }
.tri-hinweis { margin: 0.9rem 0 0; font-size: 0.85rem; color: #3b5964; }

/* Dialog der Triptychen: nur Bild und Blättern */
dialog.bild-dialog.tri-dialog .bild-dialog-inhalt { display: block; overflow: auto; text-align: center; }
dialog.bild-dialog.tri-dialog .bild-dialog-bild { height: 100%; }
dialog.bild-dialog.tri-dialog .bild-dialog-flaeche { height: 100%; align-items: flex-start; }
dialog.bild-dialog.tri-dialog .bild-dialog-flaeche img { max-height: calc(100vh - 12.5rem); max-height: calc(100dvh - 12.5rem); }
