/* Mobile-first Responsive Styles for Nadim's Portfolio */

/* Base Mobile Optimizations */
:root {
  --mobile-padding: 16px;
  --section-spacing-mobile: 60px;
  --text-size-adjust: 0.85;
}

/* Fix viewport issues on mobile */
@viewport {
  width: device-width;
  zoom: 1.0;
}

/* Global Mobile Adjustments */
@media (max-width: 768px) {
  h1, .hero-title {
    font-size: calc(32px * var(--text-size-adjust));
    line-height: 1.2;
  }
  
  h2, .section-title {
    font-size: calc(24px * var(--text-size-adjust));
  }
  
  h3 {
    font-size: calc(20px * var(--text-size-adjust));
  }
  
  p {
    font-size: calc(16px * var(--text-size-adjust));
  }
  
  .container {
    padding-left: var(--mobile-padding);
    padding-right: var(--mobile-padding);
  }
  
  section {
    padding: 50px 0;
    margin-bottom: var(--section-spacing-mobile);
  }
  
  .btn {
    padding: 10px 16px;
    font-size: 14px;
  }
}

/* ======= HEADER & NAVIGATION ======= */
@media (max-width: 768px) {
  header {
    padding: 12px 0;
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1000;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    background-color: rgba(13, 2, 33, 0.8);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  }
  
  body {
    padding-top: 60px; /* Compensate for fixed header */
  }
  
  /* Menu open state - prevent body scroll */
  body.menu-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
  }
  
  .logo {
    font-size: 24px;
  }
  
  /* ===== COMPLETELY REBUILT MOBILE MENU ===== */
  /* Hide original nav links */
  .nav-links {
    display: none !important;
  }
  
  /* Create a completely new mobile menu container that will be shown via JavaScript */
  .mobile-menu-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 9999; /* Extremely high z-index */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease;
  }
  
  .mobile-menu-container.active {
    opacity: 1;
    visibility: visible;
  }
  
  /* Menu links container */
  .mobile-nav-links {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 80%;
    max-width: 300px;
  }
  
  /* Individual menu links */
  .mobile-nav-link {
    display: block;
    width: 100%;
    padding: 15px 20px;
    margin: 10px 0;
    font-size: 18px;
    color: white !important; /* Force white color */
    text-align: center;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
    text-decoration: none;
    font-weight: bold;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3); /* Add shadow for depth */
    letter-spacing: 0.5px; /* Improve readability */
  }
  
  .mobile-nav-link:active {
    transform: scale(0.95);
    background-color: var(--primary);
    color: var(--dark);
  }
  
  /* Close button in mobile menu */
  .mobile-menu-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
  }
  
  .mobile-menu-close:before,
  .mobile-menu-close:after {
    content: '';
    position: absolute;
    width: 20px;
    height: 3px;
    background-color: white;
    border-radius: 3px;
  }
  
  .mobile-menu-close:before {
    transform: rotate(45deg);
  }
  
  .mobile-menu-close:after {
    transform: rotate(-45deg);
  }
  
  /* Original nav link styles for reference only - these won't be used */
  .nav-link {
    display: none;
  }
  
  .mobile-menu {
    display: flex !important;
    z-index: 1002; /* Above everything */
    cursor: pointer;
    margin-right: 10px; /* Make space for the CTA button */
  }
  
  /* Mobile CTA button */
  .mobile-cta {
    display: block !important;
    padding: 6px 10px;
    background-color: var(--primary);
    color: var(--dark) !important;
    border-radius: 4px;
    font-size: 14px;
    font-weight: bold;
    text-decoration: none;
    z-index: 1002;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  }
  
  .mobile-cta:active {
    transform: scale(0.95);
  }
  
  /* Mobile menu overlay */
  .mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    animation: fadeIn 0.3s ease forwards;
    pointer-events: auto !important; /* Ensure overlay captures clicks */
    touch-action: auto !important; /* Ensure touch events work */
  }
  
  @keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
  }
  
  /* Make hamburger menu more visible */
  .mobile-menu span {
    height: 3px;
    margin: 3px 0;
    width: 26px;
    background-color: var(--primary);
    border-radius: 2px;
    transition: all 0.3s ease;
  }
  
  .mobile-menu.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
  }
  
  .mobile-menu.active span:nth-child(2) {
    opacity: 0;
  }
  
  .mobile-menu.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
  }
  
  /* Improve tap targets */
  .nav-link, .social-link, button, .btn, a {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

/* Hide mobile-only elements on desktop */
.mobile-break {
  display: none;
}

/* ======= HERO SECTION ======= */
@media (max-width: 768px) {
  /* Show mobile line break */
  .mobile-break {
    display: inline;
  }
  .hero {
    flex-direction: column;
    min-height: calc(100vh - 60px);
    padding-top: 30px;
    margin-top: 30px;
  }
  
  .hero-content {
    width: 100%;
    text-align: center;
    margin-bottom: 2rem;
    padding: 0 15px;
  }
  
  .hero-title {
    font-size: 30px;
    line-height: 1.4;
    margin-bottom: 15px;
    letter-spacing: 0.5px; /* Add more space between characters */
    word-spacing: 2px; /* Add more space between words */
    color: #ffffff !important; /* Pure white for maximum contrast */
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.5); /* Shadow for better readability */
    font-weight: 600; /* Slightly bolder for better contrast */
  }
  
  /* Add more breathing room to the name and make it stand out */
  .hero-title .highlight {
    display: inline-block;
    margin: 0 2px;
    color: var(--primary) !important; /* Make name pop with primary color */
    text-shadow: 0 0 10px rgba(0, 255, 163, 0.3); /* Glow effect */
  }
  
  /* Make hero description more readable */
  .hero-description {
    color: #ffffff !important;
    opacity: 0.95 !important;
    font-weight: 400;
    line-height: 1.6;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
  }
  
  .hero-subtitle {
    font-size: 18px;
    margin-bottom: 15px;
  }
  
  .hero-description {
    max-width: 100%;
    font-size: 16px;
    line-height: 1.5;
  }
  
  .hero-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-gap: 10px;
    width: 100%;
    margin-top: 20px;
  }
  
  .hero-buttons .btn {
    margin: 0;
    width: 100%;
    padding: 12px 5px;
    font-size: 14px;
  }
  
  /* Make "Download CV" button full width */
  .hero-buttons .btn-download {
    grid-column: span 2;
    margin-top: 10px;
  }
  
  .terminal-container {
    width: 100%;
    height: auto;
    margin-top: 0;
    min-height: 250px;
    transform: scale(0.9);
    max-width: 100%;
    overflow: hidden;
  }
  
  .terminal-header {
    padding: 8px 12px;
  }
  
  .terminal-body {
    max-height: 180px;
    padding: 10px;
    font-size: 12px;
  }
  
  .terminal-line {
    margin-bottom: 6px;
  }
  
  /* Adjust hero background elements for mobile */
  .accent-circle {
    opacity: 0.4;
    transform: scale(0.6);
  }
  
  /* Optimize animations for mobile */
  .animate-fade-in {
    animation-duration: 0.5s;
  }
  
  .delay-300 {
    animation-delay: 0.1s;
  }
}

