.block-gallery h2 { margin-bottom: 16px; }
.block-gallery .gallery-description { margin-bottom: 24px; max-width: 800px; }
.block-gallery .gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    align-items: stretch;   /* alle Kacheln einer Zeile gleich hoch */
}
.block-gallery .gallery-item {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform 0.3s ease;
}
.block-gallery .gallery-item:hover { transform: scale(1.03); }

/* Alle Kacheln einer Zeile werden gleich hoch (auch bei unterschiedlich langen
   Bildunterschriften) — die Kachel ist ein Flex-Container, der Bildbereich hat
   eine feste Höhe, die Bildunterschrift füllt den Rest. */
.block-gallery .gallery-item {
    display: flex;
    flex-direction: column;
    height: 100%;
}
.block-gallery .gallery-item > a,
.block-gallery .gallery-item > img {
    flex: 0 0 auto;
}

/* Zugeschnitten: das Bild füllt den Bildbereich und wird an den Rändern beschnitten. */
.block-gallery .gallery-grid.fit-cover .gallery-item img {
    width: 100%; height: 220px; object-fit: cover; display: block;
}

/* Vollständig: das ganze Bild bleibt sichtbar, nichts wird abgeschnitten.
   Der Bildbereich behält dieselbe feste Höhe wie bei "Zugeschnitten", damit das
   Layout gleichmäßig bleibt — das Bild wird darin eingepasst. Je nach
   Seitenverhältnis entstehen dabei helle Ränder. */
.block-gallery .gallery-grid.fit-contain .gallery-item img {
    width: 100%; height: 220px; object-fit: contain; display: block;
    background: #fff;
    padding: 8px;
}

/* Fallback für Altbestände ohne fit-Klasse */
.block-gallery .gallery-grid:not(.fit-cover):not(.fit-contain) .gallery-item img {
    width: 100%; height: 220px; object-fit: cover; display: block;
}
.block-gallery figcaption {
    padding: 8px 12px;
    font-size: 0.9rem;
    color: var(--text-medium);
    text-align: center;
    flex: 1 0 auto;   /* füllt die Resthöhe → gleich hohe Kacheln */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Lightbox */
.lightbox-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.92);
    display: none;
    align-items: center; justify-content: center;
    z-index: 9999;
}
.lightbox-overlay.show { display: flex; }
.lightbox-overlay img {
    max-width: 90vw; max-height: 85vh;
    border-radius: var(--radius-sm);
}
.lightbox-overlay .lightbox-caption {
    position: absolute; bottom: 30px; left: 0; right: 0;
    text-align: center; color: white; font-size: 1rem;
}
.lightbox-overlay .lightbox-close {
    position: absolute; top: 20px; right: 30px;
    background: none; border: none;
    color: white; font-size: 2.5rem; cursor: pointer;
}

/* Verlinkte Bildunterschrift */
.block-gallery .gallery-caption-link {
    color: var(--brand-accent, var(--brand-primary));
    font-weight: 600;
    text-decoration: none;
}
.block-gallery .gallery-caption-link:hover { text-decoration: underline; }

/* Bild ist verlinkt (nur wenn die Lightbox deaktiviert ist) */
.block-gallery .gallery-image-link { display: block; }
