/* ==========================================================================
   Bilder-Raster & Polaroid-Karten (Haupt-Galerie)
   ========================================================================== */
.gallery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 40px 24px;
  margin-top: 45px;
  width: 100%;
}

.shot {
  margin: 0;
  background: #ffffff;
  padding: 12px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1), box-shadow 0.4s ease;
}

/* Dynamische Rotationen für alle Elemente */
.shot:nth-child(4n+1) { transform: rotate(-1.7deg); }
.shot:nth-child(4n+2) { transform: rotate(1.6deg); }
.shot:nth-child(4n+3) { transform: rotate(-0.8deg); }
.shot:nth-child(4n+4) { transform: rotate(1deg); }

.shot:hover {
  transform: translateY(-8px) scale(1.01) rotate(0deg) !important;
  box-shadow: 0 30px 70px rgba(67, 59, 48, 0.2);
}

/* Das erste (sichtbare) Hauptbild einer Kategorie */
.shot img {
  display: block;
  width: 100%;
  height: 360px;
  object-fit: cover;
}

.shot figcaption {
  padding: 12px 7px 3px;
  font: 500 24px/1.2 "Caveat", cursive;
  color: var(--ink);
  text-align: center;
}

/* ==========================================================================
   FEHLENDE REGEL: Versteckte Zusatzbilder im Raster rigoros ausblenden
   ========================================================================== */
.gallery .shot img.hidden-image,
.shot img.hidden-image {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  height: 0 !important;
  width: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
}

/* ==========================================================================
   Variables Lightbox-Design (HTML5 Dialog) - Mobile & Desktop Fix
   ========================================================================== */
dialog#lightbox {
  /* Behebt den Mobile-Bug: Standard-Browser-Styles komplett überschreiben */
  all: unset;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);

  /* Layout-Verhalten für Mobilgeräte */
  display: none;
  width: min(600px, 85vw); /* Verhindert, dass das Bild auf Handys ausbricht */
  height: auto;
  max-height: 80vh;
  z-index: 1000;
  box-sizing: border-box;
}

/* Wenn der Dialog mittels .showModal() aktiv ist, erzwinge display: block */
dialog#lightbox[open] {
  display: block;
}

/* Der abgedunkelte Hintergrund */
dialog#lightbox::backdrop {
  background: rgba(24, 23, 20, 0.92);
  backdrop-filter: blur(5px);
}

/* Das eigentliche Bild in der Lightbox */
dialog#lightbox img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 75vh; /* Garantiert Platz für Schließen-X und Pfeile */
  object-fit: contain;
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.6);
  border-radius: 4px;
}

/* Schließen-Button oben rechts */
dialog#lightbox .close {
  position: absolute;
  top: -45px;
  right: 0;
  color: #ffffff;
  font-size: 42px;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  transition: transform 0.2s ease;
}

dialog#lightbox .close:hover {
  transform: scale(1.1);
}

/* Formatierung der Navigationspfeile im Dialog */
dialog#lightbox .nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(4px);
  color: #ffffff;
  border: none;
  font-size: 24px;
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.2s, transform 0.2s;
  user-select: none;
  z-index: 1110;
}

dialog#lightbox .nav-btn:hover {
  background: rgba(255, 255, 255, 0.4);
  transform: translateY(-50%) scale(1.05);
}

dialog#lightbox .prev { left: -65px; }
dialog#lightbox .next { right: -65px; }

/* ==========================================================================
   Responsive Optimierungen (Speziell für Handys)
   ========================================================================== */
@media (max-width: 768px) {
  .shot img { height: 300px; }

  /* Auf Mobilgeräten schieben wir die Pfeile leicht ins Bild, damit sie nicht außerhalb des Displays liegen */
  dialog#lightbox {
    width: 90vw;
  }
  dialog#lightbox .prev { left: 10px; }
  dialog#lightbox .next { right: 10px; }
  dialog#lightbox .close { top: -40px; right: 5px; }
}

@media (max-width: 650px) {
  .gallery { grid-template-columns: 1fr; gap: 32px; }
  .shot { max-width: 450px; margin: 0 auto; }
}
