// ---------------------------------------------------------------------
//  Global Header Styles
// ---------------------------------------------------------------------

$header-height: 64px;
$header-height-lg: 80px;

.site-header {
  position: fixed;
  display: block;
  z-index: 10;
  width: 100%;
  left: 0;
  top: 0;
  transition: opacity $trans, background $trans;
  color: $white;
}

body {
  &.is-sticky {
    .site-header {
      margin-top: 0;
      opacity: 0;
      background: $black;
      > .container-wide {
        height: $header-height;
      }
    }
  }
  &.scrolling-up {
    .site-header {
      opacity: 1;
    }
  }

  &.faq {
    padding-top: $header-height;

    @include start-at($header-breakpoint) {
      padding-top: $header-height-lg;
    }
    .site-header {
      background: $black;
    }
  }
}

.site-header > .container-wide {
  padding: 0 $wrapper-padding;
  height: $header-height-lg;
  //background: $black;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: height $trans;

  @include start-at($large) {
    height: $header-height-lg;
  }
}

body.is-sticky {
  .site-header {

  }
}

body.menu-is-active {
  .site-header {
    background: url('../img/direction/static.jpg') center / cover no-repeat;
  }
}


// ----------------------------------------
// Logo Styles
// ----------------------------------------

$max-logo-width: 168px;

.site-branding {
  width: $max-logo-width;
  padding-right: 12px;

  a {
    display: block;
    max-width: 136px;
    width: 100%;

    @include start-at($large) {
      max-width: $max-logo-width;
    }

    &:hover {
      cursor: pointer;
    }
  }

  img {
    width: 100%;
  }


  @include start-at($header-breakpoint) {
    width: 25%;
  }

  @include start-at($large) {
    width: 20%;
  }
}


// ----------------------------------------
// Desktop Navigation
// ----------------------------------------

.desktop-navigation {
  flex-grow: 1;
  width: 80%;
  display: flex;
  align-items: center;
  justify-content: center;

  @include stop-at($header-breakpoint) {
    display: none;
  }

  @include start-at($header-breakpoint) {
    width: 50%;
  }

  @include start-at($large) {
    width: 60%;
  }

  li {
    margin-left: 14px;

    @include stop-at($header-breakpoint) {
      margin: 0 14px;
    }

    &:first-child {
      margin-left: 0;
    }

    @include start-at(1600px) {
      margin-left: 24px;
    }
  }

  .has-sub-nav > div,
  > li > a {
    position: relative;
    font-size: 16px;
    color: currentColor;
    font-family: $sans-serif;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 12px 4px;
    transition: color $trans;
    position: relative;
    text-decoration: none;

    @include start-at(1600px) {
      font-size: 18px;
    }
  }

  li.is-active,
  li.is-parent {
    a {
      color: $white;

      &:before {
        opacity: 1;
        transform: translate3d(-6px, 0, 0);
      }
      &:after {
        opacity: 1;
        transform: translate3d(6px, 0, 0);
      }
    }
  }
}

.desktop-navigation > li > a,
.mobile-navigation a {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 12px 4px;

  &:before,
  &:after {
    content: '{';
    color: $brand;
    display: block;
    font-weight: 500;
    opacity: 0;
    transition: transform $trans, opacity $trans;
  }

  &:after {
    content: '}';
  }

  &:hover {
    color: var(--color-scale-gray-8);

    &:before {
      opacity: 1;
      transform: translate3d(-6px, 0, 0);
    }
    &:after {
      opacity: 1;
      transform: translate3d(6px, 0, 0);
    }
  }
}

.desktop-navigation li.is-active a:not(.btn-alt),
.mobile-navigation li.is-active a:not(.btn) {
  &:before {
    opacity: 1;
    transform: translate3d(-6px, 0, 0);
  }
  &:after {
    opacity: 1;
    transform: translate3d(6px, 0, 0);
  }
}


// ----------------------------------------
// utility
// ----------------------------------------

.site-header__utility {
  display: flex;
  justify-content: flex-end;
  align-items: center;

  .btn-alt {
    height: 44px;
    padding: 0 12px;
    min-width: 168px;

    @include stop-at($header-breakpoint) {
      display: none;
    }
  }

  .has-sub-nav {
    position: relative;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    padding: 8px 0;

    &.mr-3 {
      .sub-nav {
        width: 200px;
      }
    }
  }

  @include start-at($header-breakpoint) {
    width: 25%;
  }

  @include start-at($large) {
    width: 20%;
  }
}

// ----------------------------------------
// Slide out Panel
// ----------------------------------------

