/* ═══════════════════════════════════════════════════════
   Gallery — Overview Cards + Masonry Grid + Lightbox
   Uses CSS custom properties from mainstyle.css (:root)
   ═══════════════════════════════════════════════════════ */

/* ── Overview: Card-Grid ────────────────────────────── */
.gallery-overview-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.gallery-card {
  display: flex;
  flex-direction: column;
  background: var(--color-bg-card);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: inherit;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  transition: box-shadow 0.22s ease, transform 0.22s ease;
}
.gallery-card:hover {
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.13);
  transform: translateY(-3px);
}
.gallery-card:hover .gallery-card__cover img {
  transform: scale(1.04);
}
.gallery-card:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Cover image */
.gallery-card__cover {
  position: relative;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  background: var(--color-primary);
  flex-shrink: 0;
}
.gallery-card__cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.35s ease;
}
.gallery-card__cover-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: rgba(255, 255, 255, 0.35);
}

/* Image-count badge */
.gallery-card__count {
  position: absolute;
  bottom: 0.5rem;
  right: 0.55rem;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-family: var(--font-display);
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  padding: 0.2rem 0.5rem;
  border-radius: 20px;
  line-height: 1.4;
}
.gallery-card__count::after {
  content: ' Bilder';
}

/* Card body */
.gallery-card__body {
  padding: 0.85rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1;
}
.gallery-card__title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  line-height: 1.3;
  color: var(--color-primary);
  margin: 0;
}
.gallery-card__meta {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  margin: 0;
}
.gallery-card__desc {
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--color-text-muted);
  margin-top: 0.2rem;
}

@media (max-width: 480px) {
  .gallery-overview-grid { grid-template-columns: 1fr; }
}

/* ── Single Gallery: Header ─────────────────────────── */
.gallery-breadcrumb {
  margin-bottom: 0.6rem;
}
.gallery-breadcrumb a {
  color: var(--color-primary);
  text-decoration: none;
  font-size: 0.88rem;
}
.gallery-breadcrumb a:hover { text-decoration: underline; }

.gallery-meta__sub {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-top: 0.25rem;
}
.gallery-meta__desc {
  margin-top: 0.75rem;
  font-size: 0.95rem;
  line-height: 1.6;
}

/* ── Masonry Grid ───────────────────────────────────── */
.gallery-grid {
  columns: 2;
  column-gap: 0.5rem;
  margin-top: 1.5rem;
}

.gallery-grid figure {
  display: block;
  max-width: none;
  padding: 0;
  break-inside: avoid;
  margin: 0 0 0.5rem;
  overflow: hidden;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.gallery-grid figure a {
  display: block;
  line-height: 0;
}
.gallery-grid img {
  display: block;
  width: 100%;
  height: auto;
  transition: opacity 0.18s ease;
}
.gallery-grid figure:hover img { opacity: 0.88; }

@media (max-width: 480px) {
  .gallery-grid { columns: 1; }
}

/* ── Lightbox ───────────────────────────────────────── */
#gallery-lightbox {
  border: none;
  padding: 0;
  margin: 0;
  background: rgba(0, 0, 0, 0.96);
  width: 100dvw;
  height: 100dvh;
  max-width: 100dvw;
  max-height: 100dvh;
}
#gallery-lightbox[open] {
  display: flex;
  align-items: center;
  justify-content: center;
}
#gallery-lightbox::backdrop {
  background: rgba(0, 0, 0, 0.96);
}

#lb-img {
  max-width: calc(100dvw - 130px);
  max-height: 90dvh;
  object-fit: contain;
  display: block;
  touch-action: pan-y;
}

#lb-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  color: #fff;
  font-size: 2.2rem;
  line-height: 1;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  opacity: 0.75;
  border-radius: 4px;
  transition: opacity 0.15s ease, background 0.15s ease;
}
#lb-close:hover { opacity: 1; background: rgba(255,255,255,0.1); }

#lb-prev,
#lb-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #fff;
  font-size: 3rem;
  line-height: 1;
  padding: 1rem;
  cursor: pointer;
  opacity: 0.65;
  transition: opacity 0.15s ease;
}
#lb-prev:hover,
#lb-next:hover { opacity: 1; }
#lb-prev { left: 0.25rem; }
#lb-next { right: 0.25rem; }

@media (max-width: 768px) {
  #lb-prev, #lb-next { display: none; }
  #lb-img {
    max-width: 100dvw;
    max-height: 88dvh;
    touch-action: none;
  }
}
