//
// Navigation
// --------------------------------------------------
//

// Primary navigation and subnav


// Shared nav item styles
.nav-item {
  color: $black;
  display: block;
  position: relative;
  flex-shrink: 0;
  font-family: $Roboto;
  padding: map-get($spacing, 3);
  font-size: 1.5rem;

  &:hover, &:focus {
    text-decoration: none;;
  }

  &:hover {
    font-weight: 700;
  }

  // this reserves space for the bold version that appears on hover
  &:before {
    display: block;
    content: attr(title);
    font-weight: bold;
    height: 1px;
    color: transparent;
    overflow: hidden;
    visibility: hidden;
    margin-bottom: -1px;
  }
}

// top-level nav items
.nav {
  & > .nav-item {
    text-align: center;

    .nav-item {
        padding: map-get($spacing, 1) map-get($spacing, 3);
    }
  }

  // top-level and subnav
  .nav-item:hover {
    color: $red;
  }

  >.nav-item {

    &:not(.has-subnav):hover,
    &--active {
      font-weight: bold;
  
      &:after {
        background: $red;
        content: "";
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        height: 5px;
      }
    }
  }
}

// Secondary navigation and subnav
.nav--secondary .nav-item {
  text-align: center;

  &:not(:hover):not(.nav-item--active) {
    &.theme-text,
    &.theme-text-alt {
      color: $black !important;
    }
  }
}

// subnav chevron
.subnav-icon {
  cursor: pointer;
  display: inline-block;
  margin-left: 2px;
  padding: 1rem;
  position: relative;
  transform: scale(0.7);

  &::before,
  &::after {
    background: $white;
    bottom: 0;
    content: '';
    display: block;
    height: 0.2rem;
    margin: auto;
    position: absolute;
    top: 0;
    transition: transform 0.2s cubic-bezier(0.8, 0.2, 0.5, 0.1);
    width: calc(50% + 0.1875rem);
  }

  &::before {
    left: 0;
    transform: rotate(45deg);
  }

  &::after {
    right: 0;
    transform: rotate(-45deg);
  }
}

// subnav-level nav items, only currently appears on primary nav
.has-subnav {
  position: relative;

  &:hover, &:focus {
    .subnav {
      display: block;
    }
  }

  .nav-item--active {
    color: $red;
  }

  .subnav-toggle:hover {
    font-weight: 700;
  }

  &:hover,
  &.subnav-focus {
    .subnav-icon {
      &::before {
        transform: rotate(-45deg);
      }

      &::after {
        transform: rotate(45deg);
      }
    }

    .subnav {
      opacity: 1;
      visibility: visible;
    }
  }
}

// subnav container
.subnav {
  opacity: 0;
  padding: 2rem 4rem 3rem;
  transition: all 0.4s ease-in-out;
  visibility: hidden;
  white-space: nowrap;

  .nav-item {
    font-weight: normal;
    font-size: $text-7;
    margin-bottom: 1rem;
    padding: 0.5rem 1rem !important;

    &:hover {
      font-weight: normal;
    }
  }
}
