// ------------------------------------------------------------
// Back to top link
//
// The one and only anchor link that brings user back to top
// when hitting the rock bottom.
// ------------------------------------------------------------

.top {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: $color_body;
  width: 40px;
  height: 40px;
  text-decoration: none;
  opacity: 0;
  transition: opacity .3s 0s, visibility 0s .3s;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;

  @media (max-width: $container-mobile) {
    width: 30px;
    height: 30px;
  }

  &.is-visible,
  &.fade-out,
  .no-touch &:hover {
    transition: opacity .3s 0s, visibility 0s 0s;
  }

  &.is-visible { // The button becomes visible
    opacity: 1;
  }

  &.fade-out { // If the user keeps scrolling down, the button is out of focus and becomes less visible
    opacity: .3;

    &:hover {
      opacity: 1;
    }
  }

  .no-touch &:hover {
    opacity: 1;
  }

  svg {
    fill: #fff;
    margin: 0;
    opacity: .8;
    transition: all .3s ease;
    position: relative;
    width: 20px;
    height: 20px;

    @media (max-width: $container-mobile) {
      width: 15px;
      height: 15px;
    }
  }

  &:hover,
  &:focus,
  &:active {
    background: $color_links;

    svg {
      fill: #fff;
      margin-top: -35%;
    }
  }
}
