/**
 * Content AI Suite – Writer inline images (float, size) + Lightbox
 * Für Content mit .cas-img-link / .cas-img (Marker [[IMAGE_N: links/rechts]]).
 */

.cas-img-link {
  text-decoration: none;
}

.cas-img {
  display: block;
  height: auto;
  border-radius: 12px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

.cas-img-left {
  float: left;
  margin: 0.2em 1em 0.8em 0;
  width: 22%;
  max-width: 220px;
}

.cas-img-right {
  float: right;
  margin: 0.2em 0 0.8em 1em;
  width: 22%;
  max-width: 220px;
}

@media (max-width: 700px) {
  .cas-img-left,
  .cas-img-right {
    float: none;
    width: 100%;
    max-width: 100%;
    margin: 0 0 1em 0;
  }
}

/* --- Galerie (Restbilder nach Inline): 3 Spalten, quadratische Kacheln (1:1 crop) --- */
.cas-gallery,
.cas-writer-gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 25px;
}

.cas-writer-gallery__item {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 12px;
}

.cas-writer-gallery__item > a {
  position: absolute;
  inset: 0;
  display: block;
}

.cas-writer-gallery__item > a > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 12px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

/* Fallback: Galerie ohne __item (älteres Markup) */
.cas-gallery img {
  width: 100%;
  height: auto;
  border-radius: 12px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

@media (max-width: 900px) {
  .cas-writer-gallery {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 520px) {
  .cas-writer-gallery {
    grid-template-columns: 1fr;
  }
}

/* --- Lightbox --- */
.cas-lightbox {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 999999;
}

.cas-lightbox.is-open {
  display: block;
}

.cas-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
}

.cas-lightbox-dialog {
  position: relative;
  max-width: min(92vw, 1100px);
  max-height: 88vh;
  margin: 6vh auto 0 auto;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.cas-lightbox-img {
  max-width: 92vw;
  max-height: 88vh;
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  background: #fff;
}

.cas-lightbox-close {
  position: absolute;
  top: -14px;
  right: -14px;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 0;
  cursor: pointer;
  font-size: 26px;
  line-height: 38px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  background: #fff;
  color: #1d2327;
}

.cas-lightbox-close:hover {
  background: #f0f0f1;
}

/* Prev/Next Navigation */
.cas-lightbox-prev,
.cas-lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.9);
  color: #1d2327;
  font-size: 24px;
  line-height: 48px;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  z-index: 10;
}

.cas-lightbox-prev:hover,
.cas-lightbox-next:hover {
  background: #fff;
}

.cas-lightbox-prev {
  left: 16px;
}

.cas-lightbox-next {
  right: 16px;
}

.cas-lightbox-prev:disabled,
.cas-lightbox-next:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Copy deterrent: kein Text/Bild-Auswahl im Overlay */
.cas-lightbox {
  user-select: none;
}
