.image-overlay-section {
  position: relative;
  display: inline-block; /* Makes sure the overlay is positioned correctly */
}

.overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(to right, rgb(255, 255, 255), #045ec5); /* Gradient overlay */
  z-index: 1; /* Ensures overlay is above the image */
}
.image-overlay-section img {
  display: block; /* Removes bottom gap in inline-block elements */
  width: 100%; /* Ensures the image is responsive */
  height: auto; /* Maintains aspect ratio */
  z-index: 0; /* Ensures the image is below the overlay */
}
  #gallery {
    display: grid;
    height: calc(100vh - 10px);
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(6, 1fr);
    gap: 0.5em;
  }
  @media (max-width: 800px) {
    #gallery {
      display: flex;
      flex-wrap: wrap;
      justify-content: center;
      align-items: flex-start;
    }
    #gallery > div {
      width: 48%;
      margin: 1%;
    }
  }
  @media (max-width: 350px) {
    #gallery > div {
      width: 98%;
    }
  }
  #gallery > div {
    overflow: hidden;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2), 0 3px 20px rgba(0, 0, 0, 0.19);
    display: flex;
    align-items: center;
    justify-content: center;
  }
  #gallery > div:nth-child(6n + 1) {
    grid-column: span 2;
    grid-row: span 2;
  }
  #gallery > div:nth-child(2) {
    grid-column: span 3;
    grid-row: span 3;
  }
  #gallery > div:nth-child(4) {
    grid-column: span 1;
    grid-row: span 2;
  }
  #gallery img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: all 1s ease;
  }
  #gallery a {
    position: absolute;
    opacity: 0;
    color: #fff;
    background: #000;
    font: bold 4em Helvetica;
    text-shadow: 0 -1px 5px #fff, -1px 0px 5px #fff, 0 1px 5px #fff, 1px 0px 5px #fff;
    padding: 2rem;
    width: 100%;
    height: 100%;
    mix-blend-mode: difference;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 1s ease;
    text-decoration: none;
  }
  #gallery div:hover img {
    filter: blur(4px);
  }
  #gallery div:hover a {
    opacity: 1;
  }
  
  .lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    opacity: 0;
    transition: opacity 450ms ease-in-out;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 9999;
  }
  .lightbox:target {
    opacity: 1;
    pointer-events: auto;
  }
  .lightbox img {
    max-width: 100%;
    max-height: 90vh;
    filter: blur(50px);
    transition: filter 450ms ease-in-out;
  }
  .lightbox:target img {
    filter: blur(0);
  }
  .lightbox .content {
    max-width: 90%;
    position: relative;
    color: white;
  }
  .lightbox .title {
    position: absolute;
    bottom: 0;
    width: 100%;
    padding: 1em;
    background-color: rgba(0, 0, 0, 0.4);
    text-align: center;
    opacity: 0;
    transform: translateY(50%);
    transition: all 450ms ease-in-out;
  }
  .lightbox .content:hover .title {
    opacity: 1;
    transform: translateY(0);
  }
  .lightbox a.close {
    position: absolute;
    top: 1em;
    right: 1em;
    width: 2em;
    height: 2em;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    font-size: 1.5em;
    text-decoration: none;
    opacity: 0;
    transform: scale(0);
    transition: all 0.3s ease-in-out;
  }
  .lightbox a.close {
    opacity: 1;
    transform: scale(1);
    transition: all 0.3s ease-in-out;
  }
  
  .lightbox:target a.close {
    opacity: 1;
    transform: scale(1);
  } 
  
  .lightbox a.close::after {
    content: '×';
  }
  /* Medium devices (tablets, 801px to 1199px) */
@media (min-width: 801px) and (max-width: 1199px) {
    #gallery {
      grid-template-columns: repeat(4, 1fr);
      grid-template-rows: repeat(4, 1fr);
    }
  
    #gallery > div:nth-child(6n + 1),
    #gallery > div:nth-child(2),
    #gallery > div:nth-child(4) {
      grid-column: span 2 !important;
      grid-row: span 2 !important;
    }
  }
  
  /* Small devices (mobiles in portrait, up to 800px) */
  @media (max-width: 800px) {
    #gallery {
      display: flex;
      flex-wrap: wrap;
      justify-content: center;
      align-items: flex-start;
    }
  
    #gallery > div {
      width: 48%;
      margin: 1%;
      height: 150px;
    }
  
    .lightbox .content {
      max-width: 95%;
    }
  
    .lightbox img {
      max-height: 60vh;
    }
  
    .lightbox .title {
      font-size: 0.9em;
      padding: 0.5em;
    }
  
    .lightbox a.close {
      top: 0.5em;
      right: 0.5em;
      width: 1.5em;
      height: 1.5em;
      font-size: 1.2em;
    }
  }
  
  /* Extra small devices (mobile under 350px) */
  @media (max-width: 350px) {
    #gallery > div {
      width: 98%;
      height: 130px;
    }
  
    .lightbox img {
      max-height: 50vh;
    }
  
    .lightbox a.close {
      font-size: 1em;
    }
  }
  