/**
 * Mobile Enhancement CSS
 * Advanced mobile responsiveness, touch interactions, and PWA optimizations
 */

/* ===== Touch-Friendly Interactions ===== */
@media (max-width: 768px) {
  /* Larger touch targets */
  .btn, .cta-button, .nav-link {
    min-height: 44px;
    min-width: 44px;
    touch-action: manipulation;
  }

  /* Improved button spacing for touch */
  .btn + .btn {
    margin-left: 12px;
    margin-top: 8px;
  }

  /* Touch-optimized forms */
  input, textarea, select {
    min-height: 44px;
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
    touch-action: manipulation;
  }

  /* Focus states for accessibility */
  input:focus, textarea:focus, select:focus {
    outline: 2px solid #ff6b35;
    outline-offset: 2px;
  }

  /* Modal improvements */
  .modal-content {
    width: 95vw;
    max-width: 95vw;
    margin: 5vh auto;
    max-height: 90vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .modal-header {
    padding: 1rem;
    position: sticky;
    top: 0;
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    z-index: 10;
  }

  .modal-close {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
  }
}

/* ===== Enhanced Navigation for Mobile ===== */
@media (max-width: 768px) {
  .navbar {
    height: 60px;
    position: fixed;
    width: 100%;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
  }

  .nav-container {
    justify-content: space-between;
    padding: 0 1rem;
  }

  .nav-toggle {
    display: flex;
    flex-direction: column;
    width: 30px;
    height: 30px;
    justify-content: space-around;
    background: transparent;
    border: none;
    cursor: pointer;
    touch-action: manipulation;
  }

  .nav-toggle-line {
    width: 100%;
    height: 3px;
    background: #ff6b35;
    border-radius: 2px;
    transition: all 0.3s ease;
  }

  .nav-toggle.active .nav-toggle-line:nth-child(1) {
    transform: rotate(45deg) translate(8px, 8px);
  }

  .nav-toggle.active .nav-toggle-line:nth-child(2) {
    opacity: 0;
  }

  .nav-toggle.active .nav-toggle-line:nth-child(3) {
    transform: rotate(-45deg) translate(8px, -8px);
  }

  .nav-menu {
    position: fixed;
    top: 60px;
    right: -100%;
    width: 80%;
    height: calc(100vh - 60px);
    background: linear-gradient(135deg, rgba(15, 15, 35, 0.95), rgba(26, 26, 46, 0.95));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    padding: 2rem 0;
    transition: right 0.3s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .nav-menu.active {
    right: 0;
  }

  .nav-item {
    margin: 0;
    width: 100%;
  }

  .nav-link {
    display: block;
    padding: 1rem 2rem;
    color: #e2e8f0;
    text-decoration: none;
    font-size: 1.1rem;
    font-weight: 500;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
    touch-action: manipulation;
  }

  .nav-link:hover, .nav-link:focus {
    background: rgba(255, 107, 53, 0.1);
    color: #ff6b35;
    padding-left: 2.5rem;
  }

  /* Close menu when clicking outside */
  .nav-overlay {
    position: fixed;
    top: 60px;
    left: 0;
    width: 100%;
    height: calc(100vh - 60px);
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
  }

  .nav-overlay.active {
    opacity: 1;
    visibility: visible;
  }
}

/* ===== Hero Section Mobile Optimization ===== */
@media (max-width: 768px) {
  .hero {
    padding: 100px 0 60px;
    min-height: calc(100vh - 60px);
    display: flex;
    align-items: center;
  }

  .hero h1 {
    font-size: 2.5rem;
    line-height: 1.2;
    margin-bottom: 1rem;
    text-align: center;
  }

  .hero p {
    font-size: 1.1rem;
    line-height: 1.5;
    text-align: center;
    margin-bottom: 2rem;
  }

  .hero .cta-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
  }

  .cta-button {
    width: 100%;
    max-width: 280px;
    text-align: center;
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
  }
}

/* ===== Feature Cards Mobile ===== */
@media (max-width: 768px) {
  .features {
    padding: 60px 0;
  }

  .features h2 {
    font-size: 2.2rem;
    text-align: center;
    margin-bottom: 2rem;
  }

  .features-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .feature-card {
    padding: 1.5rem;
    text-align: center;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    transition: all 0.3s ease;
  }

  .feature-card:hover, .feature-card:focus-within {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 107, 53, 0.3);
  }

  .feature-card h3 {
    font-size: 1.3rem;
    margin-bottom: 1rem;
    color: #ff6b35;
  }

  .feature-card p {
    font-size: 1rem;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.8);
  }
}

