@use "sass:math";

@import '~styles/config';

$panel-color: $color-ocean;

.navigationPanel {
  position: fixed;
  top: -100vh;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 8000000;

  padding: 0;
  margin: 0;
  height: 100vh;

  @include colorify('background-color', 'background');

  // tablet and narrower
  @media (max-width: $max-tablet) {
    transition: background-color 200ms ease-in-out, top 400ms ease-in-out;
  }

  // tablet and wider
  @media (min-width: $min-tablet) {
    top: 0;
    bottom: 0;
    left: -275px;

    width: 300px;

    transition: background-color 200ms ease-in-out, left 200ms ease-in-out;

    box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.125);

    &.background-white {
      box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.125);
    }
  }

  // 1024px and smaller - AND - 1700px and wider
  @media (min-height: $min-1024) and (min-width: $min-2000) {
    left: 0;
    right: auto;

    &.background-white {
      background-color: $color-dark;
      box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.125);
    }
  }

  @media (max-height: $max-1024) and (min-width: $min-tablet) {
    left: -310px;
    width: 340px;
  }

  @media (max-height: $max-1024) and (min-width: $min-2000) {
    left: 0;
  }

  &.isOpen {
    top: 0;
    background-color: $color-dark;

    transition: background-color 200ms ease-in-out, left 200ms ease-in-out;

    @media (max-width: $max-tablet) {
      transition: background-color 200ms ease-in-out, top 400ms ease-in-out;
    }

    @media (min-width: $min-tablet) {
      left: 0;
      right: auto;
    }
  }

  &.isClosed {
    background-color: $color-white;
    // when navpanel is default open on wide screen, keep it dark
    @media (min-width: $min-2000) {
      background-color: $color-dark;
    }
  }

  // openButton

  &__open {
    @include reset-button;

    display: flex;
    align-items: center;
    justify-content: center;

    position: absolute;

    height: 50px;
    width: 50px;

    border-radius: 25px;

    cursor: pointer;

    background-color: $color-ocean;

    transition: right 200ms ease-in-out;
    fill: $color-white;

    @media (max-width: $max-tablet) {
      bottom: -40px;
      left: 50%;

      height: 40px;
      width: 80px;
      border-radius: 0 0 40px 40px;

      transform: translateX(-40px);

      box-shadow: 0 0 10px 1px rgba(255, 255, 255, 0.125);

      .isOpen & {
        top: 0;
      }

      .background-white & {
        box-shadow: 0 0 10px 1px rgba(35, 35, 35, 0.125);
      }

      .isOpen.background-white & {
        box-shadow: 0 0 10px 1px rgba(255, 255, 255, 0.125);
      }
    }

    @media (max-width: $max-mobile) {
      left: 38%;

      .isOpen & {
        left: 50%;
      }
    }

    @media (min-width: $min-tablet) {
      top: 50%;
      right: -35px;
      transform: translateY(-25px);

      .isOpen & {
        right: -25px;
      }
    }

    @media (min-width: $min-2000) {
      display: none;
    }
  }

  &__open:hover &__openSVG,
  &__open:focus &__openSVG,
  &__open:active &__openSVG {
    animation-duration: 1s;
    animation-iteration-count: 1;
    animation-timing-function: ease-in-out;

    @media (max-width: $max-tablet) {
      // arrow down
      animation-name: wobble-vertical-arrowDown;
    }

    @media (min-width: $min-tablet) {
      // arrow right
      animation-name: wobble-horizontal-arrowRight;
    }

    .isOpen & {
      @media (max-width: $max-tablet) {
        // arrow up
        animation-name: wobble-vertical-arrowUp;
      }

      @media (min-width: $min-tablet) {
        // arrow left
        animation-name: wobble-horizontal-arrowLeft;
      }
    }
  }

  &__openSVG {
    // arrow down
    transform: rotate(90deg);
    transition: transform 200ms ease-in-out;

    @media (min-width: $min-tablet) {
      // arrow right
      transform: rotate(0deg);
    }

    .isOpen & {
      // arrow up
      transform: rotate(270deg);

      @media (min-width: $min-tablet) {
        // arrow left
        transform: rotate(180deg);
      }
    }
  }

  &__pin {
    @include reset-button;

    position: absolute;
    top: $gutter*3.5;
    right: 20px;

    height: 40px;
    width: 40px;

    cursor: pointer;

    @media (max-width: $max-tablet) {
      display: none;
    }

    @media (min-width: $min-2000) {
      display: none;
    }
  }

  &__pinSVG {
    height: 22px;
    width: 14px;

    transform: rotate(45deg);
    fill: $color-grey700;

    .isPinned & {
      fill: $color-pink;
    }
  }

  &__wrapper {
    padding: 30px 0;
    height: 100%;

    font-size: 14px;
    color: $color-white;

    @media (min-width: $min-tablet) {
      padding: 40px 0 $gutter;
    }

  }

  &__content {
    display: flex;
    flex-wrap: wrap;
    align-content: space-between;

    height: 100%;

    visibility: hidden;
    opacity: 0;

    transition: visibility $transition-enter ease-in-out, opacity $transition-enter ease-in-out;


    @media (min-width: $min-2000) {
      visibility: visible;
      opacity: 1;
    }

    .isOpen & {
      visibility: visible;
      opacity: 1;
      transition: visibility $transition-leave ease-in-out, opacity $transition-leave ease-in-out;
    }
  }

  &__top {
    width: 100%;
  }

  &__logo {

    &SVG { // stylelint-disable-line
      margin-left: $gutter;
      height: 32px;
    }

    path { // stylelint-disable-line
      fill: $color-white;
    }
  }


  // Navigation

  &__navWrapper {
    display: flex;
    flex-direction: row;

    @media (min-height: $min-1024) and (min-width: $min-tablet) {
      flex-direction: column;
    }
  }

  &__nav {
    width: 100%;
  }

  &__navTitle {

    padding-bottom: math.div($gutter, 3);
    margin: $gutter $gutter $gutter*0.5;

    border-bottom: 1px solid $color-grey400;

    font-size: 16px;
    font-weight: 300;
    text-transform: uppercase;
  }

  &__navList {
    @include reset-list;

    &.subLink {
      padding-bottom: 5px;
    }

    &.hoverLink {

      position: absolute;
      left: 100%;
      top: -15px;

      padding: $gutter*0.5 0;

      visibility: hidden;
      opacity: 0;

      background: $color-white;
      color: $color-dark;

      transition: visibility $transition-enter ease-in-out, opacity $transition-enter ease-in-out;

      box-shadow: 0 20px 70px 0 rgba(32, 32, 32, 0.15);

      @media (min-width: $min-tablet) and (min-height: $min-1024) {
        left: calc(100% - 20px);
        z-index: 1;
      }
    }

    .mobileHoverLeft &.hoverLink {
      @media (max-width: $max-tablet) {
        left: 0;
        transform: translate(-100%);
      }
    }

    // small arrow at top
    &.hoverLink::before {
      content: '';
      position: absolute;
      left: -7px;
      top: 23px;

      width: 0;
      height: 0;
      border-top: 7px solid transparent;
      border-bottom: 7px solid transparent;
      border-right: 7px solid $color-white;

      box-shadow: 0 20px 70px 0 rgba(32, 32, 32, 0.15);
    }

    .mobileHoverLeft &.hoverLink::before {
      @media (max-width: $max-tablet) {
        right: -13px;
        left: auto;

        border-right: 7px solid transparent;
        border-left: 7px solid $color-white;
      }
    }
  }

  &__navItem {
    position: relative;

    .subLink & {
      padding-left: 30px;
      font-weight: 400;
    }

    .hoverLink & {
      padding-left: 0;
      white-space: nowrap;
    }
  }

  .subLink &__navItem:hover > &__navList.hoverLink,
  .link &__navItem:hover > &__navList.hoverLink {
    visibility: visible;
    opacity: 1;
  }

  &__navLink {
    @include reset-anchor;
    display: flex;
    justify-content: space-between;

    margin-left: 4px;
    padding: 5px 30px 5px 26px;

    transition:
      box-shadow $transition-enter ease-in-out,
      color $transition-enter ease-in-out,
      fill $transition-enter ease-in-out;

    fill: $color-grey700;

    @media (max-height: $max-1024) and (max-width: $max-tablet) {
      padding: 2px 30px 3px 26px;
    }

    .subLink &,
    .hoverLink & {
      padding: 5px 30px 5px 16px;

      box-shadow: -4px 0 0 0 rgba(255, 255, 255, 1);

      @media (max-height: $max-1024) and (max-width: $max-tablet) {
        padding: 2px 30px 3px 16px;
      }
    }

    .hoverLink & {
      padding: 5px 20px 5px 16px;
      fill: $color-grey400;
    }

    .subLink &:hover,
    .subLink &:focus,
    .subLink &.selected,
    .hoverLink &:hover,
    .hoverLink &:focus,
    .hoverLink &.selected {
      box-shadow: -4px 0 0 0 rgba(18, 170, 149, 1);
    }

    &:hover,
    &:focus,
    &.selected {
      color: $panel-color;
      fill: $color-grey400;

      .hoverLink & {
        fill: $color-grey700;
      }
    }

    &.selected {
      font-weight: 600;
    }
  }

  &__navLinkNewTab {
    margin-left: 15px;
  }

  &__navLinkNewTabIcon {
    height: 10px;
  }

  // ProfileInfoBox
  &__profiles {
    flex-grow: 1;
    flex-wrap: wrap;

    margin: 0 $gutter*0.5;

    border-top: 5px solid $panel-color;
    border-bottom: 1px solid $panel-color;

    @media (max-width: $max-tablet) {
      display: flex;
    }
    @media (min-width: $min-mobile) and (max-width: $max-tablet) {
      flex-wrap: nowrap;
    }
    @media (max-height: $max-1024) and (min-width: $min-tablet) {
      display: flex;
    }
  }

  &__profileInfo {
    position: relative;

    padding: $gutter*0.5 $gutter*0.5;
    width: 50%;

    cursor: default;

    font-size: 14px;

    @media (min-width: $min-mobile) {
      width: 33%;
    }

    @media (min-width: $min-tablet) and (min-height: $min-1024) {
      width: 100%;
    }

    @media (min-width: $min-tablet) and (max-height: $max-1024) {
      width: 50%;
    }
  }

  &__profileInfo:hover &__hoverNavList {
    display: block;
    visibility: visible;
    opacity: 1;
  }

  &__created {
    position: relative;
    padding: $gutter*0.5 $gutter*0.5 0 $gutter*0.5;

    width: 100%;
    font-size: 14px;

    @media (min-width: $min-mobile) and (max-width: $max-tablet) {
      width: 33%;
    }
  }

  &__link {
    @include reset-anchor;

    &:hover,
    &:focus {
      color: $panel-color;
    }
  }

  &__label {
    width: 100%;
    font-weight: 600;
  }

}

