/* ============================================================
   Hexo 主题样式
   基于文章渲染样式测试页面转换
   ============================================================ */

/* ==================== 全局重置 & CSS变量 ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #ffffff;
    --text: #1a1a1a;
    --text-secondary: #666666;
    --text-toc-sub: #555555;
    --text-hover: #000000;
    --border: #e0e0e0;
    --icon-color: #2a2a2a;
    --icon-hover: #000000;
    --icon-stroke-width: 1.75px;
}

[data-theme="dark"] {
    --bg: #000000;
    --text: #e8e8e8;
    --text-secondary: #aaaaaa;
    --text-toc-sub: #bbbbbb;
    --text-hover: #ffffff;
    --border: #2a2a2a;
    --icon-color: #d0d0d0;
    --icon-hover: #ffffff;
}

html, body {
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ==================== 主布局 ==================== */
.app {
    display: flex;
    justify-content: center;
    align-items: stretch;
    min-height: 100vh;
    padding: 40px 30px;
    gap: 40px;
    max-width: 1400px;
    margin: 0 auto;
}

/* ==================== 左栏：图标按钮 ==================== */
.left-actions {
    position: fixed;
    left: 28px;
    bottom: 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    z-index: 300;
}

.icon-btn,
.theme-toggle,
.toc-toggle-mobile {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--icon-color);
    width: 30px;
    height: 30px;
}

.icon-btn:hover,
.theme-toggle:hover,
.toc-toggle-mobile:hover {
    color: var(--icon-hover);
}

.icon-btn svg,
.theme-toggle svg,
.toc-toggle-mobile svg {
    width: 24px;
    height: 24px;
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: var(--icon-stroke-width);
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ==================== 手机端目录按钮 ==================== */
.toc-toggle-mobile {
    display: none;
}

/* ==================== 文章内容 ==================== */
.main-content {
    flex: 0 1 75%;
    min-width: 0;
    padding: 0 10px 80px 10px;
    margin-left: 70px;
}

.article-title {
    font-size: 2.2rem;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 18px;
    letter-spacing: -0.01em;
}

.article-meta {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 32px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 18px;
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

/* ===== 文章正文 ===== */
.article-body {
    font-size: 1.05rem;
    line-height: 1.9;
    color: var(--text);
    font-family: "Inter", -apple-system, BlinkMacSystemFont,
        "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Noto Sans SC",
        sans-serif;
}

.article-body p {
    margin-bottom: 20px;
    color: var(--text);
}

.article-body h1 {
    font-size: 2.0rem;
    font-weight: 700;
    color: var(--text);
    margin: 48px 0 16px 0;
    scroll-margin-top: 16px;
}
.article-body h2 {
    font-size: 1.8rem;
    font-weight: 600;
    color: var(--text);
    margin: 44px 0 14px 0;
    line-height: 1.3;
    letter-spacing: -0.3px;
    scroll-margin-top: 16px;
    font-family: "Inter", "SF Pro Display", -apple-system,
        "PingFang SC", "Microsoft YaHei", "Noto Sans SC",
        sans-serif;
}
.article-body h3 {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text);
    margin: 32px 0 10px 0;
    letter-spacing: -0.3px;
    scroll-margin-top: 16px;
    font-family: "Inter", "SF Pro Display", -apple-system,
        "PingFang SC", "Microsoft YaHei", "Noto Sans SC",
        sans-serif;
}
.article-body h4 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    margin: 24px 0 6px 0;
    letter-spacing: -0.3px;
    scroll-margin-top: 16px;
    font-family: "Inter", "SF Pro Display", -apple-system,
        "PingFang SC", "Microsoft YaHei", "Noto Sans SC",
        sans-serif;
}
.article-body h5 {
    font-size: 1.0rem;
    font-weight: 600;
    color: var(--text);
    margin: 20px 0 6px 0;
    scroll-margin-top:16px;
}
.article-body h6 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    margin:16px 0 4px 0;
    scroll-margin-top:16px;
}

