/* Critical mobile viewport and scrolling fixes */
/* This file should be loaded last to override any conflicting styles */

/* Global mobile reset for proper viewport behavior */
@media (max-width: 768px) {
    /* Force proper document structure */
    html {
        position: relative !important;
        height: auto !important;
        min-height: 100% !important;
        width: 100% !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        -webkit-text-size-adjust: 100% !important;
        -ms-text-size-adjust: 100% !important;
        box-sizing: border-box !important;
    }
    
    *, *::before, *::after {
        box-sizing: border-box !important;
    }
    
    body {
        position: relative !important;
        height: auto !important;
        min-height: 100vh !important;
        width: 100% !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    /* Ensure all sections are visible and scrollable */
    section {
        position: relative !important;
        display: block !important;
        width: 100% !important;
        min-height: auto !important;
        visibility: visible !important;
        opacity: 1 !important;
        transform: none !important;
        margin: 0 !important;
        padding: 80px 0 60px 0 !important;
        scroll-margin-top: 80px !important;
        z-index: 1 !important;
    }
    
    /* Container proper sizing */
    .container {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 15px !important;
        margin: 0 auto !important;
        position: relative !important;
        box-sizing: border-box !important;
    }
    
    /* Header positioning - ensure it doesn't interfere with content */
    .glass-header {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        height: 60px !important;
        z-index: 1000 !important;
        display: flex !important;
        align-items: center !important;
        background: rgba(10, 10, 15, 0.95) !important;
        backdrop-filter: blur(10px) !important;
        box-shadow: 0 2px 20px rgba(0, 0, 0, 0.5) !important;
        transform: translateZ(0) !important;
        will-change: transform !important;
    }
    
    /* Hero section specific */
    #home.hero {
        padding-top: 140px !important;
        padding-bottom: 80px !important;
        min-height: calc(100vh - 60px) !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    /* All content sections should be properly spaced */
    #about {
        padding-top: 100px !important;
        padding-bottom: 80px !important;
    }
    
    #skills {
        padding-top: 100px !important;
        padding-bottom: 80px !important;
    }
    
    #projects {
        padding-top: 100px !important;
        padding-bottom: 80px !important;
    }
    
    #education {
        padding-top: 100px !important;
        padding-bottom: 80px !important;
    }
    
    #interests {
        padding-top: 100px !important;
        padding-bottom: 80px !important;
    }
    
    #contact {
        padding-top: 100px !important;
        padding-bottom: 80px !important;
    }
    
    /* Ensure text and content is visible */
    h1, h2, h3, h4, h5, h6, p, span, div, li, a {
        visibility: visible !important;
        opacity: 1 !important;
        display: block !important;
        position: relative !important;
    }
    
    /* Mobile menu fixes */
    .menu-items {
        position: fixed !important;
        top: 60px !important;
        right: -100% !important;
        width: 280px !important;
        height: calc(100vh - 60px) !important;
        background: rgba(0, 0, 0, 0.95) !important;
        display: flex !important;
        flex-direction: column !important;
        padding-top: 30px !important;
        transition: right 0.3s ease !important;
        z-index: 999 !important;
        overflow-y: auto !important;
        transform: translateZ(0) !important;
    }
    
    .menu-items.active {
        right: 0 !important;
    }
    
    .menu-btn {
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        align-items: center !important;
        width: 30px !important;
        height: 30px !important;
        cursor: pointer !important;
        z-index: 1001 !important;
        position: relative !important;
    }
    
    /* Prevent horizontal scroll */
    .projects-container,
    .skills-content,
    .interests-grid,
    .contact-content {
        width: 100% !important;
        overflow-x: hidden !important;
        position: relative !important;
    }
    
    /* Force project carousel to be visible */
    .projects-carousel {
        width: 100% !important;
        display: flex !important;
        position: relative !important;
        will-change: transform !important;
    }
    
    .projects-page {
        width: 100% !important;
        flex-shrink: 0 !important;
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 15px !important;
        padding: 0 15px !important;
    }
    
    /* Project cards responsiveness */
    .project-card {
        width: 100% !important;
        min-height: 300px !important;
        display: flex !important;
        flex-direction: column !important;
        position: relative !important;
    }
    
    /* Skills grid proper layout */
    .skills-category {
        margin-bottom: 40px !important;
        width: 100% !important;
    }
    
    .skills-grid {
        display: grid !important;
        grid-template-columns: repeat(auto-fit, minmax(60px, 1fr)) !important;
        gap: 15px !important;
        width: 100% !important;
    }
    
    /* Interests grid layout */
    .interests-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 20px !important;
        width: 100% !important;
    }
    
    /* Timeline responsive */
    .timeline {
        width: 100% !important;
        position: relative !important;
    }
    
    .timeline-item {
        width: 100% !important;
        margin-bottom: 30px !important;
        position: relative !important;
    }
    
    /* Contact form responsiveness */
    .contact-form {
        width: 100% !important;
        max-width: 100% !important;
    }
    
    .form-group {
        width: 100% !important;
        margin-bottom: 20px !important;
    }
    
    input, textarea, select {
        width: 100% !important;
        box-sizing: border-box !important;
    }
}

/* Additional fix for very tall screens (like Poco X3 NFC) */
@media (max-width: 500px) and (min-height: 800px) {
    /* Increase padding for better visibility on tall screens */
    section {
        padding: 100px 0 80px 0 !important;
    }
    
    #home.hero {
        padding-top: 160px !important;
        padding-bottom: 100px !important;
    }
    
    .container {
        padding: 0 20px !important;
    }
}

/* Force visibility for any hidden elements */
.hidden, [style*="display: none"], [style*="visibility: hidden"] {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Ensure scroll behavior is smooth */
html {
    scroll-behavior: smooth !important;
}

/* Fix any z-index issues */
@media (max-width: 768px) {
    .preloader {
        z-index: 9999 !important;
    }
    
    .glass-header {
        z-index: 1000 !important;
    }
    
    .menu-items {
        z-index: 999 !important;
    }
    
    .menu-btn {
        z-index: 1001 !important;
    }
    
    section {
        z-index: 1 !important;
    }
}
