/* ============================================================
   mobile-fixes.css — MOBILE-ONLY SAFETY NET (≤780px)
   Loaded LAST on every customer-facing page. Every rule in this
   file lives inside @media (max-width: 780px), so desktop
   (>780px) styling is completely untouched.

   Goals: no horizontal page overflow, balanced 25.392px left/right
   gutters, and every heading, paragraph, nav item, button, form
   field, badge, project card, caption, and section fully inside
   the viewport with readable wrapping.
   ============================================================ */

@media (max-width: 780px) {

  /* --- 1. Kill horizontal page overflow --- */
  html,
  body {
    max-width: 100% !important;
    overflow-x: hidden !important;
  }

  /* --- 2. Nothing is wider than the screen --- */
  section,
  header,
  footer,
  nav,
  main,
  article,
  aside,
  div,
  figure,
  img,
  picture,
  video,
  iframe,
  embed,
  object,
  svg,
  canvas,
  table {
    max-width: 100%;
  }

  img,
  video {
    height: auto;
  }

  /* --- 3. Text wraps readably instead of clipping --- */
  h1, h2, h3, h4, h5, h6,
  p, li, blockquote, figcaption, dd, dt,
  label, span, strong, em, small, a,
  button, .btn {
    overflow-wrap: break-word !important;
    word-wrap: break-word !important;
  }

  /* Headings and long words may break anywhere rather than run off-screen */
  h1, h2, h3 {
    overflow-wrap: anywhere;
  }

  /* --- 4. Badges, chips, tags and pills wrap, never clip --- */
  [class*="badge"],
  [class*="chip"],
  [class*="tag"],
  [class*="pill"] {
    white-space: normal !important;
    max-width: 100% !important;
    overflow-wrap: break-word !important;
  }

  /* --- 5. Form fields fit the viewport --- */
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="search"],
  input[type="date"],
  input[type="number"],
  input:not([type]),
  select,
  textarea {
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  /* --- 6. Inline fixed widths can never push past the screen --- */
  [style*="width"] {
    max-width: 100% !important;
  }

  /* --- 7. Grid/flex children may shrink --- */
  .container > *,
  .hero-content > *,
  .page-hero-content > *,
  .cta-inner > *,
  [class*="grid"] > *,
  [class*="cards"] > *,
  [class*="row"] > * {
    min-width: 0 !important;
    max-width: 100% !important;
  }

  /* --- 8. Balanced 25.392px left/right gutters --- */
  .container,
  .section-inner,
  .areas-rich-inner,
  .cta-inner,
  .hero-content,
  .page-hero-content {
    padding-left: 25.392px !important;
    padding-right: 25.392px !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  /* A standalone hero form (not nested in hero content) also gets gutters */
  .hero-form:not(.hero-content *) {
    padding-left: 25.392px !important;
    padding-right: 25.392px !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  /* --- 9. Buttons, cards and nav stay inside the viewport --- */
  .btn,
  button,
  .project-card,
  [class*="card"],
  .navbar,
  .nav-container,
  .nav-links,
  .mobile-menu {
    max-width: 100% !important;
    min-width: 0 !important;
  }

  .btn,
  button {
    white-space: normal !important;
  }

  /* --- 10. Wide tables scroll inside their own box --- */
  table {
    display: block;
    width: 100%;
    overflow-x: auto;
  }
}

/* ============================================================
   390px PASS — ROOT-CAUSE GUTTER FIX + STRAGGLER COVERAGE
   The site sizes its content rail through two custom properties:
   --page-gutter and --skylit-gutter. On desktop they resolve to
   ~160-285px per side. Every rail rule in styles.css multiplies
   these variables, so redefining them to 25.392px here collapses ALL
   of them at once (containers, nav, heroes, footers, jump bars,
   service rails) — including selectors not listed by name above.
   ============================================================ */
@media (max-width: 780px) {
  /* Page-scoped gutter redefinitions (body.home-page, body.service-*-page,
     body.project-detail-page.<page>) use higher specificity than a plain
     "body" rule, so they previously kept their 63px desktop rail alive on
     phones. These selectors tie or beat every page-scoped definition, and
     this file loads last, so the 25.392px rail wins the cascade everywhere. */
  html body[class*="-page"],
  html body.project-detail-page[class] {
    --page-gutter: 25.392px;
    --skylit-gutter: 25.392px;
    --kit-gutter: 25.392px;
    --project-polish-gutter: 25.392px;
    --project-story-gutter: 25.392px;
    --bellevue-gutter: 25.392px;
    --bellevue-project-gutter: 25.392px;
    --kirkland-project-gutter: 25.392px;
    --bellevue-kitchen-gutter: 25.392px;
    --bellevue-bathroom-gutter: 25.392px;
    --bellevue-violet-gutter: 25.392px;
    --heated-floor-gutter: 25.392px;
    --issaquah-kitchen-gutter: 25.392px;
    --issaquah-bath-gutter: 25.392px;
    --kirkland-laundry-gutter: 25.392px;
    --kirkland-kitchen-gutter: 25.392px;
    --kirkland-openconcept-gutter: 25.392px;
    --kirkland-bath-gutter: 25.392px;
    --sammamish-bath-gutter: 25.392px;
    --snohomish-bath-gutter: 25.392px;
  }
  body {
    --page-gutter: 25.392px;
    --skylit-gutter: 25.392px;
  }

  /* Belt-and-braces: the exact rail containers named in the gutter audit
     (homepage hero, project heroes, project section containers incl. the
     gallery) forced onto the 25.392px rail at specificity above any
     page-inline rule. Internal card and form padding is not touched. */
  html body.home-page[class] .hero-content,
  html body.project-detail-page[class] :is(.project-hero-content, .kp-hero-content, .project-jump-inner, .kp-jump-inner),
  html body.project-detail-page[class] :is(.project-section, .kp-section, .project-cta, .kp-cta, .related-projects) > .container,
  html body.project-detail-page[class] :is(.project-breadcrumb, .kp-breadcrumb) > .container {
    padding-left: 25.392px !important;
    padding-right: 25.392px !important;
  }

  /* Named stragglers that earlier rail rules miss, forced to the
     same balanced 25.392px gutters. */
  body .footer-main,
  body .footer-bottom-inner,
  body .service-wide,
  body .nav-container,
  body .kp-hero-content,
  body .project-hero-content,
  body .kp-jump-inner,
  body .project-jump-inner {
    padding-left: 25.392px !important;
    padding-right: 25.392px !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  /* --- NORMALIZE: no nested double gutters ---
     The Before & After carousel is nested INSIDE the homepage
     .container, which already carries the 25.392px rail. It must not
     add its own 25.392px on top, or its visible margin becomes
     50.784px and its edges stop aligning with the rest of the page.
     Zeroing its side padding makes the container the single owner of
     the gutter (same as desktop, where the carousel has no side
     padding either). */
  body .ba-carousel {
    padding-left: 0 !important;
    padding-right: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  /* Trust badge band: the white band stays full-bleed, but the badge
     content inside it sits on the same 25.392px rail as every other
     section instead of touching the screen edges. */
  body .trust-bar-inner {
    padding-left: 25.392px !important;
    padding-right: 25.392px !important;
    box-sizing: border-box !important;
  }

  /* Negative side margins (e.g. the Before & After carousel header)
   may never push content past the screen edge on phones. */
  .ba-carousel-header {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  /* Hero text column and inline-styled min-widths can't force width */
  .hero-left {
    max-width: 100% !important;
  }
  [style*="min-width"] {
    min-width: 0 !important;
  }
  [style*="nowrap"] {
    white-space: normal !important;
  }

  /* Remaining container elements also fit the viewport */
  ul, ol, dl, form, fieldset, p, h1, h2, h3, h4, h5, h6,
  blockquote, .hscroll-wrap, .hscroll-gallery {
    max-width: 100%;
  }

  /* Featured Projects rail: the Touch Up rule for this container uses
     a higher-specificity padding; match it down to 25.392px on phones. */
  body.home-page .container.vo-touchup-191.vo-touchup-191,
  body.home-page .container {
    padding-left: 25.392px !important;
    padding-right: 25.392px !important;
  }
}
