@import "../pages/mixins";

.nav {
  width: 100%;
  margin: 0 auto 30px;
  padding: 0 var(--gutter);

  &.nav-dark {
    background-color: var(--black);
    margin: 0 auto 0px;
  }

  & .nav-container {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-start;

    & img {
      display: block;
      width: 100%;
    }

    & .l-col {
      flex: 1;
      padding: var(--gutter) 0 0;
    }

    /* logo link */
    & .logo {
      @add-mixin nav-logo;
      /* positioning */
      position: absolute;
      top: 23px;
      left: 36px;
    }

    & .r-col {
      flex: 1;
      padding: 20px 0 0;
      text-align: right;
    }

    & .menu-button {
      & .menu-open-btn {
        display: block;
        width: 22px;
        transition: opacity 0.2s;
        opacity: 0.8;
        /* fudge into place */
        top: 1px;

        &:hover {
          text-decoration: none;
          opacity: 1;
        }
      }
    }

    & .nav-search-toggle {
      display: block;
      margin-left: auto;

      /* icon placement */
      & .nav-search-icon {
        display: inline-block;
        vertical-align: middle;
        width: 1.5rem;
        /* fudge into place */
        top: -1px;

        /* fudge into place on bigger screens */
        @add-mixin from-xl {
          top: -0.25rem;
        }
      }

      /* label theming */
      & .nav-search-label {
        /* positioning */
        line-height: 4; /* vertically align with menu toggle */
        margin: 0.75em;
        /* transitions */
        opacity: 0.75;
        transition: opacity 0.3s ease;
        color: var(--white) !important; /* blueprint override */
      }

      /* interactions */
      &:hover, &:focus {
        text-decoration: none;

        & .nav-search-label {
          opacity: 1;
          color: var(--white); /* blueprint override */
        }
      }
    }

    & .nav-search-toggle.toggle-nav {
      margin-top: calc(var(--gutter)/2);
    }

    & .nav-search-toggle.toggle-input,
    & .nav-search-container {
      display: none;
    }
  }

  & .title-container {
    margin: var(--gutter) auto;

    /* bring closer to nav */
    @add-mixin from-lg {
      width: calc(100% - 20rem);
      margin-top: -0.5rem;
    }

    & .nav-title {
      width: 100%;
      text-align: center;

      /* main page title */
      & h1 {
        @add-mixin font-xxl;
        color: var(--white);
      }

      & .meta-title {
        white-space: nowrap;

        & .icon-container {
          display: inline-block;
          vertical-align: top;
          margin-right: 5px;
          width: 30px;
          height: 30px;
          background-color: var(--white);
          border-radius: 50%;

          & .icon {
            display: block;
            margin: 7px auto;
            height: 16px;
          }
        }
      }
    }
  }
}

