.anchorable-toc {
  position: relative;
  margin-left: -22px;
  padding-left: 22px;

  &:hover a.toc-anchor {
    display: block;
  }
}

a.toc-anchor {
  display: none;
  position: absolute;
  text-decoration: none;
  border: none;
  width: 30px;
  height: 13px;
  background: url('../images/link.png') no-repeat;
  background-size: 18px 9px;
  left: 0;
  opacity: 0.5;
  top: 50%;
  margin-top: -5px;
}

label[for="toc-toggle"] {
  cursor: pointer;
  font-size: 1.25em;
  position: relative;

  &:hover {
    color: $ember-orange;
    &:after {
      border-color: $ember-orange rgba(0, 0, 0, 0) rgba(0, 0, 0, 0) rgba(0, 0, 0, 0);
    }
    .toc-toggle:checked ~ &:after {
      border-color: rgba(0, 0, 0, 0) rgba(0, 0, 0, 0) $ember-orange rgba(0, 0, 0, 0);
    }
  }

  &:after {
    content: '';
    border-color: $light-brown rgba(0, 0, 0, 0) rgba(0, 0, 0, 0) rgba(0, 0, 0, 0);
    border-style: solid;
    border-width: 5px 4px 0 4px;
    height: 0;
    margin-left: -4px;
    margin-top: -2px;
    position: absolute;
    right: 6px;
    top: 50%;
    width: 0;
  }

  .toc-toggle:checked ~ &:after {
    border-color: rgba(0, 0, 0, 0) rgba(0, 0, 0, 0) $light-brown rgba(0, 0, 0, 0);
    border-width: 0 4px 5px 4px;
  }

  @include media($large-screen) {
    display: none;
  }
}

.toc-container {
  border-top: $base-border;
  overflow: hidden;
  display: none;

  .toc-toggle:checked ~ & {
    display: block;
  }
  @include media($large-screen) {
    display: block;

    // ensure toc-toggle can not cause toc-container to be hidden on large screen
    &[style] {
      display: block !important;
    }
  }
  
  a {
    text-decoration: none;
  }
}

li.toc-level-0 {
  margin-bottom: 0.5em;

  a {
    color: $brown;
    display: block;
    line-height: 1.25;
    padding: 0.33em 0;

    &:hover {
      color: $ember-orange;
    }
  }

  > a {
    font-weight: bold;
    margin: 0.33em 0;
  }
}

ol.toc-level-1 {
  border-left: $base-border;
  font-size: $base-font-size * 0.9;

  &:not(.selected) {
    display: none;
  }

  li {
    border-left: 3px solid transparent;
    transition: border-width $duration, margin-right $duration;

    &.selected,
    &:hover {
      border-left-color: $base-border-color;
    }

    &:hover {
      border-left-width: 6px;
      margin-right: -3px;
    }
  }

  a {
    color: $base-font-color;
    padding-left: $gutter;
  }

  .selected a {
    font-weight: 500;
  }
}