/* ======= CLIENT LOGOS SECTION ======= */
@media (max-width: 768px) {
  .logos-container {
    overflow-x: auto;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
    margin: 0 -15px;
    padding: 0 15px;
  }
  
  .logos-container::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
  }
  
  .logos-track {
    display: flex !important;
    width: auto !important;
    animation: none !important; /* Remove auto-scrolling animation */
    transition: transform 0.3s ease;
    scroll-snap-type: x mandatory;
    padding-right: 15px;
  }
  
  .logo-item {
    flex: 0 0 auto;
    width: 200px !important;
    margin-right: 15px;
    scroll-snap-align: center;
  }
  
  /* Visual indicator for scrolling */
  .logos-container::after {
    content: "← Swipe →";
    display: block;
    text-align: center;
    color: var(--primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    letter-spacing: 1px;
    margin-top: 15px;
    animation: pulse 2s infinite;
    opacity: 0.8;
  }
}

/* ======= ABOUT SECTION ======= */
@media (max-width: 768px) {
  .about-text, .about-image {
    width: 100%;
  }
  
  .about-image {
    margin-top: 30px;
  }
  
  .about-stats {
    flex-wrap: wrap;
  }
  
  .stat-card {
    width: calc(50% - 10px);
    margin-bottom: 20px;
  }
  
  /* Fix for stat numbers */
  .stat-number {
    font-size: 2.5rem !important; /* Smaller font size for mobile */
    letter-spacing: -1px; /* Tighter letter spacing */
    width: 100%; /* Full width to avoid overflow */
    text-align: center;
  }
  
  /* Ensure labels don't overflow */
  .stat-label {
    font-size: 0.9rem !important;
    text-align: center;
    width: 100%;
  }
}

