/* Projects Section */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 30px;
  max-width: 1200px;
  margin: 0 auto;
}

/* Center the last project when it's alone in the last row */
.project-card:last-child:nth-child(3n-1) {
  grid-column: 2;
}

/* If there's only one card in the last row and it's not the third item */
.project-card:last-child:nth-child(3n-2) {
  grid-column: 2;
}

.project-card {
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: var(--transition);
  position: relative;
  z-index: 1;
}

.project-card:hover {
  transform: translateY(-10px);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.15);
}

.project-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, var(--primary), rgba(37, 99, 235, 0.1));
  opacity: 0;
  z-index: -1;
  transition: opacity 0.5s ease;
  border-radius: 8px;
}

.project-card:hover::before {
  opacity: 0.05;
}

.project-img {
  height: 200px;
  overflow: hidden;
  position: relative;
}

.project-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.8s ease;
}

.project-card:hover .project-img img {
  transform: scale(1.1);
}

.project-img::after {
  content: "View Details";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(37, 99, 235, 0.8);
  color: white;
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.project-card:hover .project-img::after {
  opacity: 1;
}

.project-info {
  padding: 20px;
}

.project-info h3 {
  margin-bottom: 10px;
  color: var(--dark);
  transition: color 0.3s ease;
}

.project-card:hover .project-info h3 {
  color: var(--primary);
}

.tech-stack {
  color: var(--primary);
  font-weight: 500;
  margin-bottom: 15px;
  font-size: 0.9rem;
}

.project-info p {
  color: var(--dark-gray);
  margin-bottom: 20px;
  font-size: 0.95rem;
}

.project-links {
  display: flex;
  align-items: center;
}

.project-links a {
  margin-right: 10px;
}

/* Responsive */
@media (max-width: 1200px) {
  .projects-grid {
    gap: 25px;
    padding: 0 20px;
  }
}

@media (max-width: 992px) {
  .projects-grid {
    grid-template-columns: repeat(2, 1fr);
    max-width: 800px;
  }

  /* Reset the centering for 2-column layout */
  .project-card:last-child:nth-child(3n-1),
  .project-card:last-child:nth-child(3n-2) {
    grid-column: auto;
  }

  /* Center the last project in 2-column layout when it's alone */
  .project-card:last-child:nth-child(2n-1) {
    grid-column: 1 / -1;
    max-width: calc(50% - 12.5px);
    margin: 0 auto;
  }
}

@media (max-width: 768px) {
  .projects-grid {
    grid-template-columns: 1fr;
    max-width: 550px;
    gap: 30px;
  }

  .project-card {
    max-width: 100%;
  }

  /* Reset centering on mobile */
  .project-card:last-child:nth-child(2n-1) {
    grid-column: auto;
    max-width: 100%;
  }
}
