/* ===========================
   OVERLAY (Modal) + GALLERY
   =========================== */

:root{
  --overlay-z: 9999;
  --overlay-bg: rgba(0,0,0,0.55);
  --overlay-radius: 16px;
  --overlay-pad: 1.2rem;
  --overlay-maxw: 980px;

  /* Content width = Bild/Text-Spalte */
  --overlay-contentw: 760px;
}

/* prevent background scroll */
.no-scroll { overflow: hidden; }

.overlay{
  position: fixed;
  inset: 0;
  z-index: var(--overlay-z);
  display: none;
}

.overlay.is-open{ display: block; }

.overlay__backdrop{
  position: absolute;
  inset: 0;
  background: var(--overlay-bg);
}

/* Panel (Dialog) */
.overlay__panel{
  position: relative;
  left: 50%;
  top: 3vh;
  transform: translateX(-50%);
  width: min(calc(var(--overlay-contentw) + (2 * var(--overlay-pad))), 92vw);
  max-height: 94vh;

  /* IMPORTANT: panel itself should NOT scroll, so close button stays put */
  overflow: visible;

  background: #fff;
  border-radius: var(--overlay-radius);
  padding: var(--overlay-pad);
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}

/* Close button (always floating inside panel) */
.overlay__close{
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,0.12);
  background: #fff;
  cursor: pointer;
  font-size: 1.8rem;
  line-height: 1;
  display: grid;
  place-items: center;
  z-index: 50;
}

/* Content column: header + text + gallery share same width */
.overlay__content{
  max-width: var(--overlay-contentw);
  margin: 0 auto;

  /* IMPORTANT: content scrolls, not panel */
  max-height: calc(94vh - (2 * var(--overlay-pad)));
  overflow: auto;

  padding-top: 0.2rem;
}

/* ===========================
   HEADER + TEXT
   =========================== */

.overlay__header{
  margin-bottom: 0.6rem;
}

.overlay__header h2{
  margin: 0 0 0.35rem 0;
  text-align: center;
  position: relative;
}

.overlay__header h2::after{
  content: "";
  display: block;
  width: 3rem;
  height: 3px;
  background: #c40000;
  margin: 0.4rem auto 0;
  border-radius: 999px;
}

.overlay__header .muted{
  text-align: center;
  margin-bottom: 0.6rem;
}

.overlay__text{
  line-height: 1.55;
  text-align: justify;
  text-justify: inter-word;
  hyphens: auto;
}

.overlay__text p{
  margin-top: 0.7rem;
  margin-bottom: 0.9rem;
}

/* ===========================
   GALLERY / SLIDER
   Buttons always below image
   =========================== */

.overlay__gallery{
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

/* Frame defines constant ratio/height */
.overlay__frame{
  width: 100%;
  min-width: 0;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(0,0,0,0.04);
  aspect-ratio: 5 / 3;

  /* swipe friendly */
  touch-action: pan-y;
}

/* Displayed image */
.overlay__img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  display: block;
  cursor: zoom-in;
}

/* Controls row (prev ••• next) */
.overlay__controls{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin-top: 0.1rem;
}

.overlay__nav{
  height: 48px;
  width: 48px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,0.12);
  background: #fff;
  cursor: pointer;
  font-size: 2rem;
  line-height: 1;
  display: grid;
  place-items: center;
  user-select: none;
}

.overlay__nav:active{
  transform: translateY(1px);
}

/* Dots */
.overlay__dots{
  flex: 1 1 auto;
  display: flex;
  gap: 0.45rem;
  justify-content: center;
  padding-bottom: 0.25rem;
}

.overlay__dot{
  width: 10px;
  height: 10px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,0.22);
  background: transparent;
  cursor: pointer;
}

.overlay__dot.is-active{
  background: rgba(0,0,0,0.55);
}

/* ===========================
   LIGHTBOX (full view)
   =========================== */

.overlay__lightbox{
  position: fixed;
  inset: 0;
  z-index: calc(var(--overlay-z) + 1);
  background: rgba(0,0,0,0.75);
  display: none;
  align-items: center;
  justify-content: center;
}

.overlay__lightbox.is-open{
  display: flex;
}

.overlay__lightbox img{
  width: min(96vw, 1400px);
  height: min(92vh, 980px);
  object-fit: contain;
  background: rgba(0,0,0,0.20);
  border-radius: 12px;
  display: block;
}

/* ===========================
   Mobile tweaks
   =========================== */

@media (max-width: 640px){
  .overlay__panel{
    width: calc(100vw - 12px);
    top: 2vh;
    padding: 0.9rem;
  }

  .overlay__content{
    max-width: 100%;
    max-height: calc(94vh - (2 * 0.9rem));
    padding-top: 0.1rem;
  }

  .overlay__close{
    top: 0.4rem;
    right: 0.4rem;
  }

  .overlay__nav{
    width: 44px;
    height: 44px;
    font-size: 1.8rem;
  }

  .overlay__dot{
    width: 9px;
    height: 9px;
  }
}