/* ======= SKILLS SECTION ======= */
@media (max-width: 768px) {
  .skills-grid {
    grid-template-columns: 1fr;
    gap: 15px;
  }
  
  .skill-card {
    margin-bottom: 0;
    padding: 20px;
    transition: transform 0.3s ease;
  }
  
  .skill-card:active {
    transform: scale(0.98);
  }
  
  .skill-title {
    font-size: 18px;
    margin: 10px 0;
  }
  
  .skill-description {
    font-size: 14px;
    margin-bottom: 15px;
  }
  
  .skill-icon {
    width: 40px;
    height: 40px;
    font-size: 16px;
  }
  
  .skill-tags {
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 10px;
  }
  
  .skill-tag {
    margin: 4px;
    font-size: 12px;
    padding: 4px 8px;
  }
  
  /* Create a horizontal scrollable skills section for small phones */
  @media (max-width: 480px) {
    .skills-grid {
      display: flex;
      overflow-x: auto;
      scroll-snap-type: x mandatory;
      padding: 10px 0 20px 0;
      margin: 0 -15px;
      padding: 0 15px;
      scrollbar-width: none; /* Firefox */
    }
    
    .skills-grid::-webkit-scrollbar {
      display: none; /* Safari and Chrome */
    }
    
    .skill-card {
      flex: 0 0 85%;
      scroll-snap-align: center;
      margin-right: 15px;
    }
    
    /* Add indicator dots for scrolling */
    .skills-section-indicators {
      display: flex;
      justify-content: center;
      margin-top: 20px;
    }
    
    .skills-section-indicators .indicator {
      width: 8px;
      height: 8px;
      border-radius: 50%;
      background-color: var(--surface-light);
      margin: 0 5px;
    }
    
    .skills-section-indicators .indicator.active {
      background-color: var(--primary);
    }
  }
}

/* ======= EDUCATION SECTION ======= */
@media (max-width: 768px) {
  .education-grid {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding: 10px 0 20px 0;
    margin: 0 -15px;
    padding: 10px 15px 20px;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
    gap: 15px;
  }
  
  .education-grid::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
  }
  
  .education-card {
    flex: 0 0 85%;
    scroll-snap-align: center;
    margin-bottom: 0;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
    background-color: var(--surface-dark);
  }
  
  .education-year {
    font-size: 16px;
    margin-bottom: 10px;
    color: var(--primary);
  }
  
  .education-card h3 {
    font-size: 18px;
    margin-bottom: 10px;
  }
  
  .education-card p {
    font-size: 14px;
    opacity: 0.9;
  }
  
  /* Space for indicators */
  .education {
    padding-bottom: 30px;
  }
}

