// --------------------- //
#main-menu {
  font-size: @font-size-small;
  margin-left: -@grid-gutter-width-half;

  & > li {
    & > a {
      @media (min-width: @screen-sm-min) and (max-width: @screen-sm-max) {
        &:first-child {
          padding-left: @grid-gutter-width-half;
        }
        padding-top: 3px;
        padding-bottom: 3px;
      }
    }
  }
}

header {
  #logo {
    .navbar-brand {
      margin-left: @grid-gutter-width-half;
      @media (min-width: @screen-xl-min) {
        margin-left: @grid-gutter-width-half-xl;
      }
    }
  }
  .header-menu {
    .dropdown-menu {
      & > li {
        &.active > a,
        & > a:active,
        & > a:focus,
        & > a:hover {
          background-color: @hwk-blue-light-25;
          color: @hwk-blue-dark;
        }
      }
    }
  }
}
.header-menu {
  a span.h4 {
    display: block;
  }
}


.dropdown-menu {
  border-radius: 0;
  min-width: 80px;
  border: none;

  padding: 0;
  & > li {
    & > a {
      padding: 13px 20px;
      border-bottom: 1px solid @hwk-blue-light-25;
    }
    &.active > a,
    &.active > a:hover,
    & > a:active,
    & > a:focus,
    & > a:hover {
      background-color: @hwk-blue-light-25;
      color: @hwk-blue-dark;
    }
  }
}

// --------------------- //
// SUBMENU FULL SIZE
// -> needs class .submenu-full-width
//
@media (min-width: @screen-sm-min) {
  .submenu-full-width {
    .navbar-collapse {
      .nav {
        & > li.dropdown {
          position: initial;
        }
        li.dropdown {

          &.open > ul.dropdown-menu {

            width: 100vw;
            left: 0;

            padding: 40px calc((100vw - (@container-xl - @grid-gutter-width)) / 2);
            @media (min-width: @screen-lg-min) and (max-width: @screen-lg-max) {
              padding: 40px calc((100vw - (@container-lg - @grid-gutter-width)) / 2);
            }
            @media (min-width: @screen-md-min) and (max-width: @screen-md-max) {
              padding: 40px calc((100vw - (@container-md - @grid-gutter-width)) / 2);
            }
            @media (min-width: @screen-sm-min) and (max-width: @screen-sm-max) {
              padding: 40px calc((100vw - (@container-sm - @grid-gutter-width)) / 2);
            }

            // ------------------------------ //
            // Solution COLUMNS
            //
            column-count: auto;
            column-width: @mega-menu-column-width;


            // submenu 2nd level
            & > li {
              // prevent submenu from flowing into next column
              display: inline-block; // working add to elemnt which you do not want to break
              min-width: @mega-menu-column-width;
              border-top: 1px solid @hwk-blue-dark;
              font-size: 16px;

              & > a {
                padding: 10px 0;
                font-weight: 600;
                border-bottom: none;

                &:active,
                &:focus,
                &:hover {
                  background-color: transparent !important;
                  color: @hwk-blue-light !important;
                }
              }
            }

            ul.dropdown-menu {
              position: relative;
              display: inline-block;
              float: none;
              box-shadow: none;
              // submenu 3rd level
              li {
                font-size: 16px;

                & > a {
                  background-color: transparent;
                  border: none;
                  padding: 10px 0;
                  &:active,
                  &:focus,
                  &:hover {
                    background-color: transparent !important;
                    color: @hwk-blue-light !important;
                  }
                }

                &:last-child {
                  margin-bottom: 20px;
                }
              }
            }
            // ------------------------------ //
          }
        }
        ul.dropdown-menu {
          li {
            &, & a {
              color: @hwk-blue-dark;
              background-color: transparent;
            }
            &.active,
            &.active > a {
              color: @hwk-blue-light;
            }

            a {
              max-width: @mega-menu-column-width;
              white-space: break-spaces;
            }
          }
        }
      }
    }
  }
}



