/* =========================================================
 * guidelines.css - 游玩须知页（对齐语雀 ne viewer 实测样式）
 * 数值来源：语雀文档阅读页 getComputedStyle 实测（视口 1368）
 * ========================================================= */

:root {
    --yq-text-primary: #262626; /* 标题/正文 */
    --yq-text-secondary: #585a5a; /* 顶栏文档名/目录条目 */
    --yq-text-caption: #8a8f8d; /* 弱文字 */
    --yq-text-link: #1677ff; /* 链接 */
    --yq-border: #e7e9e8; /* 边框/选中条 */
    --yq-bg-secondary: #fafafa;
    --yq-bg-tertiary: #f4f5f5;
    --yq-rail-line: #d8dad9; /* 收起态短横线 */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    min-height: 100%;
}

body {
    font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    "Helvetica Neue", Helvetica, Arial, sans-serif, "Segoe UI";
    background: #fff;
    color: var(--yq-text-primary);
    font-size: 15px;
    line-height: 1.74;
    padding-top: 52px; /* 让开固定顶栏 */
}

/* ==================== 顶栏（语雀 #header：固定 52px 白底 + rgba(0,0,0,.04) 下边线） ==================== */

.md-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 52px;
    padding: 0 16px;
    background: #fff;
    border-bottom: 1px solid rgba(0, 0, 0, .04);
}

.header-left {
    display: flex;
    align-items: center;
    min-width: 0;
}

.header-logo {
    width: 16px;
    height: 16px;
    margin-right: 8px;
    border-radius: 2px;
}

