//
// Navs
// --------------------------------------------------
// scss-lint:disable NestingDepth

// Base class
// --------------------------------------------------

.nav {
  @include clearfix();

  margin-bottom: 0;
  padding-left: 0; // Override default ul/ol
  list-style: none;

  > li {
    position: relative;
    display: block;

    > a {
      position: relative;
      display: block;
      padding: $nav-link-padding;

      &:hover,
      &:focus {
        text-decoration: none;
        background-color: $nav-link-hover-bg;
      }
    }

    // Disabled state sets text to gray and nukes hover/tab effects
    &.disabled > a {
      color: $nav-disabled-link-color;

      &:hover,
      &:focus {
        color: $nav-disabled-link-hover-color;
        text-decoration: none;
        background-color: transparent;
        cursor: not-allowed;
      }
    }
  }

  // Open dropdowns
  .open > a {
    &,
    &:hover,
    &:focus {
      background-color: $nav-link-hover-bg;
      border-color: $link-color;
    }
  }
}

// Off-canvas/hoverable navigation
// -----------------
.nav-main {
  @include clearfix();
  @include font-family-proxima-nova();

  display: flex;
  align-items: baseline;
  flex-basis: map-get($nav-default, nav-width);

  .no-flexbox.no-flexboxlegacy & {
    float: left;
    width: 80%;
  }
}

.nav-container,
.nav-section {
  display: flex;
  flex: 1;
  max-width: 100%;

  .no-flexbox.no-flexboxlegacy & {
    float: left;
  }
}

.nav-container {
  @media (min-width: $header-breakpoint) {
    flex-direction: row;
  }

  @media (max-width: $header-breakpoint - 1) {
    flex-direction: column;
  }

  .no-flexbox.no-flexboxlegacy & {
    width: 100%;
  }
}

.nav-section {
  flex-direction: column;

  .no-flexbox.no-flexboxlegacy &.nav-section-last {
    float: right;
  }
}

.nav-section-content {
  @extend %container;
}

.nav-section-action {
  @include header-link-color();
  @include header-link-padding();

  z-index: $z-index-nav-action;

  h3 {
    margin-top: 0;
    margin-bottom: 0;
    font-weight: $font-weight-base;
    font-size: $font-size-small;
  }

  .no-flexbox & {
    display: block;
  }
}

.nav-subsection {
  @include make-row(0);

  .ruled-list {
    > *:first-child {
      padding-top: 0;
    }

    > *:last-child {
      padding-bottom: 0;
    }
  }
}

.nav-detail-header {
  h4 {
    font-size: $h3-font-size;
    margin-bottom: $line-height-base / 4;
  }
}

// Off-canvas navigation
// ---------------------
@media (max-width: $header-breakpoint - 1) {
  $section-padding: .5rem;

  .nav-main {
    @include off-canvas();

    &::after {
      // HACK: this is to expose the layout to JavaScript for deciding whether
      //       nav-sections should collapse (yes on off-canvas, no otherwise)
      content: 'off-canvas';
      display: none;
    }
  }

  // HACK: clearing the badge when the menu is open
  .nav-toggle[aria-expanded="true"] [data-pinned-badge]::after {
    display: none;
  }

  .nav-container {
    flex-basis: 100%;
    // HACK: adding padding here to keep the bottom of the menu on-screen
    padding-bottom: 50%;
  }

  .nav-section-action {
    $border-config: ('border-color': transparent);
    @include header-border-left(map-merge($header-default, $border-config));

    border-bottom: 1px solid map-get($nav-default, nav-section-border);
    padding-top: $line-height-base;
    padding-bottom: $line-height-base;

    &[aria-expanded="true"] {
      border-left-color: map-get($header-default, 'border-color');
    }
  }

  .nav-section-content {
    background-color: map-get($nav-default, nav-drawer-bg);
    padding: $section-padding;
    width: 100%;
  }

  .nav-subsection {
    background-color: map-get($nav-default, nav-content-bg);

    + .nav-subsection {
      margin-top: $section-padding;
    }
  }
}


