/* Bildergalerie: Vorschaubilder und Lightbox */

/* Jede Zeile füllt die Spaltenbreite: die Bilder einer Zeile wachsen
   im Verhältnis ihrer Seitenverhältnisse (flex-grow steht im HTML). */
.gallery-row {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}

.gallery-row a {
  flex-basis: 0;
  min-width: 0;
  line-height: 0;
}

.gallery a img {
  display: block;
  width: 100%;
  height: auto;
  border: 0;
  transition: opacity 0.15s ease-in-out;
}

.gallery-hint {
  margin-top: 1em;
}

.gallery a:hover img,
.gallery a:focus-visible img {
  opacity: 0.8;
}

.gallery a:focus-visible {
  outline: 2px solid #a3195b;
  outline-offset: 2px;
}

/* Lightbox */

.lb {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  background: rgba(0, 0, 0, 0.9);
  opacity: 0;
  transition: opacity 0.2s ease-in-out;
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
}

/* Muss "display: flex" überstimmen, sonst fängt das geschlossene
   Overlay weiterhin alle Klicks der Seite ab. */
.lb[hidden] {
  display: none;
}

.lb.is-open {
  opacity: 1;
}

.lb__stage {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 3vmin;
}

.lb__img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.6);
  opacity: 1;
  transition: opacity 0.15s ease-in-out;
}

.lb.is-loading .lb__img {
  opacity: 0;
}

.lb__spinner {
  position: absolute;
  width: 38px;
  height: 38px;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  opacity: 0;
  animation: lb-spin 0.8s linear infinite;
}

.lb.is-loading .lb__spinner {
  opacity: 1;
}

@keyframes lb-spin {
  to { transform: rotate(360deg); }
}

.lb__bar {
  flex: 0 0 auto;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.9em;
  padding: 0 4vmin 1.1em;
  color: #fff;
  font-family: inherit;
  text-align: center;
}

.lb__caption {
  font-size: 1em;
}

.lb__count {
  font-size: 0.82em;
  color: rgba(255, 255, 255, 0.6);
  white-space: nowrap;
}

/* Schaltflächen */

.lb button {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.15s ease-in-out;
  -webkit-tap-highlight-color: transparent;
}

.lb button:hover,
.lb button:focus-visible {
  background: rgba(255, 255, 255, 0.22);
}

.lb button svg {
  width: 55%;
  height: 55%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lb__close {
  top: 2vmin;
  right: 2vmin;
  width: 44px;
  height: 44px;
  z-index: 2;
}

.lb__nav {
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 52px;
  z-index: 2;
}

.lb__nav--prev { left: 2vmin; }
.lb__nav--next { right: 2vmin; }

.lb__nav[hidden],
.lb__count[hidden] {
  display: none;
}

/* Mobil: Vollbild, Navigation per Wischen */

@media (max-width: 640px), (pointer: coarse) {
  .lb {
    height: 100dvh;
  }

  .lb__stage {
    padding: 0;
  }

  .lb__img {
    box-shadow: none;
  }

  /* ".lb button" ist spezifischer als ".lb__nav" – daher hier verschachtelt. */
  .lb .lb__nav {
    display: none;
  }

  .lb__bar {
    padding: 0.9em 4vmin calc(0.9em + env(safe-area-inset-bottom));
    background: rgba(0, 0, 0, 0.45);
  }

  .lb__close {
    top: calc(2vmin + env(safe-area-inset-top));
  }
}

@media (prefers-reduced-motion: reduce) {
  .lb,
  .lb__img {
    transition: none;
  }

  .lb__spinner {
    animation-duration: 2s;
  }
}
