/* ============================================================
   Flava Docs — 样式表（v12）
   · 背景画布（fixed 全屏）
   · 顶部导航栏
   · 侧边栏（树形菜单）
   · 半透明白色圆角矩形背景（20% 透明度）
   · 文档文字白色系 + 标题 rgb(190,200,255)
   · 表格全透明、无交替色
   · 搜索框深色主题
   · 文字与白色矩形边缘保持 5px 间距
   ============================================================ */

/* ---------- Reset ---------- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    margin: 0 !important;
    padding: 0 !important;
    width: 100%;
    height: 100%;
}

body {
    font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: #000;
    color: #ffffff;
    overflow: hidden;
    line-height: 1.6;
}

a { color: rgb(190, 200, 255); text-decoration: none; }
a:hover { color: #ffffff; }

/* ---------- 顶部导航栏 ---------- */
.top-navbar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 42px;
    background: rgba(20, 20, 28, 0.82);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 9999;
    display: flex;
    align-items: center;
    padding-left: 16px;
    gap: 12px;
    border-bottom: 1px solid rgba(190, 200, 255, 0.2);
    margin: 0 !important;
}

.menu-icon {
    width: 18px; height: 13px;
    display: flex; flex-direction: column; justify-content: space-between;
    cursor: pointer; flex-shrink: 0;
}
.menu-icon span {
    width: 100%; height: 1.5px;
    background: #fff; border-radius: 0;
    transition: background 0.2s;
}
.menu-icon:hover span { background: rgb(190, 200, 255); }

.nav-text {
    color: #fff;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-shadow: 0 0 10px rgba(190, 200, 255, 0.4);
}

/* ---------- 侧边栏 ---------- */
.sidebar {
    position: fixed;
    top: 42px; left: -240px;
    width: 240px;
    height: calc(100vh - 42px);
    background: rgba(20, 20, 28, 0.78);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 99;
    transition: left 0.3s ease;
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(190, 200, 255, 0.15);
    overflow: hidden;
}
.sidebar.active { left: 0; }