// keyframes for openButton

@keyframes wobble-horizontal-arrowRight {
  16.65% { transform: translateX(4px); }
  33.3% { transform: translateX(-3px); }
  49.95% { transform: translateX(2px); }
  66.6% { transform: translateX(-2px); }
  83.25% { transform: translateX(1px); }
  100% { transform: translateX(0); }
}

@keyframes wobble-horizontal-arrowLeft {
  16.65% { transform: translateX(4px) rotate(180deg); }
  33.3% { transform: translateX(-3px) rotate(180deg); }
  49.95% { transform: translateX(2px) rotate(180deg); }
  66.6% { transform: translateX(-2px) rotate(180deg); }
  83.25% { transform: translateX(1px) rotate(180deg); }
  100% { transform: translateX(0) rotate(180deg); }
}

@keyframes wobble-vertical-arrowDown {
  16.65% { transform: translateY(4px) rotate(90deg); }
  33.3% { transform: translateY(-3px) rotate(90deg); }
  49.95% { transform: translateY(2px) rotate(90deg); }
  66.6% { transform: translateY(-2px) rotate(90deg); }
  83.25% { transform: translateY(1px) rotate(90deg); }
  100% { transform: translateY(0) rotate(90deg); }
}

@keyframes wobble-vertical-arrowUp {
  16.65% { transform: translateY(4px) rotate(270deg); }
  33.3% { transform: translateY(-3px) rotate(270deg); }
  49.95% { transform: translateY(2px) rotate(270deg); }
  66.6% { transform: translateY(-2px) rotate(270deg); }
  83.25% { transform: translateY(1px) rotate(270deg); }
  100% { transform: translateY(0) rotate(270deg); }
}
