/* 基础重置和变量 */
:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --accent-color: #e74c3c;
    --text-color: #333;
    --text-light: #666;
    --text-lighter: #999;
    --bg-color: #f8f9fa;
    --bg-white: #ffffff;
    --border-color: #e1e4e8;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-hover: 0 4px 16px rgba(0,0,0,0.15);
    --radius: 8px;
    --transition: all 0.3s ease;
}

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

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

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* 头部样式 */
.site-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, #34495e 100%);
    color: white;
    padding: 30px 0;
    text-align: center;
}

.site-title {
    font-size: 2.2rem;
    margin-bottom: 10px;
}

.site-title a {
    color: white;
    text-decoration: none;
}

.site-subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* 主要内容 */
.site-main {
    min-height: calc(100vh - 200px);
    padding: 40px 0;
}

/* 介绍区域 */
.intro {
    text-align: center;
    margin-bottom: 40px;
}

.intro h2 {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.intro p {
    color: var(--text-light);
    font-size: 1.1rem;
}

/* 路径图容器 */
.path-map-section {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 40px;
    margin-top: -40px;
    overflow: hidden;
}

.path-map-container {
    width: 100%;
    padding: 20px;
}

#path-map {
    width: 100%;
    height: auto;
    max-height: 700px;
}

/* 节点样式 */
.node-group {
    cursor: pointer;
}

.node-group .node-circle {
    transition: r 0.3s ease, opacity 0.3s ease;
}

.node-group .node-inner {
    transition: r 0.3s ease, fill 0.3s ease;
}

/* 节点悬停效果 - 增大圆圈 */
.node-group:hover .node-circle {
    r: 62;
    opacity: 1;
}

.node-group:hover .node-inner {
    r: 57;
    fill: #f0f8ff;
}

.connection-line {
    transition: stroke-width 0.3s ease, opacity 0.3s ease;
}

/* 图例 */
.legend {
    margin-bottom: 40px;
}

.legend h3 {
    text-align: center;
    margin-bottom: 20px;
    color: var(--primary-color);
}

.legend-items {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 20px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 50%;
}

/* 所有主题网格 */
.all-topics {
    margin-top: 60px;
}

.all-topics h3 {
    text-align: center;
    margin-bottom: 30px;
    font-size: 1.8rem;
    color: var(--primary-color);
}

.topics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.topic-card {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    transition: var(--transition);
    text-decoration: none;
    color: inherit;
    display: block;
    border-left: 4px solid;
}

