/* ===== Indiworx Gallery – Strict Grid ===== */
.iwx-mosaic { --gap:8px; position:relative; }
.iwx-mosaic__grid { display:grid; gap:var(--gap); }

/* Mobile: 2 Spalten, Hero volle Breite */
@media (max-width:639px){
  .iwx-mosaic__grid{ grid-template-columns:repeat(2,1fr); }
  .iwx-mosaic__item{ aspect-ratio:3/2; }
  .iwx-mosaic__item.is-hero{ grid-column:1 / -1; } /* volle Breite */
}

/* Tablet: 3 Spalten, Hero spannt 3 */
@media (min-width:640px) and (max-width:1023px){
  .iwx-mosaic__grid{ grid-template-columns:repeat(3,1fr); }
  .iwx-mosaic__item{ aspect-ratio:3/2; }
  .iwx-mosaic__item.is-hero{ grid-column:span 3; }
}

/* Desktop: 4 Spalten, Höhen kommen per JS (Hero = 3 Spalten × 3 Reihen) */
@media (min-width:1024px){
  .iwx-mosaic__grid{ grid-template-columns:repeat(4,1fr); }
  .iwx-mosaic__item{ /* keine aspect-ratio hier */ }
  .iwx-mosaic__item.is-hero{ grid-column:span 3; grid-row:span 3; }
}

/* Kacheln */
.iwx-mosaic__item{ position:relative; display:block; overflow:hidden; border:0; margin:0; padding:0; cursor: pointer;}
.iwx-mosaic__item img{ width:100%; height:100%; object-fit:cover; display:block; }
.iwx-mosaic__item.is-hidden{ display:none; }

/* +N Overlay */
.iwx-mosaic__more{
  position:absolute; inset:0; display:grid; place-items:center;
  background:rgba(0,0,0,.35); color:#fff; font:600 1rem/1.2 system-ui,-apple-system,Segoe UI,Roboto,Ubuntu;
}


/* Immer ganz oben, über allem */
.iwx-lightbox[hidden] { display: none !important; }
.iwx-lightbox {
  position: fixed;
  inset: 0;
  z-index: 2147483647; /* sehr hoch, über Header/Sticky-UI */
  display: grid;
  place-items: center;
}

/* Layering innerhalb der Lightbox */
.iwx-lightbox__backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.78);
  z-index: 0;
}
.iwx-lightbox__figure {
  position: relative;
  z-index: 1;
  margin: 0;
  /* Seitenabstand, damit Controls nicht unter Header kleben */
  padding: clamp(8px, 2vmin, 16px);
  background: transparent;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: .5rem;

  /* Größenlimits – nichts unter/überlappt mehr */
  max-width: min(96vw, 1400px);
  max-height: calc(100vh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
}

/* Bild skaliert IMMER in die verfügbare Höhe, ohne Controls zu verdecken */
.iwx-lightbox__img {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 8rem); /* Platz für Header/Controls */
  object-fit: contain;
  width: auto; height: auto;
  background: #111;
  border-radius: 0;
}

/* Close und Pfeile IMMER innerhalb des Figures, mit hohem z-index */
.iwx-lightbox__close {
  position: absolute;
  top: 1rem;             
  right: 1rem;
  width: 42px; 
  height: 42px;
  z-index: 2;
  background: rgba(0,0,0,.6);
  font-size: 2rem; line-height: 1;
  border: 0; color: #fff; cursor: pointer;
}

.iwx-lightbox__nav {
  position: absolute;
  top: 50%; transform: translateY(-50%);
  z-index: 2;
  border: 0; background: rgba(0,0,0,.6); color: #fff;
  width: 40px; height: 40px; cursor: pointer; 
  display: grid; font-size: 2rem; line-height: 1;
}
.iwx-lightbox__prev { left: 1.5rem; }
.iwx-lightbox__next { right: 1.5rem; }

/* Tastaturfokus sichtbar */
.iwx-lightbox__nav:focus-visible,
.iwx-lightbox__close:focus-visible { outline: 2px solid #0ea5e9; outline-offset: 2px; }

/* Caption */
.iwx-lightbox__caption {
  color: #e5e7eb; text-align: center; font-size: .95rem;
  z-index: 1;
}

/* Kleinere Viewports: etwas mehr Innenabstand einplanen */
@media (max-width: 1023px){
  .iwx-lightbox__img { max-height: calc(100vh - 7rem); }
}

/* ===== Lightbox transitions ===== */
.iwx-lightbox {
  opacity: 0;
  transform: scale(.985);
  transition: opacity .3s ease, transform .3s ease;
}
.iwx-lightbox.is-open {
  opacity: 1;
  transform: scale(1);
}
.iwx-lightbox__backdrop {
  opacity: 0;
  transition: opacity .3s ease;
}
.iwx-lightbox.is-open .iwx-lightbox__backdrop {
  opacity: 1;
}

/* Image cross-fade on swap */
.iwx-lightbox__img {
  transition: opacity .25s ease;
  opacity: 1;
}
.iwx-lightbox__img.is-fading {
  opacity: 0;
}
