/**
 * Markdown 内容样式
 * 仅用于文章页面的 Markdown 内容渲染
 */

/* ==========================
 * Markdown 卡片组件样式
 * ========================== */

.md-card {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    margin: 16px 0;
    overflow: hidden;
    transition: box-shadow var(--transition-speed);
}

.md-card:hover {
    box-shadow: var(--shadow-md);
}

.md-card-title {
    padding: 12px 16px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-color);
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-color);
}

.md-card-content {
    padding: 16px;
    color: var(--text-color);
    line-height: 1.8;
}

/* ==========================
 * Markdown 折叠组件样式
 * ========================== */

.md-collapse {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    margin: 16px 0;
    overflow: hidden;
}

.md-collapse-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    cursor: pointer;
    user-select: none;
    transition: background var(--transition-speed);
}

.md-collapse-header:hover {
    background: var(--bg-color-light);
}

.md-collapse-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-color);
    flex: 1;
}

.md-collapse-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    transition: transform var(--transition-speed);
}

.md-collapse.expanded .md-collapse-icon {
    transform: rotate(180deg);
}

.md-collapse-content {
    padding: 0 16px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out, padding 0.3s ease-out;
}

.md-collapse.expanded .md-collapse-content {
    padding: 16px;
    max-height: 2000px;
    transition: max-height 0.5s ease-in, padding 0.3s ease-in;
}

/* Markdown 内容样式 - 可在任何地方使用 */
.markdown-content {
    color: var(--text-color);
    line-height: 1.8;
}

/* 定义代码字体 */
@font-face {
    font-family: 'JetBrains Mono';
    src: url('../fonts/JetBrainsMono-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

.markdown-content p {
    margin-bottom: 12px;
}

.markdown-content p:last-child {
    margin-bottom: 0;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
    margin: 16px 0 8px 0;
    color: var(--text-color);
    position: relative;
    padding-left: 24px;
    scroll-margin-top: calc(var(--topbar-height) + var(--categories-height) + 20px);
}

/* 使用伪元素添加左侧 # 符号 */
.markdown-content h1::before,
.markdown-content h2::before,
.markdown-content h3::before,
.markdown-content h4::before,
.markdown-content h5::before,
.markdown-content h6::before {
    content: '#';
    position: absolute;
    left: 0;
    color: var(--primary-color);
    font-weight: bold;
}

.markdown-content h1 {
    font-size: 24px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border-color);
}

.markdown-content h2 {
    font-size: 20px;
}

.markdown-content h3 {
    font-size: 18px;
}

.markdown-content h4 {
    font-size: 16px;
}

.markdown-content strong {
    color: var(--primary-color);
    font-weight: 600;
}

.markdown-content em {
    font-style: italic;
}

.markdown-content code {
    background: var(--page-bg-color);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 14px;
}

.markdown-content pre {
    background: #1e1e1e;
    padding: 12px 12px 12px 0;
    border-radius: var(--border-radius);
    overflow-x: auto;
    margin: 12px 0;
    position: relative;
    display: flex;
}

/* 行号列 */
.markdown-content pre .line-numbers {
    background: #1e1e1e;
    padding: 0 1em;
    text-align: right;
    color: #666;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    user-select: none;
    flex-shrink: 0;
    border-right: 1px solid #333;
    position: sticky;
    left: 0;
}

.markdown-content pre .line-numbers .line-number {
    display: block;
}

.markdown-content code.hljs {
    padding: 0 1em;
}

/* 代码块复制按钮 */
.markdown-content pre .copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
}

.markdown-content pre .copy-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

.markdown-content pre .copy-btn:active {
    transform: scale(0.95);
}

.markdown-content pre .copy-btn.copied {
    background: rgba(76, 175, 80, 0.2);
    border-color: rgba(76, 175, 80, 0.3);
    color: #81c784;
}

.markdown-content pre code {
    background: none;
    padding: 12px;
    margin: 0;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre;
    display: block;
    flex-grow: 1;
    overflow-x: auto;
}

.markdown-content ul,
.markdown-content ol {
    margin: 12px 0;
    padding-left: 24px;
}

.markdown-content li {
    margin: 6px 0;
}

.markdown-content blockquote {
    border-left: 4px solid var(--primary-color);
    padding-left: 16px;
    margin: 12px 0;
    color: var(--text-color-light);
    font-style: italic;
}

.markdown-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
}

.markdown-content th,
.markdown-content td {
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    text-align: left;
}

.markdown-content th {
    background: var(--page-bg-color);
    font-weight: 600;
}

/* 图片容器 */
.markdown-content .img-container {
    max-width: 100%;
    border-radius: var(--border-radius);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.markdown-content img {
    max-width: 100%;
    max-height: 60vh;
    height: auto;
    border-radius: var(--border-radius);
    display: block;
    margin: 0;
    object-fit: contain;
}

/* 图片加载失败样式 */
.markdown-content .img-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--text-color-light);
    text-align: center;
}