.topic-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.topic-card.level-0 { border-color: #3498db; }
.topic-card.level-1 { border-color: #2ecc71; }
.topic-card.level-2 { border-color: #f39c12; }
.topic-card.level-3 { border-color: #9b59b6; }
.topic-card.level-4 { border-color: #e74c3c; }
.topic-card.level-5 { border-color: #1abc9c; }
.topic-card.level-6 { border-color: #e67e22; }
.topic-card.level-7 { border-color: #34495e; }
.topic-card.level-8 { border-color: #16a085; }

.topic-card h4 {
    font-size: 1.2rem;
    margin-bottom: 8px;
    color: var(--primary-color);
}

.topic-card p {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 12px;
}

.level-badge {
    display: inline-block;
    padding: 2px 8px;
    background: var(--bg-color);
    border-radius: 12px;
    font-size: 0.75rem;
    color: var(--text-light);
}

/* 页脚 */
.site-footer {
    background: var(--primary-color);
    color: white;
    text-align: center;
    padding: 20px 0;
    margin-top: 60px;
}

/* 主题详情页样式 */
.topic-header {
    background: white;
    padding: 30px 0;
    margin-bottom: 30px;
    border-bottom: 1px solid var(--border-color);
}

.breadcrumb {
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.breadcrumb a {
    color: var(--secondary-color);
    text-decoration: none;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

.breadcrumb span {
    margin: 0 8px;
    color: var(--text-lighter);
}

.topic-meta h2 {
    font-size: 2.2rem;
    color: var(--primary-color);
    margin: 15px 0;
}

.level-badge-large {
    display: inline-block;
    padding: 4px 12px;
    background: linear-gradient(135deg, var(--secondary-color), var(--accent-color));
    color: white;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

.topic-description {
    font-size: 1.1rem;
    color: var(--text-light);
    max-width: 600px;
}

/* 内容布局 */
.content-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 40px;
}

.topic-sidebar {
    position: sticky;
    top: 20px;
    height: fit-content;
}

.sidebar-section {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.sidebar-section h4 {
    font-size: 1rem;
    color: var(--primary-color);
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--bg-color);
}

.prereq-list, .next-list {
    list-style: none;
}

.prereq-list li, .next-list li {
    margin-bottom: 8px;
}

.prereq-list a, .next-list a {
    color: var(--secondary-color);
    text-decoration: none;
    display: block;
    padding: 8px 12px;
    border-radius: 4px;
    transition: var(--transition);
}

.prereq-list a:hover, .next-list a:hover {
    background: var(--bg-color);
}

.no-prereq, .no-next {
    color: var(--text-lighter);
    font-style: italic;
}

.back-link {
    display: block;
    text-align: center;
    color: var(--secondary-color);
    text-decoration: none;
    font-weight: 500;
    padding: 10px;
    border: 2px solid var(--secondary-color);
    border-radius: var(--radius);
    transition: var(--transition);
}

.back-link:hover {
    background: var(--secondary-color);
    color: white;
}

/* 主题内容 */
.topic-main {
    background: white;
    border-radius: var(--radius);
    padding: 40px;
    box-shadow: var(--shadow);
}

.content-body {
    font-size: 1.05rem;
    line-height: 1.8;
}

.content-body h2 {
    font-size: 1.8rem;
    color: var(--primary-color);
    margin: 30px 0 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--bg-color);
}

.content-body h3 {
    font-size: 1.4rem;
    color: var(--primary-color);
    margin: 25px 0 12px;
}

.content-body h4 {
    font-size: 1.2rem;
    color: var(--text-color);
    margin: 20px 0 10px;
}

.content-body p {
    margin-bottom: 15px;
}

.content-body ul, .content-body ol {
    margin: 15px 0;
    padding-left: 30px;
}

.content-body li {
    margin-bottom: 8px;
}

.content-body strong {
    color: var(--primary-color);
}

/* KaTeX 样式调整 */
.katex-display {
    margin: 20px 0;
    overflow-x: auto;
    overflow-y: hidden;
}

.katex {
    font-size: 1.1em;
}

/* 导航 */
.topic-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 40px;
    padding-top: 30px;
    border-top: 1px solid var(--border-color);
}

.nav-prev, .nav-next {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    padding: 15px 20px;
    border-radius: var(--radius);
    transition: var(--transition);
    max-width: 250px;
}

.nav-prev:hover, .nav-next:hover {
    background: var(--bg-color);
}

.nav-next {
    text-align: right;
    margin-left: auto;
}

.nav-label {
    font-size: 0.85rem;
    color: var(--text-lighter);
    margin-bottom: 5px;
}

.nav-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--secondary-color);
}

/* 响应式设计 */
@media (max-width: 1024px) {
    .content-layout {
        grid-template-columns: 1fr;
    }
    
    .topic-sidebar {
        position: static;
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: 20px;
    }
}

@media (max-width: 768px) {
    .site-title {
        font-size: 1.6rem;
    }
    
    .intro h2 {
        font-size: 1.5rem;
    }
    
    .path-map-container {
        padding: 10px;
        overflow-x: auto;
    }
    
    #path-map {
        min-width: 800px;
    }
    
    .topics-grid {
        grid-template-columns: 1fr;
    }
    
    .topic-meta h2 {
        font-size: 1.6rem;
    }
    
    .topic-main {
        padding: 20px;
    }
    
    .topic-nav {
        flex-direction: column;
        gap: 15px;
    }
    
    .nav-prev, .nav-next {
        max-width: 100%;
        text-align: center;
    }
}

/* 打印样式 */
@media print {
    .site-header, .site-footer, .topic-sidebar, .topic-nav {
        display: none;
    }
    
    .topic-main {
        box-shadow: none;
    }
}
