/*------------------------------------*\
  Components > Site Navigation
\*------------------------------------*/

.c-nav {
  @include mq($from: tablet) {
    position: relative;
    z-index: 1;
    display: inline-block;
    line-height: 1;
    background-color: $color-white;
    padding: 0px double($base-spacing-unit);

    &-wrap {
      text-align: center;

      &:after {
        content: '';
        position: absolute;
        height: 1px;
        background-color: $color-border;
        width: 100%;
        top: 50%;
        left: 0px;
      }
    }
  }

  .menu-item {
    position: relative;
    display: block;
    font-size: $font-size-small;
    letter-spacing: 1px;

    .rtl & {
      letter-spacing: unset;
    }

    &:not(:last-child) {
      @include mq($from: tablet) {
        margin-right: half($base-spacing-unit);
      }

      @include mq($from: desktop) {
        margin-right: $base-spacing-unit;
      }
    }

    @include mq($from: tablet) {
      display: inline-block;
    }

    &.current_page_item {
      a {
        color: $color-brand;

        .home &:not(:hover) {
          color: $color-link;
        }
      }
    }
  }

  ul {
    @extend .o-plain-list;

    @include mq($from: tablet) {
      li { display: inline-block; }
    }
  }

  @include mq($until: tablet) {
    .sub-menu {
      padding-right: 0;
      padding-left: $base-spacing-unit;
    }
  }

  @include mq($from: tablet) {

    .menu-item-has-children {
      > a {
        padding-right: half($base-spacing-unit) + quarter($base-spacing-unit);

        &:after {
          content: '';
          position: absolute;
          top: 2px;
          left: auto;
          right: 0;
          width: 6px;
          height: 6px;
          border: solid $color-text;
          border-width: 0 1px 1px 0;
          transform: rotate(45deg);
        }
      }

      &:hover > .sub-menu {
        display: block;
        opacity: 1;
        visibility: visible;
      }
    }

    .sub-menu {
      opacity: 0;
      visibility: hidden;
      position: absolute;
      top: double($base-spacing-unit);
      left: 0;
      right: auto;
      z-index: 1000;
      min-width: 220px;
      text-align: left;
      background-color: $bg-white;
      transition: opacity $global-transition;
      border-radius: double($global-border-radius);
      box-shadow: 0 4px 20px rgba($color-gray, .25);
      padding: half($base-spacing-unit) ($base-spacing-unit + half($base-spacing-unit));

      @include mq($from: tablet) {
        &:before {
          content: '';
          display: block;
          width: 14px;
          height: 14px;
          background-color: $color-white;
          position: absolute;
          top: -7px;
          left: half($base-spacing-unit) + $base-spacing-unit;
          transform: rotate(45deg);
        }
      }

      .menu-item {
        display: block;
        margin-right: 0;

        &:not(:last-child) {
          border-bottom: 1px solid $color-border;
        }

        &.menu-item-has-children > a:after {
          right: auto;
          left: auto;
          top: 50%;
          right: 0;
          transform: rotate(-45deg) translate(0, -50%);
        }

        a {
          display: block;
          color: $color-gray;
          font-weight: $font-weight-regular;

          .rtl & {
            font-weight: $font-weight-bold;
          }

          @include attention() {
            color: $color-brand;
          }
        }
      }

      .sub-menu {
        top: 0;
        left: 100%;
        border-left: 1px solid $color-border;
        box-shadow: 0 10px 70px 10px rgba($color-gray, .2);
        padding: quarter($base-spacing-unit) ($base-spacing-unit + half($base-spacing-unit));

        @include mq($from: tablet) {
          &:before {
            display: none;
          }
        }
      }
    }
  } // $from: tablet

  a {
    padding: $base-spacing-unit 0;
    transition: $global-transition;
    font-weight: $font-weight-medium;

    .rtl & {
      font-weight: $font-weight-bold;
    }

    @include mq($until: tablet) {
      display: block;
      padding: half($base-spacing-unit) 0;
      border-bottom: 1px solid $color-border;
    }

    @include attention() {
      color: $color-brand;
      text-decoration: none;
    }
  }
}