/* Mobile First Responsive Design */

/* Extra Small Devices (phones, less than 576px) */
@media (max-width: 575.98px) {
    .container {
        padding: 0 var(--space-xs); /* Further reduced padding for extreme small screens */
    }
    
    .hero-title {
        font-size: 1.75rem; /* Reduced from 2rem */
    }
    
    .hero-subtitle {
        font-size: 1.1rem; /* Reduced from 1.25rem */
    }
    
    .hero-description {
        font-size: 0.9rem; /* Reduced from 0.95rem */
        line-height: 1.5; /* Improved readability */
    }
    
    .cta-button {
        padding: var(--space-sm) var(--space-md);
        font-size: 0.9rem;
    }
    
    .section-title {
        font-size: 1.75rem;
    }
    
    .about-description {
        font-size: 1rem;
    }
    
    .projects-grid {
        grid-template-columns: 1fr;
        gap: var(--space-md);
    }
    
    .mission-highlights {
        flex-direction: column;
        gap: var(--space-lg);
    }
    
    .highlight-icon {
        font-size: 2rem;
    }
    
    .footer-content {
        flex-direction: column;
        gap: var(--space-md);
        text-align: center;
    }
    
    .footer-logo {
        justify-content: center;
    }
    
    /* Header mobile fixes */
    .nav {
        padding: var(--space-md) 0; /* Increased header padding for better touch navigation */
    }
    
    .logo-img {
        height: clamp(50px, 5vw, 80px); /* Further reduced logo size for better visibility on small screens */
    }
    
    .hamburger {
        gap: 6px; /* Increased gap for better touch target */
        min-width: 48px; /* Minimum 48px width for touch target */
        min-height: 48px; /* Minimum 48px height for touch target */
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }
    
    /* Override to make social media icons horizontal on extra small screens */
    .social-media-icons {
        flex-direction: row;
        flex-wrap: wrap;
        gap: var(--space-sm);
    }
    
    .bar {
        width: 28px; /* Width for hamburger bars */
        height: 4px; /* Height for hamburger bars */
    }
}

/* Small Devices (phones, 576px and up) */
@media (min-width: 576px) and (max-width: 767.98px) {
    .container {
        padding: 0 var(--space-sm); /* Reduced padding for better whitespace */
    }
    
    .hero-title {
        font-size: 2.5rem;
    }
    
    .hero-subtitle {
        font-size: 1.5rem;
    }
    
    .projects-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .mission-highlights {
        gap: var(--space-lg);
    }
    
    /* Header mobile fixes */
    .nav {
        padding: var(--space-md) 0; /* Increased header padding for better touch navigation */
    }
    
    .logo-img {
        height: clamp(55px, 5.5vw, 90px); /* Adjusted logo size */
    }
    
    .hamburger {
        gap: 6px; /* Increased gap for better touch target */
    }
    
    .bar {
        width: 32px; /* Increased width for minimum 48x48px touch target */
        height: 4px; /* Increased height for better touch target */
    }
}

/* Medium Devices (tablets, 768px and up) */
@media (min-width: 768px) and (max-width: 991.98px) {
    .container {
        padding: 0 var(--space-lg);
    }
    
    .hero-title {
        font-size: 3rem;
    }
    
    .hero-subtitle {
        font-size: 1.75rem;
    }
    
    .projects-grid {
        grid-template-columns: repeat(2, 1fr); /* Keep 2 columns */
        gap: calc(var(--space-lg) * 0.9); /* Slightly reduced gap */
    }
    
    .project-card {
        /* Ensure consistent height */
        display: flex;
        flex-direction: column;
    }
    
    .project-content {
        flex-grow: 1; /* Allow content to expand */
    }
    
    .mission-highlights {
        flex-wrap: wrap; /* Ensure proper wrapping */
        gap: calc(var(--space-lg) * 0.8); /* Slightly reduced gap */
        justify-content: center; /* Center align */
    }
    
    .highlight {
        flex: 0 1 calc(33.333% - var(--space-lg)); /* 3 items per row with spacing */
        max-width: calc(33.333% - var(--space-lg));
    }
    
    .highlight-icon {
        font-size: 2.25rem; /* Slightly reduced from 2.5rem */
    }
    
    .about-content {
        text-align: center; /* Changed from left to center */
    }
    
    .section-title {
        text-align: center; /* Changed from left to center */
    }
    
    .mission-highlights {
        justify-content: center; /* Changed from flex-start to center */
    }
    
    /* Header mobile fixes */
    .nav {
        padding: var(--space-lg) 0; /* Increased header padding for better touch navigation */
    }
    
    .logo-img {
        height: clamp(60px, 6vw, 100px); /* Standard logo size */
    }
    
    .hamburger {
        gap: 6px; /* Increased gap for better touch target */
    }
    
    .bar {
        width: 32px; /* Increased width for minimum 48x48px touch target */
        height: 4px; /* Increased height for better touch target */
    }
    
    /* Tablet-specific navigation spacing */
    .nav-menu {
        gap: calc(var(--space-lg) * 1.2); /* Increased gap for tablet */
    }
    
    .nav-link {
        font-size: 1rem; /* Ensure readable size */
        padding: var(--space-xs) var(--space-sm);
    }
}

