/* =========================================================
   Aperto – Masonry Template
   CSS-columns approach: keine JS-Abhängigkeit, läuft überall
   ========================================================= */

.masonry-gallery {
    columns: 4 220px;
    column-gap: .75rem;
    padding-bottom: 3rem;
}

.masonry-item {
    break-inside: avoid;
    margin-bottom: .75rem;
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    display: block;
    background: var(--g-border);
}

.masonry-item img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform .35s ease;
}

.masonry-item:hover img {
    transform: scale(1.03);
}

/* Overlay */
.masonry-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,.65) 0%, rgba(0,0,0,0) 40%);
    opacity: 0;
    transition: opacity .25s;
    display: flex;
    align-items: flex-end;
    padding: .75rem;
    gap: .4rem;
}

.masonry-item:hover .masonry-overlay {
    opacity: 1;
}

.masonry-caption {
    flex: 1;
    color: rgba(255,255,255,.9);
    font-size: .8rem;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Responsive columns */
@media (max-width: 1100px) { .masonry-gallery { columns: 3 200px; } }
@media (max-width: 720px)  { .masonry-gallery { columns: 2 160px; } }
@media (max-width: 420px)  { .masonry-gallery { columns: 2 140px; column-gap: .4rem; } .masonry-item { margin-bottom: .4rem; } }
