/* Galerie-Lightbox – eigenständig, unabhängig von Divi/PurgeCSS */

.fg-lb {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: none;
  background: rgba(0, 0, 0, 0.93);
  opacity: 0;
  transition: opacity 0.25s ease;
  -webkit-tap-highlight-color: transparent;
}

.fg-lb.is-open {
  display: block;
}

.fg-lb.is-visible {
  opacity: 1;
}

/* Bühne: nimmt den ganzen Screen, Bild bleibt immer zentriert.
   Kein Flex-Wrapper um das Bild – sonst löst dessen max-height:100%
   gegen eine unbestimmte Höhe auf und das Bild läuft über den Rand. */
.fg-lb__stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 76px 76px 104px;
  box-sizing: border-box;
}

.fg-lb__img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 2px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.fg-lb__img.is-loaded {
  opacity: 1;
}

.fg-lb__caption {
  position: absolute;
  left: 50%;
  bottom: calc(58px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 2;
  width: min(72ch, calc(100% - 150px));
  color: #fff;
  font-size: 15px;
  line-height: 1.4;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85);
  pointer-events: none;
}

/* Ladeindikator */
.fg-lb__spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 38px;
  height: 38px;
  margin: -19px 0 0 -19px;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: #e27401;
  border-radius: 50%;
  animation: fg-lb-spin 0.8s linear infinite;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}

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

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

/* Bedienelemente – gemeinsame Basis */
.fg-lb__btn {
  position: absolute;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  cursor: pointer;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease, opacity 0.18s ease;
}

.fg-lb__btn svg {
  width: 40%;
  height: 40%;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.fg-lb__btn:hover,
.fg-lb__btn:focus-visible {
  background: rgba(226, 116, 1, 0.92);
  border-color: rgba(255, 255, 255, 0.85);
  outline: none;
}

.fg-lb__btn:active {
  transform: scale(0.94);
}

.fg-lb__btn[disabled] {
  opacity: 0.25;
  cursor: default;
  pointer-events: none;
}

/* Schließen – gut sichtbar, oben rechts, mit Sicherheitsabstand (Notch) */
.fg-lb__close {
  top: calc(14px + env(safe-area-inset-top, 0px));
  right: calc(14px + env(safe-area-inset-right, 0px));
  width: 52px;
  height: 52px;
  background: rgba(0, 0, 0, 0.72);
  border-color: rgba(255, 255, 255, 0.55);
}

.fg-lb__close svg {
  width: 44%;
  height: 44%;
  stroke-width: 2.6;
}

/* Vor / Zurück */
.fg-lb__nav {
  top: 50%;
  width: 56px;
  height: 56px;
  transform: translateY(-50%);
}

.fg-lb__nav:active {
  transform: translateY(-50%) scale(0.94);
}

.fg-lb__prev {
  left: 16px;
}

.fg-lb__next {
  right: 16px;
}

/* Zähler */
.fg-lb__counter {
  position: absolute;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 2;
  padding: 7px 16px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  white-space: nowrap;
  pointer-events: none;
}

/* Tablet */
@media (max-width: 980px) {
  .fg-lb__stage {
    padding: 70px 20px 108px;
  }
}

/* Handy: Pfeile nach unten neben den Zähler, damit sie das Bild nicht überdecken */
@media (max-width: 767px) {
  .fg-lb__stage {
    padding: 64px 12px 140px;
  }

  .fg-lb__caption {
    bottom: calc(84px + env(safe-area-inset-bottom, 0px));
    width: calc(100% - 32px);
  }

  .fg-lb__close {
    width: 46px;
    height: 46px;
    top: calc(10px + env(safe-area-inset-top, 0px));
    right: calc(10px + env(safe-area-inset-right, 0px));
  }

  .fg-lb__nav {
    top: auto;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    transform: none;
    width: 50px;
    height: 50px;
  }

  .fg-lb__nav:active {
    transform: scale(0.94);
  }

  .fg-lb__prev {
    left: 14px;
  }

  .fg-lb__next {
    right: 14px;
  }

  .fg-lb__caption {
    font-size: 13px;
  }

  .fg-lb__counter {
    bottom: calc(26px + env(safe-area-inset-bottom, 0px));
    font-size: 13px;
    padding: 6px 14px;
  }
}

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

  .fg-lb__spinner {
    animation: none;
  }
}

/* hidden muss die display-Regeln oben schlagen */
.fg-lb[hidden],
.fg-lb [hidden] {
  display: none !important;
}

/* Seite hinter der Lightbox einfrieren */
html.fg-lb-lock,
body.fg-lb-lock {
  overflow: hidden;
}
