/**
 * @file
 * The header on phones: logo, the menu button at its bottom right, and the menus
 * hidden until it is pressed (js/bdc-mobile-menu.js adds .bdc-menu-open to
 * the header). Open, every menu (account links and Theme, the main menu, the
 * coaching menu) is a full-width list, one link per row.
 *
 * In the module rather than a theme so bdc_theme and ndd_theme both get it.
 * The themes style the same header with !important rules keyed on the
 * header, so these do too, from the more specific `html body header…`.
 */

@media (max-width: 767px) {
  html body header.main-header > .container {
    position: relative !important;
  }
  /* The nav row and its wrappers span the header width. */
  html body header.main-header > .container > .row:nth-child(2),
  html body header.main-header .navbar-header,
  html body header.main-header nav.navbar {
    position: static !important;
    width: 100% !important;
    max-width: 100% !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  /* A block, not the theme's flex row: its column then fills the width. */
  html body header.main-header > .container > .row:nth-child(2) {
    display: block !important;
  }

  /* Bottom right of the logo area (js/bdc-mobile-menu.js moves the button
     there). It may overlap the logo a little on a narrow phone, so it has a
     half-clear background: the logo shows through, the button stays
     visible. Pinned to the logo area, it stays put when the menu opens. */
  html body header.main-header > .container > .row:first-child {
    position: relative !important;
  }
  html body header.main-header .navbar-toggle {
    display: block !important;
    position: absolute !important;
    right: 6px !important;
    bottom: 0 !important;
    top: auto !important;
    float: none !important;
    margin: 0 !important;
    padding: 9px 10px !important;
    z-index: 2;
    background: rgba(255, 255, 255, 0.6) !important;
    border: 1px solid #d1d5db !important;
    border-radius: 6px !important;
    cursor: pointer;
  }
  html body header.main-header .navbar-toggle .icon-bar {
    display: block;
    width: 22px;
    height: 2px;
    background: #4b5563;
    border-radius: 1px;
  }
  html body header.main-header .navbar-toggle .icon-bar + .icon-bar {
    margin-top: 4px;
  }
  html body header.main-header.bdc-menu-open .navbar-toggle {
    background: rgba(243, 244, 246, 0.85) !important;
  }

  /* Closed: nothing but the button. */
  html body header.main-header .region-primary-menu {
    display: none !important;
  }

  /* Open: the menus one after another, full width. */
  html body header.main-header.bdc-menu-open .region-primary-menu {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0 !important;
    width: 100% !important;
    margin: 10px 0 0 !important;
    padding: 0 !important;
    border-top: 1px solid #e5e7eb;
  }
  html body header.main-header.bdc-menu-open .region-primary-menu > nav {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    text-align: left !important;
  }
  html body header.main-header.bdc-menu-open .region-primary-menu > nav + nav {
    border-top: 6px solid #f3f4f6;
  }
  html body header.main-header.bdc-menu-open .region-primary-menu ul:not(.contextual-links) {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    white-space: normal !important;
    text-align: left !important;
  }
  html body header.main-header.bdc-menu-open .region-primary-menu ul:not(.contextual-links) > li {
    display: block !important;
    float: none !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-bottom: 1px solid #eef0f2 !important;
    overflow: visible !important;
  }
  html body header.main-header.bdc-menu-open .region-primary-menu ul:not(.contextual-links) > li:last-child {
    border-bottom: 0 !important;
  }
  html body header.main-header.bdc-menu-open .region-primary-menu ul:not(.contextual-links) > li > a,
  html body header.main-header.bdc-menu-open .region-primary-menu .bdc-theme-picker__button {
    display: block !important;
    width: 100% !important;
    padding: 12px 6px !important;
    font-size: 16px !important;
    line-height: 1.3 !important;
    white-space: normal !important;
    word-break: normal !important;
    text-align: left !important;
  }
  html body header.main-header.bdc-menu-open .region-primary-menu .bdc-theme-picker__button {
    display: flex !important;
    align-items: center;
    min-height: 0 !important;
  }
  html body header.main-header.bdc-menu-open .region-primary-menu .bdc-theme-picker {
    display: block;
  }
}
