/* ============================================================
   夜王攻略 · PDF.js 阅读器
   主题：与星月绅士团网站统一 — 深紫紫粉奢华风
   v2: 双层顶栏（网站导航 + PDF工具栏）
   ============================================================ */

:root {
    --primary-dark: #0f0518;
    --secondary-dark: #1a0a2e;
    --tertiary-dark: #25143e;
    --accent: #7c3aed;
    --accent-l: #a855f7;
    --accent-2: #ec4899;
    --accent-2l: #f472b6;
    --cyan: #22d3ee;
    --text: #ffffff;
    --text-2: #b8b8c8;
    --text-3: #8888a0;
    --border: rgba(168, 85, 247, 0.22);
    --border-l: rgba(168, 85, 247, 0.45);
    --sidebar-w: 300px;
    --site-header-h: 60px;
    --pdf-toolbar-h: 44px;
    --total-header-h: 104px;
    --serif: 'Noto Serif SC', serif;
    --sans: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--sans);
    background: var(--primary-dark);
    color: var(--text);
    line-height: 1.8;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* ===== 全局滚动条 ===== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--primary-dark); }
::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border-radius: 4px;
}

/* ============================================================
   网站导航栏（与 index.html / hezuo.html 一致）
   ============================================================ */
.bk-site-header {
    position: fixed; top: 0; left: 0; right: 0;
    height: var(--site-header-h);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 5%;
    z-index: 1600;
    transition: all 0.4s ease;
    background: rgba(15, 5, 24, 0.95);
    backdrop-filter: blur(20px) saturate(1.4);
    -webkit-backdrop-filter: blur(20px) saturate(1.4);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 20px rgba(124, 58, 237, 0.12);
}
.bk-site-header.scrolled {
    box-shadow: 0 2px 30px rgba(124, 58, 237, 0.25);
}

.bk-site-logo {
    display: flex; align-items: center; gap: 0.7rem;
    text-decoration: none; flex-shrink: 0;
}
.bk-site-logo-icon {
    width: 32px; height: 32px; border-radius: 8px;
    object-fit: cover;
    box-shadow: 0 3px 12px rgba(124, 58, 237, 0.4);
}
.bk-site-logo-text {
    font-family: var(--serif); font-size: 1.3rem; font-weight: 700;
    background: linear-gradient(135deg, var(--accent-l), var(--accent-2));
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
    white-space: nowrap;
}

.bk-site-nav ul {
    display: flex; list-style: none; gap: 2rem;
}
.bk-site-nav ul li a {
    font-size: 0.9rem; font-weight: 500;
    color: var(--text-2); text-decoration: none;
    position: relative; padding: 0.4rem 0;
    transition: color 0.3s ease;
}
.bk-site-nav ul li a:hover {
    color: var(--accent-l);
}
.bk-site-nav ul li a.active {
    color: var(--accent-l);
}
.bk-site-nav ul li a::after {
    content: ''; position: absolute; bottom: 0; left: 0;
    width: 0; height: 2px;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    transition: width 0.3s ease;
}
.bk-site-nav ul li a:hover::after,
.bk-site-nav ul li a.active::after {
    width: 100%;
}