.article-body a {
    color: var(--text);
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-thickness: 1px;
}
.article-body a:hover {
    text-decoration-thickness: 2px;
}

.article-body ul,
.article-body ol {
    margin: 0 0 20px 24px;
    color: var(--text);
}
.article-body li {
    margin-bottom: 4px;
}

.article-body blockquote {
    border-left: 3px solid var(--text);
    padding-left: 20px;
    margin: 0 0 20px 0;
    color: var(--text-secondary);
    font-style: italic;
}

/* ===== 代码块 ===== */
.article-body code,
.article-body pre code {
    font-family: "JetBrains Mono", "Fira Code", "Cascadia Code",
        "SF Mono", "Menlo", "Consolas", "Liberation Mono",
        "PingFang SC", "Microsoft YaHei", monospace;
}

.article-body code {
    font-size: 0.9em;
    background: #f0f0f0;
    color: #1a1a1a;
    padding: 1px 6px;
    border-radius: 0;
}

[data-theme="dark"] .article-body code {
    background: #1a1a1a;
    color: #e8e8e8;
}

.article-body pre {
    position: relative;
    background: #1e1e1e;
    padding: 8px 12px;
    border-radius: 0;
    overflow-x: auto;
    white-space: pre;
    line-height: 1.7;
    margin: 0 0 20px 0;
    border: 1px solid var(--border);
}

.article-body pre code {
    background: transparent;
    color: #d4d4d4;
    padding: 0;
    border-radius: 0;
    font-size: 0.95rem;
}

/* ===== 复制按钮 ===== */
.article-body pre .copy-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    padding: 2px 6px;
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.2);
    font-size: 0.7rem;
    font-family: inherit;
    cursor: pointer;
    opacity: 0;
    transition: all 0.25s ease;
    letter-spacing: 0.3px;
    line-height: 1.6;
}
.article-body pre:hover .copy-btn {
    opacity: 1;
}
.article-body pre .copy-btn:hover {
    color: rgba(255,255,255,0.7);
}
.article-body pre .copy-btn.copied {
    color: #8f8;
}

.article-body hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 40px 0;
}

/* ==================== 桌面端目录 ==================== */
.desktop-toc {
    flex: 0 0 180px;
    padding-top: 6px;
    padding-left: 10px;
    border-left: 1px solid var(--border);
    align-self: flex-start;
    position: sticky;
    top: 40px;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.desktop-toc::-webkit-scrollbar {
    display: none;
}

/* ==================== 手机端目录 ==================== */
.mobile-toc {
    display: none;
    position: fixed;
    right: -280px;
    top: 0;
    bottom: 0;
    width: 260px;
    border-left: 1px solid var(--border);
    border-right: none;
    padding: 20px 20px 30px 20px;
    background: var(--bg);
    z-index: 400;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.08);
    overflow-y: auto;
    max-height: 100vh;
    scrollbar-width: none;
    -ms-overflow-style: none;
    transition: right 0.3s ease;
}
.mobile-toc::-webkit-scrollbar {
    display: none;
}
.mobile-toc.open {
    right: 0;
    display: block;
}

/* ===== 手机端工具栏 ===== */
.mobile-toc-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0 16px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}
.mobile-toc-toolbar .toc-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    font-weight: 500;
}
.mobile-toc-toolbar .toolbar-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.mobile-toolbar-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--icon-color);
    width: 26px;
    height: 26px;
}
.mobile-toolbar-btn:hover {
    color: var(--icon-hover);
}
.mobile-toolbar-btn svg {
    width: 18px;
    height: 18px;
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: var(--icon-stroke-width);
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ===== 目录通用样式 ===== */
.toc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.toc-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    font-weight: 500;
}
.toc-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toc-global-toggle {
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    flex-shrink: 0;
}
.toc-global-toggle svg {
    width: 14px;
    height: 14px;
}
.toc-global-toggle:hover {
    color: var(--text-hover);
}

