/* ------------------------------------------------------------------
   Derma Cosmedic: mega menu for the Treatments and Concerns tabs
   Target: GenerateBlocks Pro Navigation block rendering the classic
   "Main Menu" (ul#menu-main-menu.gb-menu), mobile breakpoint 1024px.

   Markup contract (set by the menu structure, not by this file):
     li.mtc-mega              = top-level tab that opens a panel
       > ul.gb-sub-menu       = the panel
         > li.mtc-mega-col    = one column heading
           > ul.gb-sub-menu   = that column's links

   Sections B and C fix two faults that already exist on the live site
   and that the mega menu would otherwise inherit. Both were measured
   on 2026-11-15, see visual-test-report.txt.
   ------------------------------------------------------------------ */

/* ===== A. Kill the inherited dark submenu fill ====================
   GB paints a solid black background on every .gb-menu-item inside a
   sub-menu. That is fine for a one-item dropdown and unreadable in a
   panel, so it is cleared for the mega menu at every width. */
.gb-menu li.mtc-mega ul.gb-sub-menu,
.gb-menu li.mtc-mega ul.gb-sub-menu > li,
.gb-menu li.mtc-mega ul.gb-sub-menu > li > ul.gb-sub-menu > li {
  background-color: transparent;
  background-image: none;
  color: #334155;
}

/* ===== B. Desktop panel (above the GB mobile breakpoint) ========== */
@media (min-width: 1025px) {

  /* The panel is positioned against the header row so it can span the
     full content width instead of hanging off one menu item. */
  .gb-element-4f69d334 { position: relative; }

  /* Let the panel escape the <li>'s own box. */
  .gb-menu > li.mtc-mega { position: static; }

  .gb-menu > li.mtc-mega > ul.gb-sub-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    width: auto;
    min-width: 0;
    max-width: none;
    max-height: calc(100vh - 220px);
    overflow-y: auto;
    overscroll-behavior: contain;

    /* Multi-column so uneven groups pack and balance by themselves. */
    columns: 4;
    column-gap: 32px;
    padding: 26px 30px 22px;
    margin: 0;

    background-color: #ffffff;
    border: 1px solid #f1f5f9;
    border-top: 3px solid #0f172a;
    border-radius: 0 0 10px 10px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.14);
    z-index: 999;
  }

  /* Narrower screens in the desktop band cannot carry four columns. */
  @media (max-width: 1200px) {
    .gb-menu > li.mtc-mega > ul.gb-sub-menu { columns: 3; column-gap: 26px; }
  }

  /* The top-level row has roughly 460px to work with at 1025px, which
     is not enough at the theme's default link padding: the live menu
     already wraps onto two rows there. Tighten the tabs in that band. */
  @media (max-width: 1150px) {
    #menu-main-menu { flex-wrap: nowrap; }
    #menu-main-menu > li > .gb-menu-link {
      padding-left: 9px;
      padding-right: 9px;
      font-size: 15px;
      white-space: nowrap;
    }
  }

  /* A transparent bridge under the tab so the pointer can travel from
     the menu item into the panel without crossing a dead gap. */
  .gb-menu > li.mtc-mega > .gb-menu-link { position: relative; }
  .gb-menu > li.mtc-mega > .gb-menu-link::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    height: 26px;
  }

  /* ---- Columns -------------------------------------------------- */
  .gb-menu > li.mtc-mega > ul.gb-sub-menu > li.mtc-mega-col {
    display: block;
    break-inside: avoid;
    page-break-inside: avoid;
    margin: 0 0 20px;
    padding: 0;
    border: 0;
  }

  /* Column heading */
  .gb-menu > li.mtc-mega > ul.gb-sub-menu > li.mtc-mega-col > .gb-menu-link {
    display: block;
    padding: 0 0 8px;
    margin: 0 0 6px;
    border-bottom: 1px solid #e2e8f0;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: #0f172a;
    background: none;
    white-space: normal;
  }
  .gb-menu > li.mtc-mega > ul.gb-sub-menu > li.mtc-mega-col > .gb-menu-link:hover,
  .gb-menu > li.mtc-mega > ul.gb-sub-menu > li.mtc-mega-col > .gb-menu-link:focus-visible {
    color: #0e7490;
    background: none;
  }

  /* The column heading never needs a dropdown arrow on desktop. */
  .gb-menu > li.mtc-mega .mtc-mega-col > .gb-menu-link > .gb-submenu-toggle { display: none; }

  /* ---- The plain About dropdown, matched to the panels ----------
     Left on GB's default solid-black fill it reads as a different
     component sitting in the same bar. */
  #menu-main-menu > li:not(.mtc-mega) > ul.gb-sub-menu {
    padding: 10px 0;
    background-color: #ffffff;
    border: 1px solid #f1f5f9;
    border-top: 3px solid #0f172a;
    border-radius: 0 0 10px 10px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.14);
  }
  #menu-main-menu > li:not(.mtc-mega) > ul.gb-sub-menu > li { background-color: transparent; }
  #menu-main-menu > li:not(.mtc-mega) > ul.gb-sub-menu > li > .gb-menu-link {
    padding: 8px 18px;
    font-size: 14px;
    color: #334155;
  }
  #menu-main-menu > li:not(.mtc-mega) > ul.gb-sub-menu > li > .gb-menu-link:hover,
  #menu-main-menu > li:not(.mtc-mega) > ul.gb-sub-menu > li > .gb-menu-link:focus-visible {
    background-color: #f1f5f9;
    color: #0f172a;
  }

  /* ---- Third level: the actual links ---------------------------- */
  .gb-menu > li.mtc-mega > ul.gb-sub-menu > li.mtc-mega-col > ul.gb-sub-menu {
    position: static;
    display: block;
    opacity: 1;
    visibility: visible;
    transform: none;
    width: auto;
    min-width: 0;
    max-width: none;
    padding: 0;
    margin: 0;
    background: none;
    border: 0;
    box-shadow: none;
    pointer-events: auto;
  }

  .gb-menu > li.mtc-mega .mtc-mega-col > ul.gb-sub-menu > li { display: block; margin: 0; }

  .gb-menu > li.mtc-mega .mtc-mega-col > ul.gb-sub-menu > li > .gb-menu-link {
    display: block;
    padding: 6px 8px;
    margin: 0 -8px;
    border-radius: 6px;
    font-size: 14px;
    line-height: 1.35;
    font-weight: 400;
    color: #334155;
    white-space: normal;
  }
  .gb-menu > li.mtc-mega .mtc-mega-col > ul.gb-sub-menu > li > .gb-menu-link:hover,
  .gb-menu > li.mtc-mega .mtc-mega-col > ul.gb-sub-menu > li > .gb-menu-link:focus-visible {
    background-color: #f1f5f9;
    color: #0f172a;
  }

  /* Keyboard users: opening on focus as well as hover. */
  .gb-menu > li.mtc-mega:focus-within > ul.gb-sub-menu {
    opacity: 1;
    visibility: visible;
    transform: none;
    pointer-events: auto;
  }
}