/* ===== Form Improvements ===== */
@media (max-width: 768px) {
  .pre-register {
    padding: 60px 0;
  }

  .pre-register-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 100%;
  }

  .pre-register-form input {
    flex: 1;
    min-width: 0;
    border-radius: 8px;
  }

  .pre-register-form button {
    border-radius: 8px;
    white-space: nowrap;
  }

  .form-group {
    margin-bottom: 1.5rem;
  }

  .form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #e2e8f0;
  }

  .error-message {
    color: #ff4757;
    font-size: 0.9rem;
    margin-top: 0.5rem;
  }

  .success-message {
    color: #2ed573;
    font-size: 0.9rem;
    margin-top: 0.5rem;
  }
}

/* ===== FAQ Mobile Enhancement ===== */
@media (max-width: 768px) {
  .faq-item {
    margin-bottom: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    overflow: hidden;
  }

  .faq-item h3 {
    padding: 1rem;
    margin: 0;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: #e2e8f0;
    font-size: 1rem;
    text-align: left;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    touch-action: manipulation;
  }

  .faq-item h3::after {
    content: '+';
    font-size: 1.5rem;
    font-weight: 300;
    color: #ff6b35;
    transition: transform 0.3s ease;
  }

  .faq-item[aria-expanded="true"] h3::after {
    transform: rotate(45deg);
  }

  .faq-answer {
    padding: 0 1rem 1rem;
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.6;
  }
}

/* ===== Footer Mobile ===== */
@media (max-width: 768px) {
  footer {
    padding: 2rem 0;
    text-align: center;
  }

  footer .container > p {
    margin-bottom: 1rem;
  }

  footer a {
    display: inline-block;
    margin: 0.5rem;
    padding: 0.5rem;
    touch-action: manipulation;
  }
}

/* ===== PWA Enhancements ===== */
@media (max-width: 768px) {
  /* Safe area insets for modern phones */
  .hero, .features, .pre-register, .faq, footer {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  .navbar {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  /* Prevent horizontal scrolling */
  body {
    overflow-x: hidden;
  }

  /* Smooth scrolling for mobile */
  html {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
  }
}

/* ===== Accessibility Improvements ===== */
@media (max-width: 768px) {
  /* Skip link for mobile */
  .skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: #ff6b35;
    color: white;
    padding: 8px;
    text-decoration: none;
    border-radius: 4px;
    z-index: 10000;
    font-size: 1rem;
    font-weight: 600;
    touch-action: manipulation;
  }

  .skip-link:focus {
    top: 6px;
  }

  /* High contrast focus indicators */
  *:focus {
    outline: 2px solid #ff6b35;
    outline-offset: 2px;
  }

  /* Reduced motion support */
  @media (prefers-reduced-motion: reduce) {
    * {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
    }
  }
}

/* ===== Performance Optimizations ===== */
@media (max-width: 768px) {
  /* GPU acceleration for smooth animations */
  .btn, .modal-content, .nav-menu, .feature-card {
    will-change: transform;
    transform: translateZ(0);
  }

  /* Optimize image rendering */
  img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }

  /* Smooth touch scrolling */
  .modal-content, .nav-menu {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
}

/* ===== Dark Mode Optimizations ===== */
@media (max-width: 768px) {
  @media (prefers-color-scheme: dark) {
    /* Enhance contrast for mobile dark mode */
    body {
      background: #0a0a0a;
    }

    .modal-content, .feature-card, .nav-menu {
      background: rgba(0, 0, 0, 0.8);
      backdrop-filter: blur(20px);
    }

    input, textarea, select {
      background: rgba(255, 255, 255, 0.05);
      border-color: rgba(255, 255, 255, 0.2);
    }
  }
}