.gallery_grid_outer {
  max-width: 100%;
  width: 100%;
  margin: 1.5em 0;
}

.gallery-images-container {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.gallery-image {
  box-sizing: border-box;
  position: relative;
  width: 20%;
  margin-bottom: 0;
}

.pimage {
  background-size: cover;
  background-position: center;
  height: 200px;
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(13, 43, 78, 0.12);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.gallery-image:hover .pimage {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(13, 43, 78, 0.18);
}

.gallery-image .image_link {
  width: 100%;
  height: 100%;
  cursor: pointer;
  display: block;
  position: absolute;
  z-index: 2;
}

.gallery_grid_overlay {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  background: linear-gradient(180deg, transparent 30%, rgba(13, 43, 78, 0.75) 100%);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  flex-direction: column;
  opacity: 0;
  transition: opacity 0.3s ease;
  border-radius: 12px;
  z-index: 1;
}

.gallery-image:hover .gallery_grid_overlay,
.gallery-image:focus-within .gallery_grid_overlay {
  opacity: 1;
}

/* Tablet: 4 columns */
@media (max-width: 1023px) {
  .gallery-image {
    width: 25%;
  }

  .pimage {
    height: 170px;
  }
}

/* Mobile: horizontal scroll carousel */
@media (max-width: 768px) {
  .gallery_grid_outer {
    margin-left: -16px;
    margin-right: -16px;
    width: calc(100% + 32px);
  }

  .gallery-images-container {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    gap: 10px;
    padding: 4px 16px 12px;
    scrollbar-width: none;
  }

  .gallery-images-container::-webkit-scrollbar {
    display: none;
  }

  .gallery-image {
    width: 130px;
    flex: 0 0 130px;
    scroll-snap-align: start;
  }

  .pimage {
    height: 165px;
    border-radius: 10px;
  }

  .gallery_grid_overlay {
    opacity: 0.3;
  }
}

/* Small phones */
@media (max-width: 480px) {
  .gallery-image {
    width: 120px;
    flex: 0 0 120px;
  }

  .pimage {
    height: 150px;
  }
}

/* Compact 320px */
@media (max-width: 360px) {
  .gallery-image {
    width: 110px;
    flex: 0 0 110px;
  }

  .pimage {
    height: 140px;
  }
}
