$header-icon-size: 40px;
$header-logo-h: 50px;
$header-logo-w: 117px;
$header-height: 3.725em;

%header-base {
  position: fixed;
  width: 100%;
  z-index: $zIndex-10;
  padding: 0 1em;
  height: $header-height;

  @include gmq(ipad) {
    position: absolute;
  }

  .vinli-icon {
    width: $header-icon-size;
    height: $header-icon-size;
  }

  .vinli-logo {
    width: $header-logo-w;
    height: $header-logo-h;
  }
}

%header-dark {
  background: palette(gray, xx-dark);
  color: white;
}

%header-light {
  background: $white;
  color: palette(gray, light);
  box-shadow: 0 0 5px 0 red inset;
}

%header-flex {
  display: flex;
  align-items: center;
}

.portal-info {
  display: flex;
  align-items: center;
  order: -1;
}

.portal-name {
  padding: 0 1em;

  @include gmq(desk) {
    border-right: 1px solid palette(gray);
  }
}

// Header Navigation //
%header-nav-list {
  margin: 0;
  padding: 0;
}

%header-nav-item {
  list-style: none;
}

%header-nav-link {
  color: rgba($white, 0.7);
  text-decoration: none;
  white-space: inherit;
  word-break: none;

  &:hover {
    color: palette(blue, light);
  }

  &.active {
    color: $white;
  }
}

.nav {

  // Nav List
  &__list {
    @extend %header-nav-list;

    @include gmq(desk) {
      align-items: center;
      display: flex;
    }
  }

  // Nav Item
  &__item {
    @extend %header-nav-item;

    @include gmq(portable) {
      align-items: center;
      border-bottom: 1px solid rgba(black, 0.2);
      box-shadow: 0 1px 0 rgba(white, 0.1) inset;
      min-height: 60px;
      padding: 1em;
      position: relative;
    }

    @include gmq(desk) {
      align-self: center;
    }

    &--current-device {
      .nav__link {
        display: inline-block;
      }
    }
  }

  // Nav Link
  &__link {
    @extend %header-nav-link;

    @include gmq(portable) {
      @include abs-overlay;

      display: flex !important;
      align-items: center;
      padding: 1em;
    }

    @include gmq(desk) {
      padding: 1em;
      flex: 1;
      justify-content: space-around;
    }
  }

  // Secondary Nav Pushes to the right
  &--secondary {
    margin-left: auto;

    @include gmq(portable) {
      margin-bottom: 4.3em;
    }
  }
}

// Off Canvas for Responsive Menu
.off-canvas {
  display: flex;
  align-items: center;

  @include gmq(desk) {
    width: 100%;
  }

  @include gmq(portable) {
    background: palette(gray, x-light);
    flex-direction: column;
    min-height: 100vh;
    overflow: auto;
    position: absolute;
    top: 0;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    width: $mobile-nav-width;
    z-index: $zIndex-9;

    &--dark {
      background: palette(gray, xx-dark);
    }

    > div,
    nav {
      width: 100%;
    }

    &--left {
      left: 0;
    }

    &--right {
      right: 0;
    }

    &--open {
      transform: translateX(0);

      .nav__item {
        &:nth-child(1) {
          .nav__link {
            animation-delay: 0.05s;
          }
        }

        &:nth-child(2) {
          .nav__link {
            animation-delay: 0.1s;
          }
        }

        &:nth-child(3) {
          .nav__link {
            animation-delay: 0.15s;
          }
        }

        &:nth-child(4) {
          .nav__link {
            animation-delay: 0.2s;
          }
        }
      }

      .nav__link {
        animation-duration: 0.3s;
        animation-fill-mode: both;
        animation-name: fadeInLeftShort;
      }
    }
  }

  @include gmq(ipad) {
    width: $mobile-nav-width--sm;
  }
}

// Container to wrap things that only show in portable views
.vinli-app__header {
  transition: transform 0.3s ease;

  .container {
    position: relative;
    display: flex;

    @include gmq(desk) {
      display: none;
    }
  }

  &.nav-open {
    transform: translateX($mobile-nav-width);

    @include gmq(ipad) {
      transform: translateX($mobile-nav-width--sm);
    }
  }

  .btn--back {
    animation-duration: 0.3s;
    animation-fill-mode: both;
    animation-name: fadeInLeftShort;
    padding-left: 0;

    .icon-arrow-left {
      fill: $white;
    }
  }
}

// Route Name (context for portable views)
.route-name {
  @include font-primary;

  @include gmq(portable) {
    text-align: center;
    font-size: 1em;
    font-weight: 100;

    @include center();
  }

  @include gmq(desk) {
    display: none;
  }
}

@include gmq(portable) {
  .sign-up {
    width: 100%;
    font-size: 1em;
  }
}

// Nav Toggle
$button-size: 20px;
$line-color: white;

@mixin line() {
  background: $line-color;
  border-radius: $button-size / 14;
  display: inline-block;
  height: $button-size / 7;
  transition: all 0.5s cubic-bezier(0.3, 0, 0, 1.3);
  user-select: none;
  width: $button-size;
}

.nav__toggle {
  appearance: none;
  background: transparent !important;
  border-radius: $button-size / 7;
  border: none;
  cursor: pointer;
  padding: 11px 7px 15px;
  top: 0;
  transition: 0.3s;
  user-select: none;
  z-index: $zIndex-10;

  @include gmq(portable) {
    animation-duration: 0.3s;
    animation-fill-mode: both;
    animation-name: fadeInRightShort;
    display: inline-block;
  }

  @include gmq(desk) {
    display: none;
  }

  &:focus {
    outline: 0;
  }

  &__lines,
  &__lines::before,
  &__lines::after {
    @include line;
  }

  &__lines {
    position: relative;

    &::before,
    &::after {
      content: '';
      left: 0;
      position: absolute;
      transform-origin: 50%;
    }

    &::before {
      top: $button-size / 4;
    }

    &::after {
      top: -$button-size / 4;
    }
  }

  &--close {
    .nav__toggle__lines {
      background: transparent;

      &::before,
      &::after {
        transform-origin: 50% 50%;
        top: 0;
        width: $button-size;
      }

      &::before {
        transform: rotate3d(0, 0, 1, 405deg);
      }

      &::after {
        transform: rotate3d(0, 0, 1, -405deg);
      }
    }
  }
}

// The brand-block is a colored square behind the logo
// to signify which demographic the app is for
// i.e. Consumer, Developer, Enterprise, OEM, etc.
%brand-block {
  display: flex;
  padding: 0.6em;
}

@each $theme, $color in $ui-colors {
  .brand-block--#{$theme} {
    @extend %brand-block;

    background: $color;
    border-bottom: 1px solid $color;

    .vinli-icon {
      @include gmq(portable) {
        width: 38px;
        height: 38px;
      }
    }
  }
}