.navigation-drawer {
  position: fixed;
  height: 100%;
  width: 100%;
  right: 0;
  background: rgba($black, 0.96);
  background: url('../img/direction/static.jpg') center / cover no-repeat;
  z-index: 10;
  bottom: $header-height;
  top: $header-height;
  padding-bottom: $header-height;
  overflow-x: hidden;
  overflow-y: auto;
  pointer-events: none;
  transition: transform $trans, opacity $trans;
  transform: translate3d(100%, 0, 0);

  @include start-at($header-breakpoint) {
    max-width: 432px;
  }

  @include start-at($header-breakpoint) {
    display: none !important;
    border: 0;
    clip: rect(0 0 0 0);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
  }

  &:after {
    content: '';
    width: 180px;
    height: 180px;
    position: absolute;
    bottom: 72px;
    right: -24px;
    background: url('../img/direction/orb-blue.svg') center / cover no-repeat;
    z-index: -1;
    transform: rotate(-45deg);
  }

  > div {
    min-height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0 32px;

    @include start-at($medium) {
      padding: 0 44px;
    }

    @include start-at($large) {
      padding: 0 52px;
    }
    @include start-at($xlarge) {
      padding: 0 68px;
    }
    @include start-at(1600px) {
      padding: 0 72px;
    }

    .btn {
      width: 100%;
      margin: 48px 0;
    }
  }

  hr {
    background: $border;
  }

  .menu-is-active & {
    opacity: 1;
    pointer-events: inherit;
    transform: translate3d(0, 0, 0);
  }
}

.mobile-navigation {
  text-align: right;
  padding: 40px 0;
  flex-grow: 1;

  a {
    font-size: 24px;
    font-weight: 700;
    color: $white;
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    padding: 4px 0;
    transition: color $trans;

    svg {
      fill: currentColor;
      margin-right: 8px;
    }
  }

  li {
    margin-bottom: 12px;
  }

  li.is-active,
  li.products li.is-active,
  li.products.is-active,
  li.current-menu-item {
    a {
      color: $white;
    }
  }
}


// ----------------------------------------
// Menu Is Open
// ----------------------------------------
.menu-is-active {
  overflow: hidden;

  .menu-mask {
    display: block;
    position: absolute;
    z-index: 8;
    top: 0;
    bottom: 0;
    right: 0;
    left: 0;
    opacity: 1;
    background: rgba(0,0,0,0.4);
  }
}




// ----------------------------------------
// Sub Menu
// ----------------------------------------

.has-sub-nav {
  position: relative;

  > div {
    display: flex;
    align-items: center;
    justify-content: center;

    svg, img {
      margin: 4px 0 0 8px !important;
    }
  }

  &:hover {
    cursor: pointer;

    .sub-nav {
      display: block;
      visibility: visible;
    }
  }
  &:focus,
  &.is-active {
    .sub-nav {
      display: block;
      visibility: visible;
    }
  }
  > a:focus {
    + .sub-nav {
      display: block;
      visibility: visible;
    }
  }
}

.site-header.is-focused {
  .sub-nav {
    visibility: visible;
  }
  .navigation-drawer {
    opacity: 1;
    pointer-events: inherit;
  }
}

.sub-nav {
  position: absolute;
  background: #161D27;
  padding: 24px 18px;
  width: 368px;
  text-align: left;
  left: 0;
  //transform: translate3d(-50%, 0, 0);
  top: 100%;
  border-radius: 8px;
  display: none;
  visibility: hidden;
  background: white;

  &.sub-nav--sm {
    width: 220px;
    padding: 18px;
  }
  
  &.is-active {
    visibility: visible;
  }

  &:focus,
  &:hover {
    visibility: visible;
  }

  li {
    margin: 0 !important;

    + li {
      margin-top: 2px !important;
    }
  }

  .bold-link {
    border-top: 1px solid #C4C4C4;
    margin-top: 8px !important;
    padding-top: 8px;
    a {
      font-weight: bold;
    }
  }
  a,
  li > span {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    font-size: 16px !important;
    height: auto !important;
    justify-content: flex-start !important;
    padding: 4px !important;
    color: $black !important;
    transition: opacity $trans;

    img {
      max-width: 88px;
      margin-left: 6px;
    }

    &:before,
    &:after {
      display: none !important;
    }

    &:hover {
      opacity: 0.6;
    }
  }

  li > span {
    cursor: default !important;

    &:hover {
      opacity: 1 !important;
      cursor: default !important;
    }
  }

  li.is-active {
    a {
      opacity: .6;
    }
  }
}




// ----------------------------------------
// Sub Menu
// ----------------------------------------

.burger {
  position: relative;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;

  @include start-at($header-breakpoint) {
    display: none;
  }

  svg {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate3d(-50%, -50%, 0);
  }

  span {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate3d(-50%, -50%, 0);
    transition: opacity 0.4s ease;
  }
  .open {
    opacity: 0;

    img {
      width: 16px;
      margin: 0 auto;
    }
  }
  .closed {
    opacity: 1;
  }
  &:hover {
    cursor: pointer;
  }

  .menu-is-active & {
    .open {
      opacity: 1;
    }
    .closed {
      opacity: 0;
    }
  }
}
