/* ============================================================================
   ROTHLER PDP-Bildergalerie: Lightbox mit iOS-artigem Zoom (Stile)
----------------------------------------------------------------------------
   Gehoert zu js/rothler-pdp-lightbox.js — Anlass und Architektur stehen dort.
   Basis ist das erprobte DH-Modul (§47, 25-pdp-lightbox.css), angepasst:
   - Markenfarbe rothler-Blau #147bcb statt DH-Rot (94x in clear.css belegt)
   - Oeffnen/Schliessen mit Fade + leichtem Scale (.is-in), wie iOS Fotos
   - Klassen-Prefix rlb (rothler lightbox), kein Kundenfoto-Teil
   ALS EIGENE DATEI, nicht in custom.css: das CSS-Bundle wird mit
   max-age=1 Jahr gecacht und seine URL aendert sich nicht — eine neue Datei
   mit eigenem ?v= wirkt sofort bei allen. Rollback = Datei + Einbindung weg.
   ========================================================================= */

/* --- Sichtbares Signal an der Galerie: das Bild reagiert ------------------ */
#gallery .square-image img.product-image {
  cursor: zoom-in;
}

#gallery_wrapper {
  position: relative;
}

.rlb-gallery-zoom {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 7px 11px;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: #1f2937;
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(6px);
}

.rlb-gallery-zoom svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.rlb-gallery-zoom:hover {
  border-color: rgba(20, 123, 203, 0.4);
  color: #147bcb;
}

.rlb-gallery-zoom:focus-visible {
  outline: 2px solid #147bcb;
  outline-offset: 2px;
}

/* Auf schmalen Telefonen nur das Symbol — Text kostet dort zu viel Bildflaeche */
@media (max-width: 575.98px) {
  .rlb-gallery-zoom {
    right: 8px;
    bottom: 8px;
    min-height: 34px;
    padding: 8px;
  }

  .rlb-gallery-zoom span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

/* --- Overlay -------------------------------------------------------------- */
body.rlb-offen {
  overflow: hidden;
}

/* Chat-Knopf (fixiert unten rechts) laege sonst UEBER der Miniaturleiste.
   Nur solange die Bildansicht offen ist; existiert das Widget nicht, tut die
   Regel nichts. (Muster von DH uebernommen, dort am Live-DOM ermittelt.) */
body.rlb-offen #chatbot-widget {
  display: none !important;
}

.rlb {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  /* DECKEND: bei Teiltransparenz blieben Kopfzeile und Titel als Geisterbild
     lesbar (bei DH an den Pixeln gemessen). Die Ware soll wirken. */
  background: #0b0e13;
  overscroll-behavior: contain;
  /* KEIN touch-action:none am Overlay! Der Browser bildet die Schnittmenge
     ueber die Vorfahrenkette — ein "none" hier macht auch die Miniaturleiste
     unwischbar. Die Geste wird nur an der Buehne unterdrueckt. */
  /* Einblendung: JS setzt .is-in einen Frame nach .is-open */
  opacity: 0;
  transition: opacity 200ms ease-out;
}

.rlb.is-open {
  display: flex;
  flex-direction: column;
  align-items: stretch;      /* Fuss volle Breite — sonst shrink-to-fit */
  justify-content: flex-start;
}

.rlb.is-in {
  opacity: 1;
}

/* Bild kommt beim Oeffnen minimal groesser rein — wie das Aufblenden in der
   iOS-Fotos-App. Nur die Huelle (Wrapper-Transition), NIE das transform des
   Bilds selbst — das gehoert der Zoom-Engine. */
.rlb__stage {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 0;
  overflow: hidden;
  cursor: zoom-in;
  /* Hier — und nur hier — gehoeren die Gesten uns (Pinch, Wischen, Ziehen). */
  touch-action: none;
  transform: scale(0.96);
  transition: transform 220ms cubic-bezier(0.2, 0.8, 0.3, 1);
}

.rlb.is-in .rlb__stage {
  transform: scale(1);
}

.rlb--static,
.rlb--static .rlb__stage {
  transition: none;
  transform: none;
  opacity: 1;
}

.rlb__stage.is-zoomed {
  cursor: grab;
}

.rlb__stage.is-zoomed:active {
  cursor: grabbing;
}

