/**
 * Mobile Enhancements for XSSNow
 * Fixes mobile responsiveness issues including navbar, terminal, and layout problems
 */

/* CSS Custom Properties for mobile */
:root {
  --mobile-padding: 1rem;
  --mobile-max-height: calc(var(--vh, 1vh) * 100);
  --mobile-safe-area-top: env(safe-area-inset-top);
  --mobile-safe-area-bottom: env(safe-area-inset-bottom);
}

/* Mobile Navigation Fixes */
@media (max-width: 768px) {
  /* Enhanced Mobile Navigation */
  .navbar {
    padding: 0.75rem 0;
    background: rgba(10, 10, 10, 0.98);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(0, 255, 65, 0.3);
  }

  .nav-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--mobile-padding);
    position: relative;
  }

  .nav-brand {
    font-size: 1.3rem;
    z-index: 10001;
  }

  .mobile-menu-toggle {
    display: flex !important;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    padding: 12px 8px;
    cursor: pointer;
    z-index: 10001;
    position: relative;
  }

  .mobile-menu-toggle span {
    width: 24px;
    height: 3px;
    background: var(--neon-green);
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    border-radius: 2px;
    transform-origin: center;
  }

  .mobile-menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
  }

  .mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
    transform: scale(0);
  }

  .mobile-menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
  }

  .nav-menu {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(10, 10, 10, 0.98);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(0, 255, 65, 0.2);
    padding: 1rem var(--mobile-padding);
    gap: 0.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    z-index: 9998;
  }

  .nav-menu.active {
    display: flex;
  }

  .nav-menu .nav-link {
    padding: 0.8rem 0;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 1rem;
    transition: all 0.3s ease;
  }

  .nav-menu .nav-link:last-child {
    border-bottom: none;
  }

  .nav-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 10001;
  }

  .github-btn span {
    display: none;
  }

  .github-btn {
    padding: 0.5rem;
    min-width: auto;
  }

  /* Terminal Section Mobile Fixes */
  .terminal-section {
    padding: 4rem var(--mobile-padding) 4rem;
    margin-top: 0;
  }

  .terminal-window {
    height: auto;
    min-height: 200px;
    max-height: 60vh;
    overflow-y: auto;
    border-radius: 8px;
    margin: 2rem 0;
  }

  .terminal-header {
    padding: 0.75rem 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .terminal-title {
    font-size: 0.9rem;
  }

  .terminal-controls {
    gap: 0.3rem;
  }

  .terminal-controls span {
    width: 12px;
    height: 12px;
  }

  .terminal-content {
    padding: 1rem;
    font-size: 0.85rem;
    line-height: 1.4;
    max-height: 50vh;
    overflow-y: auto;
  }

  .terminal-line {
    margin-bottom: 0.5rem;
    word-wrap: break-word;
    white-space: pre-wrap;
  }

  /* Command input in terminal */
  .terminal-input {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
    flex-wrap: wrap;
  }

  .terminal-prompt {
    color: var(--neon-green);
    font-weight: bold;
    flex-shrink: 0;
  }

  .terminal-cursor {
    background: var(--neon-green);
    animation: blink 1s infinite;
  }

  /* Hero Section Mobile Adjustments */
  .hero {
    padding: 6rem var(--mobile-padding) 4rem;
    text-align: center;
    min-height: auto;
  }

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

  .hero-subtitle {
    font-size: 1rem;
    margin-bottom: 2rem;
    line-height: 1.5;
  }

  .hero-description {
    font-size: 1rem;
    line-height: 1.6;
    margin-bottom: 2rem;
  }

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

  .cta-button,
  .secondary-button {
    width: 100%;
    max-width: 280px;
    padding: 1rem 2rem;
    font-size: 1rem;
  }

  /* Zigzag/Stats Section Mobile Fixes */
  .stats-section,
  .zigzag-section {
    padding: 3rem var(--mobile-padding);
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
    max-width: 100%;
  }

  .stat-card {
    padding: 1.5rem;
    text-align: center;
  }

  .stat-number {
    font-size: 2rem;
    margin-bottom: 0.5rem;
  }

  .stat-label {
    font-size: 0.9rem;
  }

  /* Features Section Mobile */
  .features-section {
    padding: 3rem var(--mobile-padding);
  }

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

  .feature-card {
    padding: 1.5rem;
  }

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

  /* Categories Section Mobile */
  .categories-section {
    padding: 3rem var(--mobile-padding);
  }

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

  .category-card {
    padding: 1.5rem;
  }

  /* Footer Mobile */
  footer {
    padding: 2rem var(--mobile-padding) 1rem;
  }

  .footer-content {
    grid-template-columns: 1fr;
    gap: 2rem;
    text-align: center;
  }

  .footer-section h3 {
    margin-bottom: 1rem;
  }

  .footer-links {
    justify-content: center;
  }

  .footer-bottom {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }

  /* Animations for mobile */
  @keyframes slideInDown {
    from {
      opacity: 0;
      transform: translateY(-30px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  @keyframes blink {
    0%, 50% {
      opacity: 1;
    }
    51%, 100% {
      opacity: 0;
    }
  }

  /* Touch-friendly improvements */
  .btn, .cta-button, .secondary-button, .nav-link {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
  }

  /* Prevent text selection on UI elements */
  .mobile-menu-toggle,
  .nav-link,
  .btn {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
  }

  /* Smooth scrolling adjustments for mobile */
  html {
    scroll-behavior: smooth;
    scroll-padding-top: 80px;
  }

  /* Fix for mobile browsers viewport */
  body {
    min-height: var(--mobile-max-height);
    padding-top: var(--mobile-safe-area-top);
    padding-bottom: var(--mobile-safe-area-bottom);
  }
}

/* Extra small devices */
@media (max-width: 480px) {
  :root {
    --mobile-padding: 0.75rem;
  }

  .hero-content h1 {
    font-size: 2rem;
  }

  .hero-subtitle {
    font-size: 0.9rem;
  }

  .terminal-window {
    min-height: 150px;
  }

  .terminal-content {
    font-size: 0.8rem;
    padding: 0.75rem;
  }

  .nav-brand {
    font-size: 1.1rem;
  }

  .stat-number {
    font-size: 1.8rem;
  }

  .feature-card,
  .category-card,
  .stat-card {
    padding: 1rem;
  }
}

/* Landscape mobile fixes */
@media (max-width: 768px) and (orientation: landscape) {
  .hero {
    padding: 6rem var(--mobile-padding) 3rem;
  }

  .terminal-window {
    max-height: 40vh;
  }

  .hero-content h1 {
    font-size: 2.2rem;
  }
}

/* High DPI mobile displays */
@media (max-width: 768px) and (-webkit-min-device-pixel-ratio: 2) {
  .terminal-content,
  .nav-link,
  .btn {
    font-size: 0.9rem;
  }
}