.subnav {
  z-index: 100;
  padding: calc(var(--gutter) * 0.75) var(--gutter);
  width: 100%;
  color: var(--white);
  background-color: var(--black);
  box-shadow: 0 0 2rem rgba(0, 0, 0, 0.25);
  /* transitions */
  will-change: opacity, transform;
  transition:
    opacity 0.2s ease-out,
    transform 0.3s ease-out;

  &.hidden {
    left: 0; /* override canon */
    opacity: 0;
    transform:
      translateX(-100%)
      rotateY(140deg);
  }

  /* sidebar layout on bigger screens */
  @media (min-width: 600px) {
    max-width: 28rem;
  }

  & .button-set-container {
    display: flex;
    flex-direction: row;
    align-items: center;
    margin-bottom: 1.5rem;
    top: -1px; /* fudge into place */
  }

  & .menu-close-btn {
    display: inline-block;
    padding: 0;
    margin-right: 1em;
    width: 22px;
  }

  & .home-link {
    @add-mixin nav-logo;
    /* positioning */
    flex: 1 0 auto;

    /* if home page */
    &.is-active {
      opacity: 1;
    }

    /* sizing is fussy because of flex */
    & .home-link-img {
      width: 96px;
      min-width: 96px;
    }
  }

  & .lang-selector {
    @add-mixin font-xs;
    @add-mixin body-font;
    line-height: 42px;
    margin-left: auto;

    & .lang {
      display: inline-block;
      padding: 0 0.5em;
      text-decoration: none;
      color: inherit;

      &.current,
      &:hover {
        text-decoration: underline;
        opacity: 1;
      }

      &.other {
        transition: opacity 0.2s;
        opacity: 0.8;
      }
    }

    &:hover .lang {
      opacity: 0.8;
      text-decoration: none;

      &:hover {
        text-decoration: underline;
        opacity: 1;
      }
    }
  }

  /* subnav search */
  & .search-sidebar {

    /* remove excess padding */
    & .search-input {
      padding-right: 1em;
    }
  }

  & .subnav-subtitle {
    @add-mixin font-uppercase;
    margin-top: 2em;
  }

  & .subnav-list,
  & > ul {
    @add-mixin font-xs;
    list-style: none;
    padding: 0;
    margin: 0;
    @add-mixin body-font;
    line-height: 18px;
    text-transform: uppercase;
    color: var(--white);

    & a,
    & .subnav-link {
      /* typography */
      @add-mixin heading-font;
      @add-mixin font-smoothing;
      @add-mixin font-uppercase;
      text-decoration: none;
      /* sizing */
      display: block;
      line-height: 2;
      /* theming */
      color: var(--white); /* override default link style */
      /* border */
      border-left-width: 4px;
      border-left-style: solid;
      padding-left: 0.75em;
      /* fudge into place */
      margin-left: 1px;
      /* transitions */
      opacity: 0.75;
      transition:
        opacity 0.15s ease-out,
        border 0.15s ease-out,
        color 0.15s ease-out;

      /* white border & text color if no theme applied */
      &:not([class*=border]) {
        border-color: var(--dark-1);
        color: var(--white);

        &:hover, &:focus {
          border-color: var(--light-3);
        }
      }

      /* hover effect */
      &:not(.link-soon) {
        &:hover, &:focus {
          opacity: 1;
        }
      }
    }

    /* coming soon...? */
    & .link-soon {
      opacity: 0.3;
      pointer-events: none;
      z-index: -1;
    }
  }
}

@add-mixin from-xx {
}

@add-mixin from-xs {
  .nav {
    & .subnav {
      width: 370px;
    }
  }
}

@add-mixin from-sm {
  .nav {
    & .nav-container {
      & .r-col {
        padding: 20px 0 0;
      }

      & .nav-search-toggle.toggle-nav {
        display: none;
      }

      & .nav-search-toggle.toggle-input {
        display: block;
        position: absolute;
        z-index: 40;
        right: 0;
      }

      & .nav-search-container {
        display: block;
        padding-left: 20px;

        & .nav-search-wrapper {
          margin-left: auto;
          width: 6em;
          will-change: width;
          transition: all 0.5s ease;

          /* fudge search input into position */
          & .search-nav {
            top: 0.25em;
          }

          /* make space for close icon */
          & .search-nav-main .search-input {
            padding-right: 50px;
          }
        }
      }

      & .nav-search {
        &.closed {
          & .nav-search-wrapper {
            opacity: 0;
          }
        }

        &.open {
          & .nav-search-label {
            opacity: 0;
          }
          & .nav-search-wrapper {
            margin-right: -15px;
            width: 100%;
            opacity: 1;
          }
        }
      }
    }
  }
}

/* tags and parent links */
.title-container .meta-title {
  text-align: center;

  & .separator {
    margin-left: 0.5em;
    margin-right: 0.5em;
  }
}

@add-mixin for-md {
  .nav-search-wrapper {
    & .search-component .input input {
      background-image: none;
      padding-left: 22px;
      padding-right: 48px;
    }
  }
}

@add-mixin from-md {
  & .subnav {
    & .nav-search-wrapper {
      padding: 0 var(--gutter-half);
    }
  }
}