/* Large Devices (desktops, 992px and up) */
@media (min-width: 992px) and (max-width: 1199.98px) {
    .container {
        max-width: 1140px; /* Increased from default 1200px with padding */
        padding: 0 var(--space-xl);
    }
    
    .projects-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .about-content {
        text-align: left;
    }
    
    .section-title {
        text-align: left;
    }
}

/* Extra Large Devices (large desktops, 1200px and up) */
@media (min-width: 1200px) {
    .projects-grid {
        grid-template-columns: repeat(3, 1fr); /* Changed from 2 to 3 columns */
    }
    
    .container {
        max-width: 1400px; /* Increased container width */
        padding: 0 var(--space-xxl);
    }
}

/* Navigation Responsive Styles */
@media (max-width: 768px) {
    .nav-menu {
        position: fixed;
        top: 70px;
        right: -100%;
        width: 90%;
        height: calc(100vh - 70px);
        background: rgba(10, 10, 10, 0.95);
        backdrop-filter: blur(20px);
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;
        padding-top: var(--space-lg);
        gap: var(--space-md);
        transition: var(--transition-normal);
        border-left: 1px solid var(--border-color);
        z-index: 999;
    }
    
    .nav-menu.active {
        right: 0;
    }
    
    .nav-link {
        font-size: 1rem;
        padding: var(--space-xs) var(--space-md);
    }
    
    .hamburger {
        display: flex;
    }
    
    .hamburger.active .bar:nth-child(1) {
        transform: rotate(-45deg) translate(-5px, 6px);
    }
    
    .hamburger.active .bar:nth-child(2) {
        opacity: 0;
    }
    
    .hamburger.active .bar:nth-child(3) {
        transform: rotate(45deg) translate(-5px, -6px);
    }
    
    .logo-text {
        display: none;
    }
}

/* Hero Section Responsive Adjustments */
@media (max-width: 768px) {
  .hero {
      height: 70vh; /* Reduced from 80vh */
      min-height: 400px; /* Further reduced for extreme small screens */
  }
   
  /* Extreme small screen optimizations */
  @media (max-width: 320px) {
    .hero {
        height: 60vh; /* Even smaller height for tiny screens */
        min-height: 350px; /* Increased minimum height for better visibility on very small screens */
    }
    
    .hero-title {
        font-size: 1.5rem; /* Further reduced title size */
    }
    
    .hero-subtitle {
        font-size: 1rem; /* Further reduced subtitle size */
    }
    
    .hero-description {
        font-size: 0.85rem; /* Further reduced description size */
    }
  }
   
  .hero-content {
      padding: 0 var(--space-md);
  }
   
  .hero-title {
      margin-bottom: var(--space-sm);
      overflow-wrap: break-word;
      word-break: break-word;
  }
   
  .hero-subtitle {
      overflow-wrap: break-word;
      word-break: break-word;
  }
   
  .hero-description {
      margin-bottom: var(--space-lg);
      line-height: 1.5; /* Improved text readability on mobile */
      overflow-wrap: break-word;
      word-break: break-word;
  }
   
  /* Mobile optimizations for animated slogan */
  .animated-slogan {
      opacity: 0.7; /* Further reduce opacity for less visual distraction */
      font-size: 0.85rem; /* Even smaller text for better fit */
      letter-spacing: 0.5px; /* Improve readability */
      padding: 0 var(--space-xs); /* Add horizontal padding */
      max-width: 90%; /* Prevent overflow on small screens */
      margin: 0 auto; /* Center align */
      display: block; /* Ensure it takes full width when needed */
      overflow-wrap: break-word; /* Allow text to wrap for better mobile readability */
      word-break: break-word; /* Ensure long words break if needed */
      overflow: visible; /* Allow content to flow naturally */
  }
   
  /* Additional optimization for very small screens */
  @media (max-width: 320px) {
      .animated-slogan {
          font-size: 0.75rem; /* Even smaller for tiny screens */
          letter-spacing: 0.3px;
      }
  }
   
  /* Improve button touch targets */
  .cta-button {
      padding: var(--space-md) var(--space-lg); /* Increased padding for better touch target */
      min-height: 48px; /* Minimum 48px height for touch target */
      min-width: 48px; /* Minimum 48px width for touch target */
      display: inline-flex;
      align-items: center;
      justify-content: center;
  }
   
  .github-button {
      padding: var(--space-sm) var(--space-md); /* Increased padding for better touch target */
      min-height: 40px; /* Minimum height for touch target */
      min-width: 40px; /* Minimum width for touch target */
      display: inline-flex;
      align-items: center;
      justify-content: center;
  }
}

