/* Global mobile hardening layer (375px / 390px) */
html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden !important;
}

* {
  box-sizing: border-box;
}

:where(main, section, article, div, ul, li, p, h1, h2, h3, h4, h5, h6, a, button, input, textarea) {
  min-width: 0;
}

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

:where(table) {
  display: block;
  max-width: 100%;
  overflow-x: auto;
}

/* Desktop default safety for injected mobile nav elements */
.nav-burger {
  display: none !important;
}

.nav-mobile {
  display: none !important;
}

@media (max-width: 900px) {
  /* NAV */
  .nav {
    top: 0 !important;
    padding: 12px 20px !important;
    min-height: 58px !important;
    gap: 10px !important;
  }

  .nav-logo img {
    height: 21px !important;
    width: auto !important;
  }

  .mega-nav,
  .mega-panel,
  .mega-overlay {
    display: none !important;
  }

  .nav-right {
    display: flex !important;
    align-items: center !important;
    margin-left: auto !important;
    gap: 8px !important;
  }

  .nav-cta {
    min-height: 36px !important;
    padding: 0 11px !important;
    font-size: 10px !important;
    letter-spacing: .01em !important;
    white-space: nowrap !important;
  }

  .nav-burger {
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    gap: 4px !important;
    padding: 6px !important;
    margin-left: 2px !important;
    cursor: pointer !important;
    background: transparent !important;
    border: 0 !important;
  }

  .nav-burger span {
    width: 20px !important;
    height: 1px !important;
    background: currentColor !important;
    opacity: .85 !important;
    display: block !important;
  }

  .nav.navbar-dark .nav-burger {
    color: #fff !important;
  }

  .nav:not(.navbar-dark) .nav-burger {
    color: #111 !important;
  }

  .nav-mobile {
    position: fixed !important;
    inset: 0 !important;
    z-index: 1200 !important;
    background: #0a0a0a !important;
    display: none !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 0 !important;
    padding: 24px !important;
  }

  .nav-mobile.open {
    display: flex !important;
  }

  .nav-mobile .mob-l {
    width: min(320px, 100%) !important;
    padding: 14px 0 !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
    text-align: center !important;
    color: rgba(255, 255, 255, 0.9) !important;
    font-size: 20px !important;
    line-height: 1.2 !important;
  }

  .nav-mobile .mob-cta {
    margin-top: 16px !important;
    width: min(320px, 100%) !important;
    min-height: 48px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 999px !important;
    padding: 0 16px !important;
  }

  body.mobile-nav-open {
    overflow: hidden !important;
  }

  /* Global horizontal safety */
  :where(#site, main, section, .section, .wrap, .hero-inner, .hero-header, .cases-wrap, .page-shell, .ccm-inner, .ccm-chap, .ccm-pilot-wrap, .hero-head, .hero-b2b-inner) {
    max-width: 100% !important;
  }

  :where([class*="track-wrap"], [class*="logo-wrap"], [class*="ticker-wrap"]) {
    overflow: hidden !important;
    max-width: 100% !important;
  }

  :where([class*="track"], [class*="ticker"]) {
    max-width: 100vw !important;
  }

  /* Paddings mobile: minimum 20px */
  :where(.wrap, .hero-inner, .hero-header, .cases-wrap, .page-shell, .ccm-inner, .ccm-chap, .ccm-pilot-wrap, .hero-head, .hero-b2b-inner) {
    padding-left: 20px !important;
    padding-right: 20px !important;
  }

  /* HERO */
  :where(.hero, .hero-sec, .ccm-hero, .hero-b2b, .detail-hero) {
    padding-top: 108px !important;
  }

  :where(.hero-h1, .hero-title, .hero-headline, .detail-title, .svc-headline, .ccm-hero-h1, .ia-hero-title) {
    font-size: clamp(28px, 9vw, 36px) !important;
    line-height: 1.12 !important;
  }

  :where(.hero-sub, .hero-subtext, .hero-subline, .hero-subtitle, .svc-subtext, .detail-sub, .ccm-hero-sub, .ia-hero-sub, .detail-exp) {
    font-size: 16px !important;
    line-height: 1.6 !important;
  }

  :where(.hero-ctas, .ccm-cta-btns, .hero-actions, .hero-buttons) {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
  }

  :where(.hero-ctas a, .hero-ctas button, .ccm-cta-btns a, .ccm-cta-btns button, .hero-actions a, .hero-actions button, .hero-buttons a, .hero-buttons button) {
    width: 100% !important;
    justify-content: center !important;
  }

  /* Logos strip */
  :where(.logos-track img, .prefooter-logos-track img, .ccm-client-logos-track img) {
    height: 24px !important;
    width: auto !important;
    margin: 0 18px !important;
  }

  /* Prospect Experience / philosophy cards */
  :where(.prospect-grid, .prospect-cards, .philo-grid, .pillars-grid) {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  :where(.prospect-card, .philo-card, .pillar-card) {
    padding: 24px !important;
  }

  /* Comment ça marche / steps */
  :where(.steps-grid, .process-grid, .timeline, .ccm-chap-inner, .ccm-pilot-shell, .ccm-pilot-rdv-grid, .ccm-pilot-calendar-grid) {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  :where(.timeline-step, .step-card, .process-step, .ccm-phase) {
    padding: 20px !important;
  }

  :where(.timeline-step-head, .step-head, .process-head) {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 8px !important;
  }

  /* Offer carousel / horizontal cards */
  :where(.carousel-track, .svc-carousel-track, .cards-track, .team-grid) {
    -webkit-overflow-scrolling: touch;
  }

  :where(.carousel-card, .offer-card, .team-card) {
    min-width: 85vw !important;
  }

  :where(.team-nav-btn, .carousel-nav, .carousel-progress, .carousel-arrows) {
    display: inline-flex !important;
  }

  /* Dashboard */
  :where(.dashboard-grid, .ccm-pilot-shell, .ccm-pilot-rdv-grid, .ccm-pilot-calendar-grid, .ia-process-grid) {
    grid-template-columns: 1fr !important;
  }

  :where(.ccm-pilot-dashboard, .dashboard, .dashboard-card) {
    max-width: 100% !important;
    overflow: hidden !important;
  }

  :where(.ccm-pilot-donut-wrap, .ccm-pilot-donut-svg) {
    width: 88px !important;
    height: 88px !important;
  }

  /* Team orbital fallback */
  :where(.orbit-wrap, .team-orbit, .orbit-stage, .orbit-rings, .orbit-ring, .orbit-line) {
    display: none !important;
  }

  /* Remove team sections on mobile */
  :where(.team-sec, .section-team, #equipe) {
    display: none !important;
  }

  :where(.team-grid) {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
    max-width: 100% !important;
  }

  :where(.team-card) {
    min-width: 0 !important;
    padding: 24px !important;
  }

  /* Testimonials */
  :where(.testi-grid, .testi-masonry, .testimonials-grid, .cases-grid) {
    grid-template-columns: 1fr !important;
  }

  :where(.testi-card, .testimonial-card, .case-card) {
    width: 100% !important;
    min-width: 0 !important;
  }

  /* FAQ */
  :where(.faq-grid, .faq-list, .accordion-list) {
    grid-template-columns: 1fr !important;
    width: 100% !important;
  }

  :where(.faq-item, .accordion-item) {
    width: 100% !important;
  }

  /* Contact form */
  :where(.contact-wrap, .contact-grid, .contact-sec .wrap, .contact-form, .modal-form) {
    width: 100% !important;
    max-width: 100% !important;
  }

  :where(input, select, textarea, button, .modal-inp) {
    min-height: 48px !important;
  }

  textarea,
  .modal-textarea {
    min-height: 120px !important;
  }

  :where(.contact-form button, .contact-form .btn, .modal-submit, .contact-sec .btn-dark) {
    width: 100% !important;
    justify-content: center !important;
  }

  /* Footer */
  :where(.footer-top) {
    grid-template-columns: 1fr !important;
    gap: 22px !important;
    text-align: center !important;
  }

  :where(.footer-brand, .footer-col) {
    align-items: center !important;
  }

  :where(.footer-copy) {
    max-width: 100% !important;
  }

  :where(.footer-bottom) {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    text-align: center !important;
    gap: 12px !important;
  }

  /* Offer / case pages common grids */
  :where(.problem-grid, .compare-grid, .metrics-grid, .included-grid, .deliver-grid, .account-grid, .kpi-grid, .focus-panel, .phone-grid, .team-grid) {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  :where(.timeline)::before,
  :where(.timeline-line) {
    display: none !important;
  }
}

@media (max-width: 420px) {
  .nav {
    min-height: 56px !important;
  }

  .nav-cta {
    font-size: 9.5px !important;
    padding: 0 10px !important;
  }

  :where(.hero, .hero-sec, .ccm-hero, .hero-b2b, .detail-hero) {
    padding-top: 102px !important;
  }

  :where(.hero-h1, .hero-title, .hero-headline, .detail-title, .svc-headline, .ccm-hero-h1, .ia-hero-title) {
    font-size: clamp(27px, 9.5vw, 34px) !important;
  }
}