/* ======= PROCESS SECTION ======= */
@media (max-width: 768px) {
  .process-container {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding: 10px 0 20px 0;
    margin: 0 -15px;
    padding: 10px 15px 20px;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
    gap: 15px;
  }
  
  .process-container::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
  }
  
  .process-step {
    flex: 0 0 85%;
    scroll-snap-align: center;
    width: auto;
    margin-bottom: 0;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
  }
  
  /* Space for indicators */
  .process {
    padding-bottom: 30px;
  }
}

/* ======= PROJECTS SECTION ======= */
@media (max-width: 768px) {
  /* Project filters as horizontal scrollable menu */
  .project-filters {
    display: flex;
    overflow-x: auto;
    white-space: nowrap;
    padding: 5px 0 15px 0;
    margin: 0 -15px 20px -15px;
    padding: 5px 15px 15px 15px;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
    scroll-snap-type: x mandatory;
    justify-content: flex-start;
  }
  
  .project-filters::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
  }
  
  .filter-btn {
    margin: 0 6px 0 0;
    font-size: 13px;
    padding: 8px 14px;
    flex: 0 0 auto;
    scroll-snap-align: start;
  }
  
  .filter-btn:last-child {
    margin-right: 0;
  }
  
  /* Projects grid */
  .projects-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  
  .project-card {
    margin-bottom: 0;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    overflow: hidden;
  }
  
  .project-image {
    height: 180px;
  }
  
  .project-overlay {
    opacity: 0.5; /* Always show overlay for better text visibility */
  }
  
  .project-content {
    padding: 15px;
  }
  
  .project-title {
    font-size: 18px;
    margin-bottom: 8px;
  }
  
  .project-description {
    font-size: 14px;
    margin-bottom: 10px;
  }
  
  .project-tech {
    flex-wrap: wrap;
    margin-bottom: 10px;
  }
  
  .project-tech-item {
    margin: 3px;
    font-size: 11px;
    padding: 3px 8px;
  }
  
  /* Case Study Section */
  .case-studies {
    margin-top: 40px;
  }
  
  .case-study-heading {
    font-size: 22px;
    margin-bottom: 15px;
    text-align: center;
  }
  
  .case-study-container {
    flex-direction: column;
    border-radius: 12px;
    padding: 0;
    overflow: hidden;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
  }
  
  .case-study-content {
    width: 100%;
    padding: 20px;
  }
  
  .case-study-header h4 {
    font-size: 18px;
  }
  
  .case-study-badge {
    font-size: 12px;
    padding: 4px 8px;
  }
  
  .case-study-section h5 {
    font-size: 16px;
    margin-bottom: 8px;
  }
  
  .case-study-section p {
    font-size: 14px;
    line-height: 1.5;
  }
  
  .case-study-tech li {
    font-size: 13px;
    margin-bottom: 5px;
  }
  
  .case-study-metrics {
    flex-direction: column;
  }
  
  .metric {
    margin: 10px 0;
  }
  
  .case-study-image {
    margin-top: 0;
    order: -1; /* Show image first on mobile */
    height: 200px;
    width: 100%;
    border-radius: 0;
  }
  
  /* Optimize animations */
  .secure-comms-scene {
    transform: scale(0.8);
  }
  
  /* Horizontal scroll for projects on very small screens */
  @media (max-width: 480px) {
    .projects-grid {
      display: flex;
      overflow-x: auto;
      scroll-snap-type: x mandatory;
      padding: 10px 0 20px 0;
      margin: 0 -15px;
      padding: 0 15px 20px;
      scrollbar-width: none;
    }
    
    .projects-grid::-webkit-scrollbar {
      display: none;
    }
    
    .project-card {
      flex: 0 0 85%;
      scroll-snap-align: center;
      margin-right: 15px;
    }
  }
}

