$arrow-animation-distance: 6px !default;

#ftw-mobile-menu {
  @include translate(-100%);
  z-index: $zindex-overlay + 1;
  position: absolute;
  top: 0;
  width: 100%;
  font-size: $font-size-medium;
  max-width: calc(100% - #{$size-mobile-button});
  background-color: $color-content-background;

  &.open {
    @include translate();
    max-width: none;
  }

  > ul {
    margin: 0;
    position: absolute;
    top: $size-mobile-button;
    box-shadow: $box-shadow-primary;
  }
}

#offcanvas-content {
  height: 100vh;
  transition: transform .2s linear;
  will-change: transform;
}

#ftw-mobile-wrapper {
  @include screen-medium {
    display: none;
  }
}

#ftw-mobile-menu-overlay {
  @include linear-gradient(
    to left,
    #29323c,
    #485563
  );
  cursor: pointer;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: $zindex-overlay;
  opacity: 0;
  transition: opacity .4s linear;
  pointer-events: none;
  will-change: opacity;
}

html.menu-open {
  overflow: hidden;
}

.menu-closed {
  #ftw-mobile-menu {
    display: none;

    &.open {
      display: block;
    }
  }
}

.menu-open {

  body {
    overflow: hidden;
  }

  #offcanvas-content {
    @include transform(translate(100%) translate(-$size-mobile-button));
    @include screen-large() {
      @include transform(none);
    }
  }

  #ftw-mobile-menu {
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    height: 100vh;
    display: block;
  }

  #ftw-mobile-menu-overlay {
    opacity: .8;
    pointer-events: initial;
  }
}

.mobile-menu-navigation-mobile-button {
  overflow: hidden;

  &:before, &:after {
    pointer-events: none;
    content: "";
    display: block;
    height: $size-mobile-button - 2px;
    width: 50px;
    position: absolute;
    top: 0;
    z-index: $zindex-base;
    background-size: $size-mobile-button / 2, 100%;
    background-repeat: no-repeat, repeat;
    animation-duration: 1s;
    animation-iteration-count: infinite;
    animation-direction: alternate;
    transition: opacity .2s ease-out;
    opacity: 0;
  }

  &:before {
    left: -$arrow-animation-distance;
    animation-name: arrow-wobble-left;
    background-image:
      embed-resource("../resources/images/arrow-left.svg", $fill-css:('.icon', $color-content-background)),
      linear-gradient(to left, rgba(0,0,0,0) 0%,rgba(72,85,99,.6) 80%, rgba(72,85,99,.8) 100%)
    ;
    background-position: center left 5px, top right;
  }

  &:after {
    right: -$arrow-animation-distance;
    animation-name: arrow-wobble-right;
    background-image:
      embed-resource("../resources/images/arrow-right.svg", $fill-css:('.icon', $color-content-background)),
      linear-gradient(to right, rgba(0,0,0,0) 0%,rgba(72,85,99,.6) 80%, rgba(72,85,99,.8) 100%)
    ;
    background-position: center right 5px, top right;
  }
}

#ftw-mobile-menu {

  &.scroll-right {
    .mobile-menu-navigation-mobile-button {
      &:before {
        opacity: 0;
      }

      &:after {
        opacity: 1;
      }
    }
  }

  &.scroll-left {
    .mobile-menu-navigation-mobile-button {
      &:before {
        opacity: 1;
      }

      &:after {
        opacity: 0;
      }
    }
  }
}

@include keyframes(arrow-wobble-right) {
  from {
    @include translate($x: 0);
  }
  to {
    @include translate($x: -$arrow-animation-distance);
  }
}

@include keyframes(arrow-wobble-left) {
  from {
    @include translate($x: 0);
  }
  to {
    @include translate($x: $arrow-animation-distance);
  }
}

// plone.app.multilingual
#portal-languageselector-wrapper {
  @include screen-large() {
    display: block;
  }
  display: none;
}
