s ease-out;
  }

  /* Project header animations */
  .project-item h2 {
    opacity: 0.5;
    transform: translateY(5px);
    transition: opacity 0.4s ease-out, transform 0.4s ease-out;
  }

  .project-item.appear h2 {
    opacity: 1;
    transform: translateY(0);
  }

  /* Enhanced touch feedback for gallery items */
  .project-gallery .gallery-item:active {
    transform: scale(0.98);
    transition: transform 0.2s ease-out;
  }

  /* Optimize animations for low-power devices */
  @media (prefers-reduced-motion: reduce) {

    .project-item,
    .gallery-item,
    .project-item h2 {
      transition: none;
      opacity: 1;
      transform: none;
    }
  }
}

/* Extra small screens optimization */
@media (max-width: 480px) {

  /* Even faster animations on very small screens */
  .project-item {
    opacity: 0.3;
    transform: translateY(8px);
    transition: opacity 0.35s ease-out, transform 0.35s ease-out;
  }

  /* Minimal delays between elements */
  .project-item:nth-child(n),
  .project-item.appear .gallery-item:nth-child(n) {
    transition-delay: 0.02s;
  }

  /* Ensure content is visible quickly on small screens */
  .horizontal-scroll-gallery .gallery-item {
    opacity: 0.4;
  }
}

/**
 * Scroll indicator styles for mobile devices
 */

/* Mobile scroll indicator styling */
.mobile-scroll-indicator {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 15px;
  opacity: 0.6;
  transition: opacity 0.3s ease;
  z-index: 2;
  pointer-events: none;
}

.mobile-scroll-indicator.fade-out {
  opacity: 0;
}

.scroll-dots {
  display: inline-flex;
  gap: 4px;
  background: rgba(255, 255, 255, 0.8);
  padding: 4px 8px;
  border-radius: 12px;
}

.scroll-dots span {
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #666;
  flex-shrink: 0;
}

/* Animated version of scroll indicator */
@media (prefers-reduced-motion: no-preference) {
  .scroll-dots span {
    animation: pulse 1.5s infinite;
  }

  .scroll-dots span:nth-child(2) {
    animation-delay: 0.2s;
  }

  .scroll-dots span:nth-child(3) {
    animation-delay: 0.4s;
  }

  @keyframes pulse {

    0%,
    100% {
      opacity: 0.5;
      transform: scale(0.8);
    }

    50% {
      opacity: 1;
      transform: scale(1);
    }
  }
}

/* Horizontal swipe indicator for mobile galleries */
.horizontal-scroll-gallery {
  position: relative;
}

.horizontal-scroll-gallery:before {
  content: '';
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  background-color: rgba(0, 0, 0, 0.4);
  border-radius: 50%;
  pointer-events: none;
  opacity: 0.6;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: swipe-hint 2s ease-in-out infinite;
}

.horizontal-scroll-gallery:after {
  content: '→';
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  color: white;
  font-size: 16px;
  font-weight: bold;
  pointer-events: none;
  z-index: 6;
}

@keyframes swipe-hint {

  0%,
  100% {
    transform: translateY(-50%) translateX(0);
  }

  50% {
    transform: translateY(-50%) translateX(-10px);
  }
}

/* Hide indicators once user has scrolled */
.horizontal-scroll-gallery.scrolled:before,
.horizontal-scroll-gallery.scrolled:after {
  display: none;
}

/* Fix conflict with existing scroll indicators */
@media (max-width: 768px) {

  /* Override the existing text-based scroll indicator when using the new animated one */
  .project-gallery:before,
  .horizontal-scroll-gallery:before {
    content: none;
  }
}



@media (max-width: 768px) {

  /* Project header and demo button styling */
  .project-header {
    flex-direction: column;
    gap: 0.75rem;
    /* Reduced gap */
    align-items: center;
    text-align: center;
    padding: 1.2rem 1rem 0.75rem;
    /* Reduced padding */
  }

  .project-header h2 {
    font-size: 1.4rem;
    margin-bottom: 0;
    /* Remove bottom margin */
  }

  .demo-button {
    width: 100%;
    justify-content: center;
    padding: 0.6rem 1rem;
    font-size: 0.95rem;
    margin-bottom: 0;
    /* Remove bottom margin */
  }

  /* Ensure proper spacing with content */
  .project-content {
    padding-top: 1.25rem;
    /* Slightly reduced top padding */
  }
  .project-description p {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 0.9rem;
    line-height: 1.4;
    margin-bottom: 1rem;
  }

  .tech-stack {
    gap: 0.5rem;
    margin-top: 0.8rem;
  }

  .project-gallery {
    display: flex;
    overflow-x: auto;
    gap: 1rem;
    padding-bottom: 1rem;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
  }

  .gallery-item {
    flex: 0 0 85%;
    max-width: 85%;
  }

  .project-image {
    height: 220px;
  }
}

/**
 * Mobile-specific styles for modal image counter
 */

