/* Mobile Homepage Improvements */

/* Prevent any horizontal overflow */
@media (max-width: 768px) {
    * {
        box-sizing: border-box;
    }
    
    html, body {
        overflow-x: hidden;
        width: 100%;
        margin: 0;
        padding: 0;
        /* Prevent vertical over-scroll */
        overscroll-behavior-y: none;
    }

    /* Ensure main container doesn't extend past viewport */
    body {
        min-height: 100vh;
        max-height: 100%;
        position: relative;
    }

    /* Fix for any sections that might be causing extra height */
    .section {
        max-width: 100%;
        overflow: hidden;
    }

    /* Ensure footer sticks properly */
    footer, .new-footer {
        margin-top: auto;
        width: 100%;
        overflow: hidden;
    }

    /* Fix for particles container */
    #particles-js {
        height: 100%;
        max-height: 100vh;
        overflow: hidden;
    }

    /* Fix for hero section */
    .hero {
        max-height: 100vh;
        overflow: hidden;
    }

    /* Prevent any sections from extending beyond viewport */
    .about-growth-section,
    .services-section,
    .portfolio-showcase,
    .testimonials-section,
    .contact-cta,
    .booking-promo-enhanced {
        max-width: 100%;
        overflow-x: hidden;
    }

    /* Fix for any absolute positioned elements */
    .about-growth-section::before,
    .services-section::before,
    .portfolio-showcase::before,
    .testimonials-section::before {
        width: 100%;
        max-width: 100%;
        left: 0;
        right: 0;
    }

    /* Ensure container doesn't overflow */
    .container {
        max-width: 100%;
        margin-left: auto;
        margin-right: auto;
        padding-left: 1rem;
        padding-right: 1rem;
        overflow-x: hidden;
    }

    /* Fix for booking promo section if it's causing issues */
    .booking-two-column-layout {
        max-width: 100%;
        overflow: hidden;
    }

    /* Remove any transform that might cause overflow */
    .ag-core-grid,
    .ag-diff,
    .process-flow {
        transform: none;
    }

    /* General mobile adjustments */
    @media (max-width: 768px) {

        /* Improve overall spacing and readability */
        .hero-content {
            padding: 2rem 1rem 3rem;
        }

        .hero-content h1 {
            font-size: 2rem;
            line-height: 1.3;
            margin-bottom: 1rem;
        }

        .hero-content p {
            font-size: 1rem;
            line-height: 1.5;
            margin-bottom: 1.5rem;
        }

        .hero-buttons {
            flex-direction: column;
            align-items: center;
            width: 100%;
        }

        .hero-buttons .btn {
            width: 100%;
            margin: 0.5rem 0;
            padding: 0.9rem 1rem;
            text-align: center;
        }

        /* Fix particles background */
        #particles-js {
            height: 100%;
        }

        /* About Growth Section Fixes */
        .about-growth-section {
            padding: 3rem 0;
            overflow-x: hidden; /* Prevent horizontal scroll */
        }

        .ag-badge {
            font-size: 0.85rem;
            padding: 0.4rem 0.8rem;
        }

        /* Fix Strategic Django Engineering heading */
        .ag-heading {
            font-size: 1.8rem;
            line-height: 1.3;
            text-align: center;
            padding: 0 1rem;
            word-wrap: break-word;
            overflow-wrap: break-word;
            hyphens: auto;
            margin: 1rem auto;
            max-width: 100%;
        }

        .ag-sub {
            font-size: 1rem;
            line-height: 1.5;
            padding: 0 1rem;
            text-align: center;
            word-wrap: break-word;
            overflow-wrap: break-word;
            max-width: 100%;
        }

        /* Ensure the gradient text doesn't cause overflow */
        .grad-text {
            word-wrap: break-word;
            overflow-wrap: break-word;
            display: inline-block;
            max-width: 100%;
        }

        /* Fix trust row - prevent overflow */
        .ag-trust-row {
            flex-direction: column;
            align-items: center;
            gap: 1rem;
            margin: 1.5rem 0;
            padding: 0 1rem;
        }

        .ag-trust-item {
            font-size: 0.85rem;
            text-align: center;
            justify-content: center;
            width: 100%;
            max-width: 200px;
        }

        /* Core grid adjustments */
        .ag-core-grid {
            grid-template-columns: 1fr;
            gap: 1.5rem;
            padding: 0 1rem;
            margin: 0 auto 3rem;
        }

        .ag-block {
            padding: 1.5rem;
            margin: 0;
            width: 100%;
            box-sizing: border-box;
            max-width: 100%;
            overflow: hidden;
        }

        /* Fix for CTA buttons alignment */
        .ag-cta-inline {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 1rem;
            margin: 1.5rem 0;
            width: 100%;
        }

        .ag-cta-inline .btn {
            width: 100%;
            max-width: 280px;
            text-align: center;
            margin: 0;
        }

        /* Fix for benefits list and any long text */
        .ag-benefits {
            width: 100%;
            padding: 0;
            margin: 1rem 0;
            list-style: none;
        }

        .ag-benefits li {
            width: 100%;
            padding: 0.8rem 0;
            word-wrap: break-word;
            overflow-wrap: break-word;
            box-sizing: border-box;
            display: flex;
            align-items: flex-start;
            gap: 0.8rem;
            position: relative;
            padding-left: 0; /* Override desktop padding-left */
        }

        .ag-benefits li i {
            color: var(--secondary);
            margin-top: 0.2rem;
            flex-shrink: 0;
            font-size: 0.9rem;
            position: static; /* Override desktop absolute positioning */
            left: auto;
            top: auto;
        }

        .ag-benefits li span,
        .ag-benefits li .b-tip {
            flex: 1;
            word-wrap: break-word;
            overflow-wrap: break-word;
        }

        /* Hide benefit tooltips on mobile */
        .ag-benefits li .b-tip {
            display: none;
        }

        /* Fix for any long text elements */
        .ag-block h3,
        .ag-block p,
        .ag-block ul,
        .ag-block li {
            word-wrap: break-word;
            overflow-wrap: break-word;
            max-width: 100%;
            box-sizing: border-box;
        }

        /* Code visual section - Hide entire code block on mobile */
        .ag-code {
            display: none;
        }

        /* Differentiators grid */
        .ag-diff {
            display: grid;
            grid-template-columns: 1fr;
            gap: 1rem;
            padding: 0 1rem;
        }

        .diff-item {
            padding: 1rem;
            margin: 0;
            width: 100%;
            box-sizing: border-box;
        }

        .diff-item h4 {
            font-size: 0.9rem;
            margin-bottom: 0.5rem;
        }

        .diff-item p {
            font-size: 0.8rem;
            line-height: 1.4;
        }

        .diff-detail-panel {
            padding: 1.2rem 1rem;
            margin: 1rem;
            width: calc(100% - 2rem);
            box-sizing: border-box;
        }

        .dd-title {
            font-size: 1.1rem;
        }

        /* Process section heading */
        .ag-process h3 {
            font-size: 1.6rem;
            text-align: center;
            margin: 1.5rem auto 2rem;
            padding: 0 1rem;
            word-wrap: break-word;
            overflow-wrap: break-word;
        }

        /* Process flow */
        .process-flow {
            flex-direction: column;
            padding: 0 1rem;
            align-items: center;
            gap: 2rem;
        }

        /* Hide the connecting line on mobile */
        .process-flow::before {
            display: none;
        }

        .p-step {
            width: 100%;
            margin-bottom: 0;
            padding: 1.5rem;
            background: rgba(0, 0, 0, 0.3);
            border-radius: 10px;
            border: 1px solid rgba(0, 255, 127, 0.2);
            max-width: 300px;
        }

        .p-step::before {
            position: relative;
            margin-bottom: 1rem;
        }

        .p-step h4 {
            font-size: 1.2rem;
            margin: 0.5rem 0;
        }

        .p-step p {
            font-size: 0.95rem;
            line-height: 1.4;
        }

        .p-step::before {
            height: 40px;
            width: 40px;
            font-size: 1.2rem;
        }

        /* Services Section */
        .services-section {
            padding: 3rem 0;
        }

        .services-card-grid {
            grid-template-columns: 1fr;
            gap: 1.5rem;
            padding: 0 1rem;
        }

        /* Portfolio Section - Fix featured project metrics */
        .portfolio-showcase {
            padding: 3rem 0;
            overflow-x: hidden;
        }

        .featured-project {
            display: flex;
            flex-direction: column;
            padding: 0 1rem;
            margin: 0;
            width: 100%;
            box-sizing: border-box;
        }

        .fp-media {
            width: 100%;
            margin-bottom: 1.5rem;
        }

        .fp-body {
            width: 100%;
            padding: 0;
        }

        .fp-title {
            font-size: 1.5rem;
            margin-bottom: 1rem;
        }

        /* Fix CI/CD Lifecycle metrics section - Hide on mobile */
        .fp-metrics {
            display: none;
        }

        /* Fix tags section */
        .fp-tags {
            display: flex;
            flex-wrap: wrap;
            gap: 0.5rem;
            margin: 1.5rem 0;
            width: 100%;
        }

        .fp-tags span {
            font-size: 0.8rem;
            padding: 0.3rem 0.6rem;
            margin: 0;
            white-space: nowrap;
            flex-shrink: 0;
        }

        /* Portfolio grid */
        .home-portfolio-grid {
            grid-template-columns: 1fr;
            gap: 1.5rem;
            padding: 0 1rem;
        }

        /* Testimonials Section */
        .testimonials-section {
            padding: 3rem 0;
        }

        .testimonial-content {
            padding: 1.5rem 1rem;
        }

        .testimonial-text {
            font-size: 1rem;
            line-height: 1.6;
        }

        /* Contact CTA Section */
        .contact-cta {
            padding: 3rem 1rem;
        }

        .contact-cta h2 {
            font-size: 1.8rem;
            margin-bottom: 1rem;
        }

        .contact-cta p {
            font-size: 1rem;
            margin-bottom: 1.5rem;
        }

        .contact-cta .btn {
            width: 100%;
            max-width: 300px;
        }

        /* Booking promo section */
        .booking-promo {
            padding: 2rem 1rem;
        }

        .booking-promo h2 {
            font-size: 1.6rem;
        }

        .booking-promo .btn {
            width: 100%;
            max-width: 280px;
        }

        /* Booking promo enhanced section - FIXED FOR MOBILE */
        .booking-promo-enhanced {
            padding: 2rem 0 !important;
            overflow-x: hidden;
        }

        .booking-two-column-layout {
            grid-template-columns: 1fr !important;
            gap: 1.5rem !important;
            max-width: 100% !important;
            margin: 0 !important;
            padding: 0 1rem !important;
        }

        .booking-content {
            text-align: center !important;
            max-width: 100% !important;
            padding: 0 !important;
            margin: 0 !important;
        }

        .booking-content h2 {
            font-size: 1.8rem !important;
            line-height: 1.3 !important;
            margin-bottom: 1rem !important;
        }

        .booking-content p {
            font-size: 1rem !important;
            margin-bottom: 1.5rem !important;
        }

        .booking-cta-btn {
            width: 100% !important;
            max-width: 280px !important;
            padding: 1rem 1.5rem !important;
            font-size: 1rem !important;
            margin: 0 auto 1.5rem !important;
            display: block !important;
        }

        .booking-benefits {
            flex-direction: column !important;
            gap: 0.8rem !important;
            align-items: center !important;
            padding: 0 !important;
            margin: 0 !important;
        }

        .code-block-container {
            max-width: 100% !important;
            margin: 0 !important;
            padding: 0 !important;
            overflow-x: auto;
        }

        .code-block {
            font-size: 0.75rem !important;
            padding: 1rem !important;
            line-height: 1.4 !important;
            overflow-x: auto;
            white-space: nowrap;
        }

        .code-block pre {
            margin: 0 !important;
            overflow-x: auto;
        }

        .code-block code {
            white-space: pre;
            overflow-x: auto;
        }

        /* General container fixes */
        .container {
            padding-left: 1rem;
            padding-right: 1rem;
            max-width: 100%;
            overflow-x: hidden;
        }

        /* Prevent any potential horizontal scroll */
        body {
            overflow-x: hidden;
        }

        .about-growth-section .container {
            width: 100%;
            max-width: 100%;
            padding: 0;
        }
    }

    .ag-core-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .ag-diff {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
    }

    .diff-item {
        padding: 1rem;
    }

    .diff-item h4 {
        font-size: 0.9rem;
    }

    .diff-item p {
        font-size: 0.8rem;
    }

    .diff-detail-panel {
        padding: 1.2rem;
        margin-top: 1rem;
    }

    .dd-title {
        font-size: 1.1rem;
    }

    .process-flow {
        flex-direction: column;
    }

    .p-step {
        width: 100%;
        margin-bottom: 2rem;
    }

    .p-step::before {
        height: 40px;
        width: 40px;
        font-size: 1.2rem;
    }

    /* Services Section */
    .services-section {
        padding: 3rem 0;
    }

    .services-card-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    /* Portfolio Section */
    .portfolio-showcase {
        padding: 3rem 0;
    }

    .featured-project {
        display: flex;
        flex-direction: column;
    }

    .fp-media {
        width: 100%;
        margin-bottom: 1.5rem;
    }

    .fp-body {
        width: 100%;
    }

    .fp-title {
        font-size: 1.5rem;
    }

    .home-portfolio-grid {
        grid-template-columns: 1fr;
    }

    /* Testimonials Section */
    .testimonials-section {
        padding: 3rem 0;
    }

    .testimonial-content {
        padding: 1.5rem;
    }

    .testimonial-text {
        font-size: 1rem;
        line-height: 1.6;
    }

    /* Contact CTA Section */
    .contact-cta {
        padding: 3rem 0;
    }

    .cta-card {
        padding: 1.5rem;
    }

    /* Code display */
    .ag-code {
        font-size: 0.8rem;
    }

    .code-tabs {
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 0.5rem;
    }

    .code-tab {
        font-size: 0.8rem;
        padding: 0.5rem 0.8rem;
    }

    /* Final CTA */
    .ag-final-cta {
        padding: 2rem 1rem;
        margin-top: 2rem;
    }

    .cta-copy h3 {
        font-size: 1.3rem;
    }

    .cta-actions {
        flex-direction: column;
        width: 100%;
    }

    .cta-actions .btn {
        width: 100%;
        margin: 0.5rem 0;
    }
}