.sidebar-header {
    padding: 14px 16px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.back-button {
    display: inline-block;
    color: rgb(190, 200, 255);
    font-size: 0.85rem;
    transition: color 0.2s;
}
.back-button:hover { color: #ffffff; }

.sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 8px 20px;
}
.sidebar-body::-webkit-scrollbar { width: 4px; }
.sidebar-body::-webkit-scrollbar-thumb { background: rgba(190,200,255,0.25); border-radius: 2px; }

.tree-title {
    color: rgba(255,255,255,0.35);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    padding: 0 12px;
    margin-bottom: 8px;
}

.tree-list { list-style: none; }
.tree-list li { margin: 1px 0; }

.tree-list .tree-label,
.tree-list [data-route] {
    display: block;
    padding: 7px 12px;
    color: rgba(255,255,255,0.7);
    font-size: 0.88rem;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
    user-select: none;
}
.tree-list .tree-label:hover,
.tree-list [data-route]:hover {
    color: rgb(190, 200, 255);
    background: rgba(190, 200, 255, 0.08);
}
.tree-list [data-route].active {
    color: #ffffff;
    background: rgba(190, 200, 255, 0.15);
    font-weight: 600;
}

.tree-item.has-children > .tree-label::before {
    content: '▸ ';
    display: inline-block;
    transition: transform 0.2s;
    color: rgba(255,255,255,0.3);
    font-size: 0.75rem;
}
.tree-item.has-children.open > .tree-label::before {
    content: '▾ ';
    color: rgb(190, 200, 255);
}

.tree-children {
    list-style: none;
    padding-left: 16px;
    border-left: 1px solid rgba(255,255,255,0.05);
    margin-left: 14px;
    display: none;
}
.tree-item.has-children.open > .tree-children { display: block; }

/* ---------- 背景画布 ---------- */
.grid-canvas {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    z-index: 0;
    pointer-events: none;
}
.fire-canvas {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    z-index: 1;
    pointer-events: none;
}

/* ============================================================
   核心：半透明白色圆角矩形背景
   - position: fixed → 钉在视口，永远铺满可视区
   - 离网页边缘 20px（top 62 = 42导航 + 20间距）
   - z-index 5，在画布之上、文字容器之下
   ============================================================ */
.content-bg {
    position: fixed;
    z-index: 5;
    top: 62px;          /* 42px 导航栏 + 20px 间距 */
    left: 20px;
    right: 20px;
    bottom: 20px;
    background: rgba(255, 255, 255, 0.20);
    border-radius: 20px;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    pointer-events: none;
}

/* ============================================================
   文档内容滚动容器
   - 与 .content-bg 同级，同样 fixed 钉视口
   - 关键：各边比 .content-bg 内缩 5px
     → top: 67px (bg 62 + 5)
     → left/right: 25px (bg 20 + 5)
     → bottom: 25px (bg 20 + 5)
   - 这 5px 就是文字离白色矩形边缘的间距
   - z-index 10 在背景之上
   ============================================================ */
.content-wrapper {
    position: fixed;
    z-index: 10;
    top: 67px;           /* bg top 62 + 5px 间距 */
    left: 38px;          /* bg left 20 + 5px 间距 */
    right: 25px;         /* bg right 20 + 5px 间距 */
    bottom: 25px;        /* bg bottom 20 + 5px 间距 */
    overflow-y: auto;
    overflow-x: hidden;
    transition: left 0.3s ease;
}

/* 侧边栏打开时，背景和文字容器一起右移 */
@media (min-width: 769px) {
    body.sidebar-open .content-bg {
        left: calc(20px + 240px);
    }
    body.sidebar-open .content-wrapper {
        left: calc(25px + 240px);
    }
}

/* ---------- docsify 内容区 ---------- */
/* 用极高优先级确保 padding 不被外部样式覆盖 */
body .content-wrapper #app {
    position: relative;
    z-index: 1;
    /* 左右各加 20px 内边距，让文字进一步远离白色矩形边缘
       总间距 = 5px(容器缩进) + 20px(padding) = 25px */
    padding: 30px 20px 30px 20px;
}

/* ---------- Markdown 内容（白色系） ---------- */
.markdown-section {
    color: #ffffff;
    line-height: 1.85;
}

/* 标题统一浅蓝紫 rgb(190,200,255) */
.markdown-section h1,
.markdown-section h2,
.markdown-section h3,
.markdown-section h4 {
    color: rgb(190, 200, 255);
    margin-top: 28px;
    margin-bottom: 14px;
    font-weight: 700;
    text-shadow: 0 0 14px rgba(190, 200, 255, 0.35);
}

.markdown-section h1 {
    font-size: 2rem;
    border-bottom: 2px solid rgba(190, 200, 255, 0.35);
    padding-bottom: 10px;
}
.markdown-section h2 {
    font-size: 1.45rem;
    border-bottom: 1px solid rgba(190, 200, 255, 0.25);
    padding-bottom: 6px;
}
.markdown-section h3 { font-size: 1.15rem; }
.markdown-section h4 { font-size: 1rem; }

