/* ================================================================
   MOBILE RESPONSIVENESS OVERRIDES
   ================================================================ */

/* General Container Fixes */
@media (max-width: 768px) {
    :root {
        --section-px: 1rem;
    }
    
    .hero-h1 {
        font-size: clamp(2rem, 10vw, 3rem) !important;
    }

    .hero-h2 {
        font-size: clamp(1.5rem, 8vw, 2.5rem) !important;
    }

    .container {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
        padding-inline: 1rem !important;
    }
    
    section {
        padding-top: 4rem !important;
        padding-bottom: 4rem !important;
    }
}

/* Mobile Menu Toggle Button */
.mobile-menu-toggle {
    display: none;
    color: var(--on-surface);
    font-size: 2rem;
    background: transparent;
    border: none;
    cursor: pointer;
    z-index: 60;
    padding: 0.5rem;
}

@media (max-width: 1279px) {
    .mobile-menu-toggle {
        display: block;
    }

    .nav-links {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        height: 100dvh; /* dynamic viewport height — iOS Safari 15.4+ */
        background: rgba(14, 14, 14, 0.98);
        -webkit-backdrop-filter: blur(20px);
        backdrop-filter: blur(20px);
        flex-direction: column;
        justify-content: flex-start;
        align-items: flex-start;
        padding: 6rem 2rem 2rem 2rem;
        gap: 1.5rem;
        z-index: 50;
        -webkit-transform: translateY(-100%);
        transform: translateY(-100%);
        opacity: 0;
        -webkit-transition: transform 0.4s ease, opacity 0.4s ease;
        -moz-transition: transform 0.4s ease, opacity 0.4s ease;
        transition: transform 0.4s ease, opacity 0.4s ease;
        display: flex !important;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        pointer-events: none;
    }

    .nav-links.active {
        -webkit-transform: translateY(0);
        transform: translateY(0);
        opacity: 1;
        pointer-events: auto;
    }
    
    .nav-item {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
        height: auto;
    }
    
    .nav-link {
        font-size: 1.25rem;
        width: 100%;
        justify-content: space-between;
        padding-bottom: 0.5rem;
        border-bottom: 1px solid rgba(255,255,255,0.05);
    }

    /* Mobile Mega Menu */
    .mega-menu {
        position: static !important;
        transform: none !important;
        width: 100% !important;
        max-width: 100% !important;
        box-shadow: none !important;
        background: transparent !important;
        display: none !important;
        opacity: 1 !important;
        visibility: visible !important;
        padding: 1rem 0 0 0 !important;
        border: none !important;
    }

    .nav-item.mobile-open .mega-menu {
        display: block !important;
    }

    .mega-grid {
        display: flex;
        flex-direction: column;
        gap: 1.5rem;
        padding: 0;
    }

    .mega-col h4 {
        margin-bottom: 0.5rem;
        font-size: 0.85rem;
    }
    
    .mega-col ul li a {
        padding: 0.5rem 0;
        font-size: 1rem;
    }

    /* Product Mega Grid specifically */
    .products-mega .mega-grid {
        grid-template-columns: 1fr;
    }

    .product-preview-pane {
        display: none; /* Hide preview on mobile to save space */
    }
    
    .product-list-col {
        padding: 0;
        background: transparent;
        border: none;
    }
    
    .product-item-link {
        padding: 0.75rem 0;
        border-radius: 0;
    }
    
    .mega-card {
        display: none; /* Hide featured card in mobile menu to save space */
    }
    
    .mega-footer {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
        padding: 1.5rem 0;
        background: transparent;
    }
}

/* Dashboard Mockup Mobile Swap */
.tab-mobile-img {
    display: none;
    width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    margin: 1.5rem 0 0.5rem 0;
    object-fit: contain;
    border: 1px solid rgba(255,255,255,0.1);
}

