/* 主题变量 */
:root {
    --bg-color: #f8f5f0; /* 更温暖的米白色 */
    --text-color: #382e25; /* 增加5%对比度 */
    --primary-color: #6b4f3d; /* 更柔和的赤陶色 */
    --secondary-color: #9d7c6b; /* 与主色协调的陶土色 */
    --timeline-line: #c2ab90; /* 更自然的木质色调 */
    --quote-bg: #f0ebe1;
    --timeline-bg: #f9f7f1;
    --font-title: 28px;
    --font-subtitle: 20px;
    --font-body: 16px;
    
    @media (max-width: 768px) {
        --font-title: 24px;
        --font-subtitle: 18px;
    }
}

[data-theme="night"] {
    --bg-color: #1e1c17; /* 背景颜色 */
    --text-color: #c4bfbb; /* 文本颜色 */
    --primary-color: #c3aaa2; /* 主色调 */
    --secondary-color: #c3aaa2; /* 次色调 */
    --quote-bg: #2b271e; /* 引言背景 */
    --timeline-bg: #1e1c17; /* 时间线背景 */
    --timeline-line: #546e7a; /* 时间线线条 */
}

/* 基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    position: relative;
    font-family: 'Times New Roman', serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    user-select: none; /*禁止选中文本*/
    background-image: 
        linear-gradient(to right,
            rgba(198, 179, 156, 0.03) 1px,
            transparent 1px),
        linear-gradient(to bottom,
            rgba(198, 179, 156, 0.03) 1px,
            transparent 1px);
    background-size: 24px 24px;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 30px;
    background-color: var(--bg-color);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    margin-top: 30px;
    margin-bottom: 30px;
}

h1 {
    text-align: center;
    margin-bottom: 30px;
    color: var(--primary-color);
    font-size: 36px;
    font-weight: normal;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.historical-quote {
    text-align: center;
    font-family: 'Times New Roman', serif;
    font-size: 24px;
    padding: 20px;
    background-color: var(--quote-bg);
    color: var(--primary-color);
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
    font-style: italic;
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.1);
}

#back-to-top {
    transform: translate3d(0, 100px, 0) translateY(100px); /* 启用GPU加速 */
    will-change: transform, opacity; /* 声明变化属性 */
    z-index: 9999;
    position: fixed;
    bottom: 40px;
    right: 30px;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    border: none;
    cursor: pointer;
    opacity: 0;
    transition: 
        opacity 0.3s ease,
        transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94),
        visibility 0.3s;
    visibility: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#back-to-top.show {
    opacity: 0.9;
    visibility: visible;
    transform: translateY(0);
}

#back-to-top:hover {
    opacity: 1;
    transform: scale(1.1) rotate(360deg);
    background: var(--secondary-color);
}

/* 夜间模式适配 */
[data-theme="night"] #back-to-top {
    background: var(--primary-color);
    color: var(--text-color);
    box-shadow: 0 4px 12px rgba(255,255,255,0.1);
}

/* 移动端适配 */
@media (max-width: 768px) {
    #back-to-top {
        bottom: 20px;
        right: 15px;
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
}

.search-box {
    margin-bottom: 30px;
    display: flex;
    justify-content: center;
}

#search-input {
    width: 70%;
    padding: 12px;
    font-size: 16px;
    border: 1px solid #b39d7d;
    border-radius: 4px 0 0 4px;
    background-color: var(--bg-color);
    color: var(--text-color);
}

#search-btn {
    padding: 12px 24px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
    font-family: 'Times New Roman', serif;
    font-size: 16px;
}

[data-theme="night"] #search-btn {
    background-color: var(--primary-color); /* 使用主色调 */
    color: black; /* 使用文本色 */
}

.period-buttons, .type-buttons {
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.period-btn, .type-btn {
    padding: 10px 20px;
    font-size: 16px;
    background-color: var(--bg-color);
    color: var(--text-color); /* 动态文字颜色 */
    border: 1px solid #b39d7d;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.period-btn:hover, .type-btn:hover {
    background-color: #f0ebe1;
}

.period-btn.active, .type-btn.active {
    background-color: var(--primary-color);
    color: white !important;
    
}

/* 新增黑暗模式覆盖 */
[data-theme="night"].period-btn.active,
[data-theme="night"].type-btn.active {
    color: #000 !important;
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.3);
}

.timeline-container {
    position: relative;
    z-index: 1; /* 创建新的层叠上下文 */
    max-width: 800px;
    margin: 0 auto;
}

/* 添加清除按钮样式 */
#clear-btn {
    padding: 12px 24px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s;
}
[data-theme="night"] #clear-btn {
    padding: 12px 24px;
    background-color: var(--primary-color);
    color: black;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s;
}
#clear-btn:hover {
    background-color: var(--primary-color);
}

.clickable-text {
    color: var(--primary-color) !important; /* 使用主题主色 */
    cursor: pointer;
    text-decoration: underline;
    font-weight: 600; /* 更显眼的字体 */
    position: relative;
    transition: all 0.3s ease;
    text-decoration: none !important;
}

