/* =========================================================
   Montenegro Listings Theme v3.0.5
   TOC placement + anchor scroll correction
   ========================================================= */

:root {
  --ml-toc-anchor-offset: var(--ml-floating-top-offset, 120px);
}

html {
  scroll-padding-top: var(--ml-toc-anchor-offset) !important;
}

body:not(.wp-admin) :where(main#content, .entry-content, .elementor-widget-container) :where(h1[id], h2[id], h3[id], h4[id], h5[id], h6[id]) {
  scroll-margin-top: var(--ml-toc-anchor-offset) !important;
}

/* TOC must sit directly under the hero/media block. */
body:not(.wp-admin) :where(main#content, .entry-content, .elementor-widget-container) :where(.ek-hero, .ek-hero-image, .ek-image-block, .ek-hero__media) + :where(.ek-faq.eko-toc, .ek-faq--toc),
body:not(.wp-admin) :where(main#content, .entry-content, .elementor-widget-container) :where(.ek-hero, .ek-hero-image, .ek-image-block, .ek-hero__media) + p + :where(.ek-faq.eko-toc, .ek-faq--toc),
body:not(.wp-admin) :where(main#content, .entry-content, .elementor-widget-container) :where(.ek-faq.eko-toc.ml-toc-stick-to-hero, .ek-faq--toc.ml-toc-stick-to-hero) {
  margin-top: 0 !important;
  padding-top: 0 !important;
}

body:not(.wp-admin) :where(main#content, .entry-content, .elementor-widget-container) :where(.ek-faq.eko-toc.ml-toc-stick-to-hero, .ek-faq--toc.ml-toc-stick-to-hero) > details,
body:not(.wp-admin) :where(main#content, .entry-content, .elementor-widget-container) :where(.ek-faq.eko-toc.ml-toc-stick-to-hero, .ek-faq--toc.ml-toc-stick-to-hero) > .ek-container > details {
  margin-top: 0 !important;
}

/* Empty paragraphs created by wpautop between hero and TOC must not create a visual gap. */
body:not(.wp-admin) :where(main#content, .entry-content, .elementor-widget-container) p.ml-empty-between-hero-and-toc {
  display: none !important;
  margin: 0 !important;
  padding: 0 !important;
  height: 0 !important;
  line-height: 0 !important;
}

/* =========================================================
   Ekosphere Estate 4.0.1
   TOC anchor clearance + compact TOC-to-eyebrow rhythm
   ========================================================= */

/* Keep the first eyebrow directly below the TOC without a large empty band. */
body:not(.wp-admin) :where(main#content, .entry-content, .elementor-widget-container)
:where(.ek-faq.eko-toc, .ek-faq--toc, [data-eko-toc]) + :where(.ek-sub, .ek-eyebrow),
body:not(.wp-admin) :where(main#content, .entry-content, .elementor-widget-container)
:where(.ek-faq.eko-toc, .ek-faq--toc, [data-eko-toc]) + p + :where(.ek-sub, .ek-eyebrow) {
  margin-top: 14px !important;
  padding-top: 0 !important;
}

/* Remove empty wpautop paragraphs between TOC and eyebrow. */
body:not(.wp-admin) :where(main#content, .entry-content, .elementor-widget-container)
:where(.ek-faq.eko-toc, .ek-faq--toc, [data-eko-toc]) + p:empty {
  display: none !important;
  margin: 0 !important;
  padding: 0 !important;
  height: 0 !important;
}

/* =========================================================
   Ekosphere Estate 4.0.2
   Exact Floating-Nav anchor parity + compact hero/eyebrow spacing
   ========================================================= */

/* The TOC is inside .ek-hero on the affected pages. Remove the hero's
   inherited bottom spacing and apply one controlled gap to the eyebrow. */
body:not(.wp-admin) main#content :where(.ek-hero.ml-hero-has-toc) {
  margin-bottom: 12px !important;
  padding-bottom: 0 !important;
}

body:not(.wp-admin) main#content :where(.ek-hero.ml-hero-has-toc) + :where(.ek-sub, .ek-eyebrow),
body:not(.wp-admin) main#content :where(.ek-hero.ml-hero-has-toc) + p + :where(.ek-sub, .ek-eyebrow) {
  margin-top: 0 !important;
  padding-top: 0 !important;
}

body:not(.wp-admin) main#content p.ml-empty-between-toc-and-eyebrow,
body:not(.wp-admin) main#content :where(.ek-hero.ml-hero-has-toc) + p:empty {
  display: none !important;
  height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  line-height: 0 !important;
}

/* =========================================================
   Ekosphere Estate 4.0.3
   Layout-shift-safe anchor lock + deterministic TOC spacing
   ========================================================= */

/* Remove the legacy 40px TOC bottom margin from eko.css everywhere. */
body:not(.wp-admin) :where(.ek-faq.eko-toc, .ek-faq--toc, [data-eko-toc]) {
  margin-bottom: 8px !important;
}

/* When the TOC belongs to the hero, the hero itself must not add a second gap. */
body:not(.wp-admin) :where(.ek-hero.ml-hero-has-toc) {
  margin-bottom: 8px !important;
  padding-bottom: 0 !important;
}

/* Marked by JS, therefore independent of the exact eyebrow class or HTML tag. */
body:not(.wp-admin) :where(.ml-first-content-after-toc) {
  margin-top: 0 !important;
  padding-top: 0 !important;
}

/* Common Elementor/WordPress wrappers must not reintroduce a large first-child gap. */
body:not(.wp-admin) :where(.ml-first-content-after-toc) > :first-child,
body:not(.wp-admin) :where(.ml-first-content-after-toc) > .elementor-widget-container > :first-child {
  margin-top: 0 !important;
  padding-top: 0 !important;
}

body:not(.wp-admin) p.ml-empty-between-toc-and-eyebrow,
body:not(.wp-admin) p.ml-empty-between-hero-and-toc {
  display: none !important;
  height: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  line-height: 0 !important;
}
