/* ==========================================================================
   Atlas Trades - Mobile Optimizations
   Loaded AFTER page-specific styles so these rules win.
   Targets: touch devices, small screens, iOS Safari quirks.
   ========================================================================== */

/* --- Global mobile-safety rules (apply on all viewports) --- */
html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    -webkit-tap-highlight-color: rgba(20, 184, 166, 0.2);
    overflow-x: hidden;
    max-width: 100vw;
}

img, video, iframe {
    max-width: 100%;
    height: auto;
}

/* Fix background-attachment: fixed bug on iOS Safari (causes broken hero) */
@supports (-webkit-touch-callout: none) {
    .hero::before,
    .hero {
        background-attachment: scroll !important;
    }
}

/* Disable custom SVG cursor on touch devices — blocks native tap feedback */
@media (hover: none) and (pointer: coarse) {
    body,
    a,
    button,
    .btn,
    .nav-cta {
        cursor: auto !important;
    }
}

/* ==========================================================================
   Tablet & smaller (≤ 900px)
   ========================================================================== */
@media (max-width: 900px) {
    nav {
        padding: 0 20px !important;
    }

    .hero {
        min-height: auto !important;
        height: auto !important;
        padding: 100px 20px 60px !important;
        background-attachment: scroll !important;
    }

    .hero::before {
        background-attachment: scroll !important;
    }

    .content-section,
    .features-section,
    .cta-section,
    .what-we-do,
    .industries,
    .stats,
    .testimonial {
        padding: 60px 20px !important;
    }

    .features-grid,
    .footer-grid,
    .footer-content {
        grid-template-columns: 1fr !important;
        gap: 24px !important;
    }
}

/* ==========================================================================
   Mobile (≤ 768px) — core mobile layout fixes
   ========================================================================== */
@media (max-width: 768px) {
    /* Typography: better scaling for small screens */
    .hero h1,
    h1 {
        font-size: clamp(32px, 9vw, 44px) !important;
        line-height: 1.15 !important;
        letter-spacing: -1px !important;
    }

    .hero p,
    section p {
        font-size: clamp(15px, 4vw, 17px) !important;
        line-height: 1.6 !important;
    }

    h2 {
        font-size: clamp(26px, 7vw, 36px) !important;
        line-height: 1.2 !important;
    }

    h3 {
        font-size: 20px !important;
    }

    /* Hero section adjustments */
    .hero {
        padding-top: 90px !important;
        padding-bottom: 50px !important;
    }

    .hero-badge {
        font-size: 11px !important;
        padding: 6px 14px !important;
    }

    .hero-content {
        padding: 0 16px !important;
    }

    /* Buttons — touch-target minimum 48px */
    .btn,
    .hero-buttons a,
    .nav-cta,
    button {
        min-height: 48px !important;
        padding: 14px 24px !important;
        font-size: 15px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .hero-buttons {
        flex-direction: column !important;
        gap: 12px !important;
        width: 100% !important;
        max-width: 320px !important;
        margin: 0 auto !important;
    }

    .hero-buttons a,
    .hero-buttons .btn {
        width: 100% !important;
    }

    /* Navigation — mobile menu */
    nav {
        height: 64px !important;
        padding: 0 16px !important;
    }

    .nav-logo {
        font-size: 17px !important;
    }

    .nav-cta {
        display: none !important; /* use mobile menu link instead */
    }

    .hamburger {
        display: flex !important;
        min-width: 44px !important;
        min-height: 44px !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 8px !important;
    }

    .nav-links,
    #navLinks,
    #nav-menu {
        display: none;
        position: fixed !important;
        top: 64px !important;
        left: 0 !important;
        right: 0 !important;
        bottom: auto !important;
        flex-direction: column !important;
        gap: 0 !important;
        background-color: rgba(10, 10, 10, 0.98) !important;
        backdrop-filter: blur(20px) !important;
        -webkit-backdrop-filter: blur(20px) !important;
        padding: 20px 0 !important;
        border-bottom: 1px solid #2A2A2A !important;
        list-style: none !important;
        z-index: 999 !important;
        max-height: calc(100vh - 64px) !important;
        overflow-y: auto !important;
    }

    .nav-links.active,
    #navLinks.active,
    #nav-menu.active {
        display: flex !important;
    }

    .nav-links li,
    #navLinks li,
    #nav-menu li {
        width: 100% !important;
    }

    .nav-links a,
    #navLinks a,
    #nav-menu a {
        display: block !important;
        padding: 16px 24px !important;
        min-height: 48px !important;
        font-size: 16px !important;
        border-bottom: 1px solid rgba(42, 42, 42, 0.5) !important;
        width: 100% !important;
    }

    .nav-links a::after,
    #navLinks a::after,
    #nav-menu a::after {
        display: none !important;
    }

    /* Dropdown in mobile menu */
    .dropdown-menu {
        position: static !important;
        opacity: 1 !important;
        visibility: visible !important;
        transform: none !important;
        max-height: 0 !important;
        overflow: hidden !important;
        transition: max-height 0.3s ease !important;
        margin-top: 0 !important;
        border: none !important;
        box-shadow: none !important;
        background-color: rgba(20, 184, 166, 0.05) !important;
        border-radius: 0 !important;
    }

    .nav-item.active .dropdown-menu,
    .dropdown.active .dropdown-menu,
    .nav-dropdown.active .dropdown-menu,
    .nav-item-dropdown.active .dropdown-menu {
        max-height: 500px !important;
    }

    .dropdown-menu a {
        padding: 14px 40px !important;
        font-size: 14px !important;
    }

    /* Cards and grids */
    .feature-card,
    .industry-card,
    .service-card {
        padding: 24px 20px !important;
    }

    .features-grid,
    .industries-grid,
    .services-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }

    /* Footer */
    footer {
        padding: 40px 20px 24px !important;
    }

    .footer-grid,
    .footer-content {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 32px !important;
        text-align: left !important;
    }

    .footer-col,
    .footer-section {
        width: 100% !important;
    }

    /* Sections: tighter vertical rhythm */
    section {
        padding: 50px 20px !important;
    }

    .content-wrapper,
    .features-wrapper,
    .cta-content {
        padding: 0 !important;
    }

    /* Prevent horizontal overflow */
    .hero,
    nav,
    section,
    footer {
        max-width: 100vw !important;
        overflow-x: hidden !important;
    }
}

/* ==========================================================================
   Small mobile (≤ 480px) — very tight spacing
   ========================================================================== */
@media (max-width: 480px) {
    .hero h1,
    h1 {
        font-size: clamp(28px, 10vw, 38px) !important;
    }

    .hero {
        padding: 80px 16px 40px !important;
    }

    section {
        padding: 40px 16px !important;
    }

    .content-section,
    .features-section,
    .cta-section {
        padding: 40px 16px !important;
    }

    .feature-card,
    .industry-card {
        padding: 20px 18px !important;
    }

    .nav-logo {
        font-size: 16px !important;
        letter-spacing: 0.5px !important;
    }

    footer {
        padding: 32px 16px 20px !important;
    }

    .hero-badge {
        font-size: 10px !important;
        padding: 5px 12px !important;
        margin-bottom: 16px !important;
    }
}

/* ==========================================================================
   Landscape phones — prevent content being hidden
   ========================================================================== */
@media (max-width: 900px) and (orientation: landscape) {
    .hero {
        min-height: auto !important;
        padding-top: 90px !important;
    }
}

/* ==========================================================================
   Reduced motion — respect user preference
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .hero::before {
        background-attachment: scroll !important;
    }
}