// Hoverable navigation
// --------------------
@media (min-width: $header-breakpoint) {
  .nav-section:last-child {
    align-items: flex-end;
  }

  .nav-section-action {
    $border-config: ('border-color': transparent);
    @include header-border-top(map-merge($header-default, $border-config));

    text-align: center;
  }

  .nav-section.is-active .nav-section-action,
  .nav-section:hover .nav-section-action {
    background-color: map-get($nav-default, nav-content-bg);
    border-top-color: map-get($header-default, 'border-color');
    border-bottom: 5px solid transparent;
    margin-bottom: -$header-border-width;
    z-index: $z-index-nav-action + 1;
  }

  .nav-section-content {
    @include header-border-top($header-default);

    position: absolute;
    left: 0;
    top: 100%;

    z-index: $z-index-nav-content;
    box-shadow: map-get($nav-default, nav-content-shadow);
    background: map-get($nav-default, nav-content-bg);

    // Override hard-coded height from collapse plugin
    // scss-lint:disable ImportantRule
    height: auto !important;
    padding: map-get($nav-default, nav-content-padding);

    &.nav-section-content-pin-right {
      left: auto;
      right: 0;
    }

    // HACK: Fix for iOS < 7 to make the browser respect our z-index
    .no-flexbox.flexboxlegacy & {
      transform: translateZ(1px);
    }
  }

  .nav-subsection {
    width: 50%;
  }

  .no-js .nav-section:hover,
  .nav-section.is-active {
    .nav-section-content {
      display: block;
    }
  }
}



// Tabs
// -------------------------

// Give the tabs something to sit on
.nav-tabs {
  border-bottom: 1px solid $nav-tabs-border-color;

  > li {
    float: left;
    // Make the list-items overlay the bottom border
    margin-bottom: -1px;

    // Actual tabs (as links)
    > a {
      margin-right: 2px;
      line-height: $line-height-base-ratio;
      border: 1px solid transparent;
      border-radius: $border-radius-base $border-radius-base 0 0;

      &:hover {
        border-color: $nav-tabs-link-hover-border-color $nav-tabs-link-hover-border-color $nav-tabs-border-color;
      }
    }

    // Active state, and its :hover to override normal :hover
    &.active > a {
      &,
      &:hover,
      &:focus {
        color: $nav-tabs-active-link-hover-color;
        background-color: $nav-tabs-active-link-hover-bg;
        border: 1px solid $nav-tabs-active-link-hover-border-color;
        border-bottom-color: transparent;
        cursor: default;
      }
    }
  }
}


// Pills
// -------------------------
.nav-pills {
  > li {
    float: left;

    // Links rendered as pills
    > a {
      border-radius: $nav-pills-border-radius;
    }

    + li {
      margin-left: 2px;
    }

    // Active state
    &.active > a {
      &,
      &:hover,
      &:focus {
        color: $nav-pills-active-color;
        background-color: $nav-pills-active-bg;
      }
    }
  }
}


// Stacked pills
.nav-stacked {
  > li {
    float: none;

    + li {
      margin-top: 2px;
      margin-left: 0; // no need for this gap between nav items
    }
  }
}


// Nav variations
// --------------------------------------------------

// Justified nav links
// -------------------------

.nav-justified {
  width: 100%;

  > li {
    float: none;

    > a {
      text-align: center;
      margin-bottom: 5px;
    }
  }

  > .dropdown .dropdown-menu {
    top: auto;
    left: auto;
  }

  @media (min-width: $screen-sm-min) {
    > li {
      display: table-cell;
      width: 1%;

      > a {
        margin-bottom: 0;
      }
    }
  }
}

.nav-justified.nav-tabs {
  // Move borders to anchors instead of bottom of list
  border-bottom: 0;

  > li > a {
    // Override margin from .nav-tabs
    margin-right: 0;
    border-radius: $border-radius-base;
  }

  > .active > a,
  > .active > a:hover,
  > .active > a:focus {
    border: 1px solid $nav-tabs-justified-link-border-color;
  }

  @media (min-width: $screen-sm-min) {
    > li > a {
      border-bottom: 1px solid $nav-tabs-justified-link-border-color;
      border-radius: $border-radius-base $border-radius-base 0 0;
    }

    > .active > a,
    > .active > a:hover,
    > .active > a:focus {
      border-bottom-color: $nav-tabs-justified-active-link-border-color;
    }
  }
}



// Tabbable tabs
// -------------------------

// Hide tabbable panes to start, show them when `.active`
.tab-content {
  > .tab-pane {
    display: none;
  }

  > .active {
    display: block;
  }
}


// Dropdowns
// -------------------------

// Specific dropdowns
.nav-tabs .dropdown-menu {
  // Remove the top rounded corners here since there is a hard edge above the menu
  @include border-top-radius(0);

  // make dropdown border overlap tab border
  margin-top: -1px;
}