@media (max-width: 1024px) {
    /* Hide the entire right-side desktop mockup section */
    .products-preview {
        display: none !important;
    }
    
    /* Show the image only inside the active tab */
    .products-tab.active .tab-mobile-img {
        display: block !important;
        animation: fadeIn 0.4s ease forwards;
    }
}

@-webkit-keyframes fadeIn {
    from { opacity: 0; -webkit-transform: translateY(10px); transform: translateY(10px); }
    to { opacity: 1; -webkit-transform: translateY(0); transform: translateY(0); }
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Base structural fixes for elements that overflow */
@media (max-width: 1024px) {
    .bento-grid, .features-grid, .grid, .footer-grid, .product-grid, .service-grid, .sg-grid, .sg-grid-caps, .cap-grid, .capabilities-grid, .pillars-grid, .why-sg-grid, .why-boss-grid, .regions-grid {
        grid-template-columns: 1fr !important;
        display: flex;
        flex-direction: column;
        gap: 2rem;
    }
    
    .footer-grid {
        gap: 2rem;
    }
    
    .products-mega {
        width: 100% !important;
    }
    
    /* Scrollytelling responsive fixes */
    .hero-h1 {
        font-size: clamp(2rem, 8vw, 4rem);
    }
    
    /* Two column layouts to single column */
    .flex-row {
        flex-direction: column !important;
    }
    
    .w-1\/2 {
        width: 100% !important;
    }
    
    /* Stats grid */
    .stats-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 1.5rem;
    }
}

@media (max-width: 768px) {
    .btn-group,
    .boss-btn-group,
    .sg-btn-group,
    .hero-ctas {
        flex-direction: column !important;
        width: 100%;
    }
    
    .btn-group > *,
    .boss-btn-group > *,
    .sg-btn-group > *,
    .hero-ctas > * {
        width: 100%;
        text-align: center;
    }

    .navbar {
        position: fixed !important;
        top: 0px !important;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr !important;
    }
    
    .hero-h1 {
        font-size: 2rem !important;
    }
}

/* ================================================================
   ABOUT PAGE RESPONSIVE OVERRIDES
   ================================================================ */
@media (max-width: 991px) {
    .about-hero {
        padding: 120px 1.5rem 60px !important;
        min-height: auto !important;
    }
    .about-title {
        font-size: clamp(2rem, 6vw, 3.5rem) !important;
        letter-spacing: -1px !important;
        line-height: 1.15 !important;
    }
    .about-sub {
        font-size: 1rem !important;
    }
    .stats-section {
        padding: 60px 0 !important;
    }
    .stat-item h2 {
        font-size: 2.5rem !important;
    }
    .story-section {
        padding: 60px 0 !important;
    }
    .story-grid {
        gap: 2rem !important;
    }
    .section-header h2 {
        font-size: 2rem !important;
    }
    .value-card {
        padding: 1.5rem !important;
    }
    .value-card h3 {
        font-size: 1.25rem !important;
    }
}

@media (max-width: 768px) {
    .map-section {
        padding: 60px 1rem !important;
    }
    .map-section h2 {
        font-size: 2rem !important;
    }
    .map-grid {
        grid-template-columns: 1fr !important;
        gap: 1.5rem !important;
        margin-top: 2rem !important;
    }
    .region-card {
        padding: 1.5rem !important;
    }
    .region-title {
        font-size: 1.5rem !important;
    }
    .region-num {
        font-size: 2rem !important;
    }
    .pulse-indicator {
        top: 1.5rem !important;
        right: 1.5rem !important;
    }
    .region-card:hover .region-content,
    .region-card.active .region-content {
        margin-top: 1.5rem !important;
        padding-top: 1.5rem !important;
    }
    .city-grid {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }
    .city-item {
        padding: 1rem !important;
    }
}

/* Ensure images don't overflow */
img, canvas, video {
    max-width: 100%;
    height: auto;
}

/* Hide scrollbar but keep functionality */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--surface-lowest, #000); 
}
::-webkit-scrollbar-thumb {
    background: var(--surface-bright, #2c2c2c); 
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary, #ff9069); 
}
