/* ========================================
   COMPREHENSIVE MOBILE OPTIMIZATIONS
   ======================================== */

/* Mobile Navigation */
@media (max-width: 992px) {
    header nav {
        flex-wrap: nowrap;
        justify-content: space-between;
    }

    .nav-links {
        display: none;
    }

    .nav-toggle,
    .mobile-menu-btn {
        display: flex !important;
        flex-direction: column;
        justify-content: space-between;
        align-items: center;
        padding: 12px 10px;
        width: 44px;
        height: 44px;
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        color: #fff;
        cursor: pointer;
        z-index: 1001;
    }

    .nav-links.active {
        display: flex !important;
        flex-direction: column;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background: rgba(5, 5, 5, 0.98);
        backdrop-filter: blur(20px);
        padding: 8rem 2rem;
        z-index: 1000;
        gap: 2rem;
        align-items: center;
        justify-content: center;
        animation: fadeIn 0.3s ease;
    }

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

        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .nav-links.active a {
        font-size: 1.5rem;
        font-weight: 700;
        color: #fff;
        font-family: var(--font-heading);
    }

    .nav-right {
        display: flex !important;
    }

    /* Hide the Start Project button on mobile, but keep the hamburger */
    .nav-right .btn-light {
        display: none !important;
    }

    .nav-links.active~.nav-right {
        display: flex !important;
    }
}