.markdown-content .img-error .mdi {
    font-size: 48px;
    color: var(--text-color-light);
    margin-bottom: 12px;
    opacity: 0.5;
}

.markdown-content .img-error .img-error-text {
    font-size: 14px;
    line-height: 1.6;
}

.markdown-content hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 16px 0;
}

/* ==========================
 * 自定义滚动条样式
 * ========================== */

/* Webkit 浏览器 (Chrome, Safari, Edge) */
.markdown-content pre::-webkit-scrollbar,
.markdown-content pre code::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.markdown-content pre::-webkit-scrollbar-track,
.markdown-content pre code::-webkit-scrollbar-track {
    background: #2d2d2d;
    border-radius: 4px;
}

.markdown-content pre::-webkit-scrollbar-thumb,
.markdown-content pre code::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 4px;
    border: 2px solid #2d2d2d;
}

.markdown-content pre::-webkit-scrollbar-thumb:hover,
.markdown-content pre code::-webkit-scrollbar-thumb:hover {
    background: #666;
}

.markdown-content pre::-webkit-scrollbar-thumb:active,
.markdown-content pre code::-webkit-scrollbar-thumb:active {
    background: #777;
}

/* Firefox */
.markdown-content pre,
.markdown-content pre code {
    scrollbar-width: thin;
    scrollbar-color: #555 #2d2d2d;
}

/* ==========================
 * 文章目录样式
 * ========================== */

.toc-card {
    position: sticky;
    top: calc(var(--topbar-height) + var(--categories-height) + 20px);
}

.toc-card .card-title {
    position: relative;
    padding-right: 50px;
}

.toc-progress {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: var(--primary-color);
    font-weight: 600;
}

.article-toc {
    max-height: 500px;
    overflow-y: auto;
}

.toc-loading,
.toc-empty {
    text-align: center;
    color: var(--text-color-light);
    padding: 20px 0;
}

.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc-sub-list {
    list-style: none;
    padding-left: 20px;
    margin: 5px 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out, opacity 0.3s ease-out;
    opacity: 0;
}

.toc-sub-list.expanded {
    max-height: 500px;
    opacity: 1;
    transition: max-height 0.3s ease-in, opacity 0.3s ease-in;
}

.toc-item {
    margin: 5px 0;
}

/* 目录项折叠按钮 */
.toc-item-toggle {
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-right: 4px;
    vertical-align: middle;
    cursor: pointer;
    transition: transform 0.2s;
    color: var(--text-color-light);
    font-size: 12px;
    line-height: 16px;
    text-align: center;
}

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

.toc-item-toggle.collapsed {
    transform: rotate(-90deg);
}

/* 有子项的目录项添加特殊样式 */
.toc-item.has-children > .toc-link {
    display: inline-flex;
    align-items: center;
}

.toc-link {
    display: block;
    padding: 6px 10px;
    color: var(--text-color);
    text-decoration: none;
    border-radius: 4px;
    transition: all 0.2s;
    font-size: 14px;
    line-height: 1.5;
}

.toc-link:hover {
    background: var(--page-bg-color);
    color: var(--primary-color);
}

.toc-link.active {
    background: var(--primary-color);
    color: #fff;
}

.toc-level-1 {
    font-weight: 600;
}

.toc-level-2 {
    font-weight: 500;
}

.toc-level-3 {
    font-weight: 500;
}

/* ==========================
 * 移动端适配
 * ========================== */

@media (max-width: 767px) {
    /* 移动端文章页面图片高度调整为50vh */
    .markdown-content img {
        max-height: 50vh;
    }
}

/* ==========================
 * 友链卡片样式
 * ========================== */

.links-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin: 16px 0;
}

/* 友链卡片 a 标签样式 - 覆盖所有 a 标签默认样式 */
.link-card-a {
    display: block;
    text-decoration: none;
    color: var(--text-color);
    transition: all var(--transition-speed);
    position: static;
    padding: 0;
    margin: 0;
    border: none;
    background: none;
    box-shadow: none;
    outline: none;
}

.link-card-a::before,
.link-card-a::after {
    display: none;
}

.link-card-a:hover {
    color: var(--text-color);
    background: none;
    padding: 0;
    border-radius: 0;
    transform: none;
}

.link-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background-color: var(--bg-color);
    border-radius: var(--border-radius);
    transition: all var(--transition-speed);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-xs);
}

