/* Mobile Responsiveness Fixes for JK Fenesta Website */

/* Prevent horizontal scroll on all devices */
html, body {
    max-width: 100%;
    overflow-x: hidden !important;
    position: relative;
}

/* Ensure all elements respect viewport width */
* {
    box-sizing: border-box;
}

/* Fix for containers */
.max-w-7xl {
    max-width: min(1280px, 100vw);
    padding-left: clamp(1rem, 3vw, 3rem);
    padding-right: clamp(1rem, 3vw, 3rem);
}

/* Ensure images don't overflow */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Fix for absolute positioned elements that might overflow */
.absolute {
    max-width: 100vw;
}

/* Prevent text from causing overflow */
h1, h2, h3, h4, h5, h6, p, span, div {
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

/* Fix for wide backgrounds */
.fixed, .absolute {
    max-width: 100vw;
}

/* Mobile-specific fixes */
@media (max-width: 768px) {
    /* Reduce padding on mobile */
    .px-6, .px-8, .px-10, .px-12 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    .lg\:px-12 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    /* Fix for large text that might overflow */
    .text-5xl {
        font-size: clamp(2rem, 8vw, 3rem) !important;
        line-height: 1.2 !important;
    }
    
    .text-6xl {
        font-size: clamp(2.5rem, 10vw, 3.5rem) !important;
        line-height: 1.2 !important;
    }
    
    .text-7xl {
        font-size: clamp(3rem, 12vw, 4rem) !important;
        line-height: 1.1 !important;
    }
    
    /* Ensure grid doesn't overflow */
    .grid {
        width: 100%;
        grid-template-columns: 1fr !important;
    }
    
    /* Fix for flex containers */
    .flex {
        flex-wrap: wrap;
    }
    
    /* Prevent wide buttons from overflowing */
    button, a.button, .btn {
        max-width: 100%;
        white-space: normal;
    }
    
    /* Fix for navigation */
    nav {
        width: 100vw;
        max-width: 100vw;
    }
    
    /* Fix for sections */
    section {
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
    }
    
    /* Fix for containers with negative margins */
    .mx-auto {
        margin-left: auto;
        margin-right: auto;
        max-width: 100%;
    }
    
    /* Fix for carousel/slider */
    .overflow-x-auto {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Ensure cards fit properly */
    .rounded-3xl, .rounded-2xl {
        margin-left: 0.5rem;
        margin-right: 0.5rem;
    }
    
    /* Fix for gap spacing */
    .gap-8, .gap-10, .gap-12 {
        gap: 1rem !important;
    }
    
    /* Fix for hero section */
    .min-h-screen {
        min-height: 100vh;
        min-height: -webkit-fill-available;
    }
}

/* Extra small devices (phones in portrait mode) */
@media (max-width: 480px) {
    /* Even more aggressive padding reduction */
    .px-6, .px-8, .px-10, .px-12 {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }
    
    /* Smaller text for very small screens */
    .text-5xl {
        font-size: 1.75rem !important;
    }
    
    .text-6xl {
        font-size: 2rem !important;
    }
    
    .text-7xl {
        font-size: 2.5rem !important;
    }
    
    /* Reduce gap further */
    .gap-4, .gap-6, .gap-8 {
        gap: 0.5rem !important;
    }
}

/* Landscape mode fixes for tablets */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {
    .min-h-screen {
        min-height: 100vh;
    }
}

/* Fix for iOS Safari viewport height issue */
@supports (-webkit-touch-callout: none) {
    .min-h-screen {
        min-height: -webkit-fill-available;
    }
}

/* Prevent zoom on input focus (iOS) */
input, select, textarea {
    font-size: 16px !important;
}

/* Fix for sticky elements on mobile */
.fixed, .sticky {
    width: 100vw;
    max-width: 100vw;
    left: 0;
    right: 0;
}

/* Ensure modals and overlays fit properly */
.modal, .overlay {
    max-width: 100vw;
    max-height: 100vh;
}
