/**
 * Homepage Mobile Optimization
 * Comprehensive mobile-first responsive design for the main front page
 * No text truncation - all content remains readable and accessible
 */

/* ==================== VIEWPORT SETTINGS ==================== */
@viewport {
    width: device-width;
    zoom: 1;
}

/* ==================== BASE MOBILE STYLES ==================== */
@media screen and (max-width: 768px) {
    
    /* Ensure smooth scrolling and prevent horizontal overflow */
    html {
        -webkit-text-size-adjust: 100%;
        overflow-x: hidden;
    }
    
    body {
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Main container adjustments */
    .coh-landing-page {
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
    }
    
    /* ========== TYPOGRAPHY MOBILE OPTIMIZATION ========== */
    
    /* Main hero heading - responsive scaling without truncation */
    h1[style*="font-size: 2.5rem"] {
        font-size: 1.8rem !important;
        line-height: 1.2 !important;
        white-space: normal !important;
        word-break: break-word !important;
        hyphens: auto !important;
        padding: 1rem 0.5rem !important;
    }
    
    /* Secondary headings */
    h2[style*="font-size: 1.5rem"] {
        font-size: 1.3rem !important;
        line-height: 1.3 !important;
        white-space: normal !important;
        word-break: break-word !important;
    }
    
    /* Hero section main heading */
    h2[style*="font-size: 2.4rem"] {
        font-size: 1.6rem !important;
        line-height: 1.2 !important;
        padding: 1rem !important;
        white-space: normal !important;
        word-break: break-word !important;
        text-align: center !important;
    }
    
    /* Section headings */
    h2[style*="font-size: 3em"] {
        font-size: 2rem !important;
        line-height: 1.2 !important;
        white-space: normal !important;
        word-break: break-word !important;
    }
    
    h3[style*="font-size: 1.4rem"] {
        font-size: 1.2rem !important;
        line-height: 1.3 !important;
    }
    
    /* Paragraph text optimization */
    p[style*="font-size: 1.25rem"] {
        font-size: 1.1rem !important;
        line-height: 1.5 !important;
    }
    
    p[style*="font-size: 1.3em"] {
        font-size: 1.1rem !important;
        line-height: 1.5 !important;
    }
    
    p[style*="font-size: 1.1rem"] {
        font-size: 1rem !important;
        line-height: 1.6 !important;
    }
    
    /* ========== LAYOUT GRID MOBILE FIXES ========== */
    
    /* Force all grid layouts to single column on mobile */
    div[style*="grid-template-columns: repeat(auto-fit, minmax(280px, 1fr))"],
    div[style*="grid-template-columns: repeat(auto-fit, minmax(250px, 1fr))"],
    div[style*="grid-template-columns: repeat(auto-fit, minmax(300px, 1fr))"] {
        display: block !important;
        grid-template-columns: none !important;
    }
    
    /* Two-column layouts */
    div[style*="grid-template-columns: 1fr 1fr"] {
        display: block !important;
        grid-template-columns: none !important;
    }
    
    /* Calculator layout */
    div[style*="grid-template-columns: 1fr 280px"] {
        display: block !important;
        grid-template-columns: none !important;
        gap: 1rem !important;
    }
    
    /* Hero layout */
    div[style*="grid-template-columns: 1fr 300px"] {
        display: block !important;
        grid-template-columns: none !important;
        text-align: center !important;
    }
    
    /* ========== SECTION SPACING MOBILE ========== */
    
    /* Reduce excessive padding on mobile */
    section[style*="padding: 2rem 2rem"],
    section[style*="padding: 2rem"],
    section[style*="padding: 80px 0"] {
        padding: 1.5rem 1rem !important;
    }
    
    /* Container max-width adjustments */
    div[style*="max-width: 1200px"] {
        max-width: 100% !important;
        margin: 0 auto !important;
        padding: 0 1rem !important;
    }
    
    div[style*="max-width: 1000px"] {
        max-width: 100% !important;
        margin: 0 auto !important;
        padding: 0 1rem !important;
    }
    
    div[style*="max-width: 800px"] {
        max-width: 100% !important;
        margin: 0 auto !important;
        padding: 0 1rem !important;
    }
    
    /* ========== CARD LAYOUTS MOBILE ========== */
    
    /* Card spacing and padding */
    div[style*="padding: 2rem; background: #1f2937"] {
        padding: 1.5rem 1rem !important;
        margin-bottom: 1rem !important;
    }
    
    div[style*="padding: 20px; border-radius: 15px"] {
        padding: 1rem !important;
        margin-bottom: 1rem !important;
    }
    
    /* Feature cards mobile optimization */
    div[style*="padding: 20px; border-radius: 15px; border: 2px solid rgba(255,255,255,0.2)"] {
        padding: 1rem !important;
        margin-bottom: 1rem !important;
        min-height: auto !important;
    }
    
    /* Pricing cards mobile */
    div[style*="padding: 2rem; border-radius: 12px; border: 3px solid #22c55e"],
    div[style*="padding: 2rem; border-radius: 12px; border: 2px solid #4f46e5"],
    div[style*="padding: 2rem; border-radius: 12px; border: 2px solid #f59e0b"] {
        padding: 1.5rem 1rem !important;
        margin-bottom: 1.5rem !important;
    }
    
    /* ========== FORM ELEMENTS MOBILE ========== */
    
    /* All form inputs mobile optimization */
    input[type="text"],
    input[type="email"], 
    input[type="tel"],
    select,
    textarea {
        width: 100% !important;
        box-sizing: border-box !important;
        font-size: 16px !important; /* Prevents zoom on iOS Safari */
        padding: 1rem !important;
        min-height: 48px !important; /* Touch target minimum */
        border-radius: 8px !important;
        -webkit-appearance: none !important;
        appearance: none !important;
    }
    
    /* Textarea specific */
    textarea[style*="width: 100%"] {
        resize: vertical !important;
        min-height: 120px !important;
    }
    
    /* Form labels */
    label[style*="font-weight: bold"] {
        font-size: 1rem !important;
        margin-bottom: 0.5rem !important;
        display: block !important;
    }
    
    /* ========== BUTTON MOBILE OPTIMIZATION ========== */
    
    /* All buttons touch-friendly */
    button,
    a[style*="padding"],
    input[type="submit"] {
        min-height: 48px !important; /* Touch target minimum */
        padding: 1rem 1.5rem !important;
        font-size: 1rem !important;
        line-height: 1.2 !important;
        white-space: normal !important;
        word-break: break-word !important;
        box-sizing: border-box !important;
        cursor: pointer !important;
        -webkit-tap-highlight-color: rgba(0,0,0,0.1) !important;
    }
    
    /* Large prominent buttons */
    button[style*="font-size: 24px"],
    button[style*="padding: 25px 50px"] {
        font-size: 1.2rem !important;
        padding: 1.2rem 1.5rem !important;
        white-space: normal !important;
        word-break: break-word !important;
        text-align: center !important;
    }
    
    /* Preview buttons */
    button[style*="padding: 10px 14px"] {
        padding: 0.8rem 1rem !important;
        font-size: 0.9rem !important;
        min-height: 44px !important;
    }
    
    /* ========== MODAL MOBILE OPTIMIZATION ========== */
    
    /* Modal containers */
    div[style*="width: 90%; max-width: 500px; margin: 50px auto"] {
        width: 95% !important;
        margin: 20px auto !important;
        max-height: 85vh !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    div[style*="padding: 40px; border-radius: 20px"] {
        padding: 1.5rem !important;
        border-radius: 12px !important;
    }
    
    /* Modal close buttons */
    button[style*="position: absolute; right: 20px; top: 20px"] {
        right: 10px !important;
        top: 10px !important;
        font-size: 24px !important;
        padding: 8px !important;
        min-height: 40px !important;
        min-width: 40px !important;
    }
    
    /* ========== AUDIOGRAM CREATOR MOBILE FIXES ========== */
    
    /* Fix the main audiogram grid layout causing overlap */
    div[style*="display: grid; grid-template-columns: 1fr 1fr; gap: 60px; align-items: stretch"] {
        display: block !important;
        grid-template-columns: none !important;
        gap: 1.5rem !important;
        align-items: normal !important;
    }
    
    /* Form and preview containers - remove fixed heights that cause overlap */
    div[style*="height: 550px; display: flex; flex-direction: column; justify-content: space-between"],
    div[style*="height: 550px; display: flex; flex-direction: column"] {
        height: auto !important;
        min-height: 300px !important;
        margin-bottom: 1.5rem !important;
        display: block !important;
        flex-direction: unset !important;
        justify-content: unset !important;
    }
    
    /* Audiogram section padding mobile */
    section[style*="padding: 80px 0"] {
        padding: 40px 0 !important;
    }
    
    /* Audiogram section container */
    div[style*="max-width: 1200px; margin: 0 auto; padding: 0 20px"] {
        padding: 0 1rem !important;
    }
    
    /* Header text in audiogram section */
    div[style*="text-align: center; margin-bottom: 60px"] {
        margin-bottom: 30px !important;
    }
    
    /* Voice selection mobile - fix overlapping dropdown and button */
    div[style*="display: flex; gap: 6px; align-items: center"] {
        display: block !important;
        gap: 0.5rem !important;
        align-items: normal !important;
    }
    
    select[style*="flex: 1; padding: 10px"] {
        width: 100% !important;
        flex: none !important;
        margin-bottom: 0.8rem !important;
        box-sizing: border-box !important;
    }
    
    button[style*="padding: 10px 14px"][style*="white-space: nowrap"] {
        width: 100% !important;
        white-space: normal !important;
        margin-top: 0 !important;
        padding: 12px !important;
        box-sizing: border-box !important;
    }
    
    /* Content textarea in preview section */
    textarea[style*="width: 100%; padding: 10px"] {
        box-sizing: border-box !important;
        resize: vertical !important;
        min-height: 120px !important;
    }
    
    /* Fix form flex layout inside containers */
    form[style*="flex: 1"] {
        flex: none !important;
        margin-top: 1rem !important;
    }
    
    /* Prevent nested containers from overlapping */
    div[style*="background: rgba(255,255,255,0.95); padding: 20px"] {
        padding: 1rem !important;
        margin-bottom: 1rem !important;
        box-sizing: border-box !important;
    }
    
    /* Fix preview section structure */
    div[style*="background: #f0fdf4; border: 2px solid #22c55e"],
    div[style*="background: #faf5ff; border: 2px solid #9333ea"], 
    div[style*="background: #eff6ff; border: 2px solid #3b82f6"] {
        margin-bottom: 1rem !important;
        padding: 1rem !important;
        box-sizing: border-box !important;
    }
    
    /* ========== PROGRESS INDICATORS MOBILE ========== */
    
    /* Progress modal mobile */
    div[style*="max-width: 500px; width: 90%"] {
        width: 95% !important;
        margin: 20px auto !important;
        padding: 1.5rem !important;
    }
    
    /* Progress steps mobile */
    div[style*="max-width: 400px; margin: 0 auto"] {
        max-width: 100% !important;
        text-align: left !important;
    }
    
    /* ========== UTILITY MOBILE CLASSES ========== */
    
    /* Hide elements that may cause horizontal scroll */
    .mobile-hidden,
    *[style*="overflow: visible"] {
        overflow: hidden !important;
    }
    
    /* Ensure no element extends beyond viewport */
    * {
        max-width: 100vw !important;
        box-sizing: border-box !important;
    }
    
    /* Fix any remaining grid issues */
    div[style*="display: grid"] {
        display: block !important;
        grid-template-columns: none !important;
    }
}

/* ==================== SMALL MOBILE SCREENS ==================== */
@media screen and (max-width: 480px) {
    
    /* Further optimize for very small screens */
    h1[style*="font-size: 1.8rem"] {
        font-size: 1.5rem !important;
        padding: 0.8rem 0.5rem !important;
    }
    
    h2[style*="font-size: 1.6rem"] {
        font-size: 1.4rem !important;
        padding: 0.8rem !important;
    }
    
    h2[style*="font-size: 2rem"] {
        font-size: 1.6rem !important;
    }
    
    /* Tighter spacing */
    section[style*="padding: 1.5rem 1rem"] {
        padding: 1rem 0.8rem !important;
    }
    
    div[style*="padding: 1.5rem 1rem"] {
        padding: 1rem 0.8rem !important;
    }
    
    /* Smaller buttons on very small screens */
    button,
    a[style*="padding"] {
        font-size: 0.9rem !important;
        padding: 0.9rem 1.2rem !important;
    }
    
    /* Modal adjustments */
    div[style*="width: 95%"] {
        width: 98% !important;
        margin: 10px auto !important;
    }
    
    div[style*="padding: 1.5rem"] {
        padding: 1rem !important;
    }
}

/* ==================== EXTRA SMALL SCREENS ==================== */
@media screen and (max-width: 360px) {
    
    /* Ultra-compact for very small devices */
    h1 {
        font-size: 1.3rem !important;
        padding: 0.6rem 0.4rem !important;
    }
    
    h2 {
        font-size: 1.2rem !important;
        padding: 0.6rem !important;
    }
    
    section {
        padding: 0.8rem 0.6rem !important;
    }
    
    div[style*="padding"] {
        padding: 0.8rem 0.6rem !important;
    }
    
    /* Minimal button sizing */
    button,
    a[style*="padding"] {
        font-size: 0.85rem !important;
        padding: 0.8rem 1rem !important;
    }
}

/* ==================== LANDSCAPE MOBILE FIXES ==================== */
@media screen and (max-height: 500px) and (orientation: landscape) {
    
    /* Optimize for landscape mobile viewing */
    .coh-landing-page {
        padding-top: 10px !important;
        margin-top: -10px !important;
    }
    
    /* Reduce vertical padding in landscape */
    section[style*="padding"] {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }
    
    /* Modal adjustments for landscape */
    div[style*="max-height: 85vh"] {
        max-height: 90vh !important;
    }
}

/* ==================== ACCESSIBILITY ENHANCEMENTS ==================== */
@media screen and (max-width: 768px) {
    
    /* Ensure sufficient contrast and touch targets */
    button:focus,
    input:focus,
    select:focus,
    textarea:focus {
        outline: 2px solid #4f46e5 !important;
        outline-offset: 2px !important;
    }
    
    /* Improve tap targets */
    a, button, input, select, textarea {
        touch-action: manipulation !important;
    }
    
    /* Prevent text adjustment on orientation change */
    html {
        -webkit-text-size-adjust: none !important;
    }
}