/* Outer content rhythm only. 767px is the converted site's existing mobile breakpoint.
   Unlayered !important longhands beat Elementor's global/local classes (including
   their 640–767px custom CSS) without replacing horizontal gutters or desktop styles. */
@media (max-width:767px) {
  :root { --lmc-mobile-section-space:24px; }

  /* Page scaffolding must not add a second inset, gap or viewport-height floor.
     The sticky header stays in normal flow; existing scroll-margin offsets remain. */
  :root:root .elementor #root > .box-2,
  :root:root .elementor main#main-content {
    min-height:0 !important;
    height:auto !important;
    margin-block:0 !important;
    padding-block:0 !important;
  }
  :root:root .elementor #root > .box-2,
  :root:root .elementor main#main-content:has(> :is(section,div,article)) {
    row-gap:0 !important;
  }

  /* Section classification: direct content children of main, not every nested
     <section>. Includes div-based article/brand/legal frames and case-study articles.
     The 404 template has no section wrapper, so main itself owns its outer inset.
     Footer CTA, information and legal bands share this baseline, not their shell. */
  :root:root .elementor main#main-content > :is(section,div,article),
  :root:root .elementor main#main-content:has(> h1),
  :root:root .elementor main#main-content:has(> section .lmc-calc),
  :root:root .elementor footer :is(.box-153,.box-159,.box-183,.box-167),
  :root:root .elementor footer > .box-297,
  :root:root .elementor main#main-content > article.box-202 > div:has(> div > section) {
    padding-block:var(--lmc-mobile-section-space) !important;
    margin-block:0 !important;
    min-height:0 !important;
    height:auto !important;
  }

  /* Full-width inset/gutter shells, never cards: single-child content frames,
     hero heading/content wrappers, shared hero/CTA frames, and the
     brand page's div > section variant. Move their vertical inset to the parent
     boundary once. Keep grid gaps, title spacing, form fields and horizontal insets.
     Calculator's header/body/tray are sheet internals, not hero wrappers. */
  :root:root .elementor main#main-content > section > div:only-child:not(.lmc-internal-inset),
  :root:root .elementor main#main-content > section:first-child:has(h1):not(:has(> header)) > div:has(h1):not(.lmc-internal-inset),
  :root:root .elementor main#main-content > section > :is(.box-196,.box-247,.box-387,.box-213):not(.lmc-internal-inset),
  :root:root .elementor main#main-content > .box-339 > section {
    padding-block:0 !important;
    margin-block:0 !important;
    min-height:0 !important;
  }

  /* A hero can contain a separate bordered checklist/benefits strip. Its
     padding is internal divider clearance, not duplicate outer section padding.
     Keep the authored strip padding, and leave space above its divider when
     the preceding heading/content frame ends with the contact card. */
  :root:root .elementor main#main-content > section:first-child:has(h1):not(:has(> header)) > div:has(h1):not(:last-child) {
    margin-block-end:24px !important;
  }

  /* Navy Frame is a rounded sheet, despite its <section> tag. Its main owns
     the 24px exterior; the sheet's header, form and explanatory tray keep their
     original internal padding, including validation/confirmation states. */
  :root:root .elementor main#main-content > section:has(.lmc-calc) {
    padding-block:0 !important;
  }

  /* Reset only the outward-facing margins of known gutter/heading wrappers.
     Do not touch heading-to-content margins, carousel shadow/snap clearance,
     card padding, Gravity Forms, or the legal article's inset paper card. */
  :root:root .elementor main#main-content > section > :is(.box-32,.box-349):first-child,
  :root:root .elementor main#main-content > :is(section,div,article) > :is(h1,h2,h3,p):first-child {
    margin-block-start:0 !important;
  }
  :root:root .elementor main#main-content > :is(section,div,article) > :is(h1,h2,h3,p):last-child {
    margin-block-end:0 !important;
  }

  /* These headings inherited 64px tablet margins on phones.
     Reviews have no top inset on the following grid; process steps already
     have 16px of carousel/grid clearance. Both now total 24px before content.
     Keep that clearance, card spacing and all desktop/tablet margins intact. */
  :root:root .elementor .box-112 {
    margin-block-end:24px !important;
  }
  :root:root .elementor :is(.box-84,.box-424) {
    margin-block-end:8px !important;
  }

  /* Explicit section-boundary spacers only; nested/editorial spacers are untouched. */
  :root:root .elementor main#main-content > .elementor-widget-spacer,
  :root:root .elementor main#main-content > section > .elementor-widget-spacer {
    display:none !important;
  }

  /* The footer shell contains independent bands plus absolutely positioned glow
     and wordmark artwork. Do not inset, resize or clip that decorative artwork. */
  :root:root .elementor footer:is(.box-151,.box-176,.box-296),
  :root:root .elementor footer > :is(.box-45,.box-75) {
    padding-block:0 !important;
    margin-block:0 !important;
    row-gap:0 !important;
    min-height:0 !important;
  }

  /* Compact footer navigation: remove the extra 6px between already-44px
     link targets, shorten heading clearance, and reduce the large group gap.
     Header navigation and desktop footer spacing are deliberately untouched. */
  :root:root .elementor footer :is(.box-159,.box-183) {
    row-gap:24px !important;
  }
  :root:root .elementor footer :is(.box-159,.box-183) h2 {
    margin-block-end:12px !important;
  }
  :root:root .elementor footer nav ul.menu li {
    margin-block:0 !important;
  }
}
