/* BYPsNotes 笔记专用样式 */

/* === 富文本颜色类 - 简洁版（配合 <span> 使用） === */
.text-red {
    color: #dc2626 !important;
}

.text-blue {
    color: #2563eb !important;
}

.text-orange {
    color: #ea580c !important;
}

.text-cyan {
    color: #0d9488 !important;
}

.text-green {
    color: #16a34a !important;
}

.text-purple {
    color: #7c3aed !important;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", "Microsoft YaHei", sans-serif;
    line-height: 1.8;
    color: #24292e;
    max-width: 1200px;
    margin: 40px auto;
    padding: 0 20px;
    background-color: #ffffff;
    overflow-x: hidden;
}

/* 笔记内一级标题（#）紧凑样式 */
.markdown-content h1 {
    font-size: 1.4rem;
    line-height: 1.4;
    margin-top: 1.2rem;
    margin-bottom: 0.8rem;
}

/* 笔记内二级标题（##）样式 */
.markdown-content h2 {
    font-size: 1.5rem;
    line-height: 1.3;
    margin-top: 2.5em;
    margin-bottom: 0.6rem;
    border-bottom: 1px solid #d0d7de;
    padding-bottom: 0.3em;
}

/* 笔记内三级标题（###）样式 */
.markdown-content h3 {
    font-size: 1.25rem;
    margin-top: 2em;
}

/* 笔记内图片响应式：桌面端缩略图，移动端自适应 */
.markdown-content img {
    height: auto !important;
    cursor: zoom-in;
}

/* 桌面端：默认缩略图 50%，可被内联 style 覆盖 */
@media (min-width: 769px) {
    .markdown-content img {
        max-width: 50%;
    }
}

/* 移动端：强制 100% 宽度 */
@media (max-width: 768px) {
    .markdown-content img {
        max-width: 100% !important;
        width: 100% !important;
        height: auto !important;
    }

    .markdown-content figure {
        max-width: 100% !important;
        width: 100% !important;
        display: block !important;
    }
}

/* 图片灯箱遮罩 */
.img-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    cursor: zoom-out;
}

.img-lightbox img {
    max-width: 95vw !important;
    max-height: 95vh !important;
    border-radius: 4px;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
}

h2 {
    font-size: 1.85rem;
    border-bottom: 1px solid #d0d7de;
    padding-bottom: 0.3em;
    margin-top: 2.5em;
}

h3 {
    font-size: 1.55rem;
    margin-top: 2em;
}

/* 代码块样式 - 深色主题 */
.markdown-content pre,
pre {
    background-color: #1e1e1e;
    color: #ffffff;
    padding: 18px;
    border-radius: 8px;
    overflow-x: auto;
    border: 1px solid #3e3e3e;
    font-size: 0.95rem;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    line-height: 1.5;
}

/* 预格式化代码块中的 code 标签 */
.markdown-content pre code,
pre code {
    background-color: transparent !important;
    color: #ffffff !important;
    padding: 0;
    border-radius: 0;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.95rem;
}

/* 行内代码 */
.markdown-content code,
code {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    background-color: #f6f8fa;
    color: #333;
    padding: 2px 6px;
    border-radius: 3px;
}

p, ul, ol {
    margin: 1.2em 0;
}

li {
    margin: 0.45em 0;
}

.markdown-content img {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    margin: 1.8em 0;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

table {
    border-collapse: collapse;
    width: 100%;
    margin: 2em 0;
}

th, td {
    border: 1px solid #d0d7de;
    padding: 12px;
    text-align: left;
}

th {
    background-color: #f6f8fa;
}

blockquote {
    border-left: 5px solid #0969da;
    padding-left: 24px;
    color: #57606a;
    margin: 2em 0;
}

/* 暗黑模式 */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #0d1117;
        color: #e6edf3;
    }

    pre, code {
        background-color: #161b22;
        border-color: #30363d;
        color: #e6edf3;
    }

    th {
        background-color: #161b22;
    }

    h2 {
        border-color: #30363d;
    }
}

/* 导航栏样式 */
.note-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 2px solid #0969da;
}

.note-title {
    font-size: 1.8em;
    color: #2c3e50;
    font-weight: bold;
}

.note-links a {
    margin-left: 20px;
    color: #7f8c8d;
    text-decoration: none;
}

.note-links a:hover {
    color: #0969da;
    text-decoration: none;
}

/* 元信息样式 */
.note-meta {
    font-size: 0.9em;
    color: #57606a;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

/* 目录样式 */
.toc {
    background-color: #f8f9fa;
    border-left: 4px solid #0969da;
    padding: 15px;
    margin: 2em 0;
    border-radius: 0 4px 4px 0;
}

.toc h3 {
    margin-top: 0;
    margin-bottom: 10px;
    color: #2c3e50;
}

.toc ul {
    margin: 0;
    padding-left: 20px;
}

/* 链接样式 */
a {
    color: #0969da;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* 响应式设计 */
@media (max-width: 1200px) {
    body {
        max-width: 100%;
        padding: 20px 15px;
    }
}

@media (max-width: 768px) {
    body {
        max-width: 100%;
        padding: 10px;
        font-size: 14px;
        overflow-x: hidden;
    }

    /* 表格水平滚动支持 - 美化滚动条 */
    .markdown-content {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .markdown-content::-webkit-scrollbar {
        height: 4px;
    }
    
    .markdown-content::-webkit-scrollbar-track {
        background: #f1f1f1;
    }
    
    .markdown-content::-webkit-scrollbar-thumb {
        background: #ccc;
        border-radius: 2px;
    }
    
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        font-size: 12px;
        border-collapse: collapse;
    }
    
    th, td {
        padding: 6px 8px;
        min-width: 60px;
        border: 1px solid #d0d7de;
    }
    
    th {
        background-color: #f6f8fa;
        position: sticky;
        top: 0;
    }
    
    pre {
        /* 保留 pre 默认 white-space: pre（不自动换行），配合桌面端已设的 overflow-x: auto 实现横向拖动 */
        font-size: 12px;
        padding: 12px;
    }
    .markdown-content pre::-webkit-scrollbar,
    pre::-webkit-scrollbar {
        height: 4px;
    }
    .markdown-content pre::-webkit-scrollbar-track,
    pre::-webkit-scrollbar-track {
        background: transparent;
    }
    .markdown-content pre::-webkit-scrollbar-thumb,
    pre::-webkit-scrollbar-thumb {
        background: #555;
        border-radius: 2px;
    }

    /* 移动端列表紧凑化：减小左缩进与行间距 */
    .markdown-content ul,
    .markdown-content ol {
        padding-left: 1.4em;
        margin: 0.6em 0;
        /* 超长行不换行，整个列表作为一个横向滑动容器（同 Markdown 表格）*/
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .markdown-content ul::-webkit-scrollbar,
    .markdown-content ol::-webkit-scrollbar {
        height: 4px;
    }
    .markdown-content ul::-webkit-scrollbar-track,
    .markdown-content ol::-webkit-scrollbar-track {
        background: transparent;
    }
    .markdown-content ul::-webkit-scrollbar-thumb,
    .markdown-content ol::-webkit-scrollbar-thumb {
        background: #ccc;
        border-radius: 2px;
    }
    .markdown-content li {
        margin: 0.15em 0;
        line-height: 1.55;
        white-space: nowrap;
    }
    .markdown-content li > p {
        margin: 0.2em 0;
        white-space: nowrap;
    }

    .note-nav {
        flex-direction: column;
        text-align: center;
    }

    .note-links {
        margin-top: 10px;
    }
}