// --------------------- //
// MAIN MENU MOBILE
//
@media (max-width: @screen-xs-max) {

  #logo {
    min-width: 100vw !important;
    max-width: 100vw;
    display: flex;
    align-items: center;
    justify-content: space-between;

    .navbar-brand {
      margin-left: 23px !important; // same as logo icon height
    }

    .search {
      color: @hwk-blue-dark;
      margin-right: 90px;
      margin-top: 5px;
    }
  }

  .container .navbar-header {
    margin-left: -@grid-gutter-width-half-xs;
    margin-right: -@grid-gutter-width-half-xs;
  }
  .navbar-collapse {
    .nav {
      li.dropdown {
        &, a {
          color: #fff;
        }
      }
    }
  }

  .navbar-default {
    .header-menu {
      .navbar-nav {
        &, .open {
          li {
            &, a {
              color: @hwk-blue-dark;
            }

            a {
              &:active,
              &:focus,
              &:hover {
                color: @hwk-blue-dark;
              }
            }
          }
        }
      }
    }
  }

  // reset all active|hover |focus
  .navbar-nav {
    li.active a,
    .open > a,
    a:active, a:hover, a:focus {
      background-color: transparent !important;
    }
    .dropdown-menu, li {
      margin-top: 0;
      margin-bottom: 0;
      padding-top: 0;
      padding-bottom: 0;
    }

    .hwk-open > a > .caret {
      transform: scaleY(-1);
    }
  }

  .navbar-default {

    header {
      height: @header-height-xs;
    }

    .navbar-toggle {
      position: relative;
      top: -((@header-height-xs + @header-navbar-height-xs) / 2);
      border: none;
      padding: 0;
      margin: 0;
      right: 23px + 5; // see logo margin left

      .icon-bar {
        background-color: @hwk-blue-dark !important;
      }

      &:active,
      &:focus,
      &:hover {
        background-color: transparent !important;

        .icon-bar {
          &,
          &::before,
          &::after {
            background-color: @hwk-blue-light !important;
          }
        }
      }

      // hamburger animation to cross
      transition: all 0.3s linear, background-color 0s;
      width: @hamburger-width;
      height: @hamburger-width;

      .icon-bar {
        // hide others icon bars
        display: none;
        // show pnly one
        &:last-child {
          display: block;
          margin-top: 0;
        }

        &, // middle line
        &::before, // top line
        &::after { // bottom line
          position: absolute;
          width: @hamburger-width;
          height: @hamburger-line-height;
          background-color: @hamburger-line-color;
          left: 0;
        }

        &::before {
          content: '';
          bottom: (@hamburger-width / 2)-(@hamburger-line-height * 2) - 2;
        }

        &::after {
          transition: all 0.3s linear, background-color 0s;
          content: '';
          top: (@hamburger-width / 2)-(@hamburger-line-height * 2) - 2;
        }
      }
    }

    .container .navbar-collapse {
      max-height: calc(100vh - @header-height-xs);
      position: absolute;
      width: 100vw;
      top: @header-height-xs;
      background-color: @hwk-blue-dark;
      overflow-x: hidden;
      margin-left: -@grid-gutter-width-half-xs;
      margin-right: -@grid-gutter-width-half-xs;
      padding-left: @grid-gutter-width-half-xs;
      padding-right: @grid-gutter-width-half-xs;

      #main-menu {  // ul
        margin-top: 0;
        margin-bottom: 0;

        // style dropdown mobile
        .dropdown-menu {
          position: static;
          float: none;
          width: auto;
          margin-top: 0;
          background-color: transparent;
          border: 0;
          box-shadow: none;
          & > li > a {
            white-space: normal;
          }
        }
        
        // first level
        & > li {
          font-size: @font-size-base-p;
          font-weight: @font-weight-bold;
          border-top: 1px solid #fff;
          &:first-child {
            border-top: none;
          }
          &.active a {
            color: @hwk-blue-light-75;
          }
          & > a {
            padding-top: 16px;
            padding-bottom: 16px;
          }
          &.dropdown {
            // always hide when bs class is used
            // crazy js problems as it was automatically shown again after hiding ?
            &.open > .dropdown-menu {
              display: none;
            }
            // use hwk-open
            &.hwk-open > .dropdown-menu {
              display: block;
            }

            // second level
            & > .dropdown-menu { // ul
              background-color: @hwk-blue-light-25;
              & > li {
                border-bottom: 1px solid #fff;
                &:last-child {
                  border-bottom: none;
                }
                &.active a {
                  color: @hwk-blue-light;
                }
                & > a {
                  font-size: 18px;
                  font-weight: @font-weight-bold;
                  color: @hwk-blue-dark;
                  padding: 16px 15px 16px 40px;
                }
                &.dropdown {
                  & > a::after {
                    content: '';
                    display: inline-block;
                    width: 0;
                    height: 0;
                    margin-left: 6px;
                    vertical-align: middle;
                    border-color: @hwk-blue-dark;
                    border-top: @caret-width-base dashed;
                    border-top: @caret-width-base solid ~"\9"; // IE8
                    border-right: @caret-width-base solid transparent;
                    border-left: @caret-width-base solid transparent;
                  }
                  &.hwk-open > a::after {
                    transform: scaleY(-1);
                  }

                  &.hwk-open {
                    border-bottom: none;
                  }
                  &.hwk-open >  .dropdown-menu { // ul
                    display: block;
                  }
                  // third level
                  .dropdown-menu { // ul
                    background-color: #fff;
                    & > li {
                      border-bottom: 1px solid @hwk-blue-light-25;
                      &.active a {
                        color: @hwk-blue-light;
                      }
                      & > a {
                        font-size: 18px;
                        font-weight: @font-weight-normal;
                        color: @hwk-blue-dark;
                        padding: 16px 15px 16px 70px;
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }

  *[data-navbar-toggle="open"] {

    & .navbar-default, &.navbar-default {
      // menu open
      .navbar-toggle:not(.closed) {
        width: @hamburger-width + (@hamburger-line-height * 2);

        .icon-bar {
          width: @hamburger-width + (@hamburger-line-height * 2);
          top: calc(50%);
          left: 5px;
          transform: rotate(-45deg);
          // adjust properties on the after pseudo element
          &::after {
            top: 0px;
            left: 0px;
            transform: rotate(90deg);
            width: @hamburger-width + (@hamburger-line-height * 2);
          }

          // hide top line by scaling it to 0
          &::before {
            transform: scale(0);
          }
        }
      }
    }
  }
}