.link-card-a:hover .link-card {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.link-card-avatar {
    width: 56px;
    height: 56px;
    flex-shrink: 0;
    border-radius: 12px;
    overflow: hidden;
    background-color: var(--page-bg-color);
    border: 2px solid var(--border-color);
    transition: border-color var(--transition-speed);
}

.link-card-a:hover .link-card-avatar {
    border-color: var(--primary-color);
}

.link-card-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.link-card-info {
    flex: 1;
    min-width: 0;
}

.link-card-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: color var(--transition-speed);
}

.link-card-a:hover .link-card-name {
    color: var(--primary-color);
}

.link-card-description {
    font-size: 13px;
    color: var(--text-color-light);
    line-height: 1.5;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* 移动端友链卡片适配 */
@media (max-width: 767px) {
    .links-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .link-card {
        padding: 12px;
        gap: 10px;
    }

    .link-card-avatar {
        width: 48px;
        height: 48px;
        border-radius: 10px;
    }

    .link-card-name {
        font-size: 14px;
        margin-bottom: 4px;
    }

    .link-card-description {
        font-size: 12px;
        -webkit-line-clamp: 2;
    }
}

/* ==========================
 * Bilibili 视频样式
 * ========================== */

.bilibili-video-container {
    margin: 16px 0;
    border-radius: var(--border-radius);
    overflow: hidden;
    background: #000;
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 比例 */
}

.bilibili-video-iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* 移动端 Bilibili 视频适配 */
@media (max-width: 767px) {
    .bilibili-video-container {
        margin: 12px 0;
        border-radius: var(--border-radius);
    }
}

/* ==========================
 * Markdown 内容边距修复
 * ==========================
 */

/* markdown-content 第一个子元素移除上边距 */
.markdown-content > *:first-child {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

/* markdown-content 最后一个子元素移除下边距 */
.markdown-content > *:last-child {
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
}

/* ==========================
 * 音乐播放器样式
 * ==========================
 */

.music-player-container {
    margin: 16px 0;
}

.aplayer {
    margin: 0;
}

.aplayer .aplayer-list {
    max-height: 250px !important;
}

.meting-js {
    margin: 0;
}

/* ==========================
 * Aplayer 暗色模式样式
 * ========================== */

/* 播放器主体背景 */
body.dark-mode .aplayer {
    background-color: #1a1a1a !important;
}

/* 边框颜色 */
body.dark-mode .aplayer .aplayer-info {
    border-top: 1px solid #333 !important;
}

/* 歌词颜色 */
body.dark-mode .aplayer .aplayer-lrc p {
    color: #b0b0b0 !important;
}

body.dark-mode .aplayer .aplayer-lrc .aplayer-lrc-current {
    color: #ffffff !important;
}

/* 音乐信息颜色 */
body.dark-mode .aplayer .aplayer-music .aplayer-title {
    color: #e0e0e0 !important;
}

body.dark-mode .aplayer .aplayer-music .aplayer-author {
    color: #b0b0b0 !important;
}

/* 时间显示颜色 */
body.dark-mode .aplayer .aplayer-time {
    color: #b0b0b0 !important;
}

body.dark-mode .aplayer .aplayer-time-inner {
    color: #b0b0b0 !important;
}

/* 图标颜色 */
body.dark-mode .aplayer .aplayer-icon {
    color: #b0b0b0 !important;
}

body.dark-mode .aplayer .aplayer-icon:hover {
    color: #e0e0e0 !important;
}

body.dark-mode .aplayer .aplayer-icon path {
    fill: currentColor;
}

/* 播放列表颜色 */
body.dark-mode .aplayer .aplayer-list {
    background: #1a1a1a !important;
}

body.dark-mode .aplayer .aplayer-list ol {
    background: #1a1a1a !important;
}

body.dark-mode .aplayer .aplayer-list li {
    border-top: 1px solid #333 !important;
}

body.dark-mode .aplayer .aplayer-list li:hover {
    background: rgba(255, 255, 255, 0.05) !important;
}

body.dark-mode .aplayer .aplayer-list-light {
    background: rgba(255, 255, 255, 0.1) !important;
}

body.dark-mode .aplayer .aplayer-list-index {
    color: #b0b0b0 !important;
}

body.dark-mode .aplayer .aplayer-list-title {
    color: #e0e0e0 !important;
}

body.dark-mode .aplayer .aplayer-list-author {
    color: #b0b0b0 !important;
}

body.dark-mode .aplayer .aplayer-list-cur {
    background-color: var(--primary-color) !important;
}

/* 隐藏歌词区域的伪元素 */
body.dark-mode .aplayer .aplayer-lrc::before,
body.dark-mode .aplayer .aplayer-lrc::after {
    display: none !important;
}

body.dark-mode .aplayer .aplayer-time {
    color: #b0b0b0 !important;
}

body.dark-mode .aplayer .aplayer-time-inner {
    color: #b0b0b0 !important;
}

body.dark-mode .aplayer .aplayer-icon {
    color: #b0b0b0 !important;
}

body.dark-mode .aplayer .aplayer-icon:hover {
    color: #e0e0e0 !important;
}

body.dark-mode .aplayer .aplayer-icon path {
    fill: currentColor;
}

body.dark-mode .aplayer .aplayer-volume-bar-wrap {
    background: rgba(255, 255, 255, 0.1) !important;
}

body.dark-mode .aplayer .aplayer-volume-bar {
    background: rgba(255, 255, 255, 0.1) !important;
}

body.dark-mode .aplayer .aplayer-volume {
    background: var(--primary-color) !important;
}

body.dark-mode .aplayer .aplayer-list {
    background: #1a1a1a !important;
}

body.dark-mode .aplayer .aplayer-list ol {
    background: #1a1a1a !important;
}

body.dark-mode .aplayer .aplayer-list li {
    border-top: 1px solid #333 !important;
}

body.dark-mode .aplayer .aplayer-list li:hover {
    background: rgba(255, 255, 255, 0.05) !important;
}

body.dark-mode .aplayer .aplayer-list-light {
    background: rgba(255, 255, 255, 0.1) !important;
}

body.dark-mode .aplayer .aplayer-list-index {
    color: #b0b0b0 !important;
}

body.dark-mode .aplayer .aplayer-list-title {
    color: #e0e0e0 !important;
}

body.dark-mode .aplayer .aplayer-list-author {
    color: #b0b0b0 !important;
}

body.dark-mode .aplayer .aplayer-list-cur {
    background-color: var(--primary-color) !important;
}

body.dark-mode .aplayer .aplayer-notice {
    background: rgba(0, 0, 0, 0.8) !important;
    color: #e0e0e0 !important;
}

body.dark-mode .aplayer .aplayer-miniswitcher {
    background: rgba(0, 0, 0, 0.8) !important;
}

body.dark-mode .aplayer .aplayer-miniswitcher .aplayer-icon {
    color: #b0b0b0 !important;
}

body.dark-mode .aplayer .aplayer-miniswitcher .aplayer-icon:hover {
    color: #e0e0e0 !important;
}

/* ==========================
 * 网盘卡片样式
 * ==========================
 */
.netdisk-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    margin: 16px 0;
    transition: all var(--transition-speed);
    box-shadow: var(--shadow-sm);
}
.netdisk-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}
/* 网盘图标容器 */
.netdisk-icon {
    width: 56px;
    height: 56px;
    flex-shrink: 0;
    border-radius: 12px;
    overflow: hidden;
    background: var(--page-bg-color);
    display: flex;
    align-items: center;
    justify-content: center;
}
.netdisk-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
/* 网盘信息区域 */
.netdisk-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
/* 文件名和提取码容器 */
.netdisk-header {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.netdisk-filename {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-color);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.netdisk-code {
    font-size: 13px;
    color: var(--text-color-light);
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}
.netdisk-code .code-label {
    color: var(--primary-color);
    font-weight: 500;
}
.netdisk-code .code-value {
    font-family: 'JetBrains Mono', monospace;
    background: var(--page-bg-color);
    padding: 2px 6px;
    border-radius: 4px;
}
/* 网盘按钮区域 */
.netdisk-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}
.netdisk-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition-speed);
    border: none;
    outline: none;
}
/* 下载按钮 a 标签样式 - 覆盖文章中 a 标签的默认样式 */
.netdisk-btn-download {
    background: var(--primary-color);
    color: #fff;
    text-decoration: none;
    position: static;
    padding: 8px 16px;
    margin: 0;
    border: none;
    background: var(--primary-color);
    box-shadow: none;
    outline: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.netdisk-btn-download::before,
.netdisk-btn-download::after {
    display: none;
}
.netdisk-btn-download:hover {
    background: var(--primary-color-dark);
    color: #fff !important;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    padding: 8px 16px;
    margin: 0;
    border: none;
    border-radius: 8px;
}
.netdisk-btn-copy {
    background: var(--page-bg-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}
.netdisk-btn-copy:hover {
    background: var(--border-color);
    color: var(--primary-color);
}
.netdisk-btn-copy.copied {
    background: rgba(76, 175, 80, 0.1);
    border-color: rgba(76, 175, 80, 0.3);
    color: #4caf50;
}
/* 移动端网盘卡片适配 */

@media (max-width: 767px) {

    .netdisk-card {

        flex-direction: column;

        align-items: flex-start;

        padding: 12px;

        gap: 12px;

    }



    .netdisk-icon {

        width: 48px;

        height: 48px;

    }



    .netdisk-filename {

        font-size: 14px;

    }



    .netdisk-code {

        font-size: 12px;

        margin-bottom: 8px;

    }



    .netdisk-actions {

        width: 100%;

    }



    .netdisk-btn {

        flex: 1;

        justify-content: center;

    }

}