.collage {
  max-width: 800px;
  margin-inline: auto;
  display: grid;
  gap: 0.5rem;
  grid-template-rows: repeat(5, 1fr);
  grid-template-columns: repeat(8, 1fr);

  grid-template-areas:
    "b   a2  a2  a2  a3  d   ..  .."
    "a1  a2  a2  a2  a4  a4  c   .."
    "a8  a2  a2  a2  a4  a4  a5  a"
    "g   a6  a7  a7  a9  a9  e   .."
    "..  f   a7  a7  a9  a9  ..  ..";
}


.collage > div {
  overflow: hidden;
  border-radius: 0.5rem;
}

.collage img {
  width: 100%;
  aspect-ratio: 1;
  display: block;
  object-fit: cover;
  transition: all 0.5s ease-in-out;
}

.collage img:hover {
  scale: 1.15;
  rotate: 3deg;
}

.collage-item {
  position: relative;
   padding: 0 !important; /* Forces container padding to zero */
  margin: 0;
  overflow: hidden;      /* Keeps text perfectly clipped to the image boundaries */
  display: grid; /* Stacks image and text over each other */
}

.overlay-text {
  position: absolute;
  bottom: 0;         /* Anchors text to the bottom */
  left: 0;
  width: 100%;       /* Spans across the entire image width */
  font-size: 0.65rem;
  line-height: 1.1;
  /* Text and background styling */
  background: rgba(0, 0, 0, 0.5); /* Dark background for text readability */
  color: rgb(255, 255, 255);
  /*padding: 0.75rem;   /* Adds spacing inside the text box */
  text-align: center; /* Horizontally centers text */
  box-sizing: border-box; /* Prevents padding from breaking layout width */
}