.clickable-text::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--primary-color);
    transition: width 0.25s ease-out; /* 缩短动画时间 */
}

.clickable-text:hover::after {
    width: 100%;
}

.timeline-line {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background-color: #b39d7d;
    z-index: -1;
    transform: translateZ(0); /* 强制GPU加速 */
    backface-visibility: hidden;
}

.timeline-item {
    will-change: transform, opacity, display;
    display: flex;
    margin-bottom: 60px;
    position: relative;
    opacity: 0;
    transform: translateY(20px) translateZ(0);
    transition: 
        opacity 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94),
        transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94),
        display 0.3s ease;
    will-change: opacity, transform; /* 明确告知浏览器变化属性 */
    cursor: pointer;
    @media (max-width: 480px) {
        margin-bottom: 40px;
    }
}

.timeline-item.visible {
    opacity: 1;
    transform: translateY(0);
}

.timeline-content:hover {
    transform: translateY(-2px); /* 减少位移幅度 */
    box-shadow: 0 8px 16px -4px rgba(93, 64, 55, 0.15); /* 减少阴影模糊半径 */
}

.timeline-point {
    position: absolute;
    left: -12px;
    top: 45px;
    width: 25px;
    height: 25px;
    background-color: var(--secondary-color);
    box-shadow: 
        0 2px 4px rgba(93, 64, 55, 0.1),
        inset 0 -1px 1px rgba(255,255,255,0.3); /* 内阴影增强立体感 */
    border-radius: 50%;
}

[data-theme="night"].timeline-content, [data-theme="night"] modal-content{
    background: linear-gradient(145deg, 
        var(--timeline-bg) 0%, 
        rgba(0,0,0,0.3) 100%
    );
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease; /* 统一动画属性 */
}
.timeline-content {
    flex: 1;
    padding: 30px;
    background: linear-gradient(145deg, var(--timeline-bg) 0%, rgba(255,255,255,0.1) 100%);
    border-left: 4px solid var(--primary-color);
    border-radius: 12px;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
    position: relative;
    left: 40px;
    transform: translateY(9px);
    transition: 
        transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform, box-shadow; /* 仅声明需要硬件加速的属性 */
    backdrop-filter: none; /* 去除背景模糊 */
    border: 1px solid rgba(179, 157, 125, 0.15);
}

.timeline-content::before {
    content: '';
    position: absolute;
    top: -1px;
    left: -40px;
    width: 30px;
    height: calc(100% + 2px);
    background: linear-gradient(90deg, 
        rgba(179, 157, 125, 0.1) 0%, 
        transparent 100%
    );
}

.timeline-content h2 {
    font-size: 24px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--primary-color);
    position: relative;
    color: var(--primary-color);
    font-weight: 600;
}

.timeline-content h2::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 60px;
    height: 2px;
    background: var(--secondary-color);
}

.timeline-content p {
    font-size: 17px;
    line-height: 1.8;
    color: var(--text-color);
    margin-bottom: 20px;
    position: relative;
    padding-left: 20px;
}

.timeline-content p::before {
    content: '•';
    position: absolute;
    left: 0;
    color: var(--primary-color);
    font-size: 24px;
    line-height: 1;
}

.timeline-container::-webkit-scrollbar {
    width: 8px; /* 更细的滚动条 */
}

.timeline-container::-webkit-scrollbar-thumb {
    background: rgba(93, 64, 55, 0.5); /* 半透明效果 */
    border: 1px solid rgba(255,255,255,0.1);
}

.highlighted .timeline-content {
    background-color: rgba(255,214,107,0.25); /*更醒目的高亮色 */
    box-shadow: 0 0 15px rgb(151, 110, 5);
    border: 1px solid rgba(255,214,107,0.3) ;
}

[data-theme="night"] .highlighted .timeline-content{
    background-color: rgba(195, 170, 162, 0.15);
    box-shadow: 0 0 8px rgba(195, 170, 162, 0.25);
    border: 1px solid rgba(195, 170, 162, 0.2);
}

.expanded {
    height: auto !important;
}

.expanded-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.expanded-content.expanded {
    max-height: 500px;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .expanded-content.expanded {
        max-height: 1000px; /* 增大最大高度限制 */
    }

    .timeline-content {
        padding: 15px; /* 减小 padding */
    }

    .timeline-container {
        overflow: visible; /* 确保内容不会被截断 */
    }
    
    .container {
        padding: 20px;
    }

    .timeline-line {
        left: 0;
        top: 0;
        bottom: 0;
    }

    .timeline-item {
        flex-direction: column;
        left: 0;
    }

    .timeline-point {
        left: 0;
        top: 25px;
    }

    .timeline-content {
        left: 30px;
        top: 0;
        transform: none;
        padding: 20px;
    }

    #search-input {
        width: 60%;
    }

    #search-btn {
        padding: 12px 20px;
    }

    .period-buttons, .type-buttons {
        flex-wrap: wrap;
    }
}

