* {
  box-sizing: border-box;
  margin: 0;
}

body {
  display: flex;
  flex-flow: row wrap;
  padding: 5px;
  background: black;
}

.grid {
  flex: 1;
  min-width: 200px;
}

.grid-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 5px solid black;
  animation: aparecer 1s ease;
  animation-fill-mode: forwards;
  opacity: 0;
}

.grid-item .overlay {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  opacity: 0;
  background: rgba(0, 0, 0, .4);
  z-index: 1;
  transition: all .5s ease;
}


.grid-item h1 {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-35%, -50%) scale(1);
  color: white;
  z-index: 10;
  opacity: 0;
  font-family: sans-serif;
  text-decoration: none;
  transition: transform 0.5s ease, opacity 0.5s ease; /* Agregado opacity a la transición */
}

.grid-item:hover h1 {
  transform: translate(-35%, -50%) scale(1.2);
  opacity: 1;
}

.grid-item h1 a {
  transform: translate(-35%, -50%) scale(1);
  display: inline-block;
  color: white;
  opacity: 0.8;
  transition: transform 0.5s ease, opacity 0.5s ease;
}

.grid-item h1 a:hover {
  color: white;
  transform: translate(-35%, -50%) scale(1.2); /* Al pasar el mouse, aumentar el tamaño */
  text-decoration: none; /* Eliminar subrayado al pasar el mouse */
  opacity: 1;
  transition: transform 0.5s ease, opacity 0.5s ease;
}

.grid-item:nth-child(1) h1 {
  transform: translateX(100px);
}

.grid-item:nth-child(2) h1 {
  transform: translateX(-100px);
}

.grid-item:nth-child(3) h1 {
  transform: translateY(-100px);
}

.grid-item:nth-child(4) h1 {
  transform: translateY(100px);
}

.grid-item:hover .overlay {
  opacity: 1;
}

.grid-item:hover h1 {
  transform: translateY(0);
  opacity: 1;
}

@keyframes aparecer {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }

  100% {
    opacity: 1;
  }
}

.grid-item:nth-child(2) {
  animation-delay: .5s;
}
.grid-item:nth-child(3) {
  animation-delay: 1s;
}
.grid-item:nth-child(4) {
  animation-delay: 1.5s;
}
.grid-item:nth-child(5) {
  animation-delay: 2s;
}
.grid-item:nth-child(6) {
  animation-delay: 2.5s;
}
.grid-item:nth-child(7) {
  animation-delay: 3s;
}
.grid-item:nth-child(8) {
  animation-delay: 3.5s;
}
.grid-item:nth-child(9) {
  animation-delay: 4s;
}
.grid-item:nth-child(10) {
  animation-delay: 4.5s;
}

.grid-item img {
  width: 100%;
  display: block;
  object-fit: cover;
  transition: all .5s ease;
}

.grid-item:hover img {
  transform-origin: top;
  transform: scale(1.05);
}