/*
 * Bildergalerie (Lightbox) – holzhautnah.de
 * Gehört zu /fileadmin/scripte/galerie.js
 * Stand: 22.10.2026 – e-presentation
 */

.lb {
  --lb-bg: rgba(18, 20, 24, 0.94);
  --lb-fg: #ffffff;
  --lb-muted: rgba(255, 255, 255, 0.72);
  --lb-btn: rgba(255, 255, 255, 0.12);
  --lb-btn-hover: rgba(255, 255, 255, 0.24);
  --lb-gap: 16px;

  position: fixed;
  inset: 0;
  z-index: 100000; /* über Cookie-Hinweis und "Nach oben"-Button */
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}
.lb[hidden] { display: none; }
.lb.is-open { opacity: 1; }

.lb__backdrop {
  position: absolute;
  inset: 0;
  background: var(--lb-bg);
}

/* ---------- Bild ---------- */

.lb__stage {
  position: relative;
  margin: 0;
  width: 100%;
  height: 100%;
  padding: 64px 76px 72px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.lb__img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  min-height: 0;
  width: auto;
  height: auto;
  object-fit: contain;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  background: rgba(255, 255, 255, 0.04);
  transition: opacity 0.2s ease;
  user-select: none;
  -webkit-user-drag: none;
}
.lb.is-loading .lb__img { opacity: 0; }

.lb__caption {
  flex: none;
  max-width: 60ch;
  color: var(--lb-muted);
  font-size: 15px;
  line-height: 1.4;
  text-align: center;
}
.lb__caption[hidden] { display: none; }

.lb__error {
  position: absolute;
  margin: 0;
  padding: 0 var(--lb-gap);
  color: var(--lb-fg);
  font-size: 16px;
  text-align: center;
}

/* ---------- Ladeanzeige ---------- */

.lb__spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: var(--lb-fg);
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
  animation: lb-spin 0.8s linear infinite;
  transition: opacity 0.1s ease; /* nach dem Laden sofort weg */
}
.lb.is-loading .lb__spinner {
  opacity: 1;
  transition: opacity 0.2s ease 0.25s; /* erst bei längerer Ladezeit sichtbar */
}
@keyframes lb-spin { to { transform: rotate(360deg); } }

/* ---------- Zähler ---------- */

.lb__counter {
  position: absolute;
  top: 0;
  left: 0;
  padding: 18px var(--lb-gap);
  color: var(--lb-muted);
  font-size: 14px;
  line-height: 20px;
  font-variant-numeric: tabular-nums;
}

/* ---------- Schaltflächen ---------- */

.lb__btn {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--lb-btn);
  color: var(--lb-fg);
  cursor: pointer;
  transition: background-color 0.15s ease;
}
.lb__btn:hover { background: var(--lb-btn-hover); }
.lb__btn:focus { outline: none; }
.lb__btn:focus-visible { outline: 2px solid var(--lb-fg); outline-offset: 2px; }
.lb__btn svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lb__close { top: 8px; right: 8px; }
.lb__prev  { left: 14px;  top: 50%; margin-top: -24px; }
.lb__next  { right: 14px; top: 50%; margin-top: -24px; }

.lb.is-single .lb__prev,
.lb.is-single .lb__next,
.lb.is-single .lb__counter { display: none; }

/* ---------- Smartphone ---------- */

@media (max-width: 640px) {
  .lb__stage { padding: 60px 8px 84px; }
  .lb__prev,
  .lb__next {
    top: auto;
    bottom: 16px;
    margin-top: 0;
  }
  .lb__prev { left: calc(50% - 60px); }
  .lb__next { right: calc(50% - 60px); }
}

/* ---------- Weniger Bewegung gewünscht ---------- */

@media (prefers-reduced-motion: reduce) {
  .lb,
  .lb__img,
  .lb__spinner { transition: none; }
  .lb__spinner { animation-duration: 2s; }
}