/* ======= CONTACT SECTION ======= */
@media (max-width: 768px) {
  .contact {
    padding: 60px 0;
  }
  
  .contact-container {
    flex-direction: column;
  }
  
  .contact-info, .contact-form {
    width: 100%;
  }
  
  .contact-info {
    margin-bottom: 30px;
    text-align: center;
  }
  
  .contact-heading {
    font-size: 22px;
    margin-bottom: 15px;
  }
  
  .contact-description {
    font-size: 15px;
    margin-bottom: 25px;
  }
  
  .contact-list {
    margin-bottom: 30px;
  }
  
  .contact-item {
    margin-bottom: 15px;
    justify-content: center;
  }
  
  .contact-icon {
    margin-right: 10px;
    font-size: 18px;
  }
  
  .contact-text {
    font-size: 15px;
  }
  
  /* Form Styles */
  .contact-form {
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
  }
  
  .form-group {
    margin-bottom: 15px;
  }
  
  .form-label {
    font-size: 14px;
    margin-bottom: 6px;
  }
  
  .form-control {
    padding: 12px;
    font-size: 16px; /* Prevents zooming on iOS */
    border-radius: 8px;
  }
  
  textarea.form-control {
    min-height: 120px;
  }
  
  .form-submit {
    width: 100%;
    padding: 14px;
    margin-top: 10px;
    font-size: 16px;
    border-radius: 8px;
  }
  
  /* Success message */
  .success-message {
    padding: 20px;
  }
  
  .success-icon {
    font-size: 40px;
    margin-bottom: 15px;
  }
  
  /* Availability section */
  .availability-simple {
    padding: 15px;
    margin-top: 20px;
    border-radius: 8px;
  }
  
  .availability-heading {
    font-size: 18px;
    margin-bottom: 10px;
  }
}

/* ======= FOOTER ======= */
@media (max-width: 768px) {
  .footer-container {
    flex-direction: column;
    text-align: center;
  }
  
  .footer-logo {
    margin-bottom: 20px;
  }
  
  .footer-social {
    justify-content: center;
    margin-top: 20px;
  }
  
  .footer-copyright {
    margin-top: 20px;
    text-align: center;
  }
}

/* ======= FLOATING ACTION BUTTON ======= */
@media (max-width: 768px) {
  .floating-action-btn {
    bottom: 20px;
    right: 20px;
    z-index: 998; /* Ensure it's above back-to-top button */
  }
  
  /* Position the FAB options so they don't overlap */
  .fab-options {
    bottom: 70px; /* Position options above the FAB button */
    right: 0;
  }
}

/* ======= TESTIMONIALS SECTION ======= */
@media (max-width: 768px) {
  .testimonial-card {
    width: 100%;
    padding: 20px;
  }
}

/* ======= ANIMATION ADJUSTMENTS ======= */
@media (max-width: 768px) {
  .animate-fade-in, .animate-slide-left, .animate-slide-right {
    animation-duration: 0.5s;
  }
  
  .delay-100, .delay-200, .delay-300, .delay-400 {
    animation-delay: 0.1s;
  }
}

/* ======= CUSTOM ALERT OPTIMIZATION ======= */
@media (max-width: 768px) {
  .custom-alert {
    width: 90%;
    left: 5%;
  }
}

/* ======= SMALL SCREEN DEVICES ======= */
@media (max-width: 480px) {
  :root {
    --text-size-adjust: 0.8;
  }
  
  .container {
    padding-left: 12px;
    padding-right: 12px;
  }
  
  .hero-title {
    font-size: calc(28px * var(--text-size-adjust));
  }
  
  .hero-subtitle {
    font-size: calc(18px * var(--text-size-adjust));
  }
  
  .stat-card {
    width: 100%;
  }
  
  .about-stats {
    justify-content: center;
  }
  
  .section-header {
    margin-bottom: 30px;
  }
  
  .terminal-container {
    transform: scale(0.8);
  }
}

