.image-with-text-container {
  position: relative;
  display: inline-block;
}

.image-with-text-container img {
  display: block;
  padding: 1rem;
}

.image-with-text-container .overlay-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.025); /* Default background */
  transform: scale(1); /* Default scale */
  transition: transform 0.3s ease-in-out, background 0.3s ease-in-out; /* Smooth transition for both */
}

.image-with-text-container:hover .overlay-layer {
  transform: scale(1.05); /* Slightly enlarges the element */
  background: rgba(0, 0, 0, 0.05); /* Slightly darker background */
}

.image-with-text-container .text-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center; /* Center text vertically */
  justify-content: center; /* Center text horizontally */
  text-align: center; /* Ensure text is centered */
  padding: 1rem; /* Optional padding to avoid text touching edges */
  box-sizing: border-box; /* Include padding in width/height */
  z-index: 2; /* Ensure text appears above overlay */
}

.image-with-text-container .text-layer h1,
.image-with-text-container .text-layer h2,
.image-with-text-container .text-layer h3,
.image-with-text-container .text-layer h4,
.image-with-text-container .text-layer h5,
.image-with-text-container .text-layer h6 {
  color: #fff;
  font-weight: bold;
  text-align: center;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
  line-height: 1.2; /* Adjust for better readability */
  font-size: 1.4rem; /* Adjust size as needed */
  margin: 0; /* Remove default margin */
  word-wrap: break-word; /* Ensure text stays within bounds */
}
