.gallery {
    display: grid;
    grid-gap: 10px;
    position: relative;
    width: 100%;
}

.gallery.grid-1 {
    grid-template-columns: 1fr;
}
.gallery.grid-1 figure a{
    height: 30em !important;
    padding-bottom: 0 !important;
}

.gallery.grid-2 {
    grid-template-columns: 1.5fr .5fr;
}

.gallery.grid-3 {
    grid-template-columns: 1fr .5fr .5fr;
}

.gallery.grid-4 {
    grid-template-columns: 1fr 1fr .5fr .5fr;
}

.gallery.grid-5 {
    grid-template-columns: 1fr .5fr .5fr;
}


.gallery figure{
    position:relative; 
    display: block;
    margin: 0;
    padding: 0
}


.gallery figure img {
    height: 100%;
    left: 0;
    object-fit: cover;
    position: absolute;
    top: 0;
    width: 100%
}

.gallery.grid-5 figure:first-child {
    grid-row: span 2
}

.gallery figure a {
    display: block;
    height: 100%;
    overflow: hidden;
    padding-bottom: 80%;
    position: relative;
    width: 100%
}

  
.gallery figure .overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: bold;
  opacity: 0;
  transition: opacity 0.3s;
}

  
  .gallery figure:hover .overlay {
    opacity: 1;
  }


  /* Disable zoom effect for figures beyond the 5th */
.gallery figure:nth-child(n+6) {
    transition: none;
}

.gallery figure:nth-child(n+6) img {
    transition: none;
}
/* .gallery {
    display: flex;
    flex-wrap: wrap;
}

.gallery figure {
    margin: 5px;
    flex: 1 0 21%; 
}

.gallery img {
    width: 100%;
    height: auto;
    display: block;
} */