/* About Section Responsive Adjustments */
@media (max-width: 768px) {
    .about {
        padding: var(--space-lg) 0; /* Reduced section padding on mobile */
    }
    
    .about-content {
        text-align: center;
    }
    
    .section-title {
        text-align: center;
    }
    
    .mission-highlights {
        justify-content: center;
    }
    
    /* Improve text readability */
    .about-description {
        font-size: 1rem;
        line-height: 1.6;
    }
    
    .section-title {
        font-size: 1.75rem;
    }
}

/* Projects Section Responsive Adjustments */
@media (max-width: 768px) {
   .projects {
        padding: var(--space-lg) 0; /* Reduced section padding on mobile */
    }
    
    .projects-grid {
        margin-top: var(--space-md); /* Reduced margin-top */
    }
    
    .project-card {
        /* Ensure cards don't take too much height on small screens */
        margin-bottom: var(--space-sm);
    }
    
    .project-content {
        padding: var(--space-sm); /* Further reduced padding for compactness */
        word-wrap: break-word; /* Ensure text wraps properly */
        overflow-wrap: break-word;
    }
    
    .project-title {
        font-size: 1.15rem; /* Slightly reduced for better fit */
        word-wrap: break-word;
        overflow-wrap: break-word;
        margin-bottom: var(--space-xs); /* Reduced margin */
    }
    
    .project-description {
        font-size: 0.875rem; /* Slightly reduced for better fit */
        line-height: 1.4; /* Optimized line height */
        word-wrap: break-word;
        overflow-wrap: break-word;
        margin-bottom: var(--space-xs); /* Reduced margin */
    }
    
    .project-tech {
        margin-bottom: var(--space-sm); /* Reduced margin */
    }
    
    .tech-tag {
        padding: var(--space-xxs) var(--space-sm); /* Compact padding */
        font-size: 0.75rem; /* Smaller tech tags */
    }
    
    /* Improve button touch targets */
    .github-button {
        padding: var(--space-sm) var(--space-md); /* Increased padding for better touch target */
        min-height: 40px; /* Minimum height for touch target */
        min-width: 40px; /* Minimum width for touch target */
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: 0.875rem; /* Slightly smaller font */
    }
    
    /* Additional fix for very small screens */
    @media (max-width: 320px) {
        .project-description {
            font-size: 0.8rem;
        }
        
        .project-title {
            font-size: 1.1rem;
        }
        
        .tech-tag {
            font-size: 0.7rem;
            padding: var(--space-xxs) var(--space-sm);
        }
    }
}

/* Footer Responsive Adjustments */
@media (max-width: 768px) {
    .footer {
        padding: var(--space-lg) 0; /* Reduced section padding on mobile */
    }
    
    .footer-content {
        flex-direction: column;
        gap: var(--space-md);
        text-align: center;
    }
    
    .footer-logo {
        justify-content: center;
    }
    
    .footer-copyright {
        font-size: 0.9rem;
    }
    
    .social-media-icons {
        flex-direction: row;
        flex-wrap: wrap;
        gap: var(--space-sm);
        margin-top: var(--space-md);
    }
    
    .social-icon {
        width: 44px; /* Increased for better touch target */
        height: 44px; /* Increased for better touch target */
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Improve text readability */
    .footer-description {
        font-size: 0.95rem;
        line-height: 1.5;
    }
}

/* High DPI Screens */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .hero-background {
        background-image: url('../brain_background.png');
        background-size: cover;
    }
}