@media (max-width: 768px) {

    /* Critical Reset for Horizontal Overflow */
    html,
    body {
        overflow-x: hidden;
        width: 100%;
        position: relative;
    }

    .container {
        padding: 0 1.25rem;
        width: 100%;
        max-width: 100%;
    }

    /* Hero Section */
    .hero {
        padding-top: 100px;
        padding-bottom: 3rem;
        min-height: auto;
    }

    .hero-content {
        max-width: 100% !important;
        padding: 0 !important;
    }

    .hero-title {
        font-size: clamp(2rem, 10vw, 2.8rem) !important;
        line-height: 1.2 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .hero-subtitle {
        font-size: 1rem !important;
        margin-bottom: 2rem !important;
        max-width: 100% !important;
    }

    .marquee-container {
        width: 100% !important;
        margin-top: 2.5rem !important;
    }

    /* Bento Grid Overhaul */
    .bento-grid-complex {
        grid-template-columns: 1fr !important;
        height: auto !important;
        gap: 1rem !important;
    }

    .bento-card {
        grid-column: span 1 !important;
        min-height: auto !important;
        padding: 1.5rem !important;
    }

    .orbit-card {
        flex-direction: column !important;
        text-align: center !important;
        padding: 2rem 1.5rem !important;
    }

    .orbit-content {
        margin-bottom: 2rem;
    }

    .orbit-desc {
        max-width: 100% !important;
        margin: 0 auto;
    }

    .integration-grid {
        max-width: 100% !important;
        margin: 0 auto;
    }

    /* Projects Grid */
    .projects-grid {
        grid-template-columns: 1fr !important;
        gap: 1.5rem !important;
    }

    .project-image {
        height: 200px !important;
    }

    /* Calculator/Audit CTA */
    .calculator-cta-section {
        padding: 4rem 1.5rem !important;
        margin: 4rem 0 !important;
        border-radius: 20px !important;
    }

    .calculator-cta-section h2 {
        font-size: 2.2rem !important;
    }

    /* Footer */
    .footer-grid {
        grid-template-columns: 1fr !important;
        gap: 2.5rem !important;
    }

    .footer-brand {
        text-align: center;
    }

    .brand-desc {
        max-width: 100% !important;
        margin-left: auto;
        margin-right: auto;
    }

    .social-links-minimal {
        justify-content: center;
    }

    .footer-nav {
        text-align: center;
    }

    .footer-nav ul {
        align-items: center;
    }

    .footer-bottom {
        flex-direction: column !important;
        gap: 1rem !important;
        text-align: center;
    }

    /* Typography Scaling */
    .massive-title {
        font-size: 2.8rem !important;
    }

    .page-hero h1 {
        font-size: 2.2rem !important;
    }

    .fast-cta h2 {
        font-size: 2.2rem !important;
    }

    h2 {
        font-size: 2rem !important;
    }

    h3 {
        font-size: 1.5rem !important;
    }

    /* Header & Navigation */
    header {
        padding: 1rem 0;
    }

    .nav-links {
        display: none;
    }

    .logo {
        font-size: 1.1rem;
    }

    .logo-icon {
        width: 24px;
        height: 24px;
        font-size: 0.7rem;
    }

    /* Hero Section */
    main.container {
        padding-top: 120px !important;
        padding-bottom: 3rem !important;
    }

    /* Bento Grid - Stack on Mobile */
    .explained-card,
    .center-cluster,
    .analytics-card {
        min-height: 300px;
    }

    .center-cluster {
        grid-template-columns: 1fr;
    }

    .orbit-visual {
        width: 200px;
        height: 200px;
    }

    /* Integration Grid Mobile */
    .integration-grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }

    .orbit-card h3 {
        font-size: 1.8rem !important;
    }

    .orbit-card p {
        margin: 0 auto;
    }

    /* Offer Card Mobile */
    .offer-card h3 {
        font-size: 1.8rem !important;
    }

    /* Results/Work With Us Page */
    .results-hero {
        padding-top: 100px;
        padding-bottom: 2rem;
    }

    .impact-badge {
        font-size: 0.7rem;
        padding: 0.4rem 1rem;
    }

    .impact-card {
        min-height: 250px;
    }

    .card-overlay-content {
        padding: 1.5rem;
    }

    .card-overlay-content h4 {
        font-size: 1.2rem !important;
    }

    .metric-row {
        gap: 1.5rem;
        flex-wrap: wrap;
    }

    .metric-item .number {
        font-size: 1.8rem !important;
    }

    /* Studio Showcase Slides */
    .slideshow-track>div {
        padding: 2rem !important;
    }

    .slideshow-track>div>div {
        grid-template-columns: 1fr !important;
        gap: 2rem !important;
    }

    .slideshow-track img,
    .slideshow-track video {
        height: 250px !important;
    }

    /* Floating Elements on Results Page */
    .studio-feature-section {
        margin-top: 6rem !important;
    }

    .studio-feature-section h2 {
        font-size: 2rem !important;
    }

    .studio-feature-section>div[style*="position: relative"] {
        height: auto !important;
        min-height: 400px;
    }

    .floating-mini-card {
        position: relative !important;
        left: auto !important;
        right: auto !important;
        top: auto !important;
        bottom: auto !important;
        margin-bottom: 1rem;
        animation: none !important;
    }

    /* CTA Section */
    .fast-cta {
        padding: 4rem 0;
    }

    .cta-group {
        flex-direction: column;
        gap: 1rem;
    }

    .btn-impact,
    .btn-outline {
        width: 100%;
        text-align: center;
        padding: 1rem 2rem;
        font-size: 0.9rem;
    }

    /* Footer */
    .footer-grid {
        margin-bottom: 2.5rem;
    }

    .footer-bottom {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    /* Services Page */
    .services-grid {
        grid-template-columns: 1fr !important;
    }

    /* Case Studies */
    .project-card {
        margin-bottom: 1.5rem;
    }

    .project-stats {
        flex-direction: column;
        gap: 1rem;
    }

    /* About Page */
    .split-layout {
        gap: 2rem;
    }

    /* Grid Utilities */
    .grid-4,
    .grid-3,
    .grid-2 {
        grid-template-columns: 1fr !important;
        gap: 1.5rem !important;
    }

    .split-layout {
        flex-direction: column;
        gap: 3rem;
    }
}

@media (max-width: 480px) {
    .hero-title {
        font-size: 2.2rem !important;
    }

    .btn-primary,
    .btn-outline {
        width: 100%;
        justify-content: center;
    }

    .partner-logo {
        font-size: 1.1rem !important;
    }

    /* Extra Small Screens */
    .container {
        padding: 0 1rem;
    }

    .massive-title {
        font-size: 2.2rem !important;
        line-height: 1.2;
    }

    .page-hero h1 {
        font-size: 1.8rem !important;
    }

    h2 {
        font-size: 1.6rem !important;
    }

    /* Buttons */
    .btn-light,
    .btn-primary,
    .btn-impact,
    .btn-outline {
        font-size: 0.85rem;
        padding: 0.8rem 1.5rem;
    }

    /* Impact Cards */
    .impact-card {
        border-radius: 16px;
    }

    .card-overlay-content {
        padding: 1.25rem;
    }

    .card-overlay-content h4 {
        font-size: 1.1rem !important;
        margin-bottom: 0.5rem;
    }

    .card-overlay-content p {
        font-size: 0.85rem;
    }

    .metric-item .number {
        font-size: 1.5rem !important;
    }

    .metric-item .label {
        font-size: 0.7rem;
    }

    /* Studio Sections */
    .studio-feature-section h2 {
        font-size: 1.6rem !important;
    }

    .studio-feature-section p {
        font-size: 0.9rem;
    }

    /* Grid Utilities */
    .grid-4 {
        grid-template-columns: 1fr !important;
    }

    .grid-3 {
        grid-template-columns: 1fr !important;
    }

    /* Fast CTA */
    .fast-cta {
        padding: 3rem 0;
    }

    .fast-cta h2 {
        font-size: 1.8rem !important;
        margin-bottom: 2rem;
    }

    /* Stat Cards */
    .stat-card {
        padding: 1.5rem 1rem;
    }

    .stat-card h3 {
        font-size: 2rem !important;
    }

    /* Testimonials */
    .testimonial-card {
        padding: 1.5rem;
    }

    .testimonial-text {
        font-size: 0.9rem;
    }

    /* Footer */
    .site-footer {
        padding-top: 3rem;
    }

    .footer-grid {
        gap: 2rem;
    }

    .social-links-minimal {
        justify-content: center;
    }
}

/* Performance Optimizations */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {

    /* Larger touch targets */
    .btn-light,
    .btn-primary,
    .btn-impact,
    .btn-outline,
    .selection-card {
        min-height: 44px;
    }

    /* Remove hover effects on touch devices */
    .premium-hover:hover {
        transform: none;
    }

    .bento-card:hover {
        transform: none;
    }

    /* Disable animations that might cause performance issues */
    .motion-float,
    .motion-float-reverse,
    .motion-float-medium,
    .motion-pulse,
    .motion-drift,
    .motion-spin {
        animation: none;
    }

    .orbit-item {
        animation: none !important;
    }
}

/* Landscape Mobile Optimization */
@media (max-width: 992px) and (orientation: landscape) {
    .hero {
        padding-top: 80px;
        padding-bottom: 2rem;
    }

    .results-hero {
        padding-top: 80px;
    }

    .page-hero {
        padding-top: 100px;
        padding-bottom: 2rem;
    }
}

/* High DPI Screens - Optimize Images */
@media (-webkit-min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {

    .impact-img,
    .video-bg {
        image-rendering: -webkit-optimize-contrast;
    }
}