/* resources/css/modules/reader.css
   全站阅读页专属样式。
   来源：原 resources/css/reader.css（旧）+ reader 重构新增内容合并。
   以旧 reader.css 内容为准，新增部分追加在末尾。
*/

/* ══════════════════════════════════════════
   一、基础
   ══════════════════════════════════════════ */

body {
    font-family: 'Inter', sans-serif;
    transition:
        background-color 0.3s,
        color 0.3s;
}

/* ══════════════════════════════════════════
   二、主布局容器
   ══════════════════════════════════════════ */

.main-container {
    display: flex;
    gap: 20px;
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
}

/* ── TOC 侧边栏（左） ── */
.toc-sidebar {
    width: 250px;
    flex-shrink: 0;
    display: none;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
}

.toc-sidebar .card-body {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
}

/* ── 正文区（中）── */
.content-area {
    flex: 1; /* 替代原 flex-grow:1，配合 min-width 防止收缩 */
    min-width: 0; /* 修复：内容较窄时列不收缩 */
}

/* ── 右侧边栏 ── */
.right-sidebar {
    width: 220px; /* 收窄，原 300px 偏宽 */
    flex-shrink: 0;
    display: none;
}

.related-books {
    margin-top: 30px;
}

.card-img-container {
    height: 150px;
    overflow: hidden;
}

.card-img-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ══════════════════════════════════════════
   三、响应式
   ══════════════════════════════════════════ */

@media (max-width: 767px) {
    .content-area {
        width: 100%;
    }

    .main-container {
        padding: 0;
    }

    .card {
        border: none;
    }
}

@media (min-width: 768px) {
    .toc-sidebar {
        display: block;
    }
    /* content-area 不设 max-width，由 flex:1 + min-width:0 自动占满剩余空间 */
}

@media (min-width: 992px) {
    .right-sidebar {
        display: block;
    }
    /* 同上，不限制 max-width */
}

/* ══════════════════════════════════════════
   四、暗色模式
   ══════════════════════════════════════════ */

.dark-mode {
    background-color: #1a1a1a;
    color: #ffffff;
}

.dark-mode .card {
    background-color: #2a2a2a;
    border-color: #3a3a3a;
    color: #ffffff;
}

.dark-mode .navbar {
    background-color: #2a2a2a;
}

.dark-mode .offcanvas {
    background-color: #2a2a2a;
    color: #ffffff;
}

.dark-mode .offcanvas .nav-link {
    color: #ffffff;
}

.dark-mode .toc-sidebar,
.dark-mode .right-sidebar {
    background-color: #2a2a2a;
}

/* ══════════════════════════════════════════
   五、目录样式（wiki toc 风格）
   ══════════════════════════════════════════ */

.toc-sidebar ul,
.offcanvas-body ul {
    list-style: none;
    padding: 0;
}

.toc-sidebar ul li,
.offcanvas-body ul li {
    padding: 5px 0;
}

.toc-sidebar ul li a,
.offcanvas-body ul li a {
    color: #206bc4;
    text-decoration: none;
}

.toc-sidebar ul li a:hover {
    text-decoration: none;
}
.offcanvas-body ul li a:hover {
    text-decoration: underline;
}

.dark-mode .toc-sidebar ul li a,
.dark-mode .offcanvas-body ul li a {
    color: #4dabf7;
}

.toc-level-1 {
    padding-left: 0 !important;
}
.toc-level-2 {
    padding-left: 16px !important;
}
.toc-level-3 {
    padding-left: 24px !important;
}
.toc-level-4 {
    padding-left: 36px !important;
}

.toc-disabled {
    color: #6c757d;
    cursor: not-allowed;
    pointer-events: none;
}

.dark-mode .toc-disabled {
    color: #adb5bd;
}

.toc_item {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.toc_item:hover {
    color: #206bc4 !important;
    background: rgba(32, 107, 196, 0.15);
    border-radius: 2px;
    cursor: pointer;
}

.toc_item a,
.toc_item span {
    display: block;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.toc-active {
    color: #206bc4 !important;
    font-weight: 600;
    background: rgba(32, 107, 196, 0.08);
    border-left: 3px solid #206bc4;
    border-radius: 2px;
    cursor: default;
    pointer-events: none;
}

.dark-mode .toc-active {
    color: #4dabf7 !important;
    background: rgba(77, 171, 247, 0.1);
    border-left-color: #4dabf7;
}

/* TOC 折叠模式：默认隐藏 hide 项，.toc-expanded 时全部展开 */
.toc-tree:not(.toc-expanded) .toc-hidden {
    display: none;
}

.toc-toggle-all {
    display: inline-flex;
    align-items: center;
    padding: 0 0 8px;
    background: none;
    border: none;
    color: #206bc4;
    font-size: 0.85rem;
    cursor: pointer;
}

.dark-mode .toc-toggle-all {
    color: #4dabf7;
}

/* 折叠时显示「展开全部」，展开时显示「折叠」 */
.toc-tree.toc-expanded .toc-toggle-expand,
.toc-tree:not(.toc-expanded) .toc-toggle-collapse {
    display: none;
}

/* ══════════════════════════════════════════
   六、正文内容
   ══════════════════════════════════════════ */

/* 术语引用 */
.term-ref {
    cursor: pointer;
    text-decoration: underline dotted;
    text-underline-offset: 4px;
}

.term-ref:hover {
    color: var(--tblr-primary);
}

.term_invalid {
    color: red;
}

/* ══════════════════════════════════════════
   七、Navbar 图标尺寸修正
   ti 图标显式设定字号，防止继承后偏小
   ══════════════════════════════════════════ */

.navbar .nav-link .ti {
    font-size: 1.125rem;
    vertical-align: middle;
}

/* ══════════════════════════════════════════
   八、版本卡片（右侧边栏，wiki 侧边栏同款）
   ══════════════════════════════════════════ */

.reader-channel-card {
    background: var(--tblr-bg-surface);
    border: 1px solid var(--tblr-border-color);
    border-radius: var(--tblr-border-radius-lg);
    padding: 1rem 1.125rem;
    margin-bottom: 1rem;
}

.dark-mode .reader-channel-card {
    background-color: #2a2a2a;
    border-color: #3a3a3a;
}

.reader-channel-title {
    font-size: 0.6875rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--tblr-secondary);
    margin-bottom: 0.75rem;
}

.reader-channel-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.reader-channel-list li {
    margin-bottom: 2px;
}

.reader-channel-list a {
    display: block;
    font-size: 0.8125rem;
    color: var(--tblr-body-color);
    text-decoration: none;
    padding: 5px 8px;
    border-radius: var(--tblr-border-radius);
    transition: background 0.12s;
}

.reader-channel-list a:hover {
    background: var(--tblr-bg-surface-secondary);
}

.reader-channel-list a.active {
    background: var(--tblr-bg-surface-secondary);
    font-weight: 500;
    color: var(--tblr-primary);
}

.reader-channel-lang {
    font-size: 0.75rem;
    color: var(--tblr-secondary);
    display: block;
}
