/* Table List — WordPress 侧边栏目录 */

.tl-toc {
  --tl-text: #3d342c;
  --tl-muted: #8a7d72;
  --tl-active: #b5472a;
  --tl-line: #e6ddd4;
  --tl-hover: #2c2420;
  --tl-bg: transparent;
  --tl-radius: 10px;
  --tl-indent: 1rem;

  display: flex;
  flex-direction: column;
  position: sticky;
  top: 1.5rem;
  height: auto;
  max-height: none;
  overflow: hidden;
  padding: 0.25rem 0 0.25rem 0.15rem;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--tl-text);
  background: var(--tl-bg);
}

.tl-toc-scroller {
  flex: 0 0 auto;
  height: 32rem;
  max-height: calc(100vh - 14rem);
  max-height: calc(100dvh - 14rem);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--tl-line) transparent;
}

.tl-toc[hidden] {
  display: none;
}

.tl-toc-title {
  flex-shrink: 0;
  margin: 0 0 0.5rem;
  padding: 0 0.35rem 0.45rem;
  font-size: 0.6875rem;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--tl-muted);
  background: var(--tl-bg, #fff);
}

.tl-toc-list,
.tl-toc-list ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

.tl-toc-list {
  position: relative;
  border-left: 1px solid var(--tl-line);
}

.tl-toc-list > li > a {
  font-weight: 550;
}

.tl-toc-list ol {
  margin-left: var(--tl-indent);
}

.tl-toc a {
  display: block;
  position: relative;
  padding: 0.28rem 0.6rem 0.28rem 0.85rem;
  color: inherit;
  text-decoration: none;
  border-radius: 0 6px 6px 0;
  transition: color 0.15s ease, background 0.15s ease;
}

.tl-toc a::before {
  content: "";
  position: absolute;
  left: -1px;
  top: 0.35rem;
  bottom: 0.35rem;
  width: 2px;
  border-radius: 1px;
  background: transparent;
  transition: background 0.15s ease;
}

.tl-toc a:hover {
  color: var(--tl-hover);
  background: #f6eee8;
}

.tl-toc a:focus-visible {
  outline: 2px solid var(--tl-active);
  outline-offset: 2px;
}

.tl-toc a[aria-current="true"] {
  color: var(--tl-active);
  font-weight: 600;
  background: #f8ebe6;
}

.tl-toc a[aria-current="true"]::before {
  background: var(--tl-active);
}

.widget .tl-toc,
.wp-block-table-list-toc .tl-toc,
.ct-sidebar .tl-toc {
  margin: 0;
}

@media (prefers-reduced-motion: reduce) {
  .tl-toc a {
    transition: none;
  }
}

@media (max-width: 860px) {
  .tl-toc.is-collapsible .tl-toc-title {
    display: none;
  }

  .tl-toc {
    position: relative;
    top: 0;
    max-height: none;
    margin-bottom: 1.5rem;
  }

  .tl-toc.is-collapsible .tl-toc-scroller {
    display: none;
  }

  .tl-toc.is-collapsible.is-open .tl-toc-scroller {
    display: block;
    height: 20rem;
    max-height: 60vh;
    margin-top: 0.65rem;
  }

  .tl-toc.is-collapsible .tl-toc-list {
    margin-top: 0;
    padding: 0.35rem 0;
  }

  .tl-toc.is-collapsible.is-open .tl-toc-list {
    display: block;
  }

  .tl-toc-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin: 0;
    padding: 0.7rem 0.85rem;
    border: 1px solid var(--tl-line);
    border-radius: var(--tl-radius);
    background: #fff;
    color: var(--tl-text);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
  }

  .tl-toc-toggle::after {
    content: "";
    width: 0.45rem;
    height: 0.45rem;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg);
    transition: transform 0.15s ease;
  }

  .tl-toc.is-open .tl-toc-toggle::after {
    transform: rotate(-135deg);
    translate: 0 0.15rem;
  }
}

@media (min-width: 861px) {
  .tl-toc-toggle {
    display: none;
  }
}
