.main-nav {
  z-index: $nav;
  font-weight: 500;
  background: $white;

  .ssc {
    &-nav {
      @include make-container;
      @include make-container-max-widths;
      display: flex;
      gap: 5px;
      padding: 3px 15px;
    }

    &-line {
      height: 63px;
      border-radius: 10px;

      &:first-child {
        flex: 0 0 34px;
      }

      &:last-child {
        flex: 0 0 50px;
      }
    }
  }

  &__section + .ssc-nav {
    display: none;
  }

  &__top-offers {
    display: none;
  }

  &__back-btn {
    color: $blue;
    text-decoration: underline;

    .icon {
      margin-right: 10px;
    }
  }

  ul {
    list-style: none;
    margin-bottom: 0;
  }

  a {
    outline: none;
  }

  .icon-angle-right {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);

    [data-active-lvl='3'] & {
      display: none;
    }
  }

  &__top-level {
    padding: 0;

    &__label {
      @include link-primary;
      position: relative;
      display: block;
      padding: 15px 0;

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

  &__menu {
    padding: 0;

    &-wrapper {
      display: none;
    }

    &__overlay {
      position: absolute;
      top: 0;
      left: 0;
      height: 100%;
      width: 100%;
    }

    &__item {
      text-align: left;
    }

    &__label {
      @include link-primary;
      position: relative;
      display: block;

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

    &-banner {
      margin-bottom: 20px;

      & > div {
        background: $blue-wedgewood;
        color: $white;
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
        padding: 15px;
      }
    }
  }

  &__sub-menu {
    & > ul {
      padding: 0;
    }

    &__wrapper {
      display: none;
    }

    &__link {
      @include link-primary;
      position: relative;
      display: block;
      padding: 9px 20px;
      text-decoration: none;

      &:hover,
      &:focus,
      &:active,
      .is-hovered > & {
        color: $blue;
        text-decoration: none;
      }
    }
  }

  &__offers {
    &__label {
      @include link-primary;
      position: relative;
      display: block;
      width: 100%;
      text-decoration: none;
      text-transform: uppercase;

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

    &__title {
      display: inline-block;
      color: $white;
      font-size: 1.125rem;
      font-weight: 500;
      line-height: 30px;
      padding: 0 10px;
      background-color: $red;
    }

    &__item {
      margin: 16px 0 0;

      &-link {
        @include link-primary;
        text-decoration: none;

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

    &__img {
      position: relative;
      margin-top: 10px;

      img {
        max-width: 100%;
      }
    }
  }

  &__view-all {
    width: 100%;

    &__link {
      @include link-primary;
      display: block;
      padding: 0;
      line-height: 26px;
      font-weight: 400;
      color: $blue-dark;
    }
  }

  &__section {
    display: block;
    opacity: 0;
    animation: fade-in .5s ease-in-out forwards;

    &_order-line {
      color: $blue;
    }
  }

  &__button {
    display: block;
  }

  &__section-heading {
    color: $warm-grey;
    margin: 0 0 15px;

    &_browse {
      margin: 0;
    }

    &_order-line {
      color: inherit;
      display: inline-block;
      margin: 0 50px 0 12px;
    }
  }

  // sass-lint:disable no-vendor-prefixes
  &__overlay {
    // prevent overlay blinking in IE11
    @media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
      animation: none;
    }
  }

  &__menu__label:not(.main-nav__menu__label-last),
  &__sub-menu__link:not(.main-nav__sub-sub-menu__link-last) {
    &::after {
      content: '';
      position: absolute;
      right: 5px;
      top: 50%;
      height: 5px;
      width: 5px;
      border-color: inherit;
      border-width: 1px 1px 0 0;
      border-style: solid;
      transform: rotate(45deg) translateY(-70%);
    }
  }

  .nav-button {
    display: none;
  }
}

// prevent overlay blinking in Edge
@supports (-ms-ime-align: auto) {
  .main-nav__overlay {
    animation: none;
  }
}

// Animations
.main-nav__section.slide-in {
  animation: slide-in .3s;
}

.main-nav__section.slide-in-l2r {
  animation: slide-in-l2r .3s;
}

.fade-in {
  animation: fade-in .3s;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes slide-in {
  from {
    transform: translateX(100%);
  }

  to {
    transform: translateX(0);
  }
}

@keyframes slide-in-l2r {
  from {
    transform: translateX(-100%);
  }

  to {
    transform: translateX(0);
  }
}

// fix of mobile menu
.mobile-nav-opened > img {
  display: block;
  height: 0;
}

@include media-breakpoint-down(md) {
  .main-nav {
    display: none;
    position: absolute;
    z-index: $nav-mobile;
    top: auto;
    max-width: 380px;
    height: auto;
    width: 100%;
    padding: 20px 20px 40px;
    line-height: 20px;
    overflow: hidden;

    &__section {
      opacity: 1;
      animation: none;

      &_main {
        max-width: 100%;
        width: 100%;
      }
    }

    .ssc-nav {
      display: none;
    }

    &.js-visible {
      display: block;
    }

    &__top-level-wrap {
      margin-bottom: 20px;
    }

    &__top-offers {
      display: block;
      margin-bottom: 15px;

      &__img {
        width: 100%;
      }

      [data-active-lvl='2'] &,
      [data-active-lvl='3'] &,
      [data-active-lvl='4'] & {
        display: none;
      }
    }

    &__offers__wrapper {
      display: none !important;
    }

    &__back-btn__wrap {
      position: absolute;
      margin-bottom: 11px; // height + margin should be 35px: 24 + 11 = 35
      line-height: 24px;
      z-index: 2;
      top: 18px;
    }

    &__back-btn {
      [data-active-lvl='1'] & {
        display: none;
      }
    }

    &__section-heading_browse {
      display: none;

      [data-active-lvl='1'] & {
        display: block;
      }
    }

    .icon-angle-right {
      right: 0;
    }

    &__top-level {
      margin-bottom: 20px;
    }

    &__top-level__item {
      &:first-child {

        & .main-nav__top-level__label {
          border-top: 1px dashed $blue-dark;
        }

        & .main-nav__top-level__label--invert {
          border-top: 0;
        }
      }

      &.js-visible {
        border: 0;
      }

      [data-active-lvl='2'] &:not(.js-visible),
      [data-active-lvl='3'] &:not(.js-visible),
      [data-active-lvl='4'] &:not(.js-visible) {
        display: none;
      }
    }

    &__top-level__label {
      font-size: 16px;
      font-weight: 700;
      color: $blue-dark;
      border-bottom: 1px dashed $blue-dark;

      [data-active-lvl='2'] & {
        color: $gray-dark;

        & > .icon-angle-right {
          display: none;
        }
      }

      [data-active-lvl='3'] &,
      [data-active-lvl='4'] & {
        display: none;
      }
    }

    &__menu-wrapper {
      .js-visible > & {
        display: block;
      }
    }

    &__menu__item {
      border-bottom: 1px dashed $blue-dark;

      &:first-child {
        border-top: 1px dashed $blue-dark;
      }

      [data-active-lvl='3'] &:not(.js-visible),
      [data-active-lvl='4'] &:not(.js-visible) {
        display: none;
      }

      &.js-open > div {
        display: block;
      }

      &.js-visible {
        background: $white;
        margin: 0 -30px;
        padding: 0 30px;
      }
    }

    &__menu__label {
      padding: 20px 0;
      font-size: 16px;
      font-weight: 700;
      color: $blue-dark;

      [data-active-lvl='3'] & {
        color: $gray-dark;

        & > .icon {
          display: none;
        }
      }

      .js-open > &::after {
        right: 3px;
        top: calc(50% - 5px);
        transform: rotate(135deg);
      }

      &--invert:not(.main-nav__menu__label-last),
      &.active {
        margin: -1px -20px;
        padding: 20px;
        border: 0;

        &::after {
          right: 25px;
        }

        .js-open > & {
          margin-bottom: 10px;
        }
      }

      &.active {
        background-color: $blue-dark;
        color: $white;
      }

      &.active.green {
        background-color: #5c7b1e !important;
      }

      &.active.red {
        background-color: #7c0009 !important;
      }

      &:hover:not(.active),
      &:active:not(.active),
      &:focus:not(.active) {
        color: $blue-dark;
      }
    }

    &__sub-menu {
      margin-top: -15px;
      padding-left: 10px;

      .js-visible {
        .main-nav__sub-menu__link {
          color: $blue-dark;

          .icon {
            display: none;
          }
        }
      }

      &__view-more {
        display: none;
      }

      &__link {
        padding: 0;
        margin-bottom: 10px;
        line-height: 26px;
        font-weight: 400;
        color: $blue-dark;

        &--invert,
        &.active {
          margin-left: -10px;
          padding-left: 10px;
        }

        &.active {
          background-color: $blue-dark;
          color: $white;
        }

        &.active.green {
          background-color: #5c7b1e !important;
        }

        &.active.red {
          background-color: #7c0009 !important;
        }
      }

      &__wrapper {
        padding: 15px 0 20px;
        outline: none;

        .js-visible > & {
          display: block;
        }
      }

      .main-nav__sub-menu__item {

        &.js-open > div {
          display: block;
        }

        &.js-open .main-nav__sub-menu__link::after {
          right: 3px;
          top: calc(50% - 5px);
          transform: rotate(135deg);
        }

        [data-active-lvl='4'] &:not(.js-visible) {
          display: none;
        }
      }

      .main-nav__menu__label {
        padding: 15px 0;

        [data-active-lvl='3'] & {
          color: $gray-dark;
        }
      }
    }

    &__section {
      position: relative;
      background-color: #ffffff;

      &:not(:first-child) {
        display: none;
        border-top: 1px solid $gray-light;

        [data-active-lvl='1'] & {
          display: block;
        }
      }

      &.is-hidden {
        display: none;
      }
    }

    &__offers {
      display: none;

      [data-active-lvl='4'] .main-nav__menu__item.js-visible & {
        display: block;
      }

      &__wrapper {
        margin-top: 15px;
      }

      &__label {
        padding: 22px 10px;
        ffont-weight: 700;
        color: $blue-dark;
        border-top: 1px solid $gray-light;

        [data-active-lvl='4'] & {
          display: none;
        }
      }
    }

    &__view-all {
      [data-active-lvl='4'] & {
        display: none;
      }
    }

    &__overlay {
      display: none;
      z-index: $main-nav-overlay;
      position: fixed;
      top: 0;
      right: 0;
      left: 0;
      bottom: 0;
      background: $black;
      opacity: .5;

      .js-visible ~ & {
        display: block;
      }
    }


    &__top-level__label {
      padding: 20px 0;

      .js-visible > & {
        text-align: center;
      }

      &::after {
        content: '';
        position: absolute;
        right: 5px;
        top: 50%;
        height: 5px;
        width: 5px;
        border-color: inherit;
        border-width: 1px 1px 0 0;
        border-style: solid;
        transform: rotate(45deg) translateY(-70%);
      }

      &--invert,
      &.active {
        margin: -1px -20px;
        padding: 20px;
        border: 0;

        &::after {
          right: 25px;
          border-color: $white;
        }
      }

      &.active {
        background-color: $blue-dark;
        color: $white;
      }

      &.active.green {
        background-color: #5c7b1e !important;
      }

      &.active.red {
        background-color: #7c0009 !important;
      }
    }

    .js-visible {
      & > .main-nav__top-level__label {
        background: transparent !important;
        margin: 0 !important;
        color: $gray-dark !important;
        border: 0;
      }

      & > .main-nav__top-level__label,
      & > .main-nav__menu__label,
      & > .main-nav__sub-menu__label {
        &::after {
          display: none;
        }
      }
    }

    &__menu__label,
    &__sub-menu__item {
      &::after {
        right: 14px;
      }
    }

    &__button {
      [data-active-lvl='2'] &,
      [data-active-lvl='3'] &,
      [data-active-lvl='4'] & {
        display: none;
      }
    }

    .nav-button-wrap {
      background-color: $gray-bg;

      .nav-button {
        padding: 5px 10px;

        &__text {
          line-height: 24px;
        }

        .rewards-counter {
          position: static;
        }
      }
    }

    .nav-button {
      display: flex;
      align-items: center;
      padding: 10px;
      margin: 10px 0;
      color: $blue-dark;
      background-color: $gray-bg;
      text-decoration: none;

      &--singin {
        margin-top: 0;
        justify-content: center;
      }

      &__icon {
        margin-right: 10px;

        svg {
          width: auto;
          height: 16px;
        }
      }

      &__text {
        font-size: 14px;
        font-weight: 500;
        line-height: 14px;
      }
    }
  }
}

@include media-breakpoint-down(sm) {
  .main-nav.main-nav {
    max-width: none;

    &__overlay {
      background-color: $white;
    }
  }
}

@include media-breakpoint-up(lg) {
  .main-nav {
    background-color: $gray-bg;
    position: relative;
    height: 70px;

    &::after {
      display: none;
      content: '';
      position: absolute;
      bottom: 1px;
      left: 0;
      right: 0;
    }

    &.is-hovered-lvl-1 {
      &::after {
        display: block;
      }
    }

    &.with-bottom-shadow {
      box-shadow: 0 1px 1px 0 $black-transparent10;
    }

    &__back-btn__wrap {
      display: none;
    }

    &__top-level {
      @include make-col-ready;
      @include make-col(12);
      display: flex;
      align-items: stretch;
      height: 70px;

      &__label {
        height: 100%;
        font-size: 12px;
        text-transform: none;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 5px;
        margin: 0 5px;
        color: $blue-dark;

        & span {
          padding: 0 13px;
        }

        .icon-angle-right {
          display: none;
        }

        &:first-child {
          margin-left: 0;
        }

        &:last-child {
          margin-right: 0;
        }

        &:hover, 
        &:focus, 
        &:active,
        .is-hovered & {
          color: $blue-dark;
          background-color: $white;
        }

        &.green:hover,
        &.green:focus,
        &.green:active,
        .is-hovered &.green {
          background-color: #5c7b1e !important;
          color: $white !important;
        }

        &.red:hover,
        &.red:focus,
        &.red:active,
        .is-hovered &.red {
          background-color: #7c0009 !important;
          color: $white !important;
        }

        &.active {
          background-color: $blue-dark;
          color: $white;
        }

        &.active.green {
          background-color: #5c7b1e !important;
        }

        &.active.red {
          background-color: #7c0009 !important;
        }
      }

      &__item {
        min-height: 1px;
        text-align: center;
      }
    }

    &__menu-wrapper {
      z-index: 1000;
      position: absolute;
      top: 100%;
      left: 15px;
      animation: fade-in .3s;
      background-color: $white;
      padding: 30px;
      margin-top: -1px;

      .is-hovered-lvl-1 .main-nav__top-level__item:hover > &,
      .is-hovered-lvl-1 .main-nav__top-level__item.is-hovered > & {
        display: block;
      }
    }

    &__menu {
      display: grid;
      padding: 0;
      gap: 30px;

      &__label {
        margin-bottom: 10px;
        padding: 0 10px;
        line-height: 24px;
        font-weight: 700;
        font-size: 16px;
        color: $blue-dark;

        &:hover,
        &:focus,
        &:active,
        .is-hovered > & {
          background-color: $blue-darker;
          color: $white;
          text-decoration: none;
        }

        &.green:hover,
        &.green:focus,
        &.green:active {
          background-color: #5c7b1e !important;
          color: $white !important;
        }

        &.red:hover,
        &.red:focus,
        &.red:active {
          background-color: #7c0009 !important;
          color: $white !important;
        }

        &.active {
          background-color: $blue-dark;
          color: $white;
        }

        &.active.green {
          background-color: #5c7b1e !important;
        }

        &.active.red {
          background-color: #7c0009 !important;
        }
      }
    }

    &__sub-menu__wrapper {
      display: block;
    }

    &__sub-menu {
      width: 100%;

      &__link {
        width: 100%;
        margin: 10px 0;
        padding: 0 10px;
        color: $blue-dark;
        line-height: 26px;
        font-weight: 400;

        &:hover,
        &:focus,
        &:active,
        .is-hovered > & {
          background-color: $blue-darker;
          color: $white;
          text-decoration: none;
        }

        &.green:hover,
        &.green:focus,
        &.green:active {
          background-color: #5c7b1e !important;
          color: $white !important;
        }

        &.red:hover,
        &.red:focus,
        &.red:active {
          background-color: #7c0009 !important;
          color: $white !important;
        }

        &.active {
          background-color: $blue-dark;
          color: $white;
        }

        &.active.green {
          background-color: #5c7b1e !important;
        }

        &.active.red {
          background-color: #7c0009 !important;
        }
      }
    }

    &__view-all {
      display: none;
      order: 2;
      padding: 0 15px;
    }

    &__section {
      &_main {
        @include make-container;
        @include make-container-max-widths;
      }

      // sass-lint:disable no-important
      &.main-nav__section_mobile {
        display: none !important;
      }

      &-heading {
        display: none;
      }
    }

    // sass-lint:disable no-vendor-prefixes
    &__overlay {
      display: none;
      z-index: $main-nav-overlay;
      position: fixed;
      top: 0;
      right: 0;
      left: 0;
      bottom: 0;
      background: $black-transparent20;
      animation: fade-in .3s;

      .is-hovered-lvl-1 ~ & {
        display: block;
      }
    }

    &__menu__label:not(.main-nav__menu__label-last),
    &__sub-menu__link:not(.main-nav__sub-sub-menu__link-last) {
      &::after {
        display: none;
      }
    }
  }
}

@include media-breakpoint-up(lg) {
  .main-nav {
    &__menu-wrapper {
      width: 930px;
    }

    &__top-level {
      @include make-col(12);

      &-wrap {
        @include make-row;
      }
    }

    &__menu {
      width: 100%;
      grid-template-columns: repeat(4, 1fr);
    }


    &__offers__wrapper {
      display: none;
      width: 226px;
      position: absolute;
      top: 0;
      right: 0;
      min-height: 100%;
      height: auto;
      padding: 20px 0;
      background-color: $white;
    }
  }
}

@include media-breakpoint-up(xl) {
  .main-nav {
    &__menu {
      grid-template-columns: repeat(5, 1fr);
    }

    &__top-level__label {
      font-size: 14px;
    }

    &__menu-wrapper {
      width: 1111px;
    }
  }
}