.bk-site-menu-toggle {
    display: none; font-size: 1.4rem; cursor: pointer;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

/* ============================================================
   PDF 工具栏
   ============================================================ */
.bk-pdf-toolbar {
    position: fixed; top: var(--site-header-h); left: 0; right: 0;
    height: var(--pdf-toolbar-h);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 16px;
    background: rgba(26, 10, 46, 0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    z-index: 1500;
}
.bk-pdf-toolbar-left {
    display: flex; align-items: center; gap: 10px; min-width: 0;
}
.bk-pdf-toolbar-right {
    display: flex; align-items: center; gap: 4px; flex-shrink: 0;
}
.bk-book-title {
    font-family: var(--serif); font-size: 0.92rem; font-weight: 700;
    color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    display: flex; align-items: center;
}

/* 工具栏按钮 */
.bk-ctrl {
    display: inline-flex; align-items: center; gap: 5px;
    height: 32px; padding: 0 10px;
    border: 1px solid var(--border);
    background: rgba(124,58,237,.07);
    color: var(--text-2);
    border-radius: 8px; cursor: pointer;
    font-size: .8rem; font-weight: 500;
    transition: all .22s ease; user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.bk-ctrl:hover { color: #fff; border-color: var(--accent-l); background: rgba(124,58,237,.18); }
.bk-ctrl:active { transform: scale(.95); }
.bk-ctrl.btn-icon { width: 32px; padding: 0; justify-content: center; font-size: .88rem; }
.bk-ctrl:disabled { opacity: .3; cursor: not-allowed; }
.bk-sep { width: 1px; height: 18px; background: var(--border); margin: 0 2px; flex-shrink: 0; }

/* 页码输入 */
.bk-page-info {
    display: flex; align-items: center; gap: 4px;
    font-size: .8rem; color: var(--text-2);
    margin: 0 2px;
}
.bk-page-input {
    width: 44px; height: 26px; text-align: center;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: rgba(15,5,24,.6);
    color: var(--text);
    font-size: .8rem; font-variant-numeric: tabular-nums;
    outline: none; transition: border-color .2s;
}
.bk-page-input:focus { border-color: var(--accent-l); }
.bk-page-total { font-variant-numeric: tabular-nums; opacity: .7; }

.bk-zoom-info {
    min-width: 38px; text-align: center;
    font-size: .76rem; color: var(--text-3);
    font-variant-numeric: tabular-nums;
}

/* ============================================================
   加载遮罩
   ============================================================ */
.bk-loader-overlay {
    position: fixed; inset: 0; z-index: 9999;
    background: var(--primary-dark);
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
    transition: opacity .6s ease;
}
.bk-loader-overlay.bk-hidden {
    opacity: 0; pointer-events: none;
}

/* 加载层背景光效 */
.bk-loader-overlay::before {
    content: ''; position: absolute; inset: 0;
    background:
        radial-gradient(800px 400px at 50% 30%, rgba(124,58,237,.12), transparent 60%),
        radial-gradient(600px 300px at 30% 70%, rgba(236,72,153,.06), transparent 50%);
    pointer-events: none;
}

.bk-loader-content {
    position: relative; z-index: 2;
    text-align: center;
    max-width: 420px; width: 90%;
    padding: 2rem;
}

.bk-loader-logo {
    margin-bottom: 1.8rem;
}
.bk-loader-ico {
    display: inline-flex; align-items: center; justify-content: center;
    width: 72px; height: 72px; border-radius: 20px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff; font-size: 2rem;
    box-shadow: 0 8px 32px rgba(124,58,237,.45);
    animation: bkLoaderPulse 2s ease-in-out infinite;
}
@keyframes bkLoaderPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 8px 32px rgba(124,58,237,.45); }
    50% { transform: scale(1.06); box-shadow: 0 12px 44px rgba(124,58,237,.6); }
}

.bk-loader-title {
    font-family: var(--serif); font-size: 2.2rem; font-weight: 700;
    background: linear-gradient(135deg, var(--accent-l), var(--accent-2));
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
    margin-bottom: .4rem; letter-spacing: .04em;
}
.bk-loader-sub {
    font-size: .9rem; color: var(--text-3); letter-spacing: .1em;
    margin-bottom: 2.2rem;
}

/* 进度条 */
.bk-loader-bar-wrap {
    width: 100%; height: 6px;
    background: rgba(168,85,247,.12);
    border-radius: 10px; overflow: hidden;
    margin-bottom: .8rem;
    position: relative;
}
.bk-loader-bar {
    height: 100%; width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--cyan));
    border-radius: 10px;
    transition: width .3s cubic-bezier(.4,0,.2,1);
    position: relative;
    box-shadow: 0 0 16px rgba(168,85,247,.6);
}
/* 进度条流光效果 */
.bk-loader-bar::after {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,.3), transparent);
    background-size: 200% 100%;
    animation: bkLoaderShine 1.5s linear infinite;
    border-radius: 10px;
}
@keyframes bkLoaderShine {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.bk-loader-info {
    display: flex; justify-content: space-between; align-items: center;
    font-size: .82rem; color: var(--text-3);
}
.bk-loader-info span:last-child {
    font-variant-numeric: tabular-nums;
    color: var(--accent-l); font-weight: 600;
}

/* 粒子动画 */
.bk-loader-particles {
    position: absolute; inset: 0; overflow: hidden;
    pointer-events: none; z-index: 1;
}
.bk-loader-particle {
    position: absolute; width: 4px; height: 4px;
    border-radius: 50%; opacity: 0;
    animation: bkParticleFloat 8s infinite ease-in-out;
}
@keyframes bkParticleFloat {
    0% { opacity: 0; transform: translateY(100vh) scale(0); }
    10% { opacity: .7; }
    90% { opacity: .7; }
    100% { opacity: 0; transform: translateY(-10vh) scale(1.2); }
}

/* ============================================================
   布局
   ============================================================ */
.bk-layout {
    display: flex;
    padding-top: var(--total-header-h);
    height: 100vh;
}

/* ============================================================
   侧边目录
   ============================================================ */
.bk-sidebar {
    width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
    position: sticky; top: var(--total-header-h);
    height: calc(100vh - var(--total-header-h));
    background: linear-gradient(180deg, var(--secondary-dark), var(--primary-dark));
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    z-index: 1200;
    transition: transform .32s cubic-bezier(.4,0,.2,1);
}
.bk-toc-head {
    padding: 14px 16px 10px;
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.bk-toc-head h2 {
    font-family: var(--serif); font-size: 1.02rem; color: var(--text);
    display: flex; align-items: center; gap: 8px;
}
.bk-toc-head h2 i { color: var(--accent-l); }
.bk-toc-close {
    display: none;
    align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: 8px;
    background: rgba(124,58,237,.15); color: var(--text-2);
    cursor: pointer; border: none;
    transition: all .2s;
}
.bk-toc-close:hover { background: rgba(124,58,237,.3); color: #fff; }
.bk-toc-search { padding: 8px 12px; flex-shrink: 0; }
.bk-toc-search input {
    width: 100%; height: 34px; padding: 0 10px 0 32px;
    border-radius: 8px; border: 1px solid var(--border);
    background: rgba(15,5,24,.6) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238888a0' stroke-width='2'><circle cx='11' cy='11' r='7'/><path d='M21 21l-4.3-4.3'/></svg>") no-repeat 10px center;
    color: var(--text); font-size: .84rem; outline: none;
    transition: border-color .2s;
}
.bk-toc-search input:focus { border-color: var(--accent-l); }
.bk-toc-search input::placeholder { color: var(--text-3); }
.bk-toc-scroll { flex: 1; overflow-y: auto; padding: 4px 6px 20px; -webkit-overflow-scrolling: touch; }
.bk-toc-scroll::-webkit-scrollbar { width: 5px; }
.bk-toc-scroll::-webkit-scrollbar-track { background: transparent; }
.bk-toc-scroll::-webkit-scrollbar-thumb { background: linear-gradient(var(--accent), var(--accent-2)); border-radius: 3px; }

/* TOC 树 */
.bk-toc { list-style: none; }
.bk-toc .bk-toc { padding-left: 10px; border-left: 1px dashed rgba(168,85,247,.15); margin-left: 6px; }
.bk-toc-item { margin: 1px 0; }
.bk-toc-link {
    display: flex; align-items: center; gap: 6px;
    padding: 7px 9px; border-radius: 7px;
    color: var(--text-2); text-decoration: none;
    font-size: .86rem; line-height: 1.4; cursor: pointer;
    transition: all .15s ease; position: relative;
    -webkit-tap-highlight-color: transparent;
}
.bk-toc-link:hover { background: rgba(124,58,237,.1); color: #fff; }
.bk-toc-link.active {
    background: linear-gradient(90deg, rgba(124,58,237,.25), rgba(236,72,153,.08));
    color: #fff; box-shadow: inset 3px 0 0 var(--accent-l);
}
.bk-toc-link .bk-dot {
    width: 5px; height: 5px; border-radius: 50%;
    background: var(--text-3); flex: 0 0 auto; transition: background .2s;
}
.bk-toc-link.active .bk-dot { background: var(--accent-l); box-shadow: 0 0 6px var(--accent-l); }
.bk-toc-link .bk-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.bk-toc-toggle {
    margin-left: auto; width: 16px; height: 16px;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--text-3); transition: transform .2s;
    cursor: pointer; font-size: .68rem; flex-shrink: 0;
}
.bk-toc-item.collapsed > .bk-toc { display: none; }
.bk-toc-item.collapsed > .bk-toc-link .bk-toc-toggle { transform: rotate(-90deg); }
.bk-toc-link.bk-sec-link { padding-left: 22px; font-size: .8rem; }
.bk-toc-link.bk-sec-link .bk-dot { width: 4px; height: 4px; }
.bk-toc-link.active-sec { color: var(--accent-l); background: rgba(124,58,237,.1); }

/* ============================================================
   PDF 主阅读区
   ============================================================ */
.bk-main {
    flex: 1; min-width: 0;
    background:
        radial-gradient(1400px 700px at 50% -10%, rgba(124,58,237,.08), transparent 60%),
        radial-gradient(900px 500px at 80% 30%, rgba(236,72,153,.04), transparent 50%),
        var(--primary-dark);
    display: flex; flex-direction: column;
    overflow: hidden;
}

.bk-pdf-scroll {
    flex: 1;
    overflow: auto;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}
.bk-pdf-scroll::-webkit-scrollbar { width: 8px; }
.bk-pdf-scroll::-webkit-scrollbar-track { background: rgba(0,0,0,.2); }
.bk-pdf-scroll::-webkit-scrollbar-thumb {
    background: rgba(168,85,247,.3); border-radius: 4px;
}
.bk-pdf-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(168,85,247,.5);
}

/* PDF 页面容器 */
.bk-pdf-pages {
    display: flex; flex-direction: column;
    align-items: center; gap: 8px;
    padding: 20px 0 40px;
    min-height: 100%;
}

.bk-pdf-page-wrapper {
    position: relative;
    box-shadow: 0 4px 20px rgba(0,0,0,.5), 0 0 0 1px rgba(168,85,247,.1);
    background: #fff;
    border-radius: 4px;
    transition: opacity .2s;
}
.bk-pdf-page-wrapper canvas {
    display: block; border-radius: 4px;
}
.bk-pdf-page-wrapper.loading {
    opacity: .3;
}
.bk-pdf-page-wrapper.loading::after {
    content: ''; position: absolute; top: 50%; left: 50%;
    width: 32px; height: 32px; margin: -16px 0 0 -16px;
    border: 3px solid rgba(124,58,237,.2);
    border-top-color: var(--accent-l);
    border-radius: 50%;
    animation: bkSpin 1s linear infinite;
}
.bk-pdf-page-wrapper.error {
    background: linear-gradient(135deg, rgba(239,68,68,.05), rgba(239,68,68,.02)) !important;
    box-shadow: 0 0 0 2px rgba(239,68,68,.3) !important;
}
.bk-pdf-page-wrapper.error::after {
    content: '\26A0 \6E32\67D3\5931\8D25';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(239,68,68,.6);
    font-size: 14px;
    font-weight: 500;
}
@keyframes bkSpin { to { transform: rotate(360deg); } }

.bk-pdf-page-num {
    position: absolute; bottom: 4px; right: 8px;
    font-size: 11px; color: rgba(0,0,0,.25);
    font-variant-numeric: tabular-nums;
    pointer-events: none;
}

/* ============================================================
   返回顶部
   ============================================================ */
.bk-fab {
    position: fixed; right: 18px; bottom: 20px;
    width: 42px; height: 42px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff; border: none;
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem; cursor: pointer;
    box-shadow: 0 8px 24px rgba(124,58,237,.5);
    opacity: 0; transform: translateY(14px); pointer-events: none;
    transition: all .3s ease; z-index: 1300;
}
.bk-fab.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
.bk-fab:hover { transform: translateY(-3px); }

/* ============================================================
   遮罩
   ============================================================ */
.bk-overlay {
    position: fixed; inset: 0; background: rgba(5,2,10,.6);
    backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
    z-index: 1100;
    opacity: 0; pointer-events: none; transition: opacity .3s ease;
}
.bk-overlay.show { opacity: 1; pointer-events: auto; }

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 1024px) {
    .bk-sidebar {
        position: fixed; top: var(--total-header-h); left: 0;
        transform: translateX(-100%); box-shadow: 0 0 40px rgba(0,0,0,.6);
        width: 280px; flex: 0 0 280px;
    }
    .bk-sidebar.open { transform: translateX(0); }
    .bk-toc-close { display: inline-flex; }
    .bk-menu-btn { display: inline-flex !important; }
}

@media (min-width: 1025px) {
    .bk-menu-btn { display: inline-flex !important; }
}

@media (max-width: 768px) {
    .bk-site-menu-toggle { display: block; }

    .bk-site-nav ul {
        position: fixed;
        top: 0; left: 0;
        width: 100%; height: 100vh;
        background: rgba(15, 5, 24, 0.98);
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2rem;
        transform: translateX(100%);
        transition: transform 0.4s ease;
        z-index: 999;
    }
    .bk-site-nav ul.active { transform: translateX(0); }
    .bk-site-nav ul li a { font-size: 1.2rem; }

    .bk-pdf-toolbar { padding: 0 10px; }
    .bk-book-title { font-size: .82rem; max-width: 35vw; }
    .bk-ctrl { padding: 0 8px; height: 30px; }
    .bk-ctrl.btn-icon { width: 30px; padding: 0; }
    .bk-sep { display: none; }
    .bk-page-input { width: 40px; height: 24px; font-size: .76rem; }
    .bk-zoom-info { min-width: 34px; font-size: .72rem; }
    .bk-page-info { font-size: .76rem; }

    :root {
        --site-header-h: 52px;
        --pdf-toolbar-h: 40px;
        --total-header-h: 92px;
    }
}

@media (max-width: 480px) {
    .bk-site-header { padding: 0 10px; }
    .bk-site-logo-text { font-size: 1.1rem; }
    .bk-site-logo-icon { width: 28px; height: 28px; }

    .bk-pdf-toolbar { padding: 0 8px; }
    .bk-book-title { font-size: .78rem; max-width: 30vw; }
    .bk-ctrl.btn-icon { width: 28px; height: 28px; font-size: .8rem; }
    .bk-zoom-info { display: none; }
    .bk-page-info { font-size: .72rem; }
    .bk-page-input { width: 36px; height: 22px; font-size: .72rem; }
    .bk-fab { right: 12px; bottom: 14px; width: 38px; height: 38px; font-size: .9rem; }

    .bk-loader-title { font-size: 1.6rem; }
    .bk-loader-ico { width: 56px; height: 56px; font-size: 1.5rem; }
}
