/* Bildlupe — anklickbare Galeriebilder, gross dargestellt.
   Geteilter Baustein wie fake-interaction.*, scroll-reveal.* und ai-hinweis.css.

   Einbau:
   1) Am Raster  data-galerie  setzen.
   2) Eintraege sind <figure>-Elemente — oder beliebige Karten mit
      data-galerie-eintrag (Titel kommt dann aus der ersten Ueberschrift).
   3) Jedes Bild in  <span class="ai-bild"> … </span>  wickeln (KI-Hinweis).
   4) lightbox.css und lightbox.js einbinden.

   Verwendet in: handwerk (figure), fotografin (article-Karten).

   Den Knopf um das Bild baut das Skript. Ohne JavaScript bleibt das Raster ein
   normales Bildraster — nichts sieht klickbar aus, was nicht klickbar ist.

   Die Beschriftung kommt aus <figcaption>, der Alternativtext aus dem <img>.

   Farben kommen aus der jeweiligen Demo, damit die Lupe zur Seite passt:
     --lupe-grund     Hintergrund hinter dem Bild
     --lupe-schrift   Beschriftung
     --lupe-akzent    Umrandung bei Tastaturfokus                               */

:root {
  --lupe-grund: rgba(18, 13, 9, 0.94);
  --lupe-schrift: #fdfaf6;
  --lupe-akzent: #ffffff;
}

/* Auslöser im Raster */
.galerie__knopf {
  display: block;
  width: 100%;
  padding: 0;
  border: none;
  background: none;
  cursor: zoom-in;
  font: inherit;
  color: inherit;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
}

.galerie__knopf img {
  display: block;
  width: 100%;
  transition: transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

@media (hover: hover) {
  .galerie__knopf:hover img { transform: scale(1.05); }
  .galerie__knopf:hover .galerie__zeichen { opacity: 1; transform: none; }
}

/* Kleines Lupenzeichen — macht ohne Worte sichtbar, dass hier etwas passiert */
.galerie__zeichen {
  position: absolute;
  left: 10px;
  top: 10px;
  z-index: 2;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(18, 13, 9, 0.72);
  color: #fff;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}
.galerie__zeichen svg { width: 17px; height: 17px; display: block; }

/* Bei Tastaturbedienung gibt es kein Hover — dann dauerhaft zeigen */
.galerie__knopf:focus-visible { outline: 3px solid var(--lupe-akzent); outline-offset: 3px; }
.galerie__knopf:focus-visible .galerie__zeichen { opacity: 1; transform: none; }

/* Die Lupe selbst */
.lupe {
  position: fixed;
  inset: 0;
  z-index: 1500;
  display: grid;
  place-items: center;
  padding: clamp(12px, 3vw, 40px);
}
.lupe[hidden] { display: none; }

.lupe__hintergrund {
  position: absolute;
  inset: 0;
  background: var(--lupe-grund);
  cursor: zoom-out;
  animation: lupeGrundAuf 0.25s ease;
}

.lupe__dialog {
  position: relative;
  display: flex;
  align-items: center;
  gap: clamp(6px, 2vw, 22px);
  max-width: 100%;
  animation: lupeAuf 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

.lupe__figur {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

/* Der ai-bild-Wrapper traegt hier den KI-Hinweis mit — die Kennzeichnung muss
   auch in der Grossansicht sichtbar bleiben, nicht nur im Raster. */
.lupe__bild {
  display: block;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.3);
  line-height: 0;
}
.lupe__bild img {
  display: block;
  max-width: min(1000px, 86vw);
  max-height: 74vh;
  width: auto;
  height: auto;
}

.lupe__text {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 20px;
  color: var(--lupe-schrift);
  font-size: 0.95rem;
  line-height: 1.5;
}
.lupe__zaehler { opacity: 0.72; font-size: 0.85rem; white-space: nowrap; }

.lupe__schliessen,
.lupe__pfeil {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: var(--lupe-schrift);
  cursor: pointer;
  transition: background 0.2s ease;
}
.lupe__schliessen:hover,
.lupe__pfeil:hover { background: rgba(255, 255, 255, 0.26); }

.lupe__schliessen:focus-visible,
.lupe__pfeil:focus-visible { outline: 3px solid var(--lupe-akzent); outline-offset: 3px; }

.lupe__pfeil { width: clamp(38px, 5vw, 50px); height: clamp(38px, 5vw, 50px); }
.lupe__pfeil svg { width: 20px; height: 20px; }

.lupe__schliessen {
  position: absolute;
  top: -14px;
  right: -14px;
  width: 42px;
  height: 42px;
  z-index: 3;
  background: rgba(255, 255, 255, 0.92);
  color: #1a1a1a;
}
.lupe__schliessen:hover { background: #fff; }
.lupe__schliessen svg { width: 16px; height: 16px; }

/* Wenn die Lupe offen ist, darf die Seite dahinter nicht mitscrollen */
.lupe-offen { overflow: hidden; }

@keyframes lupeGrundAuf { from { opacity: 0; } to { opacity: 1; } }
@keyframes lupeAuf {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 620px) {
  /* Auf schmalen Schirmen wandern die Pfeile unter das Bild — daneben bliebe
     fuer das Bild sonst kaum Platz. Raster statt Flex-Spalte, sonst stehen die
     beiden Pfeile uebereinander statt nebeneinander. */
  .lupe__dialog {
    display: grid;
    grid-template-columns: auto auto;
    justify-content: center;
    gap: 16px 18px;
  }
  .lupe__figur { grid-row: 1; grid-column: 1 / -1; }
  .lupe__pfeil--zurueck { grid-row: 2; grid-column: 1; }
  .lupe__pfeil--vor { grid-row: 2; grid-column: 2; }
  .lupe__bild img { max-height: 62vh; }
  .lupe__schliessen { top: -10px; right: -6px; width: 38px; height: 38px; }
}

@media (prefers-reduced-motion: reduce) {
  .galerie__knopf:hover img { transform: none; }
  .lupe__hintergrund, .lupe__dialog { animation: none; }
}
