/**
 * 侠梦网 - 文章页面共用样式
 * 包含目录（TOC）的悬浮按钮+右侧面板设计，三端共用
 */

/* =====================================================
 * 悬浮目录按钮 & 目录面板（三端共用 - 知乎风格）
 * ===================================================== */

/* =====================================================
 * 左侧专栏目录面板（仅专栏文章显示）
 * ===================================================== */

/* 专栏目录侧边栏 - 桌面端左侧固定 */
.column-toc-sidebar {
    display: none;
    position: fixed;
    left: 0;
    top: 0;
    width: 320px;
    height: 100vh;
    z-index: 999;
    background: var(--bg-card);
    box-shadow: 4px 0 24px rgba(0,0,0,0.10);
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.column-toc-sidebar.show {
    display: block;
    transform: translateX(0);
}

.column-toc-sidebar-inner {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.column-toc-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.column-toc-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 210px;
}

.column-toc-title:hover {
    color: var(--primary);
}

.column-toc-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    background: var(--bg-gray);
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    flex-shrink: 0;
    transition: all 0.2s;
}

.column-toc-close:hover {
    background: var(--border);
    color: var(--text);
}

.column-toc-sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
    -webkit-overflow-scrolling: touch;
}

.column-toc-sidebar-body::-webkit-scrollbar {
    width: 4px;
}

.column-toc-sidebar-body::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

/* 章节项 */
.column-toc-chapter {
    margin-bottom: 4px;
}

.column-toc-chapter-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    cursor: pointer;
    user-select: none;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    transition: background 0.15s;
}

.column-toc-chapter-header:hover {
    background: var(--bg-gray);
}

.column-toc-chapter-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: var(--text-light);
    transform: rotate(-90deg);
    transition: transform 0.2s;
    flex-shrink: 0;
}

.column-toc-chapter-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.column-toc-chapter-body {
    display: none;
    padding-left: 12px;
}

/* 小节项 */
.column-toc-subsection {
    margin: 2px 0;
}

.column-toc-subsection .column-toc-list {
    display: none;
}

.column-toc-subsection-header {
    padding: 5px 16px 5px 28px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    transition: color 0.15s;
}

.column-toc-subsection-header:hover {
    color: var(--primary);
}

/* 小节内的文章列表 - 比小节标题多缩进 */
.column-toc-subsection .column-toc-list a {
    padding-left: 42px;
}

/* 文章列表 */
.column-toc-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.column-toc-list li {
    margin: 0;
}

.column-toc-list a {
    display: block;
    padding: 6px 16px 6px 28px;
    font-size: 13px;
    color: var(--text-secondary);
    text-decoration: none;
    line-height: 1.5;
    transition: all 0.15s;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.column-toc-list a:hover {
    color: var(--primary);
    background: rgba(22,119,255,0.04);
}

.column-toc-list a.active {
    color: var(--primary);
    font-weight: 600;
    background: var(--primary-light);
    border-right: 3px solid var(--primary);
}

/* 移动端专栏目录悬浮按钮 */
.column-toc-float-btn {
    display: flex;
    position: fixed;
    right: 16px;
    bottom: 82px;
    z-index: 999;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    font-size: 14px;
    color: var(--text);
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: var(--font-family);
    line-height: 1.4;
}

.column-toc-float-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.column-toc-float-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.16);
}

/* 悬浮按钮 - 默认显示 */
.toc-float-btn {
    display: flex;
    position: fixed;
    right: 16px;
    bottom: 32px;
    z-index: 999;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    font-size: 14px;
    color: var(--text);
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: var(--font-family);
    line-height: 1.4;
}

.toc-float-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.toc-float-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.16);
}

/* 遮罩层 - 默认隐藏 */
.toc-float-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 998;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.toc-float-overlay.show {
    display: block;
    opacity: 1;
}

/* 目录面板 - 默认隐藏，show时从右侧滑出 */
.toc-wrapper {
    display: none;
    position: fixed;
    right: 0;
    top: 0;
    width: 320px;
    height: 100vh;
    z-index: 1000;
    background: var(--bg-card);
    box-shadow: -4px 0 24px rgba(0,0,0,0.12);
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    margin: 0;
    padding: 0;
}

.toc-wrapper.show {
    display: block;
    transform: translateX(0);
}

.toc-wrapper .toc {
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    border: none;
    padding: 20px;
    overflow-y: auto;
    background: var(--bg-card);
}

.toc-wrapper .toc-title {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 8px;
    padding-bottom: 12px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border);
    cursor: default;
    background: transparent;
    border-radius: 0;
    font-size: 16px;
}

.toc-wrapper .toc-title .toc-toggle {
    display: none;
}

/* =====================================================
 * 文章布局 - 三端共用基础样式
 * ===================================================== */
.article-layout {
    display: block;
}

/* 文章主体内容区 */
.article-main {
    width: 100%;
}

/* 文章头部容器 */
.article-header-container {
    max-width: 960px;
    margin: 0 auto;
}

/* =====================================================
 * 桌面端特殊优化（>=769px）
 * ===================================================== */
@media (min-width: 769px) {
    .article-header-container,
    .article-main {
        max-width: 960px;
        margin: 0 auto;
    }

    .toc-float-btn {
        right: 24px;
        bottom: 40px;
    }

    .column-toc-float-btn {
        right: 24px;
        bottom: 90px;
    }

    .toc-wrapper {
        width: 320px;
    }
}

/* =====================================================
 * 平板端优化（>=1025px）
 * ===================================================== */
@media (min-width: 1025px) {
    .main {
        padding: 40px 24px;
    }
}
