/* V105.0.15 — Internal header/content clearance.
 * Paper headers used position:fixed, while only selected page wrappers carried
 * matching top padding. A missing/mismatched wrapper could leave content behind
 * the header. Keep the paper header sticky IN FLOW and remove the now-redundant
 * hardcoded offsets. Home + Properties photographic overlay headers are untouched.
 */

/* Internal paper header participates in layout; stays sticky on scroll. */
html body #site-header[data-header-mode="paper"] {
  position: sticky !important;
  top: 0 !important;
}

/* Respect the existing 'Keep header sticky' dashboard toggle. */
html body.shg-static-internal-header #site-header[data-header-mode="paper"] {
  position: relative !important;
  top: auto !important;
}

/* These page wrappers previously made up for an out-of-flow fixed header.
 * Sticky in-flow header now supplies exactly that height, so avoid doubling it.
 */
body:not(.home) .shg-about-page,
body:not(.home) .team-v16,
body:not(.home) .contact-page-v18,
body:not(.home) .journal-v16,
body:not(.home) .journal-single-v38,
body:not(.home) .shg-legal-page {
  padding-top: 0 !important;
}

/* The original single-property padding includes an old fixed-header allowance.
 * Retain its 38px editorial breathing room; the sticky header takes up 88px.
 */
body.single-property .detail-top {
  padding-top: 38px !important;
}

/* Fallback index/post archive: keeps the same effective distance as before. */
body .shg-generic-page {
  padding: 52px 0 100px !important;
}

/* Anchor links and editor section jumps must clear the sticky toolbar. */
html { scroll-padding-top: calc(var(--shg-header-h, 88px) + 18px); }
main section[id], main article [id], main [data-shg-section][id] {
  scroll-margin-top: calc(var(--shg-header-h, 88px) + 18px);
}

/* WordPress's logged-in toolbar remains above the theme header. */
body.admin-bar #site-header[data-header-mode="paper"] {
  top: 32px !important;
}
body.admin-bar main section[id], body.admin-bar main article [id] {
  scroll-margin-top: calc(var(--shg-header-h, 88px) + 50px);
}

@media (max-width: 820px) {
  /* Legacy mobile navigation sets overflow-y:auto on BODY, which creates a
   * non-scrolling ancestor and stops position:sticky from sticking. Keep the
   * root scroller, and use clip on body rather than hidden/auto. The menu-open
   * state deliberately stays under its existing independent handling. */
  html body:not(.shg-menu-open) {
    overflow-x: clip !important;
    overflow-y: visible !important;
  }
  body.single-property .detail-top { padding-top: 30px !important; }
  body .shg-generic-page { padding: 42px 0 80px !important; }
}
@media (max-width: 782px) {
  body.admin-bar #site-header[data-header-mode="paper"] { top: 46px !important; }
  body.admin-bar main section[id], body.admin-bar main article [id] {
    scroll-margin-top: calc(var(--shg-header-mobile-h, 74px) + 60px);
  }
}
