.touch-device {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

@media (max-width: 768px) {
  .projects-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 3rem;
    margin-top: 2rem;
  }

  .project-card .project-tilt-container,
  .project-card .project-shine,
  .project-card .project-pattern {
    display: none;
  }

  .project-card {
    position: relative;
    height: auto;
    min-height: 420px;
    width: 100%;
    perspective: none;
    margin-bottom: 2rem;
    border: none;
    box-shadow: none;
    overflow: visible;
    transition: transform 0.3s ease;
  }

  .project-card-mobile {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background-color: white;
    border-radius: 0;
    overflow: visible;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  }

  .project-image-section {
    position: relative;
    width: 100%;
    height: 260px;
    overflow: hidden;
    border: 4px solid black;
    box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.2);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 2;
  }

  .project-image-section .project-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
    filter: grayscale(20%);
    transform: scale(1.05);
  }

  .project-image-section .project-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
      135deg,
      rgba(0, 0, 0, 0.7) 0%,
      rgba(0, 0, 0, 0.3) 100%
    );
    z-index: 1;
    opacity: 0.6;
    transition: opacity 0.4s ease;
  }

  .project-number {
    position: absolute;
    top: 10px;
    left: 10px;
    font-size: 4rem;
    font-weight: 900;
    color: rgba(255, 255, 255, 0.2);
    z-index: 2;
    line-height: 1;
    transition: all 0.3s ease;
  }

  .project-expand-btn {
    position: absolute;
    bottom: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    background-color: white;
    border: 3px solid black;
    z-index: 3;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.3);
  }

  .project-expand-btn::before,
  .project-expand-btn::after {
    content: "";
    position: absolute;
    background-color: black;
    transition: all 0.3s ease;
  }

  .project-expand-btn::before {
    width: 20px;
    height: 3px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }

  .project-expand-btn::after {
    width: 3px;
    height: 20px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }

  .project-content-section {
    position: relative;
    width: 100%;
    padding: 1.5rem;
    background-color: white;
    border: 4px solid black;
    border-top: none;
    margin-top: -4px;
    z-index: 1;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform: translateY(0);
    box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.2);
  }

  .project-title {
    font-size: 1.8rem;
    font-weight: bold;
    margin-bottom: 0.8rem;
    position: relative;
    color: black;
  }

  .project-title::after {
    content: "";
    position: absolute;
    bottom: -6px;
    left: 0;
    width: 60px;
    height: 3px;
    background-color: black;
    transition: width 0.3s ease;
  }

  .project-description {
    font-size: 1rem;
    line-height: 1.5;
    color: #333;
    margin-bottom: 1.2rem;
    max-height: none;
    opacity: 1;
    overflow: visible;
    transition: all 0.3s ease;
  }

  .project-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    opacity: 1;
    transform: none;
  }

  .project-link {
    text-decoration: none;
    color: white;
    background-color: black;
    padding: 0.6rem 1.2rem;
    font-weight: bold;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 1px;
    border: 2px solid black;
    transition: all 0.3s ease;
    display: inline-block;
    position: relative;
    overflow: hidden;
    z-index: 1;
  }

  .project-link:hover,
  .project-link:active {
    background-color: white;
    color: black;
    transform: translate(-3px, -3px);
    box-shadow: 3px 3px 0 black;
  }

  .project-link::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
      90deg,
      transparent 0%,
      rgba(255, 255, 255, 0.2) 50%,
      transparent 100%
    );
    transition: transform 0.6s ease;
    z-index: -1;
  }

  .project-link:hover::before {
    transform: translateX(200%);
  }

  .project-decoration {
    position: absolute;
    background-color: black;
    z-index: 0;
    transition: all 0.3s ease;
  }

  .project-decoration-1 {
    width: 20px;
    height: 20px;
    top: -10px;
    right: 30px;
    transform: rotate(45deg);
  }

  .project-decoration-2 {
    width: 40px;
    height: 3px;
    bottom: 15px;
    right: 20px;
  }

  .project-card.touch-active .project-image-section {
    transform: translateY(-8px);
    box-shadow: 12px 12px 0 rgba(0, 0, 0, 0.25);
  }

  .project-card.touch-active .project-content-section {
    transform: translateY(8px);
    box-shadow: 12px 12px 0 rgba(0, 0, 0, 0.25);
  }

  .project-card.touch-active .project-image {
    transform: scale(1.1);
    filter: grayscale(0%);
  }

  .project-card.touch-active .project-overlay {
    opacity: 0.4;
  }

  .project-card.touch-active .project-number {
    color: rgba(255, 255, 255, 0.3);
    transform: scale(1.1) translateX(5px);
  }

  .project-card.touch-active .project-expand-btn::after {
    transform: translate(-50%, -50%) rotate(90deg);
  }

  .project-card.touch-active .project-title::after {
    width: 100px;
  }

  .project-card.touch-active .project-decoration-1 {
    transform: rotate(225deg);
  }

  .project-card.touch-active .project-decoration-2 {
    width: 60px;
  }

  .project-card:not(.touch-active)::after {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.8rem;
    color: rgba(0, 0, 0, 0.5);
    opacity: 0.7;
    transition: opacity 0.3s ease;
    pointer-events: none;
  }

  .project-card.touch-active::after {
    opacity: 0;
  }

  .project-card.scroll-animate {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.6s ease, transform 0.6s ease;
  }

  .project-card.in-view {
    opacity: 1;
    transform: translateY(0);
  }

  .project-image-section.animated {
    animation: slideInFromLeft 0.6s cubic-bezier(0.23, 1, 0.32, 1) forwards;
  }

  .project-content-section.animated {
    animation: slideInFromRight 0.6s cubic-bezier(0.23, 1, 0.32, 1) 0.1s
      forwards;
  }

  @keyframes slideInFromLeft {
    from {
      opacity: 0;
      transform: translateX(-30px);
    }
    to {
      opacity: 1;
      transform: translateX(0);
    }
  }

  @keyframes slideInFromRight {
    from {
      opacity: 0;
      transform: translateX(30px);
    }
    to {
      opacity: 1;
      transform: translateX(0);
    }
  }

  /* Mejoras para dispositivos táctiles */
  .touch-device .project-expand-btn {
    cursor: pointer;
  }

  .touch-device .project-expand-btn:active {
    transform: scale(0.9);
    background-color: #f0f0f0;
  }

  /* CORREGIDO: Estilo active para botones en dispositivos táctiles */
  .touch-device .project-link:active {
    background-color: white;
    color: black;
    transform: translate(-3px, -3px);
    box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.3);
  }

  /* NUEVO: Efecto de presión para botones */
  .touch-device .project-link:active::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.05);
    z-index: -1;
  }

  /* Ajustes para pantallas muy pequeñas - MEJORADOS */
  @media (max-width: 480px) {
    .project-image-section {
      height: 220px; /* Aumentado para mostrar más de la imagen */
      border-width: 3px;
    }

    .project-content-section {
      padding: 1.3rem; /* Ajustado para menos espacio en blanco */
      border-width: 3px;
    }

    .project-title {
      font-size: 1.5rem;
      margin-bottom: 0.7rem; /* Reducido para menos espacio en blanco */
    }

    .project-description {
      font-size: 0.9rem;
      margin-bottom: 1rem; /* Reducido para menos espacio en blanco */
      line-height: 1.4; /* Ajustado para un diseño más compacto */
    }

    .project-number {
      font-size: 3.5rem; /* Aumentado para mayor impacto visual */
    }

    .project-expand-btn {
      width: 35px;
      height: 35px;
      border-width: 2px;
    }

    .project-link {
      padding: 0.5rem 1rem;
      font-size: 0.75rem;
    }

    /* Ajuste para el indicador de expandir */
    .project-card:not(.touch-active)::after {
      font-size: 0.75rem;
      bottom: 8px;
    }
  }

  @media (max-width: 375px) {
    .project-image-section {
      height: 200px; /* Ajustado pero manteniendo buena visibilidad */
    }

    .project-content-section {
      padding: 1.1rem; /* Reducido para menos espacio en blanco */
    }

    .project-title {
      font-size: 1.3rem;
      margin-bottom: 0.6rem; /* Reducido para menos espacio en blanco */
    }

    .project-description {
      font-size: 0.85rem;
      line-height: 1.4;
      margin-bottom: 0.9rem; /* Reducido para menos espacio en blanco */
    }

    .project-number {
      font-size: 3rem;
    }

    .project-expand-btn {
      width: 30px;
      height: 30px;
    }

    .project-expand-btn::before {
      width: 15px;
    }

    .project-expand-btn::after {
      height: 15px;
    }

    /* Ajuste para el indicador de expandir */
    .project-card:not(.touch-active)::after {
      font-size: 0.7rem;
      bottom: 6px;
    }
  }

  /* NUEVO: Mejoras adicionales para la experiencia táctil */
  .touch-device .project-card {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  /* NUEVO: Efecto de presión para toda la tarjeta */
  .touch-device .project-card:active:not(.touch-active) {
    transform: scale(0.98);
    transition: transform 0.2s ease;
  }

  /* NUEVO: Mejora visual para indicar que la tarjeta es interactiva */
  .project-image-section::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
      135deg,
      transparent 0%,
      rgba(255, 255, 255, 0.05) 100%
    );
    z-index: 2;
    opacity: 0;
    transition: opacity 0.3s ease;
  }

  .project-card:not(.touch-active):hover .project-image-section::after,
  .project-card:not(.touch-active):active .project-image-section::after {
    opacity: 1;
  }
}
