:root {
  --primary-rgb: 8, 8, 8;
}

[data-theme="light"] {
  --primary-rgb: 227, 218, 201;
}

.project_items_ho {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 500px), 1fr));
  gap: 2.5rem;
  max-width: 1200px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

.project_item {
  position: relative;
  background: var(--bg-color);
  border-radius: 16px;
  overflow: hidden;
  aspect-ratio: 16/10;
  box-shadow: 0 10px 30px -15px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease-in-out;
  border: 1px solid var(--card-border);
}

.project_item:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 40px -20px rgba(0, 0, 0, 0.3);
}

.project_item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.project_item:hover img {
  transform: scale(1.1);
}

.project_item .content {
  position: absolute;
  inset: 0;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-start;
  background: linear-gradient(
    to top,
    rgba(var(--primary-rgb), 0.95) 0%,
    rgba(var(--primary-rgb), 0.7) 50%,
    rgba(var(--primary-rgb), 0.3) 100%
  );
  opacity: 0;
  transition: all 0.3s ease-in-out;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--card-border);
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  will-change: opacity;
}

.project_item:hover .content {
  opacity: 1;
}

.project_item .content h3 {
  color: var(--text-color);
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 0.8rem;
  text-align: left;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.project_item .content p {
  color: var(--text-color);
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 1.5rem;
  text-align: left;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Desktop styles for links */
.project_item .content a {
  color: var(--text-color);
  text-decoration: none;
  padding: 0.8rem 1.5rem;
  background: var(--primary-color);
  border-radius: 8px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border: 1px solid var(--card-border);
}

/* Hide mobile text by default on desktop */
.mobile-text {
  display: none;
}

.project_item .content a:hover {
  background: var(--secondary-color);
  color: var(--primary-color);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

/* Mobile Styles - Only apply below 768px */
@media (max-width: 768px) {
  .project_items_ho {
    gap: 1.5rem;
    padding: 0 1rem;
    -webkit-overflow-scrolling: touch;
  }

  .project_item {
    aspect-ratio: 16/12;
    border-radius: 12px;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
  }

  .project_item .content {
    opacity: 1;
    padding: 1.25rem;
    background: transparent;
    justify-content: flex-end;
    gap: 0.75rem;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-top: 1px solid var(--card-border);
  }

  .project_item .content h3 {
    display: none; /* Hide title on mobile */
  }

  .project_item .content p {
    display: none; /* Hide description text on mobile */
  }

  /* Show mobile text and hide desktop text on mobile */
  .mobile-text {
    display: inline;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: calc(100% - 20px); /* Allow space for the icon */
  }

  .desktop-text {
    display: none;
  }

  .project_item .content a {
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
    border-radius: 6px;
    background: rgba(var(--primary-rgb), 0.7);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    width: 100%;
    text-align: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    -webkit-appearance: none;
    appearance: none;
    position: relative;
    z-index: 1;
    margin-top: 0; /* Remove margin since title is hidden */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    height: 45px; /* Fix height to prevent expansion */
    overflow: hidden;
  }

  .project_item:active {
    transform: scale(0.98);
    transition: transform 0.2s ease;
  }

  /* Fix for iOS Safari scrolling and momentum */
  @supports (-webkit-touch-callout: none) {
    .project_items_ho {
      overflow-y: scroll;
      -webkit-overflow-scrolling: touch;
    }

    .project_item .content {
      /* Ensure GPU acceleration */
      -webkit-transform: translate3d(0, 0, 0);
      transform: translate3d(0, 0, 0);
    }

    /* Prevent text selection on tap */
    .project_item * {
      -webkit-touch-callout: none;
      -webkit-user-select: none;
      user-select: none;
    }
  }
}
