@import '_variables';

.theme-mix-toc {
  font-size: 14px;
  padding-left: 0;
  line-height: 1.2;
  border-left: 1px solid var(--border-color);
}

.toc-title,
.mobile-toc-title {
  display: flex;
  align-items: center;
  padding-top: 0.5rem;
  padding-left: 1rem;
  color: inherit;
}

.toc-items {
  list-style: none;
  margin: 0;
  padding: 0;
}

.toc-item {
  padding: 0.25rem 0;
  margin-top: 0;
  margin-bottom: 0;
  overflow: hidden;
  font-size: 13px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.toc-anchor {
  color: var(--text-secondary-color);
}

.toc-item.active .toc-anchor {
  color: var(--theme-color);
}

// 1200px and up
@media (min-width: $desktop) {
  .toc-wrap .scrollbar {
    position: sticky;
    top: 6.1rem;
    max-height: calc(100vh - 5rem);
  }

  .with-navbar .toc-wrap .scrollbar {
    max-height: calc(100vh - 8.6rem);
  }

  .toc-title {
    padding-bottom: 0.25rem;
    color: var(--theme-color);
    font-weight: 600;
  }

  .mobile-toc-title {
    display: none;
  }

  .toc-item {
    &.toc-level-2 {
      padding-left: 1rem;
    }
    &.toc-level-3 {
      padding-left: 2rem;
    }
    &.toc-level-4 {
      padding-left: 3rem;
    }
    &.toc-level-5 {
      padding-left: 4rem;
    }
    &.toc-level-6 {
      padding-left: 5rem;
    }

    &.active {
      border-left: 1px solid var(--link-color);
    }
  }
}

// less than 1200px
@media (max-width: ($desktop - 0.02px)) {
  .toc-wrap .scrollbar {
    margin: 0;
    padding: 0;
    border: none;
  }

  .toc-mask {
    position: fixed;
    z-index: 10;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: none;
  }

  .toc-open .toc-mask {
    display: block;
  }

  .toc-title {
    display: none;
  }

  .mobile-toc-title {
    position: fixed;
    right: 1.5rem;
    z-index: 10;
    justify-content: center;
    width: 4rem;
    margin-bottom: 0.5rem;
    padding: 0.5rem 0.25rem;
    border-radius: 0.25rem;
    background-color: var(--deep-bg-color);
  }

  .toc-items-wrap {
    display: none;
    position: fixed;
    top: 5.5rem;
    right: 1.5rem;
    z-index: 10;
    max-width: 318px;
    border-radius: 0.25rem;
    padding: 0.5rem;
    background-color: var(--deep-bg-color);

    &::before {
      position: absolute;
      display: inline-block;
      content: '';
      border: 0.5rem solid transparent;
      border-bottom: 0.5rem solid var(--border-color);
      top: -1rem;
      right: 1.5rem;
      left: auto;
    }

    &::after {
      position: absolute;
      display: inline-block;
      content: '';
      border: 0.5rem solid transparent;
      border-bottom: 0.5rem solid var(--deep-bg-color);
      top: calc(-1rem + 2px);
      right: 1.5rem;
      left: auto;
    }

    .toc-items {
      max-height: calc(100vh - 10rem - 1.5em);
      overflow-y: auto;
    }
  }

  .with-navbar {
    .toc-items-wrap {
      top: 9rem;
    }
  }

  .toc-items-wrap.show-toc {
    display: block;
  }

  .toc-item {
    &.toc-level-3 {
      padding-left: 1rem;
    }
    &.toc-level-4 {
      padding-left: 2rem;
    }
    &.toc-level-5 {
      padding-left: 3rem;
    }
    &.toc-level-6 {
      padding-left: 4rem;
    }
  }
}

// less than 992px
@media (max-width: ($tablet - 0.02px)) {
  .mobile-toc-title {
    right: 1rem;
  }

  .toc-items-wrap {
    right: 1rem;
  }
}
