/* auth: houzb */
/* 阅读体验：阅读进度条 / Wiki 链接 / 目录滚动高亮 / 明暗主题 / 沉浸模式 / 搜索弹层 */

/* ---------- 阅读进度条 ---------- */
#reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0;
    background: linear-gradient(90deg, #0d6efd, #6f42c1);
    z-index: 1080;
    transition: width .1s linear;
}

/* ---------- 搜索弹层（Ctrl/Cmd+K） ---------- */
.search-overlay {
    position: fixed;
    inset: 0;
    z-index: 1090;
    background: rgba(0, 0, 0, .45);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 12vh;
    backdrop-filter: blur(2px);
}
.search-panel {
    width: min(640px, 92vw);
    background: var(--bs-body-bg, #fff);
    color: var(--bs-body-color, #212529);
    border-radius: 1rem;
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, .25);
    padding: 1rem 1.25rem;
}
.search-results {
    max-height: 55vh;
    overflow-y: auto;
}
.search-results .search-item {
    display: block;
    padding: .65rem .75rem;
    border-radius: .5rem;
    color: inherit;
    text-decoration: none;
}
.search-results .search-item:hover,
.search-results .search-item.active {
    background: rgba(13, 110, 253, .08);
}
.search-results .search-item .title {
    font-weight: 600;
}
.search-results .search-item .excerpt {
    color: var(--bs-secondary-color, #6c757d);
    font-size: .85rem;
}
.search-results .search-empty {
    padding: 1rem 0;
    color: var(--bs-secondary-color, #6c757d);
    text-align: center;
}
.search-results .search-loading {
    padding: 1rem 0;
    color: var(--bs-secondary-color, #6c757d);
    text-align: center;
}

/* ---------- Wiki 链接 ---------- */
.blog-content a.wiki-link {
    border-bottom: 1px dashed #0d6efd;
    text-decoration: none;
}
.blog-content a.wiki-link-missing,
a.wiki-link-missing {
    color: #adb5bd !important;
    border-bottom: 1px dashed #adb5bd;
    text-decoration: none;
    cursor: default;
}

/* ---------- 目录滚动高亮 ---------- */
.toc a.active {
    color: #0d6efd !important;
    font-weight: 600;
}
.toc a {
    display: block;
    padding: .1rem 0;
}

/* ---------- 沉浸模式 ---------- */
body.immersive .navbar,
body.immersive footer,
body.immersive .toc {
    display: none !important;
}
body.immersive main {
    max-width: 46rem;
    margin-left: auto;
    margin-right: auto;
}
body.immersive .blog-content {
    font-size: 1.15rem;
}

/* 沉浸模式悬浮退出按钮：导航栏隐藏后仍可见，避免无法退出 */
.immersive-float {
    position: fixed;
    top: .75rem;
    right: .75rem;
    z-index: 2000;
    display: none;
    width: 2.25rem;
    height: 2.25rem;
    border: 1px solid var(--bs-border-color);
    border-radius: .5rem;
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    font-size: 1rem;
    line-height: 1;
    align-items: center;
    justify-content: center;
    box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .15);
}
body.immersive .immersive-float {
    display: inline-flex !important;
}

/* ---------- 明暗主题 ---------- */
[data-theme="dark"] body,
[data-theme="dark"] {
    --bs-body-bg: #121417;
    --bs-body-color: #d6d9de;
    --bs-secondary-color: #8b9199;
    --bs-border-color: #2a2e34;
    --bs-tertiary-bg-rgb: 18, 20, 23;
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
}
[data-theme="dark"] .navbar,
[data-theme="dark"] .navbar.bg-white,
[data-theme="dark"] footer.bg-white,
[data-theme="dark"] .card,
[data-theme="dark"] .card.bg-white {
    background-color: #171a1f !important;
    border-color: #2a2e34 !important;
    color: var(--bs-body-color);
}
[data-theme="dark"] .card .card-title a,
[data-theme="dark"] .navbar-brand,
[data-theme="dark"] .nav-link {
    color: var(--bs-body-color) !important;
}
[data-theme="dark"] .text-secondary,
[data-theme="dark"] .toc a {
    color: var(--bs-secondary-color) !important;
}
[data-theme="dark"] .blog-content pre {
    background: #1c1f24;
    color: #d6d9de;
}
[data-theme="dark"] .blog-content table th,
[data-theme="dark"] .blog-content table td {
    border-color: #2a2e34;
}
[data-theme="dark"] .blog-content blockquote {
    border-left-color: #6f42c1;
    color: var(--bs-secondary-color);
}
[data-theme="dark"] .list-group-item {
    background-color: #171a1f;
    border-color: #2a2e34;
    color: var(--bs-body-color);
}
[data-theme="dark"] .badge.text-bg-light {
    background-color: #2a2e34 !important;
    color: var(--bs-body-color) !important;
    border-color: #343a40 !important;
}
[data-theme="dark"] .pagination .page-link {
    background-color: #171a1f;
    border-color: #2a2e34;
    color: var(--bs-body-color);
}
[data-theme="dark"] .bg-body-tertiary {
    background-color: #121417 !important;
}

/* 主题/沉浸切换按钮 */
.navbar .btn-icon {
    background: none;
    border: none;
    font-size: 1.1rem;
    line-height: 1;
    padding: .25rem .4rem;
    color: inherit;
}