.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.toc-list li {
    line-height: 1.45;
    font-size: 0.88rem;
}

.toc-item-row {
    display: flex;
    align-items: center;
    gap: 4px;
}

.toc-toggle-btn {
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    flex-shrink: 0;
}
.toc-toggle-btn svg {
    width: 12px;
    height: 12px;
}
.toc-toggle-btn.collapsed svg {
    transform: rotate(-90deg);
}

.toc-list a {
    color: var(--text-secondary);
    text-decoration: none;
    display: block;
    padding: 2px 0;
    border-radius: 2px;
    flex: 1;
}
.toc-list a:hover {
    color: var(--text-hover);
}

.toc-list ul {
    list-style: none;
    padding-left: 16px;
    margin-top: 2px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.toc-list ul a {
    color: var(--text-toc-sub);
    font-size: inherit;
}
.toc-sub.collapsed {
    display: none;
}

/* ===== 手机端遮罩 ===== */
.toc-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 399;
}
.toc-overlay.active {
    display: block;
}
[data-theme="dark"] .toc-overlay {
    background: rgba(0, 0, 0, 0.6);
}

/* ==================== 响应式 ==================== */
@media (max-width: 900px) {
    .app {
        padding: 30px 20px;
        gap: 24px;
    }
    .main-content {
        flex: 1 1 55%;
        margin-left: 60px;
        padding-bottom: 70px;
    }
    .desktop-toc {
        flex: 0 0 140px;
    }
    .left-actions {
        left: 16px;
        bottom: 20px;
        gap: 12px;
    }
    .icon-btn,
    .theme-toggle {
        width: 26px;
        height: 26px;
    }
    .icon-btn svg,
    .theme-toggle svg {
        width: 20px;
        height: 20px;
    }
}

@media (max-width: 700px) {
    .app {
        flex-direction: column;
        align-items: center;
        padding: 20px 16px;
        gap: 16px;
    }
    .left-actions {
        display: none;
    }
    .toc-toggle-mobile {
        display: flex;
        position: fixed;
        right: 16px;
        bottom: 20px;
        z-index: 300;
        width: 26px;
        height: 26px;
    }
    .toc-toggle-mobile svg {
        width: 20px;
        height: 20px;
    }
    .main-content {
        flex: 1 1 100%;
        width: 100%;
        margin-left: 0;
        order: 1;
        padding-bottom: 80px;
    }
    .desktop-toc {
        display: none;
    }
    .mobile-toc {
        display: block;
        right: -280px;
        padding-top: 16px;
    }
    .mobile-toc.open {
        right: 0;
    }
    .toc-header {
        margin-bottom: 12px;
    }
    .toc-title {
        font-size: 0.8rem;
    }
    .article-title {
        font-size: 1.8rem;
    }
}

@media (max-width: 480px) {
    .app {
        padding: 14px 12px;
    }
    .article-title {
        font-size: 1.5rem;
    }
    .article-body {
        font-size: 0.98rem;
    }
    .main-content {
        padding-bottom: 70px;
    }
    .toc-toggle-mobile {
        right: 12px;
        bottom: 14px;
        width: 22px;
        height: 22px;
    }
    .toc-toggle-mobile svg {
        width: 18px;
        height: 18px;
    }
    .mobile-toc {
        width: 220px;
        right: -240px;
        padding: 12px 16px 20px 16px;
    }
    .mobile-toc.open {
        right: 0;
    }
    .mobile-toolbar-btn {
        width: 22px;
        height: 22px;
    }
    .mobile-toolbar-btn svg {
        width: 16px;
        height: 16px;
    }
}

::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--text-secondary);
    border-radius: 4px;
}
/* ===== 修复代码块双重边框 ===== */
.article-body pre code {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

.article-body pre {
    border: 1px solid var(--border);
    overflow: hidden;
}

.hljs {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
}