.md-title {
    font-size: 14px;
    font-weight: 400;
    color: var(--yq-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ==================== 正文区（语雀 .ne-viewer-body：左右 50px 内边距 + 右侧固定预留 305px） ==================== */

/* 正文列在整个页面内水平居中 */
.doc-body {
    padding: 0 50px;
}

.doc-title-wrap,
.md-content {
    max-width: 750px;
    margin: 0 auto;
}

/* 视口不足时减小两侧留白 */
@media (max-width: 1200px) {
    .doc-body {
        padding: 0 24px;
    }
}

/* 窄屏下手动展开大纲时：正文让出侧栏宽度，避免被大纲遮挡 */
@media (max-width: 1359.98px) {
    body.toc-expanded .doc-body {
        padding-right: 355px; /* 305px 大纲 + 50px 间距 */
    }
}

/* 文档大标题（语雀：36px/50px/700，无分隔线） */
.doc-title-wrap {
    margin-top: 24px;
    margin-bottom: 12px;
}

.doc-title {
    font-size: 36px;
    line-height: 50px;
    font-weight: 700;
    letter-spacing: normal;
    color: var(--yq-text-primary);
    word-break: break-word;
}

.md-content {
    padding-bottom: 120px;
    overflow-wrap: break-word;
}

.doc-loading,
.doc-error {
    color: var(--yq-text-caption);
    text-align: center;
    padding-top: 60px;
}

.doc-error {
    color: #f5222d;
}

/* ==================== Markdown 排版（语雀实测值） ==================== */

.md-content h1,
.md-content h2,
.md-content h3,
.md-content h4 {
    font-weight: 400;
    color: var(--yq-text-primary);
    padding: 0;
    word-spacing: 1px;
}

.md-content > :first-child {
    margin-top: 0 !important;
}

.md-content h1 {
    font-size: 28px;
    line-height: 40px;
    margin: 34px 0 17px;
}

.md-content h2 {
    font-size: 24px;
    line-height: 34px;
    margin: 34px 0 17px;
}

.md-content h3 {
    font-size: 20px;
    line-height: 30px;
    margin: 30px 0 15px;
}

.md-content h4 {
    font-size: 16px;
    line-height: 26px;
    margin: 26px 0 13px;
}

.md-content h5 {
    font-size: 15px;
    line-height: 26px;
    margin: 26px 0 13px;
    font-weight: 400;
}

.md-content h6 {
    font-size: 15px;
    line-height: 26px;
    margin: 26px 0 13px;
    font-weight: 400;
}

/* 正文一、二级标题加粗（层级以右侧大纲目录为准，由 guidelines.js 标注） */
.md-content .h-bold {
    font-weight: 700;
}

.md-content p {
    font-size: 15px;
    line-height: 26.1px;
    color: var(--yq-text-primary);
    margin: 0 0 7.83px;
}

.md-content li > p {
    margin: 0;
}

.md-content ul,
.md-content ol {
    margin: 0 0 7.83px;
    padding-left: 2em;
    text-indent: 0;
}

.md-content ul ul,
.md-content ul ol,
.md-content ol ol,
.md-content ol ul {
    margin-top: 0;
    margin-bottom: 0;
}

.md-content ul {
    list-style-type: disc;
}

.md-content ul ul {
    list-style-type: circle;
}

.md-content ul ul ul {
    list-style-type: square;
}

.md-content ol {
    list-style-type: decimal;
}

.md-content li {
    font-size: 15px;
    line-height: 26.1px;
}

.md-content b,
.md-content strong {
    font-weight: 700;
}

.md-content a,
.md-content a:active {
    color: var(--yq-text-link);
    text-decoration: none;
    word-wrap: break-word;
}

.md-content a:hover {
    text-decoration: underline;
}

.md-content del {
    text-decoration: line-through;
}

.md-content mark {
    background-color: #ff0;
    padding: 0;
}

.md-content blockquote {
    color: var(--yq-text-caption);
    border-left: 3px solid var(--yq-border);
    padding: 0 0 0 1em;
    margin: 0 0 7.83px;
}

.md-content code {
    font-family: monospace;
    font-size: inherit;
    line-height: inherit;
    word-wrap: break-word;
    word-break: break-all;
    background-color: rgba(0, 0, 0, .06);
    border: 1px solid rgba(0, 0, 0, .08);
    border-radius: 2px;
    padding: 0 2px;
}

.md-content pre {
    tab-size: 4;
    background: var(--yq-bg-secondary);
    border: 1px solid var(--yq-border);
    border-radius: 2px;
    margin: 0 0 7.83px;
    padding: 16px;
    font-family: Consolas, Menlo, Courier, monospace;
    font-size: 13px;
    line-height: 21px;
    overflow: auto;
}

.md-content pre code {
    display: block;
    font-size: inherit;
    line-height: inherit;
    background: none;
    border: none;
    padding: 0;
    color: inherit;
}

.md-content kbd {
    border: 1px solid var(--yq-border);
    border-radius: 3px;
    margin: 0 1px;
    padding: 0 4px;
    font-family: Consolas, Menlo, Courier, monospace;
    font-size: 13px;
    line-height: 18px;
    display: inline-block;
}

/* 表格：外层容器负责横向滚动（表格自身设 display:block 会破坏列宽计算，
   且文档里的表格带行内 width/max-width，会覆盖样式导致窄屏整页横向溢出） */
.md-table-wrap {
    margin: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.md-content table {
    border-collapse: collapse;
    border-spacing: 0;
    display: table;
    width: auto;
    min-width: 100%;
    max-width: none;
    margin: 0;
    font-size: 15px;
}

.md-content table tr {
    background: #fff;
    border-top: 1px solid var(--yq-border);
}

.md-content table tr:nth-child(odd) {
    background-color: var(--yq-bg-secondary);
}

.md-content table thead tr,
.md-content table thead tr:nth-child(odd) {
    background-color: var(--yq-bg-tertiary);
}

.md-content table td,
.md-content table th {
    border: 1px solid var(--yq-border);
    padding: 6px 8px;
    line-height: 26.1px;
    text-align: left;
    vertical-align: top;
    overflow-wrap: break-word;
    word-break: break-word;
}

.md-content table p {
    margin: 0;
}

/* 表格内的图片随单元格宽度缩放，不把表格撑宽 */
.md-content table img {
    max-width: 100%;
    height: auto;
}

.md-content img {
    max-width: 100%;
    border-radius: 4px;
    cursor: pointer;
}

.md-content hr {
    background-color: var(--yq-border);
    border: none;
    height: 2px;
    margin: 0 0 7.83px;
}

/* 锚点跳转避开固定顶栏（52px 顶栏 + 28px 余量） */
.md-content h1, .md-content h2, .md-content h3,
.md-content h4, .md-content h5, .md-content h6 {
    scroll-margin-top: 80px;
}

/* ==================== 右侧大纲（语雀 #sidePanel：展开 305px 通栏面板，收起 50px 竖条短横线） ==================== */

.toc {
    position: fixed;
    top: 52px;
    right: 0;
    bottom: 0;
    width: 305px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fff;
    letter-spacing: normal;
    font-size: 14px;
    user-select: none;
    z-index: 990;
}

/* 表头固定在顶部，不随目录列表滚动 */
.toc-head {
    flex: none;
    display: flex;
    align-items: center;
    height: 30px;
    padding: 8px 0 0 28px;
    margin-bottom: 12px;
}

/* 目录列表独立滚动 */
.toc-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.toc-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--yq-text-primary);
    margin-right: 8px;
}

.toc-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 24px;
    padding: 0;
    border: none;
    background: none;
    color: var(--yq-text-primary);
    cursor: pointer;
}

