/* Mobile-specific enhancements for all pages */

/* Iframe-specific mobile improvements */
body.in-iframe {
    /* Prevent horizontal scrolling in iframe */
    overflow-x: hidden !important;
    max-width: 100vw;
}

body.in-iframe * {
    /* Prevent elements from exceeding viewport in iframe */
    max-width: 100% !important;
    box-sizing: border-box;
}

/* Improve touch targets for mobile */
@media (max-width: 768px) {
    /* Ensure all clickable elements are at least 44px */
    button, 
    a, 
    .filter-chip, 
    .control-btn {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Improve text readability on small screens */
    body {
        -webkit-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }
    
    /* Better spacing for mobile */
    .max-w-4xl,
    .max-w-6xl {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* Improve video containers for mobile */
    video {
        width: 100% !important;
        height: auto !important;
        max-height: 250px;
    }
    
    /* Better iframe responsiveness */
    iframe {
        width: 100% !important;
        min-height: 300px;
    }
    
    /* Improve image scaling */
    img {
        max-width: 100%;
        height: auto;
    }
    
    /* Better form inputs on mobile */
    input[type="text"],
    input[type="search"] {
        font-size: 16px; /* Prevents zoom on iOS */
        -webkit-appearance: none;
        border-radius: 8px;
    }
    
    /* Improve button spacing */
    .inline-flex {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
}

/* Extra small screens (phones in portrait) */
@media (max-width: 480px) {
    /* Reduce padding for very small screens */
    .py-24 {
        padding-top: 3rem !important;
        padding-bottom: 3rem !important;
    }
    
    .py-16 {
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }
    
    /* Improve typography scaling */
    .text-4xl {
        font-size: 1.875rem !important;
    }
    
    .text-5xl {
        font-size: 2.25rem !important;
    }
    
    .text-3xl {
        font-size: 1.5rem !important;
    }
    
    /* Better grid layouts */
    .grid-cols-3 {
        grid-template-columns: repeat(1, minmax(0, 1fr)) !important;
    }
    
    .grid-cols-2 {
        grid-template-columns: repeat(1, minmax(0, 1fr)) !important;
    }
    
    /* Improve navigation spacing */
    .flex.space-x-4 {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .flex.space-x-4 > * {
        margin-left: 0 !important;
    }
    
    /* Better video sizing for small screens */
    video {
        max-height: 200px;
    }
    
    /* Improve factsheet button */
    .inline-flex.items-center.px-8 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
        font-size: 0.875rem;
    }
}

/* Landscape orientation on phones */
@media (max-height: 500px) and (orientation: landscape) {
    .py-24 {
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }
    
    .py-16 {
        padding-top: 1.5rem !important;
        padding-bottom: 1.5rem !important;
    }
    
    video {
        max-height: 150px;
    }
}

/* Improve focus states for accessibility */
@media (max-width: 768px) {
    button:focus,
    a:focus,
    input:focus {
        outline: 2px solid #3B82F6;
        outline-offset: 2px;
    }
    
    /* Remove default focus styles that may interfere */
    button:focus,
    a:focus {
        outline: 2px solid #3B82F6;
        outline-offset: 2px;
        box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
    }
}

/* Dark mode support for mobile */
@media (prefers-color-scheme: dark) and (max-width: 768px) {
    .bg-white {
        background-color: #1F2937 !important;
    }
    
    .text-gray-900 {
        color: #F9FAFB !important;
    }
    
    .text-gray-600 {
        color: #D1D5DB !important;
    }
}

/* Smooth scrolling for mobile navigation */
html {
    scroll-behavior: smooth;
}

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

/* Better mobile navigation */
@media (max-width: 768px) {
    /* Sticky headers */
    .sticky {
        position: -webkit-sticky;
        position: sticky;
    }
    
    /* Better header on mobile */
    header {
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }
    
    /* Improve logo sizing */
    .h-10 {
        height: 2rem !important;
    }
    
    /* Better section spacing */
    section {
        scroll-margin-top: 4rem;
    }
}

/* Performance optimizations for mobile */
@media (max-width: 768px) {
    /* Optimize animations */
    * {
        animation-duration: 0.1s !important;
        animation-delay: 0s !important;
        transition-duration: 0.15s !important;
    }
    
    /* Reduce motion for users who prefer it */
    @media (prefers-reduced-motion: reduce) {
        * {
            animation-duration: 0s !important;
            animation-delay: 0s !important;
            transition-duration: 0s !important;
        }
    }
}
