/* ═══════════════════════════════════════════════
   WEBSITE OPTIMIZATION & MOBILE FIXES
   Focus: Performance, Accessibility, SEO, Responsive
   ═══════════════════════════════════════════════ */

/* 1. Performance: Image Lazy Loading Placeholder */
/* Only apply opacity transition if the browser supports intersection observer (modern) */
@supports (display: grid) {
    img[loading="lazy"]:not(.lazyloaded) {
        opacity: 0;
    }
}

img.lazyloaded {
    opacity: 1;
    transition: opacity 0.4s ease-in;
}

/* 2. Global Layout Fixes */
html, body {
    overflow-x: hidden !important;
    width: 100%;
    position: relative;
}

.page, .inner-page-wrapper, .main-wrapper, #page {
    overflow-x: hidden !important;
    width: 100%;
}

/* 3. Mobile Header Fixes */
@media (max-width: 767px) {
    .wsmobileheader {
        height: 70px !important;
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        padding: 0 15px;
    }

    #wsnavtoggle {
        margin: 0 !important;
        padding: 0 !important;
        width: 45px !important;
        height: 45px !important;
        position: relative !important; /* Reset any absolute positioning */
        top: 0 !important; /* Reset top */
        display: flex !important;
        align-items: center;
        justify-content: center;
    }

    #wsnavtoggle span {
        margin: 0 !important;
        position: relative !important;
        top: 0 !important;
    }

    .wsmobileheader .smllogo {
        margin: 0 !important;
        flex: 1;
        text-align: center;
    }

    .wsmobileheader .smllogo img {
        max-height: 40px;
        width: auto !important;
    }
}

/* 4. Global Floating Buttons & Lang Switcher Fixes */
/* Stacking them to avoid overlap */
@media (max-width: 767px) {
    /* WhatsApp and Chat */
    .global-floating-btns {
        bottom: 20px !important;
        right: 15px !important;
        left: auto !important;
        display: flex;
        flex-direction: column;
        gap: 12px;
        z-index: 9999;
    }

    .floating-btn-item {
        position: relative !important;
        bottom: auto !important;
        right: auto !important;
        width: 50px !important;
        height: 50px !important;
        border-radius: 50% !important;
        margin: 0 !important;
        box-shadow: 0 4px 15px rgba(0,0,0,0.2) !important;
    }

    .floating-btn-item .btn-text {
        display: none !important;
    }

    .floating-btn-item i {
        font-size: 24px !important;
        margin: 0 !important;
    }

    /* Language Switcher */
    .fixed-lang-switcher {
        top: auto !important;
        bottom: 145px !important; /* Positioned above floating buttons */
        right: 15px !important;
        left: auto !important;
        transform: none !important;
        z-index: 9998;
    }

    .lang-tab {
        padding: 8px 12px !important;
        border-radius: 30px !important;
        box-shadow: 0 4px 10px rgba(0,0,0,0.1) !important;
    }
}

/* 5. Section Spacing & Typography Fixes for Mobile */
@media (max-width: 767px) {
    .wide-60, .wide-100, .wide-70, .wide-80 {
        padding-top: 40px !important;
        padding-bottom: 40px !important;
    }

    .section-title {
        margin-bottom: 30px !important;
    }

    .section-title h3, h3.h3-xl, h3.h3-lg, h3.h3-md {
        font-size: 1.6rem !important;
        line-height: 1.2 !important;
        margin-bottom: 15px !important;
    }

    h1, .h1-xl, .h1-lg {
        font-size: 1.8rem !important;
        line-height: 1.2 !important;
    }

    .hero-txt p, .section-title p {
        font-size: 0.95rem !important;
        line-height: 1.5 !important;
    }

    /* Hero Background Text Fix */
    .hero-5-img::after {
        display: none !important; /* Remove giant background text if it causes issues */
    }
}

/* 6. Cumulative Layout Shift (CLS) Prevention */
.hero-5-img, .img-block, .project-preview {
    background-color: #f8f9fa;
    border-radius: 12px;
    overflow: hidden;
}

/* 7. Inner Page Specific Fixes */
@media (max-width: 767px) {
    /* About Page Counter Fix */
    .year-box h2 {
        font-size: 80px !important;
        opacity: 0.08 !important;
        position: absolute !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
    }

    /* Career/Job Cards */
    .job-card, .article-card {
        margin-bottom: 25px !important;
    }

    /* Hero Padding */
    .page-hero-section {
        padding: 60px 0 !important;
    }
}

/* 8. Accessibility: Focus States */
/*a:focus, button:focus {*/
/*    outline: 2px solid #ffc20e !important;*/
/*    outline-offset: 2px;*/
/*}*/

/* 9. Mobile Animation Failsafe */
@media (max-width: 991px) {
    /* If the animation hasn't triggered within a reasonable time, ensure content is visible */
    .wow {
        animation-duration: 0.8s !important;
        animation-iteration-count: 1 !important;
    }

    /* Extra protection against stuck hidden states on mobile */
    .mobile-visible {
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    #loader-wrapper {
        display: none !important;
        visibility: hidden !important;
    }
}