.rlb__img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  transform-origin: center center;
  user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
  /* Sanftes Einblenden beim Bildwechsel; Nachbarn sind vorgeladen, sichtbar
     wird das nur auf langsamer Verbindung. transform macht das JS (rAF). */
  opacity: 1;
  transition: opacity 140ms ease-out;
}

.rlb__img.is-loading {
  opacity: 0.25;
}

.rlb--static .rlb__img {
  transition: none;
}

/* Ladeanzeige nur, wenn es wirklich dauert (JS setzt die Klasse ab 180 ms) */
.rlb__spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
  animation: rlbSpin 0.8s linear infinite;
}

.rlb__stage.is-waiting .rlb__spinner {
  opacity: 1;
}

@keyframes rlbSpin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .rlb__spinner { animation: none; }
}

/* --- Fuss: Zaehler + Miniaturleiste --------------------------------------- */
.rlb__foot {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
}

.rlb__thumbs {
  display: flex;
  gap: 8px;
  width: 100%;
  min-width: 0;
  /* Wenige Bilder mittig, viele ab links; "safe center" faellt bei Ueberlauf
     auf start zurueck. Aeltere Browser behalten die erste Zeile. */
  justify-content: flex-start;
  justify-content: safe center;
  padding: 2px 2px 6px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scroll-snap-type: x proximity;
  overscroll-behavior-x: contain;
  touch-action: pan-x;
  -webkit-overflow-scrolling: touch;
}

.rlb__thumbs::-webkit-scrollbar {
  height: 4px;
}

.rlb__thumbs::-webkit-scrollbar-thumb {
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.28);
}

.rlb__thumb {
  flex: 0 0 auto;
  width: 68px;
  height: 68px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  scroll-snap-align: center;
  overflow: hidden;
  opacity: 0.55;
  transition: opacity 140ms ease-out, border-color 140ms ease-out;
}

.rlb__thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.rlb__thumb:hover {
  opacity: 0.85;
}

.rlb__thumb.is-active {
  opacity: 1;
  border-color: #fff;
}

.rlb__thumb:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* Beim Zoomen tritt die Leiste zurueck, bleibt aber erreichbar */
.rlb.is-zoomed .rlb__thumbs {
  opacity: 0.35;
}

.rlb--static .rlb__thumb,
.rlb--static .rlb__thumbs {
  transition: none;
}

.rlb--single .rlb__thumbs {
  display: none;
}

/* --- Bedienelemente -------------------------------------------------------- */
.rlb__close,
.rlb__nav {
  position: absolute;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
  transition: background-color 140ms ease-out;
}

.rlb__close svg,
.rlb__nav svg {
  width: 22px;
  height: 22px;
}

.rlb__close:hover,
.rlb__nav:hover {
  background: rgba(255, 255, 255, 0.2);
}

.rlb__close:focus-visible,
.rlb__nav:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.rlb__close {
  top: calc(12px + env(safe-area-inset-top));
  right: calc(12px + env(safe-area-inset-right));
}

.rlb__nav--prev {
  top: 50%;
  left: calc(12px + env(safe-area-inset-left));
  transform: translateY(-50%);
}

.rlb__nav--next {
  top: 50%;
  right: calc(12px + env(safe-area-inset-right));
  transform: translateY(-50%);
}

.rlb--single .rlb__nav {
  display: none;
}

.rlb__counter {
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.rlb--single .rlb__counter {
  display: none;
}

@media (max-width: 767.98px) {
  .rlb__nav {
    width: 42px;
    height: 42px;
  }

  .rlb__nav--prev {
    left: calc(6px + env(safe-area-inset-left));
  }

  .rlb__nav--next {
    right: calc(6px + env(safe-area-inset-right));
  }

  .rlb__thumb {
    width: 60px;
    height: 60px;
  }

  .rlb__foot {
    gap: 7px;
    padding: 8px 10px calc(10px + env(safe-area-inset-bottom));
  }
}

/* Desktop: groessere Miniaturen, mehr Luft */
@media (min-width: 992px) {
  .rlb__thumb {
    width: 84px;
    height: 84px;
  }

  .rlb__foot {
    gap: 10px;
    padding: 12px 16px 18px;
  }
}
