/* Mobile Optimized CSS for skerritteconomics.com */
/* This file contains all mobile-specific optimizations and fixes */

/* ========================================
   MOBILE FOUNDATION
======================================== */

/* Ensure proper viewport behavior */
html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
    overflow-x: hidden;
}

body {
    overflow-x: hidden;
    position: relative;
    -webkit-tap-highlight-color: transparent;
}

/* Prevent horizontal scroll */
.container,
main,
section {
    overflow-x: hidden;
}

/* Fix table of contents blocking content on mobile */
@media (max-width: 768px) {
    .mobile-toc,
    .toc-mobile,
    .table-of-contents-mobile {
        position: relative !important;
        top: auto !important;
        z-index: 1 !important;
        margin-bottom: 1.5rem !important;
    }
    
    /* Ensure main content is not blocked */
    main,
    .main-content,
    .page-content {
        position: relative !important;
        z-index: 2 !important;
    }
}

/* ========================================
   MOBILE NAVIGATION FIXES
======================================== */

/* Fixed navigation for mobile */
@media (max-width: 768px) {
    .main-nav {
        position: fixed !important;
        top: 0;
        left: 0;
        right: 0;
        z-index: 9999;
        height: 60px;
        background: var(--background);
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
    
    /* Ensure body padding for fixed nav */
    body {
        padding-top: 60px !important;
    }
    
    /* Mobile menu styles */
    .nav-menu {
        position: fixed !important;
        left: -100%;
        top: 60px;
        width: 100%;
        max-width: none;
        height: calc(100vh - 60px);
        background: white;
        flex-direction: column;
        padding: 2rem 1rem;
        gap: 0;
        transition: left 0.3s ease;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        z-index: 9998;
    }
    
    .nav-menu.active {
        left: 0;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    }
    
    /* Prevent body scroll when menu is open */
    body.menu-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
    }
    
    /* Mobile menu toggle animation */
    .mobile-menu-toggle.active span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }
    
    .mobile-menu-toggle.active span:nth-child(2) {
        opacity: 0;
    }
    
    .mobile-menu-toggle.active span:nth-child(3) {
        transform: rotate(-45deg) translate(7px, -6px);
    }
}

/* ========================================
   MOBILE TYPOGRAPHY
======================================== */

