
/* 
    全局样式设置
    设置网页的基础字体、背景颜色以及响应式布局的通用样式
*/
:root {
    --main-color: #8B9467; /* 主色调：橄榄绿 */
    --background-color: #F5F5DC; /* 背景色：浅米色 */
    --accent-color: #FFA500; /* 点缀色：橘黄色 */
    --text-color: #333333; /* 文字颜色 */
    --header-height: 60px; /* 头部高度 */
    --footer-height: 100px; /* 底部高度 */
}

/* 重置默认样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 设置全局字体和背景 */
body {
    font-family: 'Open Sans', sans-serif;
    color: var(--text-color);
    background-color: var(--background-color);
    line-height: 1.6;
}

/* 头部导航栏样式 */
.header {
    position: fixed;
    top: 0;
    width: 100%;
    height: var(--header-height);
    background-color: var(--main-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.header .logo {
    font-size: 1.5em;
    color: white;
    text-decoration: none;
}

.header .nav-links {
    list-style: none;
    display: flex;
    gap: 15px;
}

.header .nav-links li a {
    color: white;
    text-decoration: none;
    font-size: 1em;
    transition: color 0.3s ease;
}

.header .nav-links li a:hover {
    color: var(--accent-color);
}

/* 主内容区样式 */
.main {
    padding: var(--header-height) 20px 20px 20px;
    max-width: 1200px;
    margin: 0 auto;
}

/* 章节导航系统 */
.sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: 200px;
    height: calc(100vh - var(--header-height));
    background-color: rgba(139, 148, 103, 0.9);
    padding: 20px;
    overflow-y: auto;
}

.sidebar ul {
    list-style: none;
}

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

.sidebar ul li a {
    color: white;
    text-decoration: none;
    font-size: 1em;
    transition: color 0.3s ease;
}

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

/* 文章内容样式 */
article {
    margin-left: 220px;
}

article h2, article h3, article h4 {
    font-family: 'Roboto', sans-serif;
    color: var(--main-color);
    margin-bottom: 10px;
}

article h2 {
    font-size: 2em;
}

article h3 {
    font-size: 1.5em;
}

article h4 {
    font-size: 1.2em;
}

article p {
    margin-bottom: 15px;
}

article pre {
    background-color: #eeeeee;
    padding: 15px;
    border-radius: 5px;
    overflow-x: auto;
    margin-bottom: 15px;
}

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

/* 按钮样式 */
.button {
    background-color: var(--accent-color);
    border: none;
    color: white;
    padding: 10px 20px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 1em;
    border-radius: 4px;
    transition: background-color 0.3s ease, transform 0.3s ease;
    cursor: pointer;
}

.button:hover {
    background-color: #FFB733;
    transform: scale(1.05);
}

/* 图片样式 */
img.decorative {
    width: 100%;
    max-width: 320px;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    margin: 10px 0;
}

img.decorative:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
}

/* 分隔线样式 */
.separator {
    height: 2px;
    background: linear-gradient(to right, var(--main-color), var(--accent-color));
    margin: 30px 0;
    border: none;
}

/* 动画效果 */
@keyframes fall {
    0% { transform: translateY(0) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(360deg); opacity: 0; }
}

.leaf {
    position: absolute;
    top: -50px;
    animation: fall 5s linear infinite;
    /* 可根据需要添加具体位置和尺寸 */
}

/* 视差滚动效果 */
.parallax {
    background-attachment: fixed;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    height: 500px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 2em;
}

@media (max-width: 768px) {
    .sidebar {
        display: none;
    }
    
    article {
        margin: 0;
    }

    .main {
        padding: var(--header-height) 10px 10px 10px;
    }

    .button {
        width: 100%;
        padding: 15px;
        font-size: 1.2em;
    }

    .parallax {
        height: 300px;
        font-size: 1.5em;
    }
}

@media (max-width: 480px) {
    .header {
        flex-direction: column;
        height: auto;
        padding: 10px;
    }

    .header .nav-links {
        flex-direction: column;
        gap: 10px;
    }

    .button {
        font-size: 1em;
        padding: 10px;
    }

    article h2 {
        font-size: 1.5em;
    }

    article h3 {
        font-size: 1.2em;
    }
}

/* 示例代码块样式 */
.code-example {
    background-color: #2d2d2d;
    color: #ccc;
    padding: 20px;
    border-radius: 5px;
    overflow-x: auto;
    margin-bottom: 20px;
    font-family: 'Courier New', Courier, monospace;
}

.code-example code {
    color: #f8f8f2;
}