/* Print Styles */
@media print {
    .header,
    .footer,
    .cta-button,
    .github-button {
        display: none;
    }
    
    body {
        color: #000;
        background: #fff;
    }
    
    .hero {
        height: auto;
        background: none;
    }
    
    .hero-background,
    .hero-overlay {
        display: none;
    }
    
    .project-card {
        break-inside: avoid;
        border: 1px solid #ccc;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    html {
        scroll-behavior: auto;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --dark-bg: #0A0A0A;
        --light-text: #F0F0F0;
        --secondary-text: #B0B0B0;
        --icon-brightness: 1.8;
        --icon-opacity: 1.0;
    }
    
    /* Override social icon filters for dark mode */
    .social-icon {
        filter: grayscale(5%) opacity(0.95) brightness(var(--icon-brightness));
        outline: 1px solid rgba(255, 255, 255, 0.15);
    }
    
    /* Enhanced hover effects */
    .social-icon:hover {
        filter: grayscale(0%) opacity(1) brightness(2.0);
        outline: 1px solid rgba(255, 255, 255, 0.25);
        transform: translateY(-2px);
        transition: all 0.3s ease;
    }
    
    /* Platform-specific enhancements with maintained colors but increased brightness */
    .social-icon.github {
        filter: brightness(var(--icon-brightness)) opacity(var(--icon-opacity)) hue-rotate(0deg);
    }
    
    .social-icon.linkedin {
        filter: brightness(var(--icon-brightness)) opacity(var(--icon-opacity)) hue-rotate(0deg);
    }
    
    .social-icon.twitter {
        filter: brightness(var(--icon-brightness)) opacity(var(--icon-opacity)) hue-rotate(0deg);
    }
    
    .social-icon.youtube {
        filter: brightness(var(--icon-brightness)) opacity(var(--icon-opacity)) hue-rotate(0deg);
    }
}

/* Orientation Specific Styles */
@media (orientation: landscape) and (max-height: 500px) {
    .hero {
        height: 100vh;
    }
    
    .hero-content {
        padding-top: 80px;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    .project-card:hover {
        transform: none;
    }
    
    .cta-button:hover,
    .github-button:hover {
        transform: none;
    }
    
    .nav-link::after,
    .nav-link::before {
        display: none;
    }
    
    /* Add touch feedback */
    .project-card:active {
        transform: scale(0.98);
    }
    
    .cta-button:active,
    .github-button:active {
        transform: scale(0.95);
    }
}

/* Very Large Screens */
@media (min-width: 1600px) {
    .container {
        max-width: 1400px;
    }
    
    .projects-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Ultra-wide Screens */
@media (min-width: 2000px) {
    .container {
        max-width: 1800px;
    }
    
    .projects-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Responsive Logo Sizing */
.logo-img {
    height: clamp(90px, 8vw, 150px); /* Responsive logo height */
    width: auto;
}

.footer-logo-img {
    height: clamp(25px, 4vw, 40px); /* Responsive footer logo */
    width: auto;
}

/* Mobile-specific logo adjustment */
@media (max-width: 768px) {
    .logo-img {
        height: clamp(50px, 5vw, 80px);
    }
    
    /* Ensure logo remains accessible when hidden */
    .logo-text {
        display: block !important;
        font-size: 1rem;
        text-align: center;
        margin-top: var(--space-xs);
    }
}

/* Image overflow protection (already in styles.css but ensuring consistency) */
img {
    max-width: 100%;
    height: auto;
}

/* Improve text readability on mobile - general */
@media (max-width: 768px) {
    body {
        font-size: 1rem; /* Changed from 0.95rem to 1rem for better readability (16px minimum) */
        line-height: 1.6;
    }
    
    h1, h2, h3, h4, h5, h6 {
        line-height: 1.3;
        overflow-wrap: break-word;
        word-break: break-word;
    }
    
    p {
        line-height: 1.6;
        overflow-wrap: break-word;
        word-break: break-word;
    }
    
    /* Ensure consistent line heights and word-wrap for all text elements */
    .hero-title,
    .hero-subtitle,
    .hero-description,
    .section-title,
    .about-description,
    .project-title,
    .project-description,
    .highlight-text,
    .footer-description,
    .footer-copyright,
    .nav-link,
    .logo-text,
    .founder-text,
    .or-text,
    .founder-name,
    .founder-tagline,
    .email-link,
    .social-icon {
        overflow-wrap: break-word;
        word-break: break-word;
    }
    
    /* Improve button touch targets globally */
    .cta-button,
    .github-button,
    .email-link,
    .social-icon {
        touch-action: manipulation; /* Improves touch responsiveness */
    }
}
   /* Performance Optimizations */
   @media (max-width: 768px) {
       /* Reduce animation intensity on mobile */
       .hero-background {
           animation: brainFloat 30s ease-in-out infinite; /* Slower animation */
       }
       
       /* Simplify or disable non-essential animations */
       .fade-in, .slide-up, .pulse, .glow, .float {
           animation-duration: 0.001ms !important;
           animation-iteration-count: 1 !important;
           transition-duration: 0.001ms !important;
       }
   }