
/* 全局样式设置 */
/* 定义颜色变量，遵循黄金比配色：70%主色，25%辅色，5%点缀色 */
:root {
    --primary-color: #2c3e50; /* 深蓝色，主色 */
    --secondary-color: #8e44ad; /* 深紫色，主色 */
    --accent-color: #e67e22; /* 亮橙色，点缀色 */
    --highlight-color: #1abc9c; /* 翠绿色，点缀色 */
    --background-gradient: linear-gradient(135deg, #2c3e50, #8e44ad);
    --text-color: #ecf0f1; /* 主文字颜色 */
    --subtext-color: #bdc3c7; /* 次要文字颜色 */
    --code-bg: #34495e; /* 代码块背景色 */
    --code-text: #ecf0f1; /* 代码块文字颜色 */
}

/* 全局字体与基础样式 */
body {
    margin: 0;
    padding: 0;
    background: var(--background-gradient);
    color: var(--text-color);
    font-family: 'Roboto', sans-serif;
    line-height: 1.6;
    transition: background 0.5s ease;
}

/* 导航栏样式 */
.navbar {
    position: sticky;
    top: 0;
    background: rgba(44, 62, 80, 0.9); /* 半透明背景 */
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.navbar a {
    color: var(--text-color);
    margin: 0 15px;
    text-decoration: none;
    font-size: 16px;
    transition: color 0.3s ease;
}

.navbar a:hover {
    color: var(--highlight-color);
}

/* 主要内容区域 */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
}

/* 章节导航系统 */
.chapter-nav {
    position: fixed;
    top: 100px;
    left: 20px;
    background: rgba(44, 62, 80, 0.8);
    padding: 20px;
    border-radius: 8px;
    width: 200px;
    font-size: 14px;
}

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

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

.chapter-nav a {
    color: var(--text-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

.chapter-nav a:hover {
    color: var(--highlight-color);
}

/* 文章内容样式 */
article {
    margin-left: 240px; /* 为章节导航留出空间 */
}

h2, h3, h4 {
    color: var(--text-color);
    margin-top: 40px;
    margin-bottom: 20px;
}

h2 {
    font-size: 2em;
}

h3 {
    font-size: 1.75em;
}

h4 {
    font-size: 1.5em;
}

p {
    font-size: 16px;
    color: var(--subtext-color);
    margin-bottom: 20px;
    text-indent: 2em;
}

pre {
    background: var(--code-bg);
    color: var(--code-text);
    padding: 15px;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 20px;
    font-size: 14px;
}

code {
    font-family: 'Courier New', Courier, monospace;
}

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

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

/* 悬停效果 */
.button, .navbar a {
    transition: all 0.3s ease;
}

.button {
    background: var(--accent-color);
    border: none;
    padding: 10px 20px;
    color: #fff;
    cursor: pointer;
    border-radius: 5px;
    font-size: 16px;
}

.button:hover {
    background: var(--highlight-color);
}

/* 代码块特殊样式 */
pre code {
    display: block;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* 背景与纹理 */
.background-section {
    background: var(--background-gradient);
    padding: 60px 20px;
    position: relative;
}

.background-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('https://images.gptkong.com/demo/sample1.png'); /* 示例纹理 */
    background-repeat: repeat;
    opacity: 0.1;
    z-index: 1;
}

.background-section > * {
    position: relative;
    z-index: 2;
}

/* 回到顶部按钮 */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--accent-color);
    color: #fff;
    padding: 10px 15px;
    border-radius: 50%;
    cursor: pointer;
    display: none;
    transition: background 0.3s ease, transform 0.3s ease;
    font-size: 18px;
}

.back-to-top.show {
    display: block;
}

.back-to-top:hover {
    background: var(--highlight-color);
    transform: scale(1.1);
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .chapter-nav {
        display: none;
    }

    article {
        margin: 0;
    }
}

@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .navbar a {
        margin: 10px 0;
    }

    .container {
        padding: 20px 10px;
    }

    h2 {
        font-size: 1.75em;
    }

    h3 {
        font-size: 1.5em;
    }

    h4 {
        font-size: 1.25em;
    }

    p {
        font-size: 15px;
    }

    .background-section {
        padding: 40px 10px;
    }
}

/* 折叠区域样式 */
.collapsible {
    background-color: var(--primary-color);
    color: white;
    cursor: pointer;
    padding: 10px;
    width: 100%;
    border: none;
    text-align: left;
    outline: none;
    font-size: 16px;
    border-radius: 5px;
    margin: 10px 0;
    transition: background 0.3s ease;
}

.collapsible:hover {
    background: var(--highlight-color);
}

.collapsible:after {
    content: '\002B'; /* 加号符号 */
    font-size: 13px;
    float: right;
}

.collapsible.active:after {
    content: "\2212"; /* 减号符号 */
}

.content-collapsible {
    padding: 0 18px;
    display: none;
    overflow: hidden;
    background-color: var(--secondary-color);
    border-radius: 5px;
    margin-bottom: 20px;
}

.content-collapsible p {
    color: #ecf0f1;
    text-indent: 2em;
}

/* 动画效果 */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.fade-in {
    animation: fadeIn 2s ease-in;
}

/* 视差滚动效果 */
.parallax {
    background-attachment: fixed;
    background-size: cover;
    background-position: center;
    height: 100vh;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 2em;
    text-align: center;
}

.parallax .content {
    background: rgba(44, 62, 80, 0.7);
    padding: 20px;
    border-radius: 10px;
}

/* 表格样式 */
table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

table, th, td {
    border: 1px solid var(--subtext-color);
}

th, td {
    padding: 10px;
    text-align: left;
}

th {
    background: var(--secondary-color);
}

td {
    background: var(--primary-color);
}

/* 链接样式 */
a {
    color: var(--highlight-color);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* 高亮文本 */
.highlight {
    color: var(--accent-color);
    font-weight: bold;
}

/* 代码示例样式 */
.code-example {
    background: var(--code-bg);
    padding: 15px;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 20px;
}

.code-example code {
    color: var(--code-text);
    font-family: 'Courier New', Courier, monospace;
}

/* 折叠内容显示 */
.collapsible.active + .content-collapsible {
    display: block;
}

/* 图片的响应式布局 */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

