/* 浮动目录侧边栏 - 简洁透明风格，支持开关灯 */

/* 按钮：只保留 > 符号 */
.float-toc-btn {
  position: fixed;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 9999;
  background: transparent;
  color: var(--sec-text-color, rgba(0, 0, 0, 0.35));
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 300;
  padding: 0;
  line-height: 1;
  transition: color 0.3s ease;
  outline: none;
  font-family: inherit;
}

.float-toc-btn:hover {
  color: var(--text-color, rgba(0, 0, 0, 0.7));
}

/* 箭头旋转动画 */
.float-toc-btn .arrow {
  display: inline-block;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.float-toc-btn.open .arrow {
  transform: rotate(90deg);
}

/* 目录面板：透明背景、居中50%屏幕高度 */
.float-toc-panel {
  position: fixed;
  left: 36px;
  top: 25%;
  width: 280px;
  height: 50vh;
  background: transparent;
  z-index: 9998;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 0;
  opacity: 0;
  visibility: hidden;
  transform: translateX(-20px);
  transition: opacity 0.35s ease, visibility 0.35s ease, transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  overscroll-behavior: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.float-toc-panel::-webkit-scrollbar {
  display: none;
}

.float-toc-panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
}

/* 目录标题 */
.float-toc-panel .toc-header {
  padding: 0 20px 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--sec-text-color, rgba(0, 0, 0, 0.5));
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

/* 目录列表样式 */
.float-toc-list {
  list-style: none;
  padding: 0 8px;
  margin: 0;
}

.float-toc-list li {
  margin: 0;
  padding: 0;
}

/* 有子标题的项：添加展开箭头 */
.float-toc-list .toc-item {
  display: flex;
  align-items: flex-start;
}

.float-toc-list .toc-arrow {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--sec-text-color, rgba(0, 0, 0, 0.25));
  cursor: pointer;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), color 0.2s ease;
  margin-top: 7px;
  user-select: none;
  font-family: inherit;
}

.float-toc-list .toc-arrow:hover {
  color: var(--text-color, rgba(0, 0, 0, 0.5));
}

/* 占位符：不可见但占位 */
.float-toc-list .toc-arrow-spacer {
  visibility: hidden;
  cursor: default;
}

.float-toc-list .toc-arrow.collapsed {
  transform: rotate(-90deg);
}

.float-toc-list .toc-link {
  flex: 1;
  display: block;
  padding: 5px 8px;
  color: var(--sec-text-color, rgba(0, 0, 0, 0.45));
  text-decoration: none;
  font-size: 13px;
  line-height: 1.5;
  border-radius: 4px;
  transition: color 0.2s ease, background 0.2s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.float-toc-list .toc-link:hover {
  color: var(--post-link-color, rgba(0, 0, 0, 0.8));
  background: var(--link-hover-bg-color, rgba(0, 0, 0, 0.04));
}

.float-toc-list .toc-link.active {
  color: var(--post-link-color, rgba(0, 0, 0, 0.85));
  font-weight: 500;
  background: var(--link-hover-bg-color, rgba(0, 0, 0, 0.06));
}

/* 子标题折叠 */
.float-toc-list .toc-children {
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.float-toc-list .toc-children.collapsed {
  max-height: 0 !important;
}

/* 层级缩进 */
.float-toc-list .toc-h1 > .toc-item .toc-link { padding-left: 8px; }
.float-toc-list .toc-h2 > .toc-item .toc-link { padding-left: 20px; }
.float-toc-list .toc-h3 > .toc-item .toc-link { padding-left: 32px; font-size: 12px; }
.float-toc-list .toc-h4 > .toc-item .toc-link { padding-left: 44px; font-size: 12px; }
.float-toc-list .toc-h5 > .toc-item .toc-link { padding-left: 56px; font-size: 11px; }
.float-toc-list .toc-h6 > .toc-item .toc-link { padding-left: 68px; font-size: 11px; }

/* 移动端适配 */
@media (max-width: 768px) {
  .float-toc-panel {
    width: 240px;
  }
  .float-toc-btn {
    font-size: 22px;
    left: 4px;
  }
  .float-toc-panel {
    left: 28px;
  }
}

