
/* 全局样式设置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 设置页面的基础字体和颜色 */
body {
    font-family: 'Roboto', sans-serif;
    font-size: 16px;
    line-height: 1.6;
    background: linear-gradient(135deg, #1e3c72, #2a5298);
    color: #ffffff;
    overflow-x: hidden; /* 防止出现水平滚动条 */
}

/* 导航栏样式 */
.navbar {
    position: fixed;
    top: 0;
    width: 100%;
    background: rgba(30, 60, 114, 0.8); /* 半透明背景 */
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 40px;
    z-index: 1000;
    transition: background 0.5s ease;
}

.navbar.scrolled {
    background: rgba(30, 60, 114, 1); /* 滚动时背景变为不透明 */
}

.navbar .logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: #ffeb3b; /* 点缀色 */
    text-decoration: none;
}

.navbar ul {
    list-style: none;
    display: flex;
    gap: 20px;
}

.navbar ul li a {
    color: #ffffff;
    text-decoration: none;
    font-size: 1rem;
    position: relative;
    transition: color 0.3s ease;
}

.navbar ul li a:hover {
    color: #ffeb3b;
}

.navbar ul li a::after {
    content: '';
    position: absolute;
    width: 0%;
    height: 2px;
    background: #ffeb3b;
    left: 0;
    bottom: -5px;
    transition: width 0.3s ease;
}

.navbar ul li a:hover::after {
    width: 100%;
}

/* 主内容区容器 */
.container {
    max-width: 1200px;
    margin: 100px auto 50px auto; /* 留出导航栏高度 */
    padding: 0 20px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 40px;
}

/* 卡片样式 */
.card {
    background: rgba(255, 255, 255, 0.1); /* 半透明背景 */
    backdrop-filter: blur(10px); /* 模糊效果 */
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-10px);
    box-shadow: 0 16px 64px 0 rgba(31, 38, 135, 0.37);
}

.card img {
    width: 100%;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.card h3 {
    margin-top: 15px;
    font-size: 1.2rem;
    color: #ffeb3b; /* 点缀色 */
}

.card p {
    margin-top: 10px;
    font-size: 0.95rem;
    color: #ffffff;
}

/* 章节导航 */
.sidebar {
    position: fixed;
    top: 100px;
    left: 20px;
    width: 200px;
}

.sidebar ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.sidebar ul li a {
    color: #ffffff;
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.3s ease;
}

.sidebar ul li a:hover {
    color: #ffeb3b;
}

/* 文章内容样式 */
article {
    max-width: 800px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
}

article h2, article h3, article h4 {
    color: #ffeb3b;
    margin-bottom: 20px;
}

article p {
    margin-bottom: 20px;
    color: #ffffff;
}

article pre {
    background: rgba(0, 0, 0, 0.7);
    padding: 15px;
    border-radius: 10px;
    overflow-x: auto;
}

article code {
    color: #ffeb3b;
    font-family: 'Courier New', Courier, monospace;
}

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

img:hover {
    transform: scale(1.05);
}

/* 提示语样式 */
.alert {
    background: rgba(255, 235, 59, 0.2);
    border-left: 5px solid #ffeb3b;
    padding: 15px;
    margin: 20px 0;
    border-radius: 5px;
}

/* 折叠区域样式 */
.collapsible {
    background-color: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    cursor: pointer;
    padding: 10px;
    width: 100%;
    border: none;
    text-align: left;
    outline: none;
    font-size: 1rem;
    border-radius: 5px;
    transition: background 0.3s ease;
}

.collapsible:hover {
    background: rgba(255, 255, 255, 0.3);
}

.content {
    padding: 0 15px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
}

/* 代码示例样式 */
.code-sample {
    background: rgba(0, 0, 0, 0.7);
    padding: 20px;
    border-radius: 10px;
    overflow-x: auto;
    margin-bottom: 20px;
}

.code-sample code {
    color: #ffeb3b;
    font-family: 'Courier New', Courier, monospace;
}

/* 关键帧动画 */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

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

    .container {
        grid-template-columns: 1fr;
        margin: 150px auto 50px auto;
    }
}

