/* §LIGHTBOX-2026-09-23 — Bild-/Video-Vorschau (ec-lightbox.js), alle Viewports.
 *
 * Muss NACH mobile-overrides.css/desktop-overrides.css laden. Deren Regeln
 * (html body.auth-ready .media-preview-overlay… !important, 0-3-2) schlägt
 * hier die ID #media-preview (1-x-x).
 *
 * Z-Index bewusst 2147483000 statt 99999: Die Mobile-Shell stapelt Ebenen bis
 * 2147482800 — mit 99999 läge die Vorschau darunter.
 *
 * Passform: Das Medium ist direktes Flex-Kind einer Fläche mit inset:0 und
 * begrenzt sich über Viewport-Einheiten — keine %-Höhen (die in der alten
 * Grid-Zeile mit Auto-Höhe wirkungslos waren und Hochformat-Bilder über den
 * Bildschirm hinauslaufen ließen). Oben/unten bleibt je 64 px + Safe-Area frei,
 * damit Schließen/Sichern das Bild nie verdecken.
 */
html body #media-preview.media-preview-overlay.active {
  position: fixed !important;
  inset: 0 !important;
  z-index: 2147483000 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
  margin: 0 !important;
  width: auto !important;
  height: auto !important;
  background: rgba(0, 0, 0, calc(.94 * var(--ec-lb-fade, 1))) !important;
  -webkit-backdrop-filter: blur(20px) !important;
  backdrop-filter: blur(20px) !important;
  overscroll-behavior: contain !important;
  animation: ec-lb-in .18s ease-out;
}
/* Bild: Gesten übernimmt ec-lightbox.js (Pinch, Pan, Wischen) — der Browser
   darf weder die Seite zoomen noch scrollen. Video behält native Bedienung. */
html body #media-preview.media-preview-overlay.active.ec-lb-image {
  touch-action: none !important;
  -webkit-user-select: none !important;
  user-select: none !important;
}
@keyframes ec-lb-in { from { opacity: 0; } to { opacity: 1; } }

html body #media-preview #media-preview-content {
  position: absolute !important;
  inset: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: auto !important;
  height: auto !important;
  max-width: none !important;
  max-height: none !important;
  padding: 0 !important;
  overflow: hidden !important;
  pointer-events: none !important;   /* Tipp daneben trifft das Overlay → schließt */
}

html body #media-preview #media-preview-content > img,
html body #media-preview #media-preview-content > video {
  display: block !important;
  flex: 0 0 auto !important;
  width: auto !important;
  height: auto !important;
  max-width: min(90vw, calc(100vw - 32px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px))) !important;
  max-height: min(85vh, calc(100vh - 128px - 2 * max(env(safe-area-inset-top, 0px), env(safe-area-inset-bottom, 0px)))) !important;
  object-fit: contain !important;
  border-radius: 12px !important;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .8) !important;
  pointer-events: auto !important;
  transform-origin: 50% 50% !important;
  will-change: transform;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
}
@supports (height: 100dvh) {
  html body #media-preview #media-preview-content > img,
  html body #media-preview #media-preview-content > video {
    max-height: min(85dvh, calc(100dvh - 128px - 2 * max(env(safe-area-inset-top, 0px), env(safe-area-inset-bottom, 0px)))) !important;
  }
}
html body #media-preview #media-preview-content > img.ec-lb-anim {
  transition: transform .22s cubic-bezier(.2, .8, .2, 1);
}
html body #media-preview.is-zoomed #media-preview-content > img {
  border-radius: 0 !important;
  box-shadow: none !important;
}

/* Bedienelemente: 44×44 (Apple-HIG-Touch-Ziel), fest an den Ecken, Safe-Area. */
html body #media-preview .media-close,
html body #media-preview .ec-lb-save {
  position: fixed !important;
  top: calc(12px + env(safe-area-inset-top, 0px)) !important;
  z-index: 2 !important;
  width: 44px !important;
  height: 44px !important;
  min-width: 44px !important;
  min-height: 44px !important;
  margin: 0 !important;
  padding: 0 !important;
  display: grid !important;
  place-items: center !important;
  border-radius: 999px !important;
  border: 1px solid rgba(255, 255, 255, .16) !important;
  background: rgba(28, 28, 32, .72) !important;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  color: #fff !important;
  font-size: 20px !important;
  line-height: 1 !important;
  cursor: pointer !important;
  pointer-events: auto !important;
  touch-action: manipulation !important;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .45) !important;
  transition: background .15s ease, transform .15s ease;
}
html body #media-preview .media-close {
  right: calc(12px + env(safe-area-inset-right, 0px)) !important;
  left: auto !important;
}
html body #media-preview .ec-lb-save {
  left: calc(12px + env(safe-area-inset-left, 0px)) !important;
  right: auto !important;
}
html body #media-preview .ec-lb-save[hidden] { display: none !important; }
html body #media-preview .ec-lb-save svg { width: 22px; height: 22px; }
html body #media-preview .media-close:hover,
html body #media-preview .ec-lb-save:hover { background: rgba(60, 60, 68, .85) !important; }
html body #media-preview .media-close:active,
html body #media-preview .ec-lb-save:active { transform: scale(.94); }
html body #media-preview .media-close:focus-visible,
html body #media-preview .ec-lb-save:focus-visible { outline: 2px solid var(--accent, #717171) !important; outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  html body #media-preview.media-preview-overlay.active { animation: none; }
  html body #media-preview #media-preview-content > img.ec-lb-anim { transition: none; }
}
