/* Modul E - Bild-Viewer (Vollbild-Lightbox). Nur Tokens aus dem Block in
   index.html, keine Hex-Werte. */

/* ---- Folienbilder als anklickbar markieren ------------------------------ */

#stage .is-zoomable {
  cursor: zoom-in;
}

#stage .is-zoomable:focus-visible {
  outline: 2px solid var(--brand-color);
  outline-offset: 3px;
  border-radius: 6px;
}

html.viewer-locked,
html.viewer-locked body {
  overflow: hidden;
}

/* ---- Overlay ------------------------------------------------------------ */

.viewer-root {
  position: fixed;
  inset: 0;
  z-index: 70;
  font-family: var(--font-body);
}

.viewer-root[hidden] { display: none; }

.viewer-backdrop {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--surface-0) 82%, transparent);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  animation: viewer-fade-in 200ms ease both;
}

.viewer-dialog {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  outline: none;
  animation: viewer-rise 220ms cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

@keyframes viewer-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes viewer-rise {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

/* ---- Bildflaeche -------------------------------------------------------- */

.viewer-canvas {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
  cursor: zoom-in;
  outline: none;
}

.viewer-canvas.is-zoomed { cursor: grab; }
.viewer-canvas.is-dragging { cursor: grabbing; }

.viewer-canvas:focus-visible {
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--brand-color) 60%, transparent);
}

.viewer-media {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 92vw;
  max-height: 100%;
  transform-origin: 50% 50%;
  will-change: transform;
}

.viewer-img {
  display: block;
  max-width: 92vw;
  max-height: calc(100vh - 160px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--radius-card);
  box-shadow: 0 30px 80px color-mix(in srgb, var(--surface-0) 70%, transparent);
  -webkit-user-drag: none;
  user-select: none;
}

/* Rastergrafiken beim Hochzoomen so scharf wie moeglich halten. */
.viewer-img.is-raster { image-rendering: -webkit-optimize-contrast; }

svg.viewer-img {
  width: min(92vw, 1200px);
  height: auto;
  background: var(--surface-1);
  padding: 16px;
}

/* ---- Leiste unten ------------------------------------------------------- */

.viewer-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  padding: 14px clamp(16px, 4vw, 48px) 20px;
  /* Chrome des Viewers ist Glas: der Verlauf traegt die Lesbarkeit, der
   * Blur loest die Leiste vom Bild. */
  background: linear-gradient(to top, color-mix(in srgb, var(--surface-0) 70%, transparent), var(--glass-tint));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  backdrop-filter: blur(var(--glass-blur));
  border-top: 1px solid var(--glass-edge);
  transition: background-color var(--theme-ease), border-color var(--theme-ease);
}

.viewer-caption {
  margin: 0;
  flex: 1 1 260px;
  min-width: 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-muted);
}

.viewer-caption[hidden] { display: none; }

.viewer-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.viewer-btn {
  min-width: 34px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--glass-edge);
  border-radius: var(--radius-btn);
  background: color-mix(in srgb, var(--surface-2) 55%, var(--glass-tint));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  backdrop-filter: blur(var(--glass-blur));
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease,
              border-color var(--theme-ease), box-shadow var(--theme-ease);
}

.viewer-btn:hover:not(:disabled) {
  background: color-mix(in srgb, var(--brand-color) 22%, var(--surface-3));
  color: var(--text-primary);
}

.viewer-btn:disabled { opacity: 0.4; cursor: default; }
.viewer-btn[hidden] { display: none; }

.viewer-btn:focus-visible,
.viewer-close:focus-visible {
  outline: 2px solid var(--brand-color);
  outline-offset: 2px;
}

.viewer-count,
.viewer-zoom {
  min-width: 52px;
  text-align: center;
  font-family: var(--font-headline);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.18em;
  color: var(--text-caption);
}

.viewer-sep {
  width: 1px;
  height: 18px;
  margin: 0 4px;
  background: var(--border-ghost);
}

.viewer-close {
  position: absolute;
  top: 18px;
  right: clamp(16px, 4vw, 48px);
  width: 38px;
  height: 38px;
  border: 1px solid var(--glass-edge);
  border-radius: var(--radius-btn);
  background: color-mix(in srgb, var(--surface-2) 50%, var(--glass-tint));
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  transition: background-color 140ms ease, border-color var(--theme-ease);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

.viewer-close:hover { background: color-mix(in srgb, var(--brand-secondary) 30%, var(--surface-3)); }

/* ---- Bewegungsreduktion ------------------------------------------------- */

.viewer-root.is-static .viewer-backdrop,
.viewer-root.is-static .viewer-dialog {
  animation: none;
}

@media (prefers-reduced-motion: reduce) {
  .viewer-bar,
  .viewer-btn,
  .viewer-close { transition: none; }
}

@media (prefers-reduced-motion: reduce) {
  .viewer-backdrop,
  .viewer-dialog { animation: none; }
  .viewer-btn { transition: none; }
}

@media (max-width: 720px) {
  .viewer-bar { justify-content: center; }
  .viewer-caption { flex-basis: 100%; text-align: center; }
  .viewer-img { max-height: calc(100vh - 200px); }
}
