$sidebar-background: #f5f7f9;

.sidebar {
  display: none;
  flex: 0 0 auto;
  position: absolute;
  top: $navbar-height + 73px;
  left: 0;
  right: 0;
  z-index: 100;
  width: 100%;
  min-width: $sidetoc-width;
  padding: 0 24px;
  border-bottom: 1px solid #d4dadf;
  box-shadow: 0px 5px 8px 0 rgba(116, 129, 141, 0.2);
  background-color: $sidebar-background;

  @media (min-width: 768px) {
    display: block;
    position: static;
    width: calc((100% - 1448px) / 2 + #{$sidetoc-width});
    padding-left: calc((100% - 1448px) / 2);
    padding-right: 0;
    border-right: 1px solid #e6ecf1;
    border-bottom: none;
    box-shadow: none;
  }

  ul {
    padding: 0;
    list-style: none;
  }

  a {
    color: #5c6975;

    @media (min-width: 768px) {
      border: 1px solid transparent;
      border-right: none;
    }
  }

  a.active {
    border-color: #e6ecf1;
    background: #fff;
    color: var(--primary);
  }
  a.active:hover,
  a.active:focus {
    background: #fff;
    color: var(--primary);
  }

  .level1 > li {
    margin: 0;
    font-weight: 400;
  }

  .toc a + .level2 {
    margin: 0 0 0 15px;
    border-left: 1px solid #e6ecf1;
  }
}

.sidetoc {
  border: none;
  background: none;

  > .toc {
    background: none;
    overflow-x: hidden;
  }

  @media (min-width: 768px) {
    position: fixed;
    top: $navbar-height;
    bottom: $footer-height;
    overflow: auto;
    width: 297px;
    padding-top: 20px;
    padding-left: 25px;

    &:before {
      position: fixed;
      width: 297px - 25px;
      height: 24px;
      display: block;
      bottom: 55px;
      background: linear-gradient(to bottom, rgba(255, 255, 255, 0) 0%, $sidebar-background 100%);
      content: '';
    }
  }
}

.toc a + ul:not(.level1) {
  margin-left: 3px;
}

.toc .nav > li > a {
  display: flex;
  justify-content: space-between;
  margin: 0;
  padding: 7px 24px 7px 16px;
  font-size: 14px;
}
.toc .nav > li > a:not(.active):hover,
.toc .nav > li > a:not(.active):focus {
  background: #e6ecf1;
}

.toc .nav > li > ul {
  display: none;
}

.toc .nav li.expanded > ul,
.toc a.active + ul {
  display: block;
}

.expand-stub {
  position: static;
  margin: -8px -16px -8px 0;
  padding: 6px 8px;
  font-size: 24px;
  line-height: 1;
  color: #9daab6;
}

.toc .nav > li .expand-stub::before,
.toc .nav > li.active .expand-stub::before {
  content: '›';
}
.toc .nav > li.active .expand-stub::before,
.toc .nav > li.expanded .expand-stub::before,
.toc .nav > li.expanded.active .expand-stub::before,
.toc .nav > li.filtered .expand-stub::before {
  position: relative;
  top: 5px;
  font-weight: bold;
  content: '˅';
}
