/* ============================================================
 * BDL Lightbox - native <dialog>, Hoch-/Querformat-faehig.
 * Ersetzt jQuery.colorbox.
 * ============================================================ */
dialog.bdl-lightbox {
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: #ffffff;
  /* Container passt sich dem Bild an (fit-content), Max-Grenzen verhindern Overflow */
  width: fit-content;
  height: fit-content;
  max-width: calc(100vw - 2rem);
  max-height: calc(100vh - 2rem);
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
  overflow: hidden;
}
dialog.bdl-lightbox::backdrop {
  background: rgba(10,20,40,.78);
  backdrop-filter: blur(2px);
}

.bdl-lightbox__inner {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 2rem);
}

.bdl-lightbox__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .6rem .9rem;
  border-bottom: 1px solid #e3e8ef;
  gap: .5rem;
  background: #f7f9fc;
  flex: 0 0 auto;
}
.bdl-lightbox__counter {
  color: #4a5a6e;
  font-size: .85rem;
  font-weight: 500;
  flex: 1 1 auto;
}
.bdl-lightbox__btn {
  width: 36px;
  height: 36px;
  background: transparent;
  border: 0;
  border-radius: 50%;
  color: #1C4F9B;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background .15s ease;
}
.bdl-lightbox__btn:hover,
.bdl-lightbox__btn:focus-visible {
  background: #E8EEF8;
  outline: none;
}
.bdl-lightbox__btn svg {
  width: 20px;
  height: 20px;
  display: block;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.bdl-lightbox__btn[disabled] { opacity: .3; cursor: default; }

.bdl-lightbox__stage {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  flex: 0 0 auto;
  overflow: hidden;
}
.bdl-lightbox__img {
  display: block;
  /* Bild bestimmt die Größe des Dialogs — Grenzen gegen Overflow */
  max-width: calc(100vw - 2rem);
  max-height: calc(100vh - 7rem); /* -7rem = Header 50 + Caption 60 + Puffer */
  width: auto;
  height: auto;
  object-fit: contain;
}

.bdl-lightbox__caption {
  padding: .8rem 1.1rem;
  color: #15293f;
  font-size: .95rem;
  background: #ffffff;
  border-top: 1px solid #e3e8ef;
  flex: 0 0 auto;
}
.bdl-lightbox__caption:empty { display: none; }

/* colorbox-Trigger-Links: Hover-Zoom-Hint, bleiben als normale Thumbnails sichtbar */
a.colorbox {
  display: inline-block;
  overflow: hidden;
  border-radius: 6px;
  transition: transform .15s ease, box-shadow .15s ease;
}
a.colorbox:hover {
  transform: scale(1.02);
  box-shadow: 0 4px 16px rgba(28,79,155,.18);
}
a.colorbox img { display: block; max-width: 100%; height: auto; }

/* Galerie-Grid fuer gemischte Formate (opt-in via .bdl-gallery) */
.bdl-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  grid-auto-rows: 180px;
  grid-auto-flow: dense;
  gap: .75rem;
  margin: 1rem 0;
}
.bdl-gallery a.colorbox,
.bdl-gallery .bdl-gallery__item {
  position: relative;
  overflow: hidden;
  border-radius: 6px;
  background: #f0f3f8;
}
.bdl-gallery a.colorbox img,
.bdl-gallery .bdl-gallery__item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
/* Hochformat: Span 2 Rows wenn Image portrait */
.bdl-gallery a.colorbox.is-portrait,
.bdl-gallery .bdl-gallery__item.is-portrait {
  grid-row: span 2;
}
.bdl-gallery a.colorbox.is-landscape-wide,
.bdl-gallery .bdl-gallery__item.is-landscape-wide {
  grid-column: span 2;
}
