
/* 
整体样式设置
设置网页的基础字体、背景颜色和文本颜色，确保视觉上的统一性和舒适性。
*/
:root {
    --primary-color: #0F4C81; /* 主色调，深蓝色 */
    --secondary-color: #E5E5EA; /* 辅助色，灰色 */
    --accent-color: #FF7E0E; /* 点缀色，亮橙色 */
    --background-color: #F0F4F8; /* 页面背景色，避免纯白 */
    --text-color: #333333; /* 正文字体颜色 */
    --heading-color: #0F4C81; /* 标题颜色，与主色调一致 */
    --code-background: #2D3748; /* 代码块背景色 */
    --code-color: #E5E5EA; /* 代码字体颜色 */
    --transition-speed: 0.3s; /* 过渡效果时间 */
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Roboto', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
}

/* 
导航栏样式
固定在页面顶部，使用主色调背景，内含导航链接，适应不同屏幕尺寸。
*/
.navbar {
    position: fixed;
    top: 0;
    width: 100%;
    background-color: var(--primary-color);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.navbar .logo {
    font-size: 1.5em;
    font-weight: bold;
}

.navbar ul {
    list-style: none;
    display: flex;
    margin: 0;
    padding: 0;
}

.navbar ul li {
    margin-left: 20px;
}

.navbar ul li a {
    color: white;
    text-decoration: none;
    font-size: 1em;
    transition: color var(--transition-speed);
}

.navbar ul li a:hover {
    color: var(--accent-color);
}

/* 
侧边栏样式
在移动端隐藏，通过汉堡菜单控制显示，增强响应式体验。
*/
.sidebar {
    display: none;
    position: fixed;
    top: 60px;
    left: 0;
    width: 250px;
    height: 100%;
    background-color: var(--secondary-color);
    padding: 20px;
    transition: transform var(--transition-speed) ease-in-out;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
}

.sidebar.open {
    display: block;
    transform: translateX(0);
}

.sidebar ul {
    list-style: none;
    padding: 0;
}

.sidebar ul li {
    margin-bottom: 15px;
}

.sidebar ul li a {
    color: var(--text-color);
    text-decoration: none;
    font-size: 1.1em;
    transition: color var(--transition-speed);
}

.sidebar ul li a:hover {
    color: var(--accent-color);
}

.hamburger {
    display: none;
    flex-direction: column;
    cursor: pointer;
}

.hamburger div {
    width: 25px;
    height: 3px;
    background-color: white;
    margin: 4px 0;
    transition: all var(--transition-speed) ease;
}

/* 
响应式设计
调整布局以适应不同屏幕尺寸，确保良好的用户体验。
*/
@media (max-width: 768px) {
    .navbar ul {
        display: none;
    }
    .hamburger {
        display: flex;
    }
    .sidebar {
        transform: translateX(-100%);
    }
}

/* 
章节导航样式
固定在页面侧边，帮助用户快速定位到指定内容区域，具有良好的可点击性和可视性。
*/
.chapter-nav {
    position: fixed;
    top: 100px;
    right: 20px;
    background-color: rgba(255, 255, 255, 0.9);
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.chapter-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.chapter-nav ul li {
    margin-bottom: 10px;
}

.chapter-nav ul li a {
    text-decoration: none;
    color: var(--primary-color);
    font-size: 0.9em;
    transition: color var(--transition-speed);
}

.chapter-nav ul li a:hover {
    color: var(--accent-color);
}

/* 
主容器样式
使用网格布局，确保内容块有序排列，适应不同设备的屏幕宽度。
*/
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 100px 20px 20px 20px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

/* 
图片样式
设置圆角、阴影和悬停效果，提升图片的美观性和互动性。
*/
.image {
    width: 100%;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    transition: transform var(--transition-speed), box-shadow var(--transition-speed);
}

.image:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 12px rgba(0,0,0,0.2);
}

/* 
文章内容样式
定义文章内的各级标题、段落和代码块的样式，确保内容的可读性和层次感。
*/
article {
    grid-column: 1 / -1;
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

article h2 {
    color: var(--heading-color);
    margin-top: 20px;
    font-size: 1.8em;
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 5px;
}

article h3 {
    color: var(--heading-color);
    margin-top: 15px;
    font-size: 1.5em;
}

article p {
    margin: 15px 0;
    font-size: 1em;
}

article pre {
    background-color: var(--code-background);
    color: var(--code-color);
    padding: 15px;
    border-radius: 8px;
    overflow-x: auto;
    font-family: 'Courier New', Courier, monospace;
    margin: 15px 0;
}

article code {
    background-color: #2D3748;
    color: #E5E5EA;
    padding: 2px 4px;
    border-radius: 4px;
    font-family: 'Courier New', Courier, monospace;
}

/* 
按钮样式
定义主要按钮的外观和悬停、点击效果，提升用户的操作体验。
*/
.button-primary {
    background-color: var(--accent-color);
    border: none;
    padding: 10px 20px;
    color: white;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color var(--transition-speed), transform 0.2s;
    font-size: 1em;
}

.button-primary:hover {
    background-color: darkorange;
    transform: scale(1.05);
}

.button-primary:active {
    background-color: orangered;
    transform: scale(0.95);
}

/* 
提示信息样式
高亮显示提示信息，吸引用户注意。
*/
.alert {
    background-color: var(--accent-color);
    color: white;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    font-size: 1.2em;
    margin-bottom: 20px;
}

/* 
折叠区域样式
定义可折叠内容的外观和展开、收起的过渡效果。
*/
.collapsible {
    background-color: var(--secondary-color);
    color: var(--text-color);
    cursor: pointer;
    padding: 10px 20px;
    width: 100%;
    border: none;
    text-align: left;
    outline: none;
    font-size: 1em;
    border-radius: 6px;
    transition: background-color var(--transition-speed);
    margin-top: 10px;
}

.collapsible:hover {
    background-color: #d4d4d4;
}

.content {
    padding: 0 20px;
    display: none;
    overflow: hidden;
    background-color: white;
    border-left: 4px solid var(--accent-color);
    border-radius: 0 0 8px 8px;
}

.content.show {
    display: block;
    animation: fadeIn 0.5s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* 
代码块内的样式
确保代码块在文章中清晰可见，且与正文内容区分开。
*/
.code-example {
    background-color: var(--code-background);
    color: var(--code-color);
    padding: 15px;
    border-radius: 8px;
    font-family: 'Courier New', Courier, monospace;
    overflow-x: auto;
    margin: 20px 0;
}

/* 
其他辅助样式
包括链接样式、列表样式等，确保整体的一致性和美观性。
*/
a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color var(--transition-speed);
}

a:hover {
    color: var(--accent-color);
}

ul {
    list-style: disc inside;
}

ol {
    list-style: decimal inside;
}