.toc-btn:hover {
    color: var(--yq-text-link);
}

/* 两个表头图标之间留出间距 */
.toc-btn + .toc-btn {
    margin-left: 8px;
}

.toc ul {
    list-style: none;
}

.toc-children {
    padding-left: 17px;
}

/* 条目：height 22 / margin-bottom 6 / padding 0 20px 0 25px / 文字 14px #585a5a */
.toc-item {
    position: relative;
    height: 22px;
    margin: 0 0 6px;
    padding: 0 20px 0 25px;
    font-size: 14px;
    line-height: 22px;
    color: var(--yq-text-secondary);
    border-left: 3px solid transparent;
    cursor: pointer;
    transition: color .12s, border-color .12s;
}

.toc-item:hover {
    color: var(--yq-text-primary);
}

/* 选中项：加粗 + 左侧深色竖条（比语雀原样加深加粗，保证醒目） */
.toc-item.active {
    font-weight: 700;
    border-left-color: var(--yq-text-primary);
}

.toc-text {
    display: block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* 折叠箭头：17px 槽位、16px 线性图标、#8a8f8d */
.toc-fold {
    position: absolute;
    left: 0;
    top: 0;
    width: 17px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--yq-text-caption);
    transition: transform .12s, color .12s;
}

.toc-fold:hover {
    color: var(--yq-text-primary);
}

.toc-node.folded > .toc-item .toc-fold {
    transform: rotate(-90deg);
}

.toc-node.folded > .toc-children {
    display: none;
}

/* ---- 收起态（语雀 ne-toc-small-view）：50px 竖条，条目变成右对齐短横线 ---- */

.toc.mini {
    width: 50px;
}

.toc.mini .toc-body {
    overflow: hidden;
}

.toc.mini .toc-head {
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
}

.toc.mini .toc-text,
.toc.mini .toc-fold {
    display: none;
}

.toc.mini .toc-children {
    padding-left: 0;
}

.toc.mini .toc-item {
    padding-right: 13px;
    border-left-color: transparent;
}

/* 每个标题一条右对齐短横线，宽度随层级递减：24/16/12/8/4/2 */
.toc.mini .toc-item::before {
    content: "";
    position: absolute;
    right: 0;
    top: 10px;
    height: 2px;
    width: 24px;
    background: var(--yq-rail-line);
}

.toc.mini .toc-item[data-depth="2"]::before {
    width: 16px;
}

.toc.mini .toc-item[data-depth="3"]::before {
    width: 12px;
}

.toc.mini .toc-item[data-depth="4"]::before {
    width: 8px;
}

.toc.mini .toc-item[data-depth="5"]::before {
    width: 4px;
}

.toc.mini .toc-item[data-depth="6"]::before {
    width: 2px;
}

.toc.mini .toc-item.active::before {
    background: var(--yq-text-primary);
}

/* 鼠标悬浮收起态竖条：恢复完整面板（语雀 .ne-toc-small-view:hover{width:305px}） */
.toc.mini:hover {
    width: 305px;
}

.toc.mini:hover .toc-body {
    overflow-y: auto;
}

.toc.mini:hover .toc-head {
    opacity: 1;
    overflow: visible;
    pointer-events: auto;
}

