#servicios {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 30px;
  width: 100%;
  height: 100vh;
  padding: 30px 5%;
  box-sizing: border-box;
  font-family: "Outfit", sans-serif;
  font-optical-sizing: auto;
  font-weight: 400;
  font-style: normal;
}

.tarjeta {
  position: relative;
  overflow: hidden;
  border-radius: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  animation: aparecer 0.6s ease forwards;
  opacity: 0;
  transform: translateY(30px);
  height: calc((100vh - 90px) / 2);
  width: 100%;
  backface-visibility: hidden;
  will-change: transform, opacity;
  transition: transform 0.2s ease;
  z-index: 1;
}

.tarjeta::after {
  content: '';
  position: absolute;
  inset: 0;
  background-color: rgba(255, 255, 255, 0.6);
  z-index: 1;
  transition: opacity 0.4s ease;
}


.tarjeta:hover::after,
.tarjeta.hover-activo::after {
  opacity: 0;
}

.tarjeta.pulse {
  animation: pulseClick 0.3s ease;
}

@keyframes pulseClick {
  0% { transform: scale(1); }
  50% { transform: scale(0.96); }
  100% { transform: scale(1); }
}

.filtro-vidrio {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
}

.filtro-vidrio::before,
.filtro-vidrio::after {
  content: '';
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  background-color: rgba(2, 156, 255, 0.35);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: transform 0.6s ease-in-out;
  transform: scaleX(1);
  z-index: 2;
}

.filtro-vidrio::before {
  left: 0;
  border-top-left-radius: 15px;
  border-bottom-left-radius: 15px;
  transform-origin: left;
}

.filtro-vidrio::after {
  right: 0;
  border-top-right-radius: 15px;
  border-bottom-right-radius: 15px;
  transform-origin: right;
}


.tarjeta:hover .filtro-vidrio::before,
.tarjeta.hover-activo .filtro-vidrio::before {
  transform: scaleX(0);
}
.tarjeta:hover .filtro-vidrio::after,
.tarjeta.hover-activo .filtro-vidrio::after {
  transform: scaleX(0);
}

.recuadro-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
  display: flex;
  gap: 10px;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
}

.recuadro-izq,
.recuadro-der {
  min-width: 140px;
  padding: 12px 20px;
  border-radius: 6px;
  font-weight: bold;
  font-size: 16px;
  text-align: center;
  transition: transform 0.6s ease-in-out, opacity 0.4s ease-in-out;
  white-space: nowrap;
  font-family: "Outfit", sans-serif;
}

.recuadro-izq {
  background-color: #029CFF;
  color: white;
}

.recuadro-der {
  background-color: white;
  color: #029CFF;
}


.tarjeta:hover .recuadro-izq,
.tarjeta.hover-activo .recuadro-izq {
  transform: translateX(-150%);
  opacity: 0;
}
.tarjeta:hover .recuadro-der,
.tarjeta.hover-activo .recuadro-der {
  transform: translateX(150%);
  opacity: 0;
}

.contenido-hover {
  position: absolute;
  bottom: 10px;
  z-index: 3;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}


.tarjeta:hover .contenido-hover,
.tarjeta.hover-activo .contenido-hover {
  opacity: 1;
  pointer-events: auto;
}

.titulo-hover {
  font-size: 24px;
  font-weight: bold;
  color: #029CFF;
  margin-bottom: 4px;
  opacity: 0;
  transition: opacity 0.4s ease;
  background-color: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 6px 12px;
  border-radius: 8px;
  font-family: "Outfit", sans-serif;
}


.tarjeta:hover .titulo-hover,
.tarjeta.hover-activo .titulo-hover {
  opacity: 1;
}

.texto-extra {
  font-size: 16px;
  color: #029CFF;
  white-space: nowrap;
  overflow: hidden;
  display: inline-block;
  border-right: 2px solid #029CFF;
  width: 0;
  animation: typing 2s steps(40, end) forwards;
  margin-top: 2px;
  opacity: 0;
  transition: opacity 0.4s ease;
  background-color: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 6px 12px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  font-family: "Outfit", sans-serif;
}


.tarjeta:hover .texto-extra,
.tarjeta.hover-activo .texto-extra {
  opacity: 1;
}


@media (min-width: 1025px) {
  .texto-extra {
    animation: typing 2s steps(40, end) 1 forwards;
  }
}

@keyframes typing {
  from { width: 0; }
  to { width: 100%; }
}

@keyframes aparecer {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ========================= RESPONSIVE ========================= */
@media (max-width: 1024px) {
  #servicios {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    height: auto;
  }

  .tarjeta {
    height: auto;
    min-height: 340px;
    overflow: visible;
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .recuadro-container {
    flex-wrap: wrap;
    gap: 8px;
  }

  .recuadro-izq,
  .recuadro-der {
    min-width: auto;
    font-size: 13px;
    padding: 8px 14px;
  }

  .titulo-hover {
    font-size: 18px;
  }

  .contenido-hover {
    width: 100%;
    padding: 10px 0;
    overflow: visible;
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .texto-extra {
    font-size: 12px;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    display: block;
    border-right: 2px solid #029CFF;
    width: 0;
    max-width: 90vw;
    animation: typing-final 4s steps(100, end) forwards;
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    padding: 6px 12px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    font-family: "Outfit", sans-serif;
    text-align: center;
  }
}

@keyframes typing-final {
  from { width: 0; }
  to { width: 90vw; }
}

/* ===== (Opcional) =====
.tarjeta.cerrando .filtro-vidrio::before,
.tarjeta.cerrando .filtro-vidrio::after {
  transform: scaleX(1);
}
.tarjeta.cerrando .recuadro-izq,
.tarjeta.cerrando .recuadro-der {
  transform: translateX(0);
  opacity: 1;
}
.tarjeta.cerrando .contenido-hover,
.tarjeta.cerrando .titulo-hover,
.tarjeta.cerrando .texto-extra {
  opacity: 0;
}
*/
