/* 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 {
        /* On mobile the header is fixed to the top and can overlap the hero.
           Add a mobile-specific header offset so the hero content is pushed
           below the header and the hero fits the remaining viewport height.

           Note: this uses an assumed header height for most mobile layouts (~96px).
           If your header is taller/shorter, adjust --mobile-header-offset accordingly
           or replace this with a small JS snippet that measures the header height. */
        --mobile-header-offset: 96px;
        min-height: auto; /* Remove min-height constraints on mobile */
        height: auto; /* Let content determine height */
        max-height: 85vh; /* Limit to 85vh on mobile for better fit */
        padding-top: var(--mobile-header-offset);
        padding-bottom: 2rem;
        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;
    }
    
    /* Preserve header container spacing */
    .header-container.container,
    header .container.header-container {
        padding-left: 20px;
        padding-right: 20px;
    }

    /* 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;
            min-height: 7rem; /* Increased for mobile stability */
            max-height: 7rem; /* Lock height on mobile */
            overflow: visible;
        }

        #typing-text {
            display: inline;
        }

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

        .hero-buttons {
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
            align-items: center;
            width: 100%;
            gap: 0.75rem;
        }

        .hero-buttons .btn {
            flex: 1 1 calc(50% - 0.5rem); /* Side by side, each takes ~50% */
            max-width: calc(50% - 0.5rem);
            margin: 0;
            padding: 0.9rem 0.5rem;
            text-align: center;
            order: 1; /* Buttons appear first */
            font-size: 0.85rem; /* Slightly smaller to fit side-by-side */
        }

        .hero-buttons .google-rating-link {
            order: 2; /* Google widget appears after buttons */
            margin-top: 0.75rem; /* Space above the widget */
            width: 100%;
            text-align: center;
        }

        /* Make Google rating widget smaller on mobile */
        .google-rating-widget {
            padding: 0.5rem 0.9rem; /* Reduced from 0.7rem 1.2rem */
            gap: 0.5rem; /* Reduced from 0.75rem */
            transform: scale(0.9); /* Make it 90% size */
        }

        .google-g-logo {
            width: 20px; /* Reduced from 24px */
            height: 20px;
        }

        .rating-stars i {
            font-size: 0.9rem; /* Reduced from 1.1rem */
        }

        .rating-score {
            font-size: 1rem; /* Reduced from 1.2rem */
        }

        .rating-source {
            font-size: 0.85rem; /* Reduced from 0.95rem */
        }

        /* 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%;
        }

        /* Hide trust row on mobile */
        .ag-trust-row {
            display: none;
        }

        /* 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;
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 0.8rem 0.5rem;
        }

        .ag-benefits li {
            width: 100%;
            padding: 0.5rem 0.3rem;
            word-wrap: break-word;
            overflow-wrap: break-word;
            box-sizing: border-box;
            display: flex;
            align-items: flex-start;
            gap: 0.4rem;
            position: relative;
            padding-left: 0;
            font-size: 0.85rem;
        }

        .ag-benefits li i {
            color: var(--secondary);
            margin-top: 0.2rem;
            flex-shrink: 0;
            font-size: 0.75rem;
            position: static;
            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;
        }

        /* Hide differentiators grid on mobile */
        .ag-diff {
            display: none;
        }

        /* Hide detail panel on mobile */
        .diff-detail-panel {
            display: none;
        }

        .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 1fr;
            gap: 1rem;
            padding: 0 0.5rem;
        }

        .service-card {
            padding: 1.25rem 0.75rem;
        }

        .service-card h3 {
            font-size: 0.95rem;
        }

        .service-card p {
            font-size: 0.8rem;
        }

        .service-icon-container i {
            font-size: 2rem;
        }

        /* 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;
        }

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

    /* ===== SERVICES SECTION - MOBILE ===== */
    .services-section {
        padding: 3rem 0;
    }

    .services-header {
        margin-bottom: 3rem;
    }

    .header-badge {
        font-size: 0.75rem;
        padding: 0.4rem 1rem;
    }

    .services-title {
        font-size: 2rem;
    }

    .services-subtitle {
        font-size: 1rem;
        padding: 0 1rem;
    }

    .services-grid {
        grid-template-columns: repeat(2, 1fr); /* 2 columns on mobile */
        gap: 0.75rem; /* Tighter gap to allow boxes to expand */
    }

    .service-card {
        padding: 1.25rem 0.75rem; /* Reduced padding to use more width */
        min-height: auto;
    }

    .service-number {
        font-size: 2rem; /* Slightly smaller for compact 2-column layout */
        top: 1rem;
        right: 1rem;
    }

    .icon-wrapper {
        width: 50px; /* Smaller icon for 2-column layout */
        height: 50px;
    }

    .icon-wrapper svg {
        width: 25px; /* Proportionally smaller */
        height: 25px;
    }

    .service-title {
        font-size: 1.1rem; /* Slightly smaller for compact layout */
    }

    .service-description {
        display: none; /* Hide descriptions on mobile */
    }

    .services-cta {
        margin-top: 3rem;
    }

    .explore-btn {
        padding: 1rem 2rem;
        font-size: 1rem;
    }

    /* Hide dead code elements */
    .floating-shapes .shape,
    .service-hover-details {
        display: none !important;
    }

    /* ===== PORTFOLIO SECTION - MOBILE ===== */
    .portfolio-showcase,
    .portfolio-showcase-new {
        padding: 3rem 0;
    }

    /* NEW PORTFOLIO STYLES - fp-new components */
    .fp-new-container {
        flex-direction: column !important;
        padding: 1.5rem !important;
        max-height: none !important;
    }

    .fp-new-badge {
        bottom: 1rem !important;
        right: 1rem !important;
        top: auto !important;
        left: auto !important;
        padding: 0.4rem 0.8rem !important;
        font-size: 0.65rem !important;
        gap: 0.3rem !important;
        background: rgba(0, 0, 0, 0.85) !important;
        color: #00ffff !important;
        border: 2px solid #00ffff !important;
    }

    .fp-new-badge i {
        font-size: 0.75rem !important;
    }

    .fp-new-image-wrapper {
        width: 100% !important;
        max-width: 100% !important;
        margin-bottom: 1.5rem;
        position: relative !important;
        overflow: hidden !important;
        border-radius: 12px !important;
    }

    .fp-new-image {
        width: 100% !important;
        height: 200px !important;
        max-height: 200px !important;
        border-radius: 12px !important;
        object-fit: cover !important;
        object-position: center !important;
    }

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

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

    .fp-new-description {
        font-size: 0.9rem !important;
        line-height: 1.5 !important;
    }

    .fp-new-stats {
        display: none !important;
    }

    .fp-new-tech-stack {
        gap: 0.5rem !important;
        margin: 1rem 0 !important;
    }

    .fp-new-tech-badge {
        font-size: 0.75rem !important;
        padding: 0.3rem 0.6rem !important;
    }

    .fp-new-btn {
        width: 100% !important;
        text-align: center !important;
        padding: 0.8rem 1.5rem !important;
    }

    /* OLD PORTFOLIO STYLES - for backward compatibility */
    .featured-project {
        display: flex;
        flex-direction: column;
    }

    .fp-media {
        width: 100%;
        margin-bottom: 1.5rem;
        min-height: auto !important;
        height: auto !important;
        max-height: 220px !important;
    }

    .fp-media img {
        height: auto !important;
        max-height: 220px !important;
        object-fit: cover !important;
    }

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

    .fp-title {
        font-size: 1.5rem;
        margin-bottom: 0.8rem !important;
    }

    .fp-desc {
        font-size: 0.9rem !important;
        line-height: 1.5 !important;
    }

    /* Hide metrics on mobile */
    .fp-metrics {
        display: none;
    }

    /* Fix tags section */
    .fp-tags {
        gap: 0.5rem;
        margin: 1.5rem 0;
    }

    .fp-tags span {
        font-size: 0.8rem;
        padding: 0.3rem 0.6rem;
    }

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

    /* ===== TESTIMONIALS SECTION - MOBILE ===== */
    .testimonials-section {
        padding: 3rem 0;
    }

    .testimonial-content {
        padding: 1.5rem;
    }

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

    /* ===== CONTACT CTA SECTION - MOBILE ===== */
    .contact-cta {
        padding: 3rem 0;
    }

    .cta-card {
        padding: 1.5rem;
    }
}

/* Small phone screens - additional optimizations */
@media (max-width: 480px) {
    .hero {
        max-height: 75vh; /* Even more compact on small phones */
        --mobile-header-offset: 80px; /* Adjust for smaller header on tiny screens */
    }

    .hero-content h1 {
        font-size: 1.8rem; /* Smaller heading on small phones */
    }

    .hero-description {
        font-size: 0.9rem; /* Smaller description text */
    }
}