/* ===== C. Mobile / tablet full-overlay ===========================
   The live overlay lays the menu out as a wrapping flex ROW inside a
   330px box, so tabs sit two and three to a line and the dropdown
   floats as a dark block. Straighten it into a single column before
   adding a mega menu to it. */
@media (max-width: 1024px) {

  /* GB is set to "full-overlay" but the open container is still a
     static 330px box inside the header flex row, so a long menu runs
     straight through the logo, phone number and Book Consultation
     button. Make it behave as the overlay it claims to be. */
  .gb-navigation--open .gb-menu-container--toggled {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: 100%;
    /* The theme does not set border-box here: with content-box the
       side padding is added to the 100% width and the submenu arrows
       are pushed past the right edge of the screen. */
    box-sizing: border-box;
    z-index: 9999;
    background-color: #ffffff;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 66px 20px 48px;
  }

  /* GB pushes the list down by --gb-menu-toggle-offset to clear a
     toggle that is now fixed to the corner instead. */
  .gb-navigation--open .gb-menu-container--toggled > #menu-main-menu {
    margin-top: 0;
    padding-top: 0;
  }

  .gb-navigation--open .gb-menu-toggle--clone {
    position: fixed;
    top: 14px;
    right: 16px;
    z-index: 10000;
  }

  .gb-menu-container--toggled > #menu-main-menu {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    width: 100%;
    gap: 0;
  }

  .gb-menu-container--toggled > #menu-main-menu > li {
    width: 100%;
    border-bottom: 1px solid #e2e8f0;
  }

  .gb-menu-container--toggled > #menu-main-menu > li > .gb-menu-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 14px 4px;
    font-size: 17px;
  }

  /* The header's own toggle is cloned into the overlay; the original
     stays in the flow behind it as a second stray close button. */
  .gb-navigation--open > .gb-menu-toggle--toggled:not(.gb-menu-toggle--clone) { display: none; }

  /* ---- The mega panel inside the overlay ------------------------ */
  .gb-menu li.mtc-mega > ul.gb-sub-menu {
    columns: auto;
    box-shadow: none;
    border: 0;
    padding: 0 0 8px;
    width: 100%;
  }

  /* Column headings read as section labels, not as tappable rows. */
  .gb-menu li.mtc-mega-col > .gb-menu-link {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: #64748b;
    padding: 14px 4px 4px;
  }

  /* Save the visitor a second tap: the third level is always open
     once the parent tab is expanded. */
  .gb-menu li.mtc-mega .mtc-mega-col > ul.gb-sub-menu {
    display: block !important;
    height: auto !important;
    max-height: none !important;
    opacity: 1 !important;
    visibility: visible !important;
    overflow: visible !important;
    position: static !important;
    width: 100%;
    padding-left: 4px;
  }

  .gb-menu li.mtc-mega .mtc-mega-col > .gb-menu-link > .gb-submenu-toggle { display: none; }

  .gb-menu li.mtc-mega .mtc-mega-col > ul.gb-sub-menu > li > .gb-menu-link {
    display: block;
    padding: 9px 4px;
    font-size: 15px;
    color: #334155;
  }
}