.markdown-section p { margin-bottom: 14px; color: #ffffff; }

/* 链接 */
.markdown-section a {
    color: rgb(190, 200, 255);
    border-bottom: 1px dashed rgba(190, 200, 255, 0.5);
    transition: all 0.2s;
}
.markdown-section a:hover {
    color: #ffffff;
    border-bottom-color: #ffffff;
}

/* 行内 code */
.markdown-section code {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.88em;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-weight: 500;
}

/* 代码块 */
.markdown-section pre {
    background: rgba(20, 20, 28, 0.92) !important;
    border: 1px solid rgba(190, 200, 255, 0.2);
    border-radius: 10px;
    padding: 18px;
    overflow-x: auto;
    margin: 16px 0;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}
.markdown-section pre code {
    background: none;
    color: #e8e8e8;
    padding: 0;
    font-size: 0.85rem;
    line-height: 1.7;
    font-weight: 400;
}

/* 引用块 */
.markdown-section blockquote {
    border-left: 4px solid rgb(190, 200, 255);
    background: rgba(190, 200, 255, 0.06);
    padding: 12px 18px;
    margin: 16px 0;
    border-radius: 0 8px 8px 0;
    color: #f0f0f0;
}

/* 表格 —— 全透明，无交替色 */
.markdown-section table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 0.9rem;
}
.markdown-section th {
    background: rgba(190, 200, 255, 0.12);
    color: #ffffff;
    padding: 10px 14px;
    text-align: left;
    border: 1px solid rgba(190, 200, 255, 0.25);
    font-weight: 700;
}
.markdown-section td {
    padding: 10px 14px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #ffffff;
    background: transparent !important;   /* 强制透明，覆盖一切 */
}
.markdown-section tr:nth-child(even) td,
.markdown-section tr:nth-child(odd) td {
    background: transparent !important;
}
.markdown-section tr:hover td {
    background: rgba(190, 200, 255, 0.06) !important;
}

.markdown-section hr {
    border: none;
    border-top: 1px solid rgba(190, 200, 255, 0.25);
    margin: 28px 0;
}

.markdown-section img {
    max-width: 100%;
    border-radius: 8px;
    border: 1px solid rgba(190, 200, 255, 0.2);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.markdown-section ul,
.markdown-section ol {
    padding-left: 1.5em;
    margin-bottom: 14px;
    color: #ffffff;
}
.markdown-section li { margin-bottom: 6px; color: #ffffff; }

/* ---------- 搜索框（深色主题） ---------- */
.search { margin-bottom: 24px; position: relative; }

.search input {
    width: 100%;
    padding: 10px 16px;
    background: rgba(20, 20, 28, 0.85);
    border: 1px solid rgba(190, 200, 255, 0.3);
    border-radius: 8px;
    color: #ffffff;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.search input::placeholder { color: rgba(255,255,255,0.45); }
.search input:focus {
    border-color: rgb(190, 200, 255);
    box-shadow: 0 0 12px rgba(190, 200, 255, 0.3);
}

/* 搜索结果面板 */
.search .results-panel {
    background: rgba(20, 20, 28, 0.95) !important;
    border: 1px solid rgba(190, 200, 255, 0.25) !important;
    border-radius: 8px;
    margin-top: 6px;
    overflow: hidden;
}
.search .results-panel a {
    color: #ffffff !important;
    padding: 10px 16px;
    display: block;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    font-size: 0.88rem;
}
.search .results-panel a:hover {
    background: rgba(190, 200, 255, 0.12) !important;
    color: rgb(190, 200, 255) !important;
}
.search .results-panel a:last-child { border-bottom: none; }
.search .results-panel .empty {
    color: rgba(255,255,255,0.5);
    padding: 10px 16px;
    font-size: 0.88rem;
}

/* ---------- 响应式 ---------- */
@media (max-width: 768px) {
    .content-bg {
        top: 56px;
        left: 12px;
        right: 12px;
        bottom: 12px;
        border-radius: 14px;
    }
    .content-wrapper {
        top: 61px;       /* bg 56 + 5 */
        left: 17px;      /* bg 12 + 5 */
        right: 17px;     /* bg 12 + 5 */
        bottom: 17px;    /* bg 12 + 5 */
        border-radius: 14px;
    }
    body .content-wrapper #app { padding: 20px 14px; }
    .markdown-section h1 { font-size: 1.6rem; }
    .markdown-section h2 { font-size: 1.25rem; }
}

/* ---------- 滚动条美化 ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: rgba(0,0,0,0.3); }
::-webkit-scrollbar-thumb {
    background: rgba(190, 200, 255, 0.25);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(190, 200, 255, 0.45); }

/* ---------- 加载提示 ---------- */
#app > p:first-child { color: rgba(255,255,255,0.5); font-size: 0.9rem; }

/* ---------- 隐藏 docsify 自带侧边栏开关 ---------- */
.sidebar-toggle { display: none !important; }
body { padding-top: 0 !important; }