@media (max-width: 768px) {
    /* Base font sizes for mobile */
    html {
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    h1 {
        font-size: 1.75rem !important;
        line-height: 1.2 !important;
    }
    
    h2 {
        font-size: 1.5rem !important;
        line-height: 1.25 !important;
    }
    
    h3 {
        font-size: 1.25rem !important;
        line-height: 1.3 !important;
    }
    
    h4 {
        font-size: 1.125rem !important;
        line-height: 1.4 !important;
    }
    
    p, li {
        font-size: 1rem !important;
        line-height: 1.6 !important;
    }
}

/* ========================================
   MOBILE HERO SECTION
======================================== */

@media (max-width: 768px) {
    .hero {
        padding: 2rem 0 3rem 0 !important;
        text-align: center;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    .hero-content {
        padding: 0 1rem;
        max-width: 100%;
    }
    
    .hero h1 {
        font-size: 1.625rem !important;
        margin-bottom: 1rem !important;
        padding: 0 0.25rem;
        line-height: 1.25 !important;
        word-wrap: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
        -webkit-hyphens: auto;
        -ms-hyphens: auto;
    }
    
    .hero-subtitle {
        font-size: 1rem !important;
        margin-bottom: 1.5rem !important;
        padding: 0 0.5rem;
    }
    
    /* Hero CTA buttons */
    .hero-cta {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.75rem !important;
        padding: 0 1rem !important;
        align-items: stretch !important;
    }
    
    .hero-cta .btn {
        width: 100% !important;
        padding: 1rem 1.5rem !important;
        font-size: 1rem !important;
        min-height: 48px !important; /* WCAG touch target */
    }
    
    .hero-cta .consultation-note {
        margin-top: 1rem !important;
        font-size: 0.875rem !important;
    }
}

/* ========================================
   MOBILE BUTTONS & TOUCH TARGETS
======================================== */

@media (max-width: 768px) {
    /* Ensure all interactive elements meet WCAG touch target size */
    .btn,
    button,
    a.practice-chip,
    input[type="submit"],
    input[type="button"] {
        min-height: 44px !important;
        min-width: 44px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    /* Button spacing */
    .btn + .btn {
        margin-top: 0.75rem;
    }
    
    /* Practice chips mobile optimization */
    .practice-areas-strip {
        padding: 1rem 0 !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .practice-areas-chips {
        display: flex !important;
        flex-wrap: nowrap !important;
        gap: 0.5rem !important;
        padding: 0 1rem !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    .practice-chip {
        flex: 0 0 auto !important;
        white-space: nowrap !important;
        padding: 0.75rem 1rem !important;
        min-height: 44px !important;
    }
}

/* ========================================
   MOBILE FORM ELEMENTS
======================================== */

/* Fix all form elements for mobile */
input,
select,
textarea {
    font-size: 16px !important; /* Prevents zoom on iOS */
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: white !important;
    color: var(--dark-text) !important;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* Select dropdown styling */
select {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231f2937' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1rem;
    padding-right: 3rem;
}

/* Focus states */
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid var(--primary-color) !important;
    outline-offset: 2px !important;
    border-color: var(--primary-color) !important;
}

/* ========================================
   MOBILE CARDS & GRIDS
======================================== */

@media (max-width: 768px) {
    /* Single column layouts on mobile */
    .services-grid,
    .credentials-grid,
    .locations-grid,
    .testimonials-grid,
    .case-studies-grid,
    .faq-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    
    /* Card padding optimization */
    .service-card,
    .credential,
    .location-card,
    .testimonial,
    .case-study,
    .faq-item {
        padding: 1.25rem !important;
        margin-bottom: 0.5rem;
    }
    
    /* Improve readability */
    .service-card h3,
    .credential h4,
    .location-card h3 {
        font-size: 1.125rem !important;
        margin-bottom: 0.75rem !important;
    }
    
    .service-card p,
    .credential p,
    .location-card p {
        font-size: 0.9375rem !important;
        line-height: 1.5 !important;
    }
}

/* ========================================
   MOBILE SECTIONS & SPACING
======================================== */

@media (max-width: 768px) {
    /* Consistent section spacing */
    section {
        padding: 2.5rem 0 !important;
    }
    
    /* Container padding */
    .container {
        padding: 0 1rem !important;
    }
    
    /* Reduce margins between elements */
    h2 {
        margin-bottom: 1rem !important;
    }
    
    h3 {
        margin-bottom: 0.75rem !important;
    }
    
    p {
        margin-bottom: 0.75rem !important;
    }
    
    ul, ol {
        margin-bottom: 0.75rem !important;
        padding-left: 1.25rem !important;
    }
}

/* ========================================
   MOBILE FOOTER
======================================== */

@media (max-width: 768px) {
    .main-footer {
        padding: 2rem 0 !important;
    }
    
    .footer-grid {
        grid-template-columns: 1fr !important;
        gap: 1.5rem !important;
        text-align: center;
    }
    
    .footer-col h4 {
        font-size: 1.125rem !important;
        margin-bottom: 0.75rem !important;
    }
    
    .footer-col ul {
        padding: 0 !important;
    }
    
    .footer-col li {
        margin-bottom: 0.5rem !important;
    }
    
    .footer-bottom {
        padding: 1rem !important;
        text-align: center !important;
        font-size: 0.875rem !important;
    }
}

/* ========================================
   MOBILE PERFORMANCE OPTIMIZATIONS
======================================== */

/* Reduce animations on mobile for better performance */
@media (max-width: 768px) {
    * {
        animation-duration: 0.3s !important;
    }
    
    /* Disable hover effects on touch devices */
    @media (hover: none) {
        .btn:hover,
        .practice-chip:hover,
        .service-card:hover,
        .location-card:hover {
            transform: none !important;
            box-shadow: none !important;
        }
    }
}

/* ========================================
   MOBILE IMAGE OPTIMIZATIONS
======================================== */

@media (max-width: 768px) {
    img {
        max-width: 100% !important;
        height: auto !important;
        display: block;
    }
    
    /* Lazy loading placeholder */
    img[loading="lazy"] {
        background: var(--light-bg);
        min-height: 200px;
    }
}

/* ========================================
   MOBILE ACCESSIBILITY
======================================== */

/* Skip navigation link */
.skip-to-content {
    position: absolute;
    left: -9999px;
    top: 10px;
    z-index: 999999;
    padding: 12px 20px;
    background-color: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: 4px;
}

.skip-to-content:focus {
    left: 10px;
}

/* Focus visible styles */
*:focus-visible {
    outline: 2px solid var(--primary-color) !important;
    outline-offset: 2px !important;
}

/* ========================================
   MOBILE TABLES
======================================== */

@media (max-width: 768px) {
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        width: 100%;
    }
    
    th, td {
        padding: 0.5rem !important;
        font-size: 0.875rem !important;
    }
}

/* ========================================
   MOBILE UTILITY CLASSES
======================================== */

@media (max-width: 768px) {
    /* Hide on mobile */
    .mobile-hide {
        display: none !important;
    }
    
    /* Show only on mobile */
    .mobile-only {
        display: block !important;
    }
    
    /* Text alignment */
    .mobile-center {
        text-align: center !important;
    }
    
    /* Spacing utilities */
    .mobile-mt-0 { margin-top: 0 !important; }
    .mobile-mt-1 { margin-top: 0.5rem !important; }
    .mobile-mt-2 { margin-top: 1rem !important; }
    .mobile-mt-3 { margin-top: 1.5rem !important; }
    
    .mobile-mb-0 { margin-bottom: 0 !important; }
    .mobile-mb-1 { margin-bottom: 0.5rem !important; }
    .mobile-mb-2 { margin-bottom: 1rem !important; }
    .mobile-mb-3 { margin-bottom: 1.5rem !important; }
    
    .mobile-p-0 { padding: 0 !important; }
    .mobile-p-1 { padding: 0.5rem !important; }
    .mobile-p-2 { padding: 1rem !important; }
    .mobile-p-3 { padding: 1.5rem !important; }
}

/* ========================================
   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;
        scroll-behavior: auto !important;
    }
}

/* ========================================
   HIGH CONTRAST MODE SUPPORT
======================================== */

@media (prefers-contrast: high) {
    * {
        border-color: currentColor !important;
    }
    
    .btn {
        border: 2px solid currentColor !important;
    }
    
    *:focus {
        outline: 3px solid currentColor !important;
        outline-offset: 3px !important;
    }
}

/* ========================================
   DARK MODE CONSIDERATIONS
======================================== */

@media (prefers-color-scheme: dark) {
    /* Ensure form elements remain light for readability */
    input,
    select,
    textarea {
        background-color: white !important;
        color: #1f2937 !important;
    }
}

/* ========================================
   PRINT STYLES
======================================== */

@media print {
    /* Hide navigation and non-essential elements */
    .main-nav,
    .mobile-menu-toggle,
    .hero-cta,
    .practice-areas-strip,
    .cta-section,
    .main-footer {
        display: none !important;
    }
    
    /* Ensure content prints properly */
    body {
        padding-top: 0 !important;
    }
    
    section {
        page-break-inside: avoid;
    }
}