/* Small phone screens */
@media (max-width: 480px) {
    .hero-content h1 {
        font-size: 1.7rem;
    }

    .ag-diff {
        grid-template-columns: 1fr;
    }

    .fp-metrics {
        flex-direction: column;
        align-items: flex-start;
    }

    .fp-metrics .metric {
        margin-bottom: 0.7rem;
    }

    .fp-tags {
        display: flex;
        flex-wrap: wrap;
    }

    .fp-tags span {
        margin-bottom: 0.5rem;
    }
}

/* Fix for typed.js cursor on mobile */
@media (max-width: 768px) {
    .typed-cursor {
        font-size: 1.8rem;
    }
}

/* Improve touch targets */
@media (max-width: 768px) {

    .btn,
    .nav-link,
    .filter-btn,
    .testimonial-nav-btn {
        min-height: 44px;
        min-width: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Service card icon alignment improvements */
    .service-card i {
        margin-top: 0.3rem;
        margin-bottom: 1rem;
    }

    /* Home page service icon container adjustments */
    .service-icon-container {
        margin-bottom: 1rem;
    }

    .service-icon-container i {
        margin: 0;
    }
}

/* Desktop icon alignment improvements */
@media (min-width: 769px) {
    /* Ensure proper icon alignment on desktop */
    .service-card i {
        margin-top: 0.8rem;
        margin-bottom: 1.2rem;
        text-align: center;
        display: block;
    }
    
    /* Ensure service icon containers are properly positioned */
    .service-icon-container {
        margin-bottom: 1.5rem;
    }
}

/* Fix for featured project on mobile */
@media (max-width: 768px) {
    /* Featured Bristol Chess project mobile fixes */
    .featured-project {
        margin-bottom: 2rem !important;
        padding: 1rem !important;
    }
    
    .fp-media {
        min-height: auto !important;
        height: auto !important;
        max-height: 220px !important;
        margin-bottom: 1rem !important;
        display: block !important;
    }
    
    .fp-media img {
        height: auto !important;
        max-height: 220px !important;
        min-height: auto !important;
        width: 100% !important;
        object-fit: cover !important;
        display: block !important;
    }
    
    .fp-body {
        padding: 0 !important;
        margin-top: 0 !important;
    }
    
    .fp-title {
        font-size: 1.4rem !important;
        margin-bottom: 0.8rem !important;
    }
    
    .fp-desc {
        font-size: 0.9rem !important;
        line-height: 1.5 !important;
        margin-bottom: 1rem !important;
    }
}

/* Add this fix for desktop to ensure consistency */
@media (min-width: 769px) {
    html, body {
        overflow-x: hidden;
        width: 100%;
    }
    
    body {
        min-height: 100vh;
    }
}