/* Mobile-First Performance Optimizations
   Skerritt Economics - January 2025 */

/* Critical Mobile Styles - Above the Fold */
@media screen and (max-width: 768px) {
    /* Optimize font sizes for mobile readability */
    html {
        font-size: 16px; /* Prevent zoom on iOS */
        -webkit-text-size-adjust: 100%;
    }
    
    body {
        font-size: 1rem;
        line-height: 1.6;
    }
    
    h1 {
        font-size: 1.75rem;
        line-height: 1.2;
    }
    
    h2 {
        font-size: 1.5rem;
        line-height: 1.3;
    }
    
    h3 {
        font-size: 1.25rem;
        line-height: 1.4;
    }
    
    /* Optimize touch targets */
    a, button, input, select, textarea {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Mobile navigation optimization */
    .nav-menu {
        position: fixed;
        top: 0;
        right: -100%;
        width: 80%;
        max-width: 320px;
        height: 100vh;
        background: white;
        box-shadow: -2px 0 8px rgba(0,0,0,0.1);
        transition: right 0.3s ease;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        z-index: 9999;
    }
    
    .nav-menu.active {
        right: 0;
    }
    
    /* Optimize images for mobile */
    img {
        max-width: 100%;
        height: auto;
        display: block;
    }
    
    /* Optimize form inputs */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="number"],
    textarea,
    select {
        width: 100%;
        padding: 12px 16px;
        font-size: 16px; /* Prevents zoom on iOS */
        border-radius: 4px;
        border: 1px solid #ddd;
        -webkit-appearance: none;
    }
    
    /* Optimize buttons */
    .btn, button {
        display: block;
        width: 100%;
        padding: 12px 24px;
        font-size: 1rem;
        text-align: center;
        touch-action: manipulation; /* Disable double-tap zoom */
    }
    
    /* Optimize content spacing */
    .container {
        padding-left: 16px;
        padding-right: 16px;
    }
    
    section {
        padding: 3rem 0;
    }
    
    /* Hide non-essential elements on mobile */
    .desktop-only {
        display: none !important;
    }
    
    /* Optimize tables for mobile */
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Optimize cards and grids */
    .services-grid,
    .cities-grid,
    .states-grid,
    .benefits-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    /* Optimize FAQ section */
    .faq-item {
        margin-bottom: 1rem;
    }
    
    .faq-item summary {
        padding: 1rem;
        font-size: 1rem;
    }
    
    /* Optimize footer for mobile */
    .footer-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
        text-align: center;
    }
}

/* Landscape mobile optimizations */
@media screen and (max-width: 768px) and (orientation: landscape) {
    .hero-section {
        min-height: auto;
        padding: 2rem 0;
    }
    
    h1 {
        font-size: 1.5rem;
    }
}

/* Small mobile devices */
@media screen and (max-width: 375px) {
    html {
        font-size: 14px;
    }
    
    .container {
        padding-left: 12px;
        padding-right: 12px;
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    h2 {
        font-size: 1.25rem;
    }
}

/* Performance optimizations */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Remove hover effects on touch devices */
    a:hover,
    button:hover {
        opacity: 1;
    }
    
    /* Increase tap target size */
    .nav-menu a {
        padding: 1rem;
        display: block;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    * {
        border-color: currentColor !important;
    }
    
    a {
        text-decoration: underline !important;
    }
}

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
    /* Add dark mode styles if needed */
}

/* Critical render path optimization */
.lazy-load {
    opacity: 0;
    transition: opacity 0.3s;
}

.lazy-load.loaded {
    opacity: 1;
}

/* Optimize web fonts loading */
.fonts-loaded body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Mobile-specific utility classes */
@media screen and (max-width: 768px) {
    .mobile-center {
        text-align: center;
    }
    
    .mobile-stack {
        flex-direction: column;
    }
    
    .mobile-hide {
        display: none;
    }
    
    .mobile-show {
        display: block;
    }
    
    .mobile-full-width {
        width: 100%;
    }
}

/* Optimize for foldable devices */
@media screen and (min-width: 768px) and (max-width: 1024px) {
    .container {
        max-width: 100%;
        padding-left: 2rem;
        padding-right: 2rem;
    }
}