#ct-main-nav{
  flex-basis: 100%;
  flex-grow: 100;
  position: relative;

  &::before{
    content: '';
    position: absolute;
    top: 1rem;
    right:  -20rem;
    bottom: -1rem;
    left:  -20rem;
    display: block;
    z-index: -1;
  }
  @include media-breakpoint-down(xl){
    //overflow: hidden;
  }
  @include media-breakpoint-up(xl) {
    flex-basis: auto;
    padding-top: 0;
    text-align: right;
    flex-grow: 1;

    &::before{
      display: none;
    }
  }

  &__wrapper{
    position: relative;
    width: 100%;
    text-align: left;

    @include media-breakpoint-up(xl) {
      width: auto;
      font-size: 0.75rem;
      text-align: right;
    }

  }
}

.ct-main-navigation{

   @at-root
   ul#{&},
   div#{&} > ul{
     display: none;
     list-style: none;
     width: 100%;
     position: relative;
     flex-direction: column;
     transition: all 200ms ease;
     margin: 0 auto;
     padding: 0;

     @include media-breakpoint-up(xl) {
       display: flex;
       flex-wrap: wrap;
       flex-direction: row;
       width: auto;
       position: relative;
       @include reset-spacing();

       .ct-menu--align-left &{
         justify-content: flex-start;
       }

       .ct-menu--align-right &{
         justify-content: flex-end;
       }

     }

     > li{
       &:not(:first-child){
         position: relative;
         @include pseudo-block( 'after', 'top', 0.125, 0, 0, false, 0 );
       }

       @include media-breakpoint-up(sm) {
         &:not(:first-child)::after{
           display: none;
         }
       }

       @include media-breakpoint-up(sm) {
         white-space: nowrap;
       }

       @include media-breakpoint-up(xl) {
         margin-left: 4rem;
         white-space: nowrap;
       }

     }
  }

  .menu-item,
  .page_item{
    position: relative;
    padding-top: .25rem;
    padding-bottom: .25rem;

    @include media-breakpoint-up(xl) {
      padding-top: 0;
      padding-bottom: 0;
    }

    &:hover {
      > .sub-menu,
      > .children {
        display: block;
      }
    }

  }

  .menu-item .menu-item,
  .page_item .page_item{
    padding: .25rem 0.125rem;
    line-height: 1.6;

    &:not(:first-child) {
      @include pseudo-block( 'after', 'top', 0.125, 0, 0, false, 0 );
    }

    @include media-breakpoint-up(xl) {
      padding: 0 1rem;

      &:not(:first-child)::after{
        left: 1rem;
        right: 1rem;
      }
    }

  }

  .sub-menu,
  .children{
    list-style: none;
    position: relative;
    transition: all 200ms ease;
    display: none;
    @include reset-spacing();

    &:not(:first-child){
      @include pseudo-block( 'after', 'top', 0.125, 0, 0, false, 0 );
    }

    @include media-breakpoint-up(xl) {
      position: absolute;
      text-align: left;
      width: 12rem;
      left: -1rem;
      padding: .5rem 0;
      background: #fff;
      box-shadow: 0px 0px 5px 0 rgba(0, 0, 0, 0.1);
      z-index: 1;
      border-radius: 2px;
      top: 100%;
      margin-bottom: -2px;
      white-space: normal;
      margin-top: 0.5rem;

      &::before{
        content: '';
        display: block;
        position: absolute;
        left: 0;
        right: 0;
        top: -1rem;
        height: 1rem;
      }

      &::after,
      &:not(:first-child)::after{
        display: none;
      }
    }

    a{
      font-size: 90%;
      padding: 0.5rem 0;

    }
  }

  .sub-menu .sub-menu,
  .children .children{

    @include media-breakpoint-up(xl) {
      left: 95%;
      top: -0.5rem;
    }
  }

  .edge > .sub-menu,
  .edge > .children{
    @include media-breakpoint-up(sm) {
      right: 0;
      left: auto;
      top: 2.5em;

      & .sub-menu,
      & .children{
        left: auto;
        right: 95%;
      }
    }
  }

  .current-menu-ancestor,
  .current-menu-parent,
  .current-menu-item,
  .current-page-parent,
  .current_page_parent,
  .current_page_ancestor,
  .current_page_item{

  }


  .menu-item-has-children > a,
  .page_item_has_children > a{
    @include themify-icon( 'before', "\e64b" );

    &::before{
      float: right;
      margin: 0 0.5rem;
      display: inline-block;

      @media(min-width: 48em){
        font-size: 0.5rem;
        line-height: 2.25;
        margin-right: 0
      }
    }
  }

  .menu-item .menu-item-has-children > a,
  .page_item .page_item_has_children > a{
    @include media-breakpoint-up(xl) {
      &::before{
        content: '\e649';
        line-height: 2.2;
      }
    }
  }

  a{
    text-decoration: none;
    transition: all 200ms ease;
    display: block;
    padding: 0.25rem 0;
  }

}


#ct-main-nav__toggle-navigation{
  position: relative;
  font-size: 1em;
  letter-spacing: 1px;
  text-transform: uppercase;
  font-weight: 400;
  flex-grow: 2;
  flex-shrink: 0;
  text-align: right;
  margin:0;

  @include media-breakpoint-up(xl) {
    display: none;
  }

  .ti-align-justify{
    position: relative;
    margin-left: .125rem;
    font-size: 1.2em;

    &::before{
      position: relative;
      top: .125rem;
    }
  }
}
#ct-main-nav__toggle-navigation-main:checked + #ct-main-nav__wrapper > ul.ct-main-navigation,
#ct-main-nav__toggle-navigation-main:checked + #ct-main-nav__wrapper > div.ct-main-navigation > ul{
  display: flex;
  padding-top: 2rem;
}

.sub-menu {
  display: none; /* Hide by default */
}

.menu-item-has-children.sub-menu-open > .sub-menu {
  display: block; /* Show when the parent has the .sub-menu-open class */
}