/* Mobile fixes layered over the Divi export. Linked last in <head> on every page. */

/* Inner pages push their first section down 100-120px to clear Divi's fixed header.
   Below 768px the header is back in normal flow, so that margin is just a blank gap. */
@media (max-width: 767px) {
  #page-container .et_pb_section_0.et_pb_section { margin-top: 0 !important; }

  /* Header: a -35px section margin pins the small logo to the top edge. Give it room
     and make the logo bigger. */
  .et-l--header .et_pb_section_0_tb_header.et_pb_section { margin-top: 0 !important; }
  .et-l--header .et_pb_row_0_tb_header.et_pb_row { padding-top: 12px !important; padding-bottom: 12px !important; }
  .et-l--header .et_pb_menu_0_tb_header { padding-top: 0 !important; }
  .et-l--header .et_pb_menu__logo-wrap,
  .et-l--header .et_pb_menu__logo { width: auto !important; max-width: none !important; overflow: visible !important; }
  .et-l--header .et_pb_menu__logo img { height: 80px !important; width: auto !important; max-width: none !important; }

  /* About: the photo keeps a desktop -70px left offset that crops it off-screen, and the
     Qualifications/Publications lists lose their bullets to the site-wide mobile li rule. */
  .page-id-202 .et_pb_image_0 { margin-left: 0 !important; width: 100% !important; }
  .page-id-202 .et_pb_text_1 li,
  .page-id-202 .et_pb_text_2 li { list-style-type: disc !important; }

  /* Blog posts pad their title row 130px each side at every width, squeezing the
     heading into a few letters per line on phones. */
  .single-post #page-container .et_pb_row_0.et_pb_row { padding-left: 0 !important; padding-right: 0 !important; }
}

/* Home "services" intro box is hard-coded to width:400px!important, which scrolls the
   page sideways on phones narrower than 400px. */
@media (max-width: 479px) {
  .service-sub-heading { max-width: 100% !important; }
}

/* Mobile menu: collapse submenus behind a toggle (js/mobile-fixes.js adds the button). */
.et_mobile_menu .menu-item-has-children { position: relative; }
.et_mobile_menu .menu-item-has-children > a { padding-right: 52px !important; }
.et_mobile_menu li.menu-item-has-children > .sub-menu { display: none !important; }
.et_mobile_menu li.menu-item-has-children.mf-open > .sub-menu { display: block !important; }
.mf-subtoggle {
  position: absolute;
  top: 0;
  right: 0;
  width: 48px;
  height: 46px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.mf-subtoggle::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 9px;
  height: 9px;
  margin: -7px 0 0 -5px;
  border-right: 2px solid #666;
  border-bottom: 2px solid #666;
  transform: rotate(45deg);
  transition: transform .2s ease;
}
.mf-open > .mf-subtoggle::before { margin-top: -2px; transform: rotate(-135deg); }

/* SG Popup Builder's floating "Leave a Message" tab ships at z-index 2147483647, above
   its own popups. On phones it covers the contact popup's bottom-right close button and
   the Book Today button. Keep it just under the popup overlay (9999). */
.sgpb-floating-button { z-index: 9998 !important; }

@media (max-width: 767px) {
  /* Contact popup: a 10-row textarea pushes Send below the fold on most phones. */
  .sgpb-content-1498 textarea { height: 110px !important; min-height: 0 !important; }

  /* Book-appointment popup: the button's top:25px nudge pushes it out of the box. */
  .sgpb-popup-builder-content-7575 .et_pb_button { top: 0 !important; }

  /* Book-appointment popup: 80% wide, centred, and lifted clear of the floating
     "Leave a Message" tab, which sits in front of it. It has no overlay, so dropping
     it below the tab (9998) is safe; the contact popup keeps its higher z-index. */
  .sgpb-popup-dialog-main-div-theme-wrapper-2 {
    left: 10% !important;
    right: auto !important;
    width: 80% !important;
    bottom: 72px !important;
    z-index: 9990 !important;
  }
  .sgpb-popup-dialog-main-div-theme-wrapper-2 .sgpb-content-7575 {
    width: 100% !important;
    max-width: none !important;
    box-sizing: border-box !important;
  }
}
