/* ==========================================================================
   Elementor fixes — loaded AFTER the design.
   The few rules that must also beat the design, each because Elementor puts
   a wrapper element where the static markup had none. Every selector here
   mirrors a selector in base.css / layout.css that relies on direct-child or
   sibling relationships, re-expressed across the widget wrapper.
   ========================================================================== */

/* base.css: `.section-heading + p.lead`, `.lead + .lead` */
.section-heading + .elementor-widget-text-editor > p.lead:first-child {
  margin-top: 16px;
}

.elementor-widget-text-editor + .elementor-widget-text-editor > .lead:first-child {
  margin-top: 16px;
}

/* layout.css "Client revisions": `.split-content > .lead + .lead`,
   `.split-content > .heading-block + .lead` */
.split-content > .elementor-widget-text-editor > .lead + .lead,
.split-content > .elementor-widget-text-editor + .elementor-widget-text-editor > .lead:first-child,
.split-content > .heading-block + .elementor-widget-text-editor > .lead:first-child {
  margin-top: -16px;
}

/* `.split-content > .heading-block[style*="margin-top"]` — the inline style
   became a pe-s-* class plus this pe-inline-mt marker. */
.split-content > .heading-block.pe-inline-mt {
  margin-top: 0 !important;
}

/* `.legal-content > p` and `.legal-content h2:first-child` — long-form copy
   sits in one Text Editor widget (pe-flow). */
.legal-content > .elementor-widget-text-editor > p {
  color: var(--text-80);
  margin-bottom: 16px;
}

.legal-content > .elementor-widget-text-editor:first-child > h2:first-child {
  margin-top: 0;
}

.legal-content > .elementor-widget-text-editor:not(:first-child) > h2:first-child {
  margin-top: 48px;
}

/* `.quick-card:last-child` — each card is its own widget, so every card is
   the last child of its wrapper. Restore the divider on all but the last. */
@media (min-width: 577px) {
  .quick-cards > .elementor-widget:not(:last-child) > .quick-card {
    border-right: 1px solid var(--color-border);
  }
}

/* Elementor Pro Theme Builder header/footer: the location wrapper is taken
   out of the box tree so .topbar, the sticky .site-header and .site-footer
   sit directly in .page-shell as in the static markup (a wrapper would end
   the sticky header's scroll range at the wrapper's bottom). */
body:not(.elementor-editor-active) .elementor.elementor-location-header,
body:not(.elementor-editor-active) .elementor.elementor-location-footer {
  display: contents;
}

/* Footer emergency wrapper: the static markup's inline styles. */
.pe-footer-emergency {
  background: var(--color-footer-bg);
  padding-bottom: 32px;
}

.pe-footer-emergency-inner {
  max-width: var(--container-max);
  margin-inline: auto;
}

/* WordPress admin bar: keep the sticky header below it. */
.admin-bar .site-header {
  top: 32px;
}

@media (max-width: 782px) {
  .admin-bar .site-header {
    top: 46px;
  }
}

@media (max-width: 600px) {
  .admin-bar .site-header {
    top: 0;
  }
}

/* Mobile menu panel sits below the admin bar too. */
.admin-bar .mobile-nav-panel {
  top: var(--wp-admin--admin-bar--height, 0px);
}

/* --------------------------------------------------------------------------
   Elementor editor only: wrappers are real boxes there, so let them take the
   grid/flex sizing their component would have had.
   -------------------------------------------------------------------------- */
.elementor-editor-active .hub-grid > .elementor-widget,
.elementor-editor-active .concerns-grid > .elementor-widget,
.elementor-editor-active .training-grid > .elementor-widget,
.elementor-editor-active .quick-cards > .elementor-widget {
  display: flex;
}

.elementor-editor-active .hub-grid > .elementor-widget > *,
.elementor-editor-active .concerns-grid > .elementor-widget > *,
.elementor-editor-active .training-grid > .elementor-widget > *,
.elementor-editor-active .quick-cards > .elementor-widget > * {
  flex: 1;
}

.elementor-editor-active .hero-cta > .elementor-widget {
  display: inline-flex;
}

.elementor-editor-active .quick-cards > .elementor-widget {
  flex: 1;
}

@media (max-width: 768px) {
  .elementor-editor-active .quick-cards > .elementor-widget {
    flex: 1 1 50%;
  }
}

@media (max-width: 576px) {
  .elementor-editor-active .quick-cards > .elementor-widget {
    flex: 1 1 100%;
  }
}

/* Images are mostly absolutely positioned (hero photo, watermark, feature
   banner); their wrapper must not become their positioning box. */
.elementor-editor-active .pe-con > .elementor-widget-pe-image {
  display: contents;
}

.pe-editor-placeholder {
  padding: 32px;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  text-align: center;
  color: var(--text-60);
  background: var(--color-white);
}

.pe-editor-placeholder i {
  color: var(--color-star);
}

/* Classic (block editor) pages/posts that are not Elementor layouts. */
.pe-classic-content > * + * {
  margin-top: 16px;
}

.pe-classic-content img {
  height: auto;
  border-radius: var(--radius-md);
}

.pe-pagination {
  margin-top: 40px;
}

.pe-pagination .nav-links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pe-pagination .page-numbers {
  padding: 8px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
}

.pe-pagination .page-numbers.current {
  background: var(--color-navy);
  border-color: var(--color-navy);
  color: var(--color-white);
}

/* --------------------------------------------------------------------------
   Elementor Pro popup: the "Medical Emergency Notice". The design's
   .emergency-modal card is the visible box; Elementor's own popup frame
   stays transparent around it.
   -------------------------------------------------------------------------- */
.pe-emergency-popup .dialog-message {
  overflow: visible;
}

.pe-emergency-popup .emergency-modal {
  max-width: none;
}

.pe-emergency-popup .dialog-close-button {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  z-index: 2;
}

.pe-emergency-popup .dialog-close-button:focus {
  outline: none;
}

.pe-emergency-popup .dialog-close-button:focus-visible {
  outline: 2px solid var(--color-sky);
  outline-offset: 2px;
}
