@media (max-width: 1200px) {
    .container {
        width: min(1080px, 92vw);
    }
}

/* --- Tablet & mobile nav overlay adjustments --- */
@media (max-width: 1024px) {
    :root {
        --header-height: 60px;
        --nav-toggle-size: 40px;
    }

    .nav-outer {
        position: relative;
        top: auto;
        left: auto;
        right: auto;
        z-index: 2000;
        padding: 0.75rem 0;
        background: rgba(255, 255, 255, 0.8);
        backdrop-filter: blur(20px) saturate(180%);
        -webkit-backdrop-filter: blur(20px) saturate(180%);
        border-bottom: 1px solid rgba(0, 0, 0, 0.05);
        box-shadow: none;
    }

    /* Remove padding since header is not fixed */
    body {
        padding-top: 0;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    html {
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Adjust scroll margin since header is not fixed */
    :where(section, [id]) {
        scroll-margin-top: 1rem;
    }

    .nav-wrapper {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 1rem;
        padding: 0 1.25rem !important;
        height: var(--header-height) !important;
        min-height: var(--header-height) !important;
        max-height: var(--header-height) !important;
        background: transparent;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        border-radius: 0;
        margin: 0 !important;
        position: relative;
        transform: none !important;
        filter: none !important;
        perspective: none !important;
        will-change: auto !important;
        isolation: auto !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box;
    }





    
    /* Hamburger is fixed, so it's taken out of normal flow */
    /* The flex layout won't be affected by it */

    .nav-wrapper.container {
        width: 100% !important;
        max-width: 100% !important;
        margin-inline: 0 !important;
    }

    .brand {
        flex: 0 1 auto;
        display: flex;
        align-items: center;
        min-width: 0;
        max-width: 100%;
        margin: 0;
    }

    .brand img {
        width: clamp(160px, 42vw, 200px);
        height: auto;
        display: block;
        max-width: 100%;
    }

    .brand-text {
        line-height: 1;
    }

    .primary-nav {
        position: fixed;
        inset: 0;
        margin: 0;
        width: 100%;
        min-height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(20px) saturate(180%);
        -webkit-backdrop-filter: blur(20px) saturate(180%);
        border-radius: 0;
        padding: calc(var(--header-height) + 2rem) 1.5rem 2rem;
        box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.05);
        border: 0;
        flex-direction: column;
        align-items: flex-start;
        gap: 0;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transform: translateX(100%);
        transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 1500;
        display: flex !important;
        isolation: isolate;
    }

    /* Navigation is visible when opened */
    .primary-nav[data-open="true"] {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: translateX(0);
        z-index: 1500;
    }

    /* Navigation is hidden when closed */
    .primary-nav[data-open="false"] {
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transform: translateX(100%);
        z-index: -1;
    }

    .primary-nav ul {
        display: flex !important;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        width: 100%;
        flex: 0 0 auto;
        list-style: none;
        margin: 0;
        padding: 0;
        visibility: visible !important;
        opacity: 1 !important;
    }

    .primary-nav li {
        width: 100%;
        border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    }

    .primary-nav li:last-child {
        border-bottom: none;
    }

    .primary-nav .nav-link {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
        width: 100%;
        padding: 1.25rem 0;
        font-size: 1rem;
        letter-spacing: 0.02em;
        text-transform: uppercase;
        color: #1a1a1a;
        line-height: 1.5;
        font-weight: 500;
        border-radius: 0;
        border: none;
        background: transparent;
        box-shadow: none;
        font-family: "Inter", sans-serif;
        transition: color 0.2s ease;
        visibility: visible !important;
        opacity: 1 !important;
    }

    .primary-nav .nav-link:hover,
    .primary-nav .nav-link:focus-visible {
        color: #6b5bff;
        background: transparent;
        transform: none;
    }

    .primary-nav .nav-link::after {
        content: "";
        display: inline-block;
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: transparent;
        background-image: none;
        transition: background 0.2s ease;
    }

    .primary-nav .nav-link:hover::after,
    .primary-nav .nav-link:focus-visible::after {
        background: #6b5bff;
    }

    .primary-nav .nav-link--active {
        color: #6b5bff;
        font-weight: 600;
        border: none;
        background: transparent;
        box-shadow: none;
    }

    .primary-nav .nav-link--active::after {
        background: #6b5bff;
        background-image: none;
    }

    .primary-nav .btn {
        width: 100%;
        align-self: stretch;
        margin-top: 1.5rem;
        border-radius: var(--btn-radius);
        font-size: var(--btn-font-size);
        padding: var(--btn-padding-y) var(--btn-padding-x);
        min-height: 2.75rem;
        background: var(--clr-accent);
        color: #ffffff;
        border-color: transparent;
        box-shadow: 0 25px 40px rgba(107, 91, 255, 0.35);
        transition: background 0.2s ease, transform 0.2s ease;
    }

    .primary-nav .btn:hover,
    .primary-nav .btn:focus-visible {
        background: var(--clr-accent-dark);
        transform: translateY(-2px);
    }

    .primary-nav .nav-link::before {
        left: 0;
    }

    .mobile-only {
        display: none;
    }

    .primary-nav .mobile-only {
        display: inline-flex !important;
        width: 100%;
        justify-content: center;
        margin-top: 1.5rem;
        padding: var(--btn-padding-y) var(--btn-padding-x);
        min-height: 2.75rem;
        background: var(--clr-accent);
        color: #ffffff;
        border-color: transparent;
        font-weight: 600;
        font-size: var(--btn-font-size);
        border-radius: var(--btn-radius);
        box-shadow: 0 25px 40px rgba(107, 91, 255, 0.35);
        visibility: visible !important;
        opacity: 1 !important;
        transition: background 0.2s ease, transform 0.2s ease;
    }

    .primary-nav .mobile-only:hover,
    .primary-nav .mobile-only:focus-visible {
        background: var(--clr-accent-dark);
        color: #ffffff;
        transform: translateY(-2px);
        box-shadow: 0 25px 40px rgba(107, 91, 255, 0.35);
    }

    .desktop-only {
        display: none;
    }

    .nav-toggle {
        display: inline-flex !important;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        margin-left: auto;
        width: var(--nav-toggle-size);
        height: var(--nav-toggle-size);
        min-width: var(--nav-toggle-size);
        min-height: var(--nav-toggle-size);
        flex-shrink: 0;
        padding: 0;
        gap: 4px;
        background: transparent;
        border: none;
        border-radius: 0;
        position: relative !important;
        box-shadow: none;
        z-index: 2100 !important;
        transition: background 0.2s ease;
        transform: none !important;
        cursor: pointer;
        pointer-events: auto;
    }

    .nav-toggle:hover,
    .nav-toggle:focus-visible {
        background: transparent;
        border: none;
        box-shadow: none;
    }

    .nav-toggle span {
        display: block;
        width: 22px;
        height: 2px;
        margin: 0;
        background: #1a1a1a;
        border-radius: 0;
        transition: transform 0.3s ease, opacity 0.3s ease, background 0.3s ease;
        transform-origin: center;
        box-shadow: none;
    }







    /* Keep header size consistent when nav is open - no size changes */
    body.nav-open .nav-wrapper {
        align-items: center !important;
        height: var(--header-height) !important;
        min-height: var(--header-height) !important;
        max-height: var(--header-height) !important;
        padding: 0 1.25rem !important;
    }

    body.nav-open .nav-outer {
        padding: 0.75rem 0 !important;
        height: auto !important;
        min-height: auto !important;
    }

    body.nav-open .brand {
        position: relative;
        top: auto;
        left: auto;
        z-index: auto;
        flex: 0 1 auto !important;
        max-width: 100% !important;
    }

    /* Keep logo size exactly the same when nav is open */
    body.nav-open .brand img {
        width: clamp(160px, 42vw, 200px) !important;
        max-width: 100% !important;
        height: auto !important;
        display: block !important;
    }

    /* Keep hamburger fixed even when menu is open */
    .nav-toggle[aria-expanded="true"],
    body.nav-open .nav-toggle {
        background: transparent;
        border: none;
        box-shadow: none;
    }

    body.nav-open .nav-toggle span {
        background: #1a1a1a;
        height: 2px;
    }

    .nav-toggle[aria-expanded="true"] span:nth-child(1),
    body.nav-open .nav-toggle span:nth-child(1) {
        transform: translateY(6px) rotate(45deg);
    }

    .nav-toggle[aria-expanded="true"] span:nth-child(2),
    body.nav-open .nav-toggle span:nth-child(2) {
        opacity: 0;
        transform: scaleX(0.4);
    }

    .nav-toggle[aria-expanded="true"] span:nth-child(3),
    body.nav-open .nav-toggle span:nth-child(3) {
        transform: translateY(-6px) rotate(-45deg);
    }

    /* Prevent scrolling of body when nav is open */
    body.nav-open {
        overflow: hidden !important;
        position: fixed !important;
        width: 100% !important;
        top: 0;
        left: 0;
        right: 0;
    }

    body.nav-open .hero,
    body.nav-open main {
        pointer-events: none;
        filter: none;
        transition: none;
    }
    
    /* Ensure mobile menu can scroll smoothly */
    .primary-nav[data-open="true"] {
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
    
    /* Ensure body scrolls normally when menu is closed */
    body:not(.nav-open) {
        overflow-x: hidden !important;
        overflow-y: auto !important;
        position: relative !important;
        height: auto !important;
        width: 100% !important;
        -webkit-overflow-scrolling: touch;
    }

    .hero_content,
    .problem_grid,
    .services_grid,
    .why_grid,
    .process_steps,
    .portfolio_list,
    .testimonial-grid,
    .pricing_grid,
    .contact_grid,
    .trust_grid,
    .footer_grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .services_grid {
        gap: 1.25rem;
    }

    .process_steps {
        gap: 1.25rem;
    }

    .project-card {
        padding: 2.25rem;
    }

    .option-grid,
    .option-grid--compact {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .hero_content,
    .problem_grid,
    .why_grid,
    .process_steps,
    .portfolio_list,
    .pricing_grid,
    .contact_grid,
    .trust_grid,
    .services_preview-grid,
    .portfolio_grid,
    .footer_grid {
        grid-template-columns: 1fr;
    }

    .services_preview-list,
    .project-metrics {
        grid-template-columns: 1fr;
    }

    .hero_text,
    .section_intro {
        text-align: center;
    }

    .hero_text h1 {
        max-width: 22ch;
        margin-inline: auto;
    }

    .hero_cta,
    .cta_actions,
    .page-hero_cta {
        justify-content: center;
    }

    .hero_pillars {
        text-align: left;
    }

    .hero_visual {
        margin-inline: auto;
    }

    .services_grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .project-card {
        padding: 2rem;
    }

    .option-grid,
    .option-grid--compact {
        grid-template-columns: 1fr;
    }

    .pricing-card--featured {
        order: -1;
    }
}

/* --- Tablet tweaks: tighter header + larger logo --- */
@media (max-width: 768px) {
    :root {
        --header-height: 60px;
    }

    .section {
        padding: 4rem 0;
    }

    .hero {
        padding-top: 3rem;
        padding-bottom: 3.5rem;
    }

    .hero_text h1 {
        max-width: none;
    }

    .nav-wrapper {
        gap: 0.75rem;
        padding: 0 16px;
        height: var(--header-height) !important;
        min-height: var(--header-height) !important;
        max-height: var(--header-height) !important;
    }

    .services_grid {
        grid-template-columns: 1fr;
    }

    .project-card {
        padding: 1.75rem;
    }

    .testimonial-grid {
        grid-template-columns: 1fr;
    }

    .pricing_grid {
        grid-template-columns: 1fr;
    }

    .cta_content {
        padding: 2.5rem 1.5rem;
    }

    .contact_intro,
    .contact_form {
        padding: 1.75rem 1.5rem;
    }

    .intake-form {
        padding: 2.25rem;
    }

    .intake-form fieldset {
        padding: 1.25rem;
    }

    .footer_grid {
        gap: 2rem;
    }

    .footer_form {
        flex-direction: column;
        align-items: stretch;
    }
}

/* --- Small phone tweaks: constrain container + header --- */
@media (max-width: 640px) {
    :root {
        --header-height: 60px;
        --btn-font-size: 0.95rem;
    }
    .container {
        width: 100%;
        padding-inline: 1.25rem;
    }

    .nav-wrapper {
        padding: 0 1.25rem !important;
        height: var(--header-height);
        min-height: var(--header-height);
        gap: 0.75rem;
    }

    .brand {
        max-width: 100%;
    }

    .nav-toggle {
        width: var(--nav-toggle-size) !important;
        height: var(--nav-toggle-size) !important;
        min-width: var(--nav-toggle-size) !important;
        min-height: var(--nav-toggle-size) !important;
    }

    .page-hero {
        text-align: center;
    }

    .hero_cta,
    .page-hero_cta,
    .cta_actions {
        flex-direction: column;
        align-items: center;
        gap: 0.75rem;
    }

    .hero {
        margin-top: 0;
        padding-top: 2.5rem;
        padding-bottom: 3rem;
    }

    .btn {
        white-space: normal;
        line-height: 1.4;
        padding: var(--btn-padding-y) var(--btn-padding-x);
        min-height: 2.75rem;
    }

    .hero_cta .btn,
    .page-hero_cta .btn,
    .cta_actions .btn {
        white-space: normal;
        line-height: 1.35;
        width: 100%;
        min-width: 0;
        max-width: 100%;
        padding: var(--btn-padding-y) var(--btn-padding-x);
        min-height: 2.75rem;
    }

    .hero_text h1 {
        font-size: clamp(1.9rem, 7.5vw, 2.4rem);
        letter-spacing: -0.02em;
    }

    .hero_text .lead {
        font-size: 1rem;
    }

    .hero_pillars {
        grid-template-columns: 1fr;
        text-align: left;
    }

    .problem h2,
    .cta_content h2 {
        font-size: clamp(1.5rem, 6.5vw, 1.9rem);
    }

    .problem p,
    .problem li,
    .cta_content p {
        font-size: 0.98rem;
    }

    .nav-wrapper {
        border-bottom-color: transparent;
        height: var(--header-height) !important;
        min-height: var(--header-height) !important;
        max-height: var(--header-height) !important;
    }

    .nav-outer {
        padding: 0.75rem 0;
        background: rgba(255, 255, 255, 0.75);
        backdrop-filter: blur(20px) saturate(180%);
        -webkit-backdrop-filter: blur(20px) saturate(180%);
        height: auto !important;
        min-height: auto !important;
    }

    .contact_form .btn {
        width: 100%;
    }

    .contact_form-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .service-stack_cta,
    .services_extra-cta {
        flex-direction: column;
        align-items: stretch;
    }

    .service-stack_cta .btn,
    .services_extra-cta .btn {
        width: 100%;
    }

    .project-card_footer .btn {
        width: 100%;
    }

    .contact_intro {
        padding: 1.75rem 1.5rem;
        text-align: center;
    }

    .contact_form {
        padding: 1.75rem 1.5rem;
        border-radius: 18px;
        gap: 1.15rem;
    }

    .contact_list {
        font-size: 1rem;
        text-align: center;
    }

    .services_extras ul {
        flex-direction: column;
        gap: 1rem;
    }

    .pricing_addons ul {
        gap: 1rem;
    }

    .footer_grid {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .footer_brand {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-align: center;
    }

    .footer_brand .brand--footer {
        display: block;
        width: fit-content;
        margin: 0 auto;
        text-align: center;
    }

    .footer_brand .brand--footer img {
        display: block;
        margin: 0 auto;
    }

    .footer_links {
        text-align: center;
        position: relative;
    }

    .footer_links ul {
        justify-items: center;
    }

    .footer_contact .btn {
        justify-self: center;
    }

    /* Ensure footer is always accessible and not blocked by header */
    .site-footer {
        position: relative;
        z-index: 1;
        isolation: isolate;
    }

    /* Footer links are always clickable and independent of header nav */
    .site-footer a,
    .footer_links a,
    .footer_contact a,
    .footer_bottom a {
        position: relative;
        z-index: 100;
        pointer-events: auto;
        cursor: pointer;
    }

    .intake-form {
        padding: 2rem;
        border-radius: 20px;
    }

    .input-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .intake-form fieldset {
        padding: 1rem 1.1rem;
        border-radius: 16px;
        gap: 1rem;
    }

    .checkbox,
    .radio {
        padding: 0.8rem 0.9rem;
        align-items: flex-start;
    }

    .trust_list li {
        text-align: center;
    }
}

@media (max-width: 480px) {
    .intake-form {
        padding: 1.6rem;
        gap: 1.75rem;
        box-shadow: 0 24px 48px rgba(23, 38, 83, 0.12);
    }

    .intake-form fieldset {
        padding: 0.95rem 1rem;
    }

    .intake-form legend {
        letter-spacing: 0.08em;
        font-size: 0.76rem;
    }

    .checkbox,
    .radio {
        font-size: 0.95rem;
        line-height: 1.4;
    }

    .intake-form input,
    .intake-form textarea,
    .intake-form select {
        font-size: 1rem;
        padding: 0.8rem 0.95rem;
    }

    .intake-form textarea {
        min-height: 120px;
    }
}

@media (max-width: 540px) {
    .primary-nav {
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        border-radius: 0;
        padding: calc(var(--header-height) + 1.25rem) 1.25rem 2rem;
    }

    .primary-nav ul {
        width: 100%;
    }

    .primary-nav .nav-link {
        padding: 1.25rem 0;
    }

    .primary-nav .btn,
    .primary-nav .mobile-only {
        width: 100%;
    }

    .hero_pillars {
        grid-template-columns: 1fr;
    }

    .contact_form .full {
        grid-column: 1;
    }
}
