/* Elev8 responsive retrofit.
   The site's pages are a fixed 1180px-wide desktop canvas built entirely with
   inline style="" attributes (a design-comp export). Some pages (the <x-dc>
   ones) are hydrated client-side by a React-based runtime, which RE-SERIALIZES
   every inline style attribute when it renders: "position:absolute" becomes
   "position: absolute", "repeat(3,1fr)" becomes "repeat(3, 1fr)", hex colors
   become rgb(). Plain (non-hydrated) pages keep the original unspaced text.
   Every [style*="..."] selector below is therefore written to match a
   substring that is IDENTICAL in both forms: either the property name up to
   and including its colon (nothing is ever inserted BEFORE a colon, so
   "prop:" matches "prop:value" and "prop: value" alike), or a value fragment
   with no colon/comma in it, or -- where a value itself would need to survive
   comma-normalization -- a structural :has() selector instead of style text.
   Inline styles beat any selector-based CSS rule regardless of specificity,
   so every rule uses !important deliberately. */

/* overflow-x:hidden on <html> makes it its own scroll container, which
   Chromium then clips to the viewport height instead of growing to fit
   body's real content -- verified live (scrollHeight got stuck at exactly
   window.innerHeight). height:auto fixes it: html still clips horizontally
   but stops capping its own vertical extent.
   Deliberately NOT also set on <body>: overflow-x:hidden on body makes body
   itself the sticky-positioning containing block, which broke every
   `position:sticky` header sitewide (they stopped sticking, scrolling away
   with the page instead) -- verified live. html's rule alone already
   prevents all horizontal overflow; the body rule was redundant. */
html {
  overflow-x: hidden !important;
  height: auto !important;
  max-width: 100vw !important;
}

@media (max-width: 860px) {

  /* 1. Load-bearing fix: stop forcing a fixed-width canvas on every page
     body. Value-only match (no colon), safe under normalization. Most pages
     use 1180px; the legal pages (privacy/terms) use a narrower 900px. */
  [style*="1180px"],
  [style*="900px"] {
    min-width: 0 !important;
    width: 100% !important;
  }

  /* 2. Section/header/footer gutters and vertical rhythm, compacted for a phone */
  header, footer, section, div:has(> nav) {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }
  section { padding-top: 40px !important; padding-bottom: 40px !important; }
  header { padding-top: 12px !important; padding-bottom: 12px !important; }
  footer { padding-top: 28px !important; padding-bottom: 28px !important; }

  /* 3. Collapse every multi-column grid used site-wide to one column.
     Property-prefix match only (the colon is never separated from the
     property name by normalization) -- no need to enumerate every value. */
  [style*="grid-template-columns:"] {
    /* minmax(0, 1fr), not bare 1fr -- a bare 1fr track still grows to fit
       a cell's intrinsic min-content width (e.g. a table inside), blowing
       past the container regardless of "1 column" -- verified live. */
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 28px !important;
  }

  /* 4. Kill full-bleed decorative hero photography -- at this width it either
     vanishes behind the text or crushes it. Structural match (a div whose
     direct child is the parallax hero photo) instead of style text, since
     the wrapper's style spans several colons/semicolons that normalization
     would otherwise break. */
  div:has(> img[data-plx]) {
    display: none !important;
  }

  /* 5. Hide the giant faded "8" / quote-mark watermark numerals.
     Value-only match ("-webkit-text-stroke:" prefix is colon-safe). */
  [style*="-webkit-text-stroke:"] {
    display: none !important;
  }

  /* 6. Footer: stack the brand block above the link row instead of side by side */
  footer[style*="justify-content:"] {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 20px !important;
  }

  /* 7. Nav: hover-only dropdowns don't exist on touch. Hide the submenus and
     flatten the top-level links into a scrollable row instead of a half-dead
     menu. Applies to every <nav>, not just ones inside <header> -- the
     homepage's above-the-fold nav sits in a plain <div>. min-width:0 is
     required or the flex item refuses to shrink below its content's
     intrinsic width and overflow-x:auto never engages. */
  nav {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap !important;
    flex-wrap: nowrap !important;
    gap: 14px !important;
    min-width: 0 !important;
    flex: 1 1 auto !important;
  }
  [data-panel] { display: none !important; }
  nav span[aria-hidden="true"] { display: none !important; } /* dropdown chevrons */

  /* 8. position:sticky inside content sections (stacked service cards, split
     CFO column) causes overlap once the grid above collapses to one column.
     "sticky" alone, no colon, survives normalization. */
  section [style*="sticky"] {
    position: static !important;
  }

  /* 9. Desktop type scale is tuned for a 1180px canvas -- cap it down.
     Plain tag selectors, unaffected by style-attribute normalization. */
  h1 { font-size: 32px !important; line-height: 1.18 !important; letter-spacing: -0.3px !important; }
  h2 { font-size: 26px !important; line-height: 1.22 !important; letter-spacing: -0.2px !important; }
  h3 { font-size: 19px !important; }

  /* 10. Negative-margin "broken grid" bleed effect (the About section's
     founder photo) overflows its column at this width. */
  [style*="-60px"] { margin: 0 0 24px 0 !important; }

  /* 11a. Form fields set flex:1 side by side (e.g. Name/Email). flex-basis:0
     still respects each input's intrinsic min-content width by default,
     which is wide enough for two of them to overflow a phone screen. */
  input, textarea, select {
    min-width: 0 !important;
  }
  div:has(> input + input) {
    flex-wrap: wrap !important;
  }

  /* 11. CTA rows (2+ pill buttons side by side) need to wrap instead of
     running off-screen. Structural match (div with 2+ adjacent <a> children)
     instead of style text, since button styling includes hex colors that
     normalize to rgb() and commas that get respaced. */
  div:has(> a + a) {
    flex-wrap: wrap !important;
  }

  /* 12. Tables wide enough to need their own scroll (comparison tables,
     tax-bracket tables with wide numeric columns) are wrapped in the HTML
     itself with <div style="overflow-x:auto;">. table{display:block;
     overflow-x:auto} alone was tried and dropped: a table's own minimum
     content width (driven by unbreakable cell text) can exceed max-width:100%
     -- verified live, it still overflowed its box. A plain div wrapper
     doesn't have that table-sizing quirk and reliably clips/scrolls. */
}