@media (max-width: 768px) {

  /* Image counter styles for mobile */
  .modal-counter {
    bottom: 10px;
    right: 10px;
    font-size: 12px;
    padding: 4px 8px;
    background-color: rgba(0, 0, 0, 0.7);
    /* Slightly darker for better visibility */
  }

  /* When caption is present, move counter above it */
  .modal-caption+.modal-counter {
    bottom: 50px;
    /* Position above the caption */
  }

  /* When in landscape mode */
  @media (orientation: landscape) {
    .modal-counter {
      bottom: 8px;
      right: 8px;
      padding: 3px 7px;
      font-size: 11px;
    }

    /* When caption is present in landscape */
    .modal-caption+.modal-counter {
      bottom: 40px;
    }
  }
}

/* Extra small screens (phones under 480px) */
@media (max-width: 480px) {
  .modal-counter {
    bottom: 8px;
    right: 8px;
    font-size: 11px;
    padding: 3px 7px;
  }

  /* Add extra contrast to make it more readable on small screens */
  .modal-counter {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  }

  /* Counter position when modal navigation arrows are visible */
  .modal-nav+.modal-counter {
    right: 50px;
    /* Move away from the navigation arrows */
  }
}

/* Improving touch feedback for mobile */
@media (hover: none) and (pointer: coarse) {

  /* Make counter more visible during touches */
  .modal-overlay.active .modal-counter {
    opacity: 1;
    transition: opacity 0.3s ease;
  }

  /* Slightly increase the counter size for easier viewing */
  .modal-counter {
    min-width: 40px;
    text-align: center;
  }
}

/**
 * Mobile-specific styles for fixed position navigation arrows
 */

@media (max-width: 768px) {

  /* Fixed position navigation arrows for mobile */
  .modal-nav {
    position: fixed;
    top: 50%;
    width: 40px;
    height: 40px;
    transform: translateY(-50%);
    opacity: 0.7;
    /* Slightly transparent by default */
  }

  .modal-nav:active {
    opacity: 1;
    transform: translateY(-50%) scale(0.95);
  }

  .modal-prev {
    left: 10px;
  }

  .modal-next {
    right: 10px;
  }

  .modal-nav i {
    font-size: 18px;
  }

  /* Make room for arrows */
  .modal-content {
    max-width: calc(100% - 80px);
  }

  /* Enhance touch targets for mobile */
  .modal-nav:before {
    content: '';
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
    z-index: -1;
  }

  /* Always show arrows on touch devices */
  body.touch-device .modal-nav {
    opacity: 0.8;
  }
}

/* Extra small screens (phones under 480px) */
@media (max-width: 480px) {
  .modal-nav {
    width: 36px;
    height: 36px;
  }

  .modal-prev {
    left: 8px;
  }

  .modal-next {
    right: 8px;
  }

  .modal-nav i {
    font-size: 16px;
  }

  /* Even more compact for very small screens */
  .modal-content {
    max-width: calc(100% - 60px);
  }
}

/* Landscape orientation adjustments */
@media (max-width: 768px) and (orientation: landscape) {
  .modal-nav {
    top: 50%;
    /* Keep centered vertically */
  }

  /* Move slightly inward to avoid system UI elements on mobile */
  .modal-prev {
    left: 15px;
  }

  .modal-next {
    right: 15px;
  }

  /* Ensure arrows are always visible in landscape */
  .modal-overlay.active .modal-nav {
    opacity: 0.9;
  }
}

/**
 * CSS fixes for modal overlay issues on mobile
 */

/* Ensure proper visibility handling */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  /* Use visibility along with opacity */
  transition: opacity 0.3s ease, visibility 0.3s ease;
  pointer-events: none;
  /* Disable when invisible */
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  /* Enable when visible */
}

/* Extra important rules for mobile to prevent overlay sticking */
@media (max-width: 768px) {
  .modal-overlay:not(.active) {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }

  /* Force hardware acceleration to improve transitions */
  .modal-overlay {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
  }
}

/**
 * Fix for alternating grayed-out projects on mobile
 * Add this to the end of mobileprojects.css
 */

/* Reset all projects to full opacity */
@media (max-width: 768px) {

  /* Override any opacity settings causing the alternating gray effect */
  .project-item {
    opacity: 1 !important;
    /* Force full opacity */
    transform: none !important;
    /* Disable transform effects */
    transition: none !important;
    /* Disable transitions temporarily */
  }

  /* Reset any alternating styles that might be causing issues */
  .project-item:nth-child(odd),
  .project-item:nth-child(even) {
    opacity: 1 !important;
    background-color: var(--card-bg) !important;
    /* Reset to default background */
  }

  /* Remove any overlays that might exist */
  .project-item:before,
  .project-item:after {
    display: none !important;
    content: none !important;
    opacity: 0 !important;
  }

  /* Ensure content is visible */
  .project-content,
  .project-description,
  .project-gallery,
  .horizontal-scroll-gallery {
    opacity: 1 !important;
  }

  /* Fix for appear animations */
  .project-item.appear,
  .project-item.fade-in.appear,
  .project-item:not(.appear) {
    opacity: 1 !important;
  }

  /* Re-enable smooth animations after page load */
  .loaded .project-item {
    transition: transform 0.3s ease !important;
  }
}

/* Add a class when page is fully loaded */
@media (max-width: 768px) {

  /* Add this script to the page */
  body:after {
    content: "";
    display: none;
  }
}