/* ======= DARK MODE PREFERENCE ======= */
@media (prefers-color-scheme: dark) {
  /* Already using dark theme, but adjusting for device preferences */
  :root {
    --primary: #00ffa3;
    --text: #ffffff;
  }
  
  /* Simplified mobile visibility fixes */
  @media (max-width: 768px) {
    /* Nothing special here - using base styles */
  }
}

/* ======= TOUCH OPTIMIZATIONS ======= */
@media (hover: none) {
  .btn:hover, .nav-link:hover, .skill-card:hover, .project-card:hover, 
  .social-link:hover, .filter-btn:hover {
    transform: none;
    box-shadow: var(--shadow-sm);
  }
  
  .btn:active, .nav-link:active, .skill-card:active,
  .project-card:active, .social-link:active, .filter-btn:active {
    transform: scale(0.98);
  }
}

/* ======= DEVICE SPECIFIC FIXES ======= */
/* iPhone Notch Safe Area */
@supports (padding-top: env(safe-area-inset-top)) {
  header {
    padding-top: env(safe-area-inset-top);
  }
  
  .nav-links {
    padding-top: calc(env(safe-area-inset-top) + 2rem);
  }
}

/* Enhance scroll performance */
* {
  -webkit-overflow-scrolling: touch;
}

/* Prevent content shift on mobile */
html, body {
  overflow-x: hidden;
  width: 100%;
}

/* Prevent zoom on input focus on iOS */
input, textarea, select, button {
  font-size: 16px;
}

/* Background effects for mobile - match main site styling */
@media (max-width: 768px) {
  /* Default styling for background elements */
  .noise, .grid, .scanlines {
    opacity: 0.5;
  }
  
  .gradient-bg {
    opacity: 0.8;
  }
  
  .accent-circle {
    transform: scale(0.8);
    opacity: 0.4;
  }
  
  .floating-elements-container {
    display: none; /* Keep this off for mobile */
  }
}

/* ======= RESPONSIVE DESIGN UTILITIES ======= */
/* Hide elements on mobile */
@media (max-width: 768px) {
  .hide-on-mobile {
    display: none !important;
  }
}

/* Hide elements on desktop */
@media (min-width: 769px) {
  .hide-on-desktop {
    display: none !important;
  }
}

/* Mobile-only text alignment */
@media (max-width: 768px) {
  .text-center-mobile {
    text-align: center !important;
  }
}

/* Better touch feedback for all interactive elements */
@media (hover: none) {
  a, button, .btn, .nav-link, .project-card, .skill-card, 
  .social-link, .filter-btn, input[type="submit"] {
    transition: transform 0.2s ease, opacity 0.2s ease, background-color 0.2s ease !important;
    -webkit-tap-highlight-color: transparent;
  }
  
  a:active, button:active, .btn:active, .nav-link:active, 
  .project-card:active, .skill-card:active, .social-link:active, 
  .filter-btn:active, input[type="submit"]:active,
  .touch-active {
    transform: scale(0.97) !important;
    opacity: 0.9 !important;
  }
  
  /* Specific style for nav links on touch */
  .nav-link.touch-active {
    background-color: rgba(0, 255, 163, 0.1);
    color: var(--primary);
  }
}

/* Optimize animations based on user preference */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  
  .animate-fade-in, .animate-slide-left, .animate-slide-right,
  .delay-100, .delay-200, .delay-300, .delay-400 {
    opacity: 1 !important;
    transform: none !important;
  }
}

/* Focus styles for better accessibility */
a:focus, button:focus, input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--primary) !important;
  outline-offset: 2px !important;
  box-shadow: 0 0 0 2px rgba(0, 255, 163, 0.3) !important;
}

/* Mobile scrolling performance optimization */
@media (max-width: 768px) {
  * {
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
  }
  
  .container, section, .projects-grid, .skills-grid, .education-grid, .process-container {
    will-change: transform;
  }
}

/* Swipeable sections indicators */
@media (max-width: 768px) {
  /* Add swipe hint to all scrollable areas */
  .skills-grid,
  .projects-grid,
  .education-grid,
  .process-container,
  .logos-track {
    position: relative;
  }
  
  .skills-grid::after,
  .projects-grid::after,
  .education-grid::after,
  .process-container::after,
  .logos-track::after {
    content: "← Swipe →";
    display: block;
    position: absolute;
    bottom: -25px;
    left: 0;
    right: 0;
    text-align: center;
    color: var(--primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    letter-spacing: 1px;
    opacity: 0.8;
    animation: pulse 2s infinite;
    pointer-events: none;
  }
  
  @keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
  }
  
  .swipe-indicators {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 25px 0 5px 0;
    gap: 8px;
  }
  
  .swipe-indicators .indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--surface-light);
    transition: background-color 0.3s ease, transform 0.3s ease;
  }
  
  .swipe-indicators .indicator.active {
    background-color: var(--primary);
    transform: scale(1.2);
  }
}

/* Initial body state */
body {
  opacity: 1 !important;
  visibility: visible !important;
}

/* Simple mobile styles matching main site styling */
@media (max-width: 768px) {
  body {
    background-color: var(--dark);
    color: var(--text);
  }
  
  /* Default spacing for sections */
  .section-header {
    margin-bottom: 25px;
  }
  
  /* Reset text styling to match main site */
  p, li, .stat-label, .about-paragraph, 
  .skill-description, .process-description, .project-description,
  .education-card p, .contact-description, .contact-text,
  .section-description {
    color: var(--text);
    opacity: 0.9;
    font-weight: 400;
    text-shadow: none;
  }
  
  /* Default highlight styling */
  .highlight {
    color: var(--primary);
    text-shadow: none;
    font-weight: normal;
  }
  
  /* Default section title styling */
  .section-title {
    color: var(--text);
    font-weight: normal;
    text-shadow: none;
    letter-spacing: normal;
  }
  
  /* Default link styling */
  a:not(.btn), .nav-link {
    color: var(--primary);
  }
  
  /* Default card styling */
  .skill-card, 
  .project-card, 
  .education-card, 
  .process-step,
  .stat-card {
    background-color: var(--surface-dark);
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(0, 255, 163, 0.1);
  }
  
  /* Default terminal styling */
  .terminal-container {
    background-color: var(--darker);
    border: 1px solid rgba(0, 255, 163, 0.2);
  }
}

/* Preloader */
.preloader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--dark);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.preloader.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.preloader-content {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.preloader-spinner {
  width: 70px;
  height: 70px;
  margin-bottom: 20px;
  position: relative;
}

.spinner-circle {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 4px solid rgba(0, 255, 163, 0.1);
  border-top-color: var(--primary);
  animation: spin 1s infinite linear;
}

.preloader-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 18px;
  color: var(--primary);
  letter-spacing: 1px;
}

.dot {
  animation: dotAnimation 1.5s infinite;
  opacity: 0;
}

.dot:nth-child(1) {
  animation-delay: 0s;
}

.dot:nth-child(2) {
  animation-delay: 0.5s;
}

.dot:nth-child(3) {
  animation-delay: 1s;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes dotAnimation {
  0% { opacity: 0; }
  50% { opacity: 1; }
  100% { opacity: 0; }
}

@media (max-width: 768px) {
  .preloader-spinner {
    width: 50px;
    height: 50px;
  }
  
  .preloader-text {
    font-size: 16px;
  }
}

/* Back to top button (mobile-optimized) */
.back-to-top-btn {
  position: fixed;
  bottom: 20px;
  left: 20px; /* Changed from right to left to avoid overlap */
  width: 50px;
  height: 50px;
  background-color: var(--primary);
  color: var(--dark);
  border: none;
  border-radius: 50%;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: all 0.3s ease;
  z-index: 997; /* Below FAB but above most content */
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent; /* Removes tap highlight on mobile */
}

.back-to-top-btn.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top-btn:active {
  transform: scale(0.95);
}