/* Stable grid instead of columns */
.masonry-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
  }
  
  /* Each item is a card */
  .masonry-item {
    position: relative;
    overflow: hidden;
    border-radius: 0.5rem;
  }
  
  /* Images reserve space with aspect-ratio so layout doesn't jump */
  .masonry-item .gallery-img {
    width: 100%;
    display: block;
    aspect-ratio: 4 / 3;    /* adjust to taste: 3/2, 16/9, etc. */
    object-fit: cover;       /* crop nicely, no stretching */
    opacity: 0;
    transition: opacity 0.3s ease;
  }
  
  /* After load */
  .masonry-item .gallery-img.loaded {
    opacity: 1;
  }
  
  .download-icon {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 14px;
    text-decoration: none;
    opacity: 0;
    transition: opacity 0.2s ease;
  }
  
  .masonry-item:hover .download-icon {
    opacity: 1;
  }
  
  .download-icon i {
    pointer-events: none;
  }