/* ============================================================
   diagram-lightbox.css v2 — Pan + Zoom Lightbox (MERIDIAN DUAL v2)
   Verankert 2026-05-25 spät · Customer kann atomar zoomen + pannen
============================================================ */

/* ─── Wrapper um <img> herum ─────────────────────────────── */
.diag-zoom-wrap {
  position: relative;
  display: inline-block;
  line-height: 0;
}
.diag-zoom-wrap > img {
  transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.diag-zoom-wrap > img:hover,
.diag-zoom-wrap > img:focus-visible {
  opacity: 0.92;
  outline: none;
}
.diag-zoom-wrap > img:focus-visible {
  box-shadow: 0 0 0 3px rgba(232, 162, 0, 0.55);
}

/* ─── + Icon (Hint auf Diagramm) ─────────────────────────── */
.diag-zoom-hint {
  position: absolute;
  bottom: 12px;
  right: 12px;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 14, 28, 0.78);
  border: 1.5px solid rgba(232, 162, 0, 0.55);
  border-radius: 50%;
  color: #E8A200;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.88);
  transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 2;
}
.diag-zoom-wrap:hover .diag-zoom-hint,
.diag-zoom-wrap:focus-within .diag-zoom-hint {
  opacity: 1;
  transform: scale(1);
}

/* Mobile: Hint immer sichtbar */
@media (hover: none), (pointer: coarse) {
  .diag-zoom-hint {
    opacity: 0.88;
    transform: scale(1);
  }
}

/* ─── Lightbox-Modal ──────────────────────────────────────── */
.diag-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(6, 14, 28, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: stretch;
  opacity: 0;
  transition: opacity 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}
.diag-lightbox[hidden] {
  display: none;
}
.diag-lightbox.is-open {
  opacity: 1;
}

/* ─── Stage (umschließt Canvas) ──────────────────────────── */
.diag-lightbox-stage {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: grab;
  /* Touch-Action: erlaubt Pan + Pinch, deaktiviert nativen browser-zoom */
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.diag-lightbox.is-dragging .diag-lightbox-stage {
  cursor: grabbing;
}

/* ─── Canvas (panbares + zoombares Container) ────────────── */
.diag-lightbox-canvas {
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: center center;
  /* Achtung: KEIN will-change:transform — erzeugt GPU-Compositing-Layer
     der SVG als Bitmap rastert. Vector-Rendering nur mit 2D-Transform
     ohne Layer-Promotion. */
}

/* Bild (Raster-Fallback PNG/JPG/WebP) */
.diag-lightbox-img {
  max-width: 96vw;
  max-height: 80vh;
  width: auto;
  height: auto;
  object-fit: contain;
  background: rgba(15, 32, 64, 0.4);
  border: 1px solid rgba(232, 162, 0, 0.20);
  border-radius: 12px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.65),
              0 0 50px rgba(232, 162, 0, 0.08);
  pointer-events: none;
  -webkit-user-drag: none;
}
.diag-lightbox-img[hidden] { display: none !important; }

/* Vector-Mode (SVG-Inline für vector-scharfes Zoom) */
.diag-lightbox-vector {
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.diag-lightbox-vector[hidden] { display: none !important; }
.diag-lightbox-vector > svg {
  background: rgba(15, 32, 64, 0.4);
  border: 1px solid rgba(232, 162, 0, 0.20);
  border-radius: 12px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.65),
              0 0 50px rgba(232, 162, 0, 0.08);
  /* Vector-scharfes Rendering bei jedem Zoom-Level */
  shape-rendering: geometricPrecision;
  text-rendering: geometricPrecision;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  display: block;
  overflow: visible;
  /* KEIN backface-visibility hidden / KEIN will-change — würde Layer-Promotion
     erzwingen und zu Bitmap-Caching führen. Browser muss bei jedem Frame
     das SVG vector-neu rendern. */
}