@media (max-width: 480px) {
    .expanded-content.expanded {
        max-height: 1000px; /* 增大最大高度限制 */
    }

    .timeline-content {
        padding: 10px; /* 减小 padding */
    }

    .timeline-container {
        overflow: visible; /* 确保内容不会被截断 */
    }
    .container {
        padding: 15px;
    }

    .timeline-content {
        padding: 15px;
    }

    #search-input {
        width: 70%;
    }

    #search-btn {
        padding: 12px 15px;
    }
}
.language-switch {
    text-align: center;
    margin: 20px 0;
}

#switch-to-en {
    padding: 10px 20px;
    background-color: #5d4037;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Times New Roman', serif;
    font-size: 16px;
    transition: background-color 0.3s ease;
}

#switch-to-en:hover {
    background-color: #8d6e63;
}

.clickable-text:hover {
    color: #8d6e63;
}

/* 新增模态框样式 */
.modal {
    cursor: pointer;/* 点击背景关闭 */
    opacity: 0;
    display: flex; /* 改用flex居中 */
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s, backdrop-filter 0.3s;
    backdrop-filter: blur(2px);
}

.modal-content button {
    background-color: var(--primary-color) !important;
    color: white !important;
}

.modal-content h2 {
    font-size: 28px;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--primary-color);
    position: relative;
}

.modal.active {
    opacity: 1;
    backdrop-filter: blur(5px);
}

.modal-content {
    width: 70%;
    max-width: 800px;
    border-radius: 16px;
    padding: 40px;
    background: linear-gradient(145deg, 
        var(--bg-color) 0%, 
        rgba(255,255,255,0.1) 100%
    );
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(179, 157, 125, 0.2);
    backdrop-filter: blur(12px);
    transition: 
        opacity 0.25s ease-out,
        transform 0.25s ease-out;
}



.modal.active .modal-content {
    transform: translateY(0);
    opacity: 1;
}

/* 关闭动画 */
.modal.closing .modal-content {
    transform: translateY(50px);
    opacity: 0;
}

.modal-content h2 {
    margin-top: 40px; /* 给按钮留出空间 */
    color: #5d4037;
    font-size: 24px;
    text-align: center;
}

.modal-content p {
    padding: 20px;
    line-height: 1.8;
    font-size: 18px;
    font-size: 18px;
    line-height: 1.8;
    padding: 20px;
    background: rgba(179, 157, 125, 0.05);
    border-radius: 8px;
    border-left: 3px solid var(--primary-color);
    margin: 15px 0;
}

/* 移动端适配 */
@media (max-width: 768px) {
    .modal-content {
        width: 90% !important;
        margin: 20% auto !important;
    }
    ::-webkit-scrollbar {
        width: 6px;
        height: 6px;
    }
    
    ::-webkit-scrollbar-thumb {
        border-width: 1px;
    }
}
/* 主题切换按钮样式 */
#theme-toggle {
    position: relative;
    width: 44px;
    height: 24px;
    border-radius: 12px;
    border: 1px solid var(--primary-color);
    background: var(--quote-bg);
    cursor: pointer;
    padding: 2px;
}

#theme-toggle span {
    position: absolute;
    transition: all 0.3s ease;
    font-size: 18px;
}

#theme-toggle .sun {
    opacity: 1;
    transform: translateX(-21px) translateY(-13px); /* 合并transform */
}

#theme-toggle .moon {
    opacity: 0;
    transform: translateX(-20px) translateY(-13px); /* 合并transform */
}

[data-theme="night"] #theme-toggle .sun {
    opacity: 0;
    transform: translateX(-1px) translateY(-13px); /* 统一Y轴位置 */
}

[data-theme="night"] #theme-toggle .moon {
    opacity: 1;
    transform: translateX(-2px) translateY(-12px); /* 正确对齐 */
}
/* 禁用低性能设备的复杂效果 */
@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
    ::-webkit-scrollbar-thumb {
        transition: none;
    }
}

::-webkit-scrollbar {
    width: 10px;  /* 纵向滚动条宽度 */
    height: 10px; /* 横向滚动条高度 */
    background: var(--bg-color);
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
    border-left: 1px solid rgba(179, 157, 125, 0.1);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 5px;
    border: 2px solid var(--bg-color);
    background-clip: content-box;
    transition: background-color 0.3s;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

::-webkit-scrollbar-corner {
    background: var(--bg-color);
}

[data-theme="night"] ::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-color: var(--bg-color);
}

[data-theme="night"] .timeline-container::-webkit-scrollbar-thumb {
    background: rgba(195, 170, 162, 0.6);
}

/* Firefox兼容方案 */
@supports (scrollbar-color: auto) {
    * {
        scrollbar-color: var(--primary-color) var(--bg-color);
        scrollbar-width: thin;
    }
}