/* ── Mobile & tablet responsive layer (loads last) ── */

html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

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

.container {
    width: 100%;
    max-width: 1200px;
    box-sizing: border-box;
}

/* Safe min tracks — never force horizontal overflow */
.services-grid,
.services-grid--two,
.content-grid,
.solutions-grid,
.faq-grid {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)) !important;
}

.services-grid--two {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)) !important;
}

/* ── Tablet and below (≤960px) ── */
@media (max-width: 960px) {
    .container {
        padding-left: 1.25rem !important;
        padding-right: 1.25rem !important;
    }

    /* Nav → hamburger earlier so links don't crush */
    .nav-links {
        position: fixed !important;
        top: 70px !important;
        left: 0 !important;
        right: 0 !important;
        background: rgba(15, 15, 20, 0.98) !important;
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        flex-direction: column !important;
        align-items: stretch !important;
        padding: 1.5rem !important;
        gap: 0.25rem !important;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        max-height: calc(100vh - 70px);
        overflow-y: auto;
        z-index: 999;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
        display: flex !important;
    }

    .nav-links.active {
        transform: translateX(0);
    }

    .nav-links li {
        width: 100%;
    }

    .nav-links a {
        display: block !important;
        width: 100%;
        padding: 0.9rem 0.5rem !important;
        white-space: normal !important;
    }

    .nav-links a:not(.nav-cta)::after {
        display: none !important;
    }

    .nav-links .nav-cta {
        margin-top: 0.5rem;
        text-align: center;
    }

    .mobile-menu-toggle {
        display: flex !important;
        z-index: 1000;
    }

    .logo-link {
        min-width: 0;
        max-width: calc(100vw - 5.5rem);
    }

    .logo-text {
        font-size: clamp(0.95rem, 3.2vw, 1.25rem) !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Grids → single column */
    .services-grid,
    .services-grid--two,
    .content-grid,
    .solutions-grid,
    .faq-grid,
    .process-strip__grid,
    .work-showcase__grid {
        grid-template-columns: 1fr !important;
        gap: 1.25rem !important;
    }

    .work-card--featured .work-card__link {
        grid-template-columns: 1fr !important;
    }

    .footer-content {
        grid-template-columns: 1fr !important;
        gap: 2rem !important;
    }

    .footer-links {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 1.5rem !important;
    }

    .trust-items {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 1rem !important;
    }

    .contact-layout {
        grid-template-columns: 1fr !important;
        gap: 2rem !important;
    }

    .process-strip__item,
    .service-card,
    .feature-block {
        padding: 1.5rem !important;
    }

    .cta-section {
        padding: 2.25rem 1.35rem !important;
    }

    .cta-buttons {
        flex-direction: column;
        align-items: stretch !important;
    }

    .cta-buttons .btn,
    .hero-cta .btn {
        width: 100%;
        text-align: center;
    }

    .work-showcase {
        padding: 3.5rem 0 !important;
    }

    .page-content,
    .services-section {
        padding: 3.25rem 0 !important;
    }

    .page-hero {
        padding: 6.5rem 0 2.75rem !important;
    }

    .section-intro {
        margin-bottom: 2.25rem !important;
    }

    .section-title--center {
        margin-bottom: 2rem !important;
    }
}

/* ── Phone (≤768px) ── */
@media (max-width: 768px) {
    .container {
        padding-left: 1.15rem !important;
        padding-right: 1.15rem !important;
    }

    .nav-content {
        gap: 0.75rem;
    }

    .logo-mark {
        width: 30px !important;
        height: 30px !important;
    }

    .section-title {
        font-size: clamp(1.5rem, 6vw, 2rem) !important;
        line-height: 1.2 !important;
    }

    .section-lead,
    .page-subtitle {
        font-size: 1rem !important;
        line-height: 1.65 !important;
    }

    .service-card,
    .feature-block,
    .content-card,
    .solution-card,
    .process-strip__item {
        padding: 1.35rem !important;
    }

    .faq-grid .feature-block {
        padding: 1.35rem !important;
    }

    .trust-item {
        padding: 1rem 0.5rem !important;
        text-align: center;
    }

    .trust-item strong {
        font-size: 1rem !important;
    }

    .trust-item span {
        font-size: 0.8125rem !important;
    }

    .process-strip__cta,
    .work-showcase__footer {
        text-align: center;
    }

    .process-strip__cta .btn,
    .work-showcase__footer .btn {
        width: 100%;
        max-width: 320px;
    }

    .why-section__content {
        max-width: 100% !important;
    }

    .cta-section h2 {
        font-size: clamp(1.35rem, 5vw, 1.85rem) !important;
    }

    .cta-section {
        padding: 2rem 1.15rem !important;
        border-radius: 12px !important;
    }

    .contact-form-large,
    .pricing-card {
        padding: 1.35rem !important;
    }

    .contact-form-large input,
    .contact-form-large textarea,
    .contact-form-large select,
    form input,
    form textarea,
    form select {
        font-size: 16px !important; /* prevent iOS zoom */
        max-width: 100%;
        box-sizing: border-box;
    }

    .page-hero {
        padding: 6rem 0 2.25rem !important;
    }

    .page-title {
        font-size: clamp(1.75rem, 7vw, 2.5rem) !important;
    }

    .footer {
        padding: 3rem 0 1.5rem !important;
    }

    .footer-legal {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.75rem !important;
    }

    .browser-frame__url {
        max-width: 55vw;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .popup-content {
        width: 94% !important;
        padding: 1.5rem !important;
        max-height: 90vh;
        overflow-y: auto;
    }

    /* Soften card hover lift on touch */
    .service-card:hover,
    .feature-block:hover,
    .work-card:hover,
    .content-card:hover {
        transform: none !important;
    }

    /* Avoid horizontal overflow from slide-in reveals */
    .flow-reveal--left,
    .flow-reveal--right {
        transform: translate3d(0, 24px, 0) !important;
    }

    .flow-reveal--left.is-visible,
    .flow-reveal--right.is-visible {
        transform: translate3d(0, 0, 0) !important;
    }
}

/* ── Small phones (≤480px) ── */
@media (max-width: 480px) {
    .container {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    .logo-text {
        font-size: 0.92rem !important;
        letter-spacing: -0.01em;
    }

    .trust-items {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }

    .trust-item {
        padding: 0.85rem 0 !important;
        border-bottom: 1px solid var(--border-color);
    }

    .trust-item:last-child {
        border-bottom: none;
    }

    .footer-links {
        grid-template-columns: 1fr !important;
        gap: 1.25rem !important;
    }

    .page-content,
    .services-section,
    .work-showcase {
        padding: 2.75rem 0 !important;
    }

    .page-hero {
        padding: 5.5rem 0 2rem !important;
    }

    .cta-section {
        padding: 1.75rem 1rem !important;
    }

    .btn {
        padding-left: 1.15rem !important;
        padding-right: 1.15rem !important;
    }

    .section-intro--left {
        max-width: 100% !important;
    }

    .hero-brand {
        font-size: 0.7rem !important;
        letter-spacing: 0.12em !important;
    }
}

/* Homepage hero mobile refinements */
@media (max-width: 960px) {
    section.hero-page > .container {
        padding-top: 6.75rem !important;
        padding-bottom: 2rem !important;
    }

    section.hero-page .hero-title {
        font-size: clamp(1.85rem, 7vw, 2.65rem) !important;
        line-height: 1.12 !important;
    }

    section.hero-page .hero-subtitle {
        font-size: 1rem !important;
        max-width: 100% !important;
    }

    .hero-page__visual {
        max-width: min(100%, 520px) !important;
        width: 100%;
        overflow: hidden;
    }

    .hero-mockup {
        transform: none !important;
        width: 100%;
    }

    .hero-mockup:hover {
        transform: none !important;
    }

    .hero-mockup img {
        width: 100%;
        height: auto;
    }
}

@media (max-width: 560px) {
    section.hero-page > .container {
        padding-top: 6rem !important;
        padding-bottom: 1.5rem !important;
    }

    .hero-page__metrics .hero-metrics,
    section.hero-page .hero-metrics {
        grid-template-columns: 1fr !important;
    }

    .hero-page__metrics .metric-item,
    section.hero-page .metric-item {
        border-right: none !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
        text-align: center !important;
        padding: 0.85rem 0 !important;
    }

    .hero-page__metrics .metric-item:last-child,
    section.hero-page .metric-item:last-child {
        border-bottom: none !important;
    }

    section.hero-page .hero-cta {
        flex-direction: column !important;
        width: 100%;
    }

    section.hero-page .hero-cta .btn {
        width: 100%;
    }
}

/* Process timeline / detail pages */
@media (max-width: 768px) {
    .process-timeline,
    .process-flow,
    .process-details {
        grid-template-columns: 1fr !important;
    }

    .process-content,
    .process-details .detail-card {
        padding: 1.25rem !important;
    }

    .pricing-grid,
    .solutions-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Touch: disable sticky hover transforms that feel laggy */
@media (hover: none) {
    .btn-primary:hover,
    .btn-secondary:hover {
        transform: none !important;
    }

    .work-card:hover .work-card__media img {
        transform: none !important;
    }
}
