/* Staging overrides: restore page title spacing so hero/title is visible below transparent header */
:root {
  --sm-header-offset: 140px;
}

/*
 * Defensive: Some staging Helix "Custom CSS" snippets mistakenly use
 * `body.sticky-header #sp-header { background:#fff; position:fixed; }`.
 * Since `sticky-header` is a persistent body class (feature-flag), that
 * forces a white/fixed header even at the top of the page.
 *
 * Keep the default (transparent/absolute) header until the template applies
 * its scroll-state class (`#sp-header.menu-fixed`).
 */
body.sticky-header:not(.no-page-title):not(.solid-header) #sp-header:not(.menu-fixed) {
  position: absolute !important;
  background: transparent !important;
  box-shadow: none !important;
}

html,
body {
  scroll-padding-top: var(--sm-header-offset);
}

:target {
  scroll-margin-top: var(--sm-header-offset);
}

body:not(.header-sticky) .sp-page-title {
  padding-top: 120px !important;
  padding-bottom: 160px !important;
  min-height: 520px !important;
}

body:not(.header-sticky) .sp-page-title h2 {
  letter-spacing: -2px !important;
  width: 100% !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  position: relative;
  margin-bottom: 32px !important;
}

.view-article .sp-page-title h2 {
  font-size: calc(16px + 4vw) !important;
  line-height: 1.05 !important;
}

body:not(.header-sticky) .article-details-wrap {
  margin-top: 100px !important;
}

/* Adjust Contents slider anchor offset for sticky header */
.article-details-wrap .article-content h3[id],
.article-details-wrap .article-content h2[id],
.article-details-wrap .article-content h4[id] {
  scroll-margin-top: var(--sm-header-offset);
}

/* Allow mobile off-canvas to scroll while locking the page behind it */
.offcanvas-menu-init.offcanvas {
  overflow: hidden;
}

.offcanvas-menu-init.offcanvas .offcanvas-menu {
  max-height: 100vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.offcanvas-menu-init.offcanvas .offcanvas-inner {
  padding-bottom: 40px;
}

/* Off-canvas (hamburger) search: remove excess spacing under the search box */
.offcanvas-menu .offcanvas-inner .sp-module.sm-offcanvas-search-module {
  margin-bottom: 20px !important;
  padding-bottom: 0 !important;
}

.offcanvas-menu .offcanvas-inner .sp-module.sm-offcanvas-search-module .search {
  margin-top: 0 !important;
}

.offcanvas-menu .offcanvas-inner .sp-module.sm-offcanvas-search-module form,
.offcanvas-menu .offcanvas-inner .sp-module.sm-offcanvas-search-module input {
  margin-bottom: 0 !important;
}

/* Cross-site switch button (SimpleMed → SimpleMed+) */
.smplus-side-switch {
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1000000;
  width: 30px;
  height: 48px;
  border-radius: 0 24px 24px 0;
  background: #00a7a7;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.75);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}

.smplus-side-switch:hover,
.smplus-side-switch:focus {
  background: #008c8c;
  color: #fff;
  text-decoration: none;
}

.smplus-side-switch:focus {
  outline: 2px solid rgba(255, 255, 255, 0.9);
  outline-offset: 1px;
}

@media (max-width: 767px) {
  .smplus-side-switch {
    top: auto;
    bottom: 96px;
    left: 0;
    transform: none;
  }
}

/* Article Quiz CTA (SimpleMed+ embed) */
.article-details-wrap iframe.smp-cta-iframe,
.article-details-wrap iframe[data-src*="plus.simplemed.co.uk/embed/cta"],
.article-details-wrap iframe[src*="plus.simplemed.co.uk/embed/cta"] {
  width: 100% !important;
  max-width: none !important;
  border: 0 !important;
  display: block;
  margin: 0 !important;
  height: 220px;
  min-height: 160px;
  max-height: none;
  overflow: hidden;
}

.article-details-wrap .smp-cta-wrap {
  position: relative;
  margin: 14px 0 24px;
}

.article-details-wrap .smp-cta-fallback {
  margin: 10px 0 0;
  text-align: center;
  line-height: 1.4;
}

.article-details-wrap .smp-cta-fallback-link {
  display: inline-block;
  color: #00a7a7;
  font-size: 12px;
  font-weight: 600;
  text-decoration: underline;
}

.article-details-wrap .smp-cta-fallback-link:hover,
.article-details-wrap .smp-cta-fallback-link:focus {
  color: #008c8c;
  text-decoration: underline;
}

.article-details-wrap .smp-cta-fallback-link:focus {
  outline: 2px solid rgba(0, 140, 140, 0.3);
  outline-offset: 2px;
}

.article-details-wrap .smp-cta-ready .smp-cta-fallback {
  display: none;
}

/* Homepage Metrics (SimpleMed+ embed) */
.smp-home-metrics {
  width: 100%;
}

.smp-metrics-frame {
  width: 100%;
  display: block;
  border: 0;
  height: 220px;
  overflow: hidden;
}

@media (max-width: 992px) {
  .smp-metrics-frame {
    height: 660px;
  }
}

/* Contact Us (SP Page Builder Ajax Contact): improve typed text contrast */
.sppb-addon-ajax-contact .sppb-ajaxt-contact-form .sppb-form-group input:not(.sppb-form-check-input),
.sppb-addon-ajax-contact .sppb-ajaxt-contact-form .sppb-form-group textarea {
  color: #111827 !important;
}

.sppb-addon-ajax-contact .sppb-ajaxt-contact-form .sppb-form-group input:not(.sppb-form-check-input)::placeholder,
.sppb-addon-ajax-contact .sppb-ajaxt-contact-form .sppb-form-group textarea::placeholder {
  color: #9ca3af !important;
  opacity: 1;
}

.sppb-addon-ajax-contact .sppb-ajaxt-contact-form .sppb-form-group input:not(.sppb-form-check-input):focus,
.sppb-addon-ajax-contact .sppb-ajaxt-contact-form .sppb-form-group textarea:focus {
  outline: 2px solid rgba(0, 167, 167, 0.35);
  outline-offset: 1px;
}