/* ─── Toolbar (unten, schwebend) ─────────────────────────── */
.diag-lightbox-toolbar {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(6, 14, 28, 0.92);
  border: 1px solid rgba(232, 162, 0, 0.32);
  border-radius: 100px;
  padding: 6px 10px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  z-index: 3;
}
.diag-lightbox-toolbar button {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 50%;
  color: #EEF2FF;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, color 0.18s, transform 0.15s;
  padding: 0;
}
.diag-lightbox-toolbar button:hover,
.diag-lightbox-toolbar button:focus-visible {
  background: rgba(232, 162, 0, 0.15);
  border-color: rgba(232, 162, 0, 0.55);
  color: #E8A200;
  outline: none;
}
.diag-lightbox-toolbar button:focus-visible {
  box-shadow: 0 0 0 3px rgba(232, 162, 0, 0.35);
}
.diag-lightbox-toolbar button:active {
  transform: scale(0.94);
}
.diag-lightbox-toolbar button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Zoom-Level-Indikator */
.diag-lightbox-zoomlevel {
  display: inline-block;
  min-width: 64px;
  text-align: center;
  font-family: 'JetBrains Mono', monospace, sans-serif;
  font-size: 0.84rem;
  font-weight: 600;
  color: #E8A200;
  letter-spacing: 0.04em;
  padding: 0 6px;
  user-select: none;
}

/* ─── Caption (Alt-Text als beschreibung) ────────────────── */
.diag-lightbox-caption {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 86vw;
  font-family: 'Inter', sans-serif;
  font-size: 0.84rem;
  line-height: 1.5;
  color: #B4C4E0;
  text-align: center;
  margin: 0;
  padding: 8px 18px;
  background: rgba(6, 14, 28, 0.75);
  border: 1px solid rgba(232, 162, 0, 0.18);
  border-radius: 100px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  pointer-events: none;
  z-index: 3;
}

/* ─── Hint (Bedienungs-Hinweis, unten) ───────────────────── */
.diag-lightbox-hint {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Inter', sans-serif;
  font-size: 0.76rem;
  color: rgba(180, 196, 224, 0.6);
  letter-spacing: 0.02em;
  pointer-events: none;
  z-index: 2;
  text-align: center;
  white-space: nowrap;
}
.diag-lightbox-hint .hint-desktop { display: inline; }
.diag-lightbox-hint .hint-mobile { display: none; }
@media (hover: none), (pointer: coarse) {
  .diag-lightbox-hint .hint-desktop { display: none; }
  .diag-lightbox-hint .hint-mobile { display: inline; }
}

/* ─── Close-Button (top-right) ───────────────────────────── */
.diag-lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 48px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 14, 28, 0.85);
  border: 1.5px solid rgba(232, 162, 0, 0.42);
  border-radius: 50%;
  color: #EEF2FF;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.2s;
  padding: 0;
  z-index: 4;
}
.diag-lightbox-close:hover,
.diag-lightbox-close:focus-visible {
  background: rgba(232, 162, 0, 0.15);
  border-color: #E8A200;
  color: #E8A200;
  outline: none;
  transform: scale(1.06);
}
.diag-lightbox-close:focus-visible {
  box-shadow: 0 0 0 3px rgba(232, 162, 0, 0.4);
}

/* ─── Body-Scroll-Lock ──────────────────────────────────── */
body.diag-lightbox-locked {
  overflow: hidden;
  position: relative;
}

/* ─── Mobile-Adjustments ─────────────────────────────────── */
@media (max-width: 600px) {
  .diag-lightbox-close {
    width: 42px;
    height: 42px;
    top: 10px;
    right: 10px;
  }
  .diag-lightbox-img {
    max-width: 96vw;
    max-height: 70vh;
    border-radius: 8px;
  }
  .diag-lightbox-caption {
    font-size: 0.74rem;
    top: 64px;
    padding: 6px 14px;
    max-width: 92vw;
  }
  .diag-lightbox-toolbar {
    bottom: 14px;
    padding: 5px 8px;
    gap: 4px;
  }
  .diag-lightbox-toolbar button {
    width: 36px;
    height: 36px;
  }
  .diag-lightbox-zoomlevel {
    min-width: 54px;
    font-size: 0.78rem;
  }
  .diag-lightbox-hint {
    bottom: 64px;
    font-size: 0.7rem;
    max-width: 90vw;
    white-space: normal;
    line-height: 1.4;
  }
  .diag-zoom-hint {
    width: 34px;
    height: 34px;
    bottom: 8px;
    right: 8px;
  }
}

/* ─── Reduce-Motion-Respekt ──────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .diag-zoom-wrap > img,
  .diag-lightbox,
  .diag-zoom-hint,
  .diag-lightbox-close,
  .diag-lightbox-toolbar button,
  .diag-lightbox-canvas {
    transition: none !important;
  }
}