.toc.mini:hover .toc-text {
    display: block;
}

.toc.mini:hover .toc-fold {
    display: flex;
}

.toc.mini:hover .toc-children {
    padding-left: 17px;
}

.toc.mini:hover .toc-item {
    padding-right: 20px;
    border-left-color: transparent;
}

.toc.mini:hover .toc-item.active {
    border-left-color: var(--yq-text-primary);
}

.toc.mini:hover .toc-item::before {
    display: none;
}

/* ==================== 正文标题折叠（悬浮标题左侧出现折叠箭头） ==================== */

.md-content .h-fold {
    position: absolute;
    left: -22px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--yq-text-caption);
    cursor: pointer;
    opacity: 0;
    transition: opacity .12s, transform .12s, color .12s;
    user-select: none;
}

.md-content h1:hover .h-fold,
.md-content h2:hover .h-fold,
.md-content h3:hover .h-fold {
    opacity: 1;
}

.md-content .folded > .h-fold {
    opacity: 1;
    color: var(--yq-text-primary);
    transform: translateY(-50%) rotate(-90deg);
}

.md-content .fold-hidden {
    display: none !important;
}

/* ==================== 回到顶部（对齐语雀：42px 圆钮，right 24 / bottom 200，位置固定不变） ==================== */

.back-top {
    position: fixed;
    right: 24px;
    bottom: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 50%;
    background: #fafafa;
    color: var(--yq-text-secondary);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s, background .2s, visibility .2s;
    z-index: 997;
    box-shadow: 0 1px 4px -2px rgba(0, 0, 0, .13),
    0 2px 8px 0 rgba(0, 0, 0, .08),
    0 8px 16px 4px rgba(0, 0, 0, .04);
}

.back-top.show {
    opacity: 1;
    visibility: visible;
}

.back-top:hover {
    background: #eff0f0;
}

/* ==================== 浏览量（左下角） ==================== */

.visit-count {
    position: fixed;
    left: 24px;
    bottom: 24px;
    font-size: 12px;
    line-height: 1;
    color: var(--yq-text-caption);
    user-select: none;
    pointer-events: none;
    z-index: 80;
}

/* ==================== 图片查看器（对齐语雀 PhotoSwipe 改版） ==================== */

.md-content img.zoomable {
    cursor: zoom-in;
}

.lightbox {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .8);
    z-index: 1500;
}

.lightbox.show {
    display: flex;
}

.lightbox img {
    max-width: 100%;
    max-height: calc(100vh - 120px);
    object-fit: contain;
    transition: transform .15s ease;
}

/* 1:1 原始尺寸：按图片真实像素显示（超出视口可拖拽/缩放查看） */
.lightbox.native img {
    max-width: none;
    max-height: none;
}

.lightbox-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 48px;
    height: 48px;
    border: none;
    background: transparent;
    color: #fff;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    opacity: .85;
}

.lightbox-close:hover {
    opacity: 1;
}

/* 底部工具条：深色药丸，圆角 4px，内边距 12px */
.lightbox-toolbar {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    background: #252525;
    border-radius: 4px;
    padding: 12px;
}

.lightbox-toolbar button {
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 2px;
    background: transparent;
    color: #d9d9d9;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.lightbox-toolbar button:hover {
    background: rgba(255, 255, 255, .12);
}

/* 激活态（语雀：background #454545） */
.lightbox-toolbar button.active {
    background: #454545;
}

.lightbox-toolbar button[data-act="fit"],
.lightbox-toolbar button[data-act="actual"] {
    font-size: 13px;
}

.lightbox-divider {
    width: 1px;
    height: 20px;
    background: rgba(255, 255, 255, .2);
    margin: 0 4px;
}

.lightbox-counter {
    min-width: 50px;
    height: 32px;
    line-height: 32px;
    color: #d9d9d9;
    font-size: 14px;
    text-align: center;
}

/* ==================== 窄屏适配 ==================== */

@media (max-width: 720px) {
    .doc-body {
        padding: 0 16px;
    }

    .doc-title {
        font-size: 28px;
        line-height: 40px;
    }

    .md-header {
        padding: 0 12px;
    }
}
