/* 侧边栏通用样式 (知乎风格目录 & 文章归档) */

/* 基础布局 */
.table-of-contents,
.archive-sidebar {
    position: fixed;
    top: 100px;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    padding: 0;
    background: transparent;
    z-index: 100;
}

/* 差异化宽度与位置 */
.table-of-contents {
    top: 160px; /* 向下移动（原继承为 100px） */
    left: max(calc((100vw - 800px) / 2 - 360px), 20px); /* 向左移动（原为 -300px） */
    width: 260px;
    max-height: calc(100vh - 200px); /* 适配新的 top 值 */
}

.archive-sidebar {
    top: 220px;
    left: max(calc((100vw - 800px) / 2 - 260px), 20px);
    width: 160px;
    max-height: calc(100vh - 260px);
}

.table-of-contents::-webkit-scrollbar,
.archive-sidebar::-webkit-scrollbar {
    width: 4px;
}

.table-of-contents::-webkit-scrollbar-thumb,
.archive-sidebar::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 2px;
}

/* 标题 */
.toc-title,
.archive-title {
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0 0 16px 0;
    padding-left: 16px;
    letter-spacing: 0.5px;
}

.toc-title {
    font-size: 14px;
    text-transform: uppercase;
}

.archive-title {
    font-size: 14px;
}

/* 列表容器 */
.toc-list,
.archive-list {
    list-style: none;
    padding: 0;
    margin: 0;
    position: relative;
}

/* 左侧引导竖线 */
.toc-list::before,
.archive-list::before {
    content: '';
    position: absolute;
    left: 4px;
    top: 8px;
    bottom: 8px;
    width: 2px;
    background: var(--glass-border);
    border-radius: 1px;
}

/* 列表项 */
.toc-item,
.archive-item {
    margin: 0;
    position: relative;
    transform-origin: left center;
}

/* 链接基础样式 */
.toc-link,
.archive-link {
    color: var(--text-secondary);
    text-decoration: none;
    display: block;
    padding: 6px 12px 6px 16px;
    transition: transform 0.2s cubic-bezier(0.25, 1, 0.5, 1), color 0.2s ease;
    line-height: 1.6;
    position: relative;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transform-origin: left center;
    cursor: pointer;
}

.toc-link {
    font-size: 13px;
}

.archive-link {
    font-size: 14px;
}

/* 圆点指示器 */
.toc-link::before,
.archive-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--glass-border);
    transition: all 0.3s var(--ease-liquid);
    z-index: 1;
}

.toc-link::before {
    border: 2px solid var(--glass-bg);
}

.archive-link::before {
    border: 2px solid var(--bg-base);
}

/* 悬停与激活状态 */
.toc-link:hover,
.archive-link:hover {
    color: var(--primary-color);
}

/* macOS Dock 风格放大效果 */
.toc-item:hover .toc-link,
.archive-item:hover .archive-link {
    transform: scale(1.15);
    font-weight: 500;
}

.toc-link:hover::before,
.archive-link:hover::before {
    background: var(--primary-color);
}

.toc-link.active,
.archive-link.active {
    color: var(--primary-color);
    font-weight: 500;
}

.toc-link.active::before,
.archive-link.active::before {
    background: var(--primary-color);
    transform: translateY(-50%) scale(1.3);
    box-shadow: 0 0 0 4px var(--mystic-glow);
}

/* 子目录缩进调整 */
.toc-item.toc-h3 .toc-link {
    padding-left: 32px;
    font-size: 12px;
}

.toc-item.toc-h3 .toc-link::before {
    left: 16px;
    width: 6px;
    height: 6px;
}

.archive-item.archive-month .archive-link {
    padding-left: 28px;
    font-size: 13px;
}

.archive-item.archive-month .archive-link::before {
    left: 16px;
    width: 6px;
    height: 6px;
}

/* 移动端右下角悬浮切换按钮 */
.toc-toggle,
.archive-toggle {
    display: none;
    position: fixed;
    right: 20px;
    bottom: 80px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0.05) 100%);
    backdrop-filter: blur(25px) saturate(180%);
    -webkit-backdrop-filter: blur(25px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: var(--shadow-soft), inset 0 1px 1px rgba(255, 255, 255, 0.6), inset 0 -1px 1px rgba(255, 255, 255, 0.2);
    color: var(--primary-color);
    font-size: 20px;
    cursor: pointer;
    z-index: 1000;
    align-items: center;
    justify-content: center;
    transition: all 0.3s var(--ease-liquid);
}

.toc-toggle:hover,
.archive-toggle:hover {
    transform: scale(1.1);
    border-color: var(--primary-color);
}

.toc-toggle.active,
.archive-toggle.active {
    background: var(--primary-color);
    color: white;
}

/* 响应式设计 - 平板及手机端隐藏并转为底部浮层 */
@media (max-width: 1200px) {
    .table-of-contents,
    .archive-sidebar {
        position: fixed;
        left: 50%;
        transform: translateX(-50%) translateY(calc(100% + 80px));
        top: auto;
        bottom: 140px;
        width: calc(100vw - 40px);
        max-width: 400px;
        max-height: 60vh;
        padding: 20px;
        background: linear-gradient(135deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0.05) 100%);
        backdrop-filter: blur(25px) saturate(180%);
        -webkit-backdrop-filter: blur(25px) saturate(180%);
        border: 1px solid rgba(255, 255, 255, 0.2);
        border-radius: 16px;
        box-shadow: var(--shadow-soft), inset 0 1px 1px rgba(255, 255, 255, 0.6), inset 0 -1px 1px rgba(255, 255, 255, 0.2);
        opacity: 0;
        pointer-events: none;
        transition: all 0.3s var(--ease-liquid);
    }

    .table-of-contents.show,
    .archive-sidebar.show {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
        pointer-events: auto;
    }

    .toc-toggle,
    .archive-toggle {
        display: flex;
    }

    .toc-title,
    .archive-title {
        padding-left: 0;
    }

    .toc-list::before,
    .archive-list::before,
    .toc-link::before,
    .archive-link::before {
        display: none;
    }

    .toc-link,
    .archive-link {
        padding: 8px 12px;
    }
    
    .archive-item.archive-month .archive-link {
        padding-left: 24px;
    }
}
