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

body {
  background-image: url("https://www.nasa.gov/sites/all/themes/custom/nasatwo/images/starfield-banner.jpg");
  font-family: "Poppins",sans-serif;
}

.wrap {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  grid-gap: 10px;
  padding: 0.5em;
  perspective: 500px;
}

.article {
  display: flex;
  flex-direction: column;
  height: 300px;
  position: relative;
  background-size: cover;
  border-radius: 7px;
  overflow: hidden;
  padding: 1em;
  cursor: pointer;
  transform: rotateX(0deg) rotateY(0deg);
  transition: all 0.2s linear;
  will-change: transform;
}

.article:nth-child(5n+1) {
  background-image: url("/Imagenes/Imagen_serv1.jpg");
}

.article:nth-child(5n+2) {
  background-image: url("/Imagenes/Imagen_serv4.jpg");
}

.article:nth-child(5n+3) {
  background-image: url("/Imagenes/Imagen_serv5.jpeg");
}

.article:nth-child(5n+4) {
  background-image: url("/Imagenes/Imagen_serv3.png");
}

.article:nth-child(5n+5) {
  background-image: url("/Imagenes/Imagen_serv6.webp");
}

.article:nth-child(6n+6) {
  background-image: url("/Imagenes/Imagen_serv2.jpg");
}

.article:nth-child(7n+7) {
  background-image: url("/Imagenes/Imagen_serv7.jpg");
}

.article:nth-child(8n+8) {
  background-image: url("/Imagenes/Imagen_serv8.webp");
}

.overlay1 {
  width: 100%;
  height: 100%;
  background-image: radial-gradient(circle at 50% 50%, rgba(0,0,0,0.3) 20%, rgba(0,0,0,0.4) 50%);
  position: absolute;
  left: 0;
  top: 0;
  z-index: -1;
}

.article h1 {
  font-size: 1.5em;
  font-family: "Poppins", sans-serif;
  margin-top: auto;
  cursor: pointer;
  transition: all 0.3s;
  position: relative;
  z-index: 2;
  pointer-events: none;
}

.article h1 span {
  color: #fff;
}

.article span.cat {
  letter-spacing: 2px;
  font-weight: bold;
  font-family: "Poppins", sans-serif;
  position: relative;
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
  color: #fff;
  font-size: 22px;
  text-transform: uppercase;
}

@media screen and (min-width: 768px) {
  .wrap {
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    grid-gap: 20px;
    padding: 1em;
  }

  .article:hover h1 {
    transform: translateY(-20px);
  }

  .article span.cat {
    color: transparent;
  }

  .popup-cat {
    width: 300px;

  }

  .article span.cat::before,
  .article span.cat::after {
    content: attr(data-hover);
    position: absolute;
    display: inline-block;
    left: 0;
    top: 0;
    white-space: nowrap;
    overflow: hidden;
    max-width: 0%;
    transition: max-width 300ms ease-out;
  }

  .article span.cat::before {
    color: rgb(0, 89, 255);
    transition-delay: 100ms;
   
  }

  .article span.cat::after {
    color: white;
  }

  .article:hover span.cat::before,
  .article:hover span.cat::after {
    max-width: 200%;

  }

  .article:hover span.cat::after {
    transition-delay: 300ms;
  }
}

@media (max-width: 576px) {
  .popup-title {
    font-size: 1em;
    font-family: "Poppins", sans-serif;
    margin-bottom: 0.5em;
    color: #ffffff;
    margin-left: 3px;
    z-index: 9999;
    position: relative;

  }
  
  .popup-cat {
    font-size: .5em;
    font-family: "Poppins", sans-serif;
    color: #ffffff;
    margin-bottom: 1em;
    text-align: center;
    font-weight: 600;
    z-index: 9999;
    position: relative;
    text-transform: uppercase;
    margin-top: 25px;
  }
}

.popup {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background: rgba(10, 10, 10, 0.85);
  backdrop-filter: blur(8.85px);
}

.popup-content {
  position: relative;
  margin: auto;
  width: 100%;
  max-width: 700px;
  height: 100%;
  max-height: 80%;
  background-color: #fff;
  overflow-y: auto;
  border-radius: 7.5px;
  animation: scaleIn 0.3s;
  margin-top: 65px;
}

.close {
  position: absolute;
  top: 20px;
  right: 30px;
  color: #ffffff;
  font-size: 40px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.35s ease-out;
  z-index: 9999;
}

.close:hover {
  transform: scale(1.085);
  color: #155fe9;
}

.popup-article {
  background-size: cover;
  background-position: center;
  border-radius: 7px;
  padding: 1em;
  height: 100%;
}

.popup-article::before {
  content: "";
  height: 100%;
  width: 100%;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  background: rgba(10, 10, 10, 0.67);
  backdrop-filter: blur(2.85px);
  mix-blend-mode: multiply;
  border-radius: 7.5px;
}

.popup-title {
  font-size: 1.85em;
  font-family: "Poppins", sans-serif;
  margin-bottom: 0.5em;
  color: #ffffff;
  margin-left: 30px;
  z-index: 9999;
  position: relative;
}

.popup-cat {
  font-size: 2.5em;
  font-family: "Poppins", sans-serif;
  color: #ffffff;
  margin-bottom: 1em;
  text-align: center;
  font-weight: 600;
  z-index: 9999;
  position: relative;
  text-transform: uppercase;
  margin-top: 25px;
  margin-left: 10px;
  width: 600px;
}

@keyframes scaleIn {
  from {
    transform: scale(0.8);
  }
  to {
    transform: scale(1);
  }
}
