/* ========== 全局重置与配色 (暖橘沉稳调) ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* 日间模式 */
    --bg: #f7f2ec;              /* 暖白背景 */
    --surface: #ffffff;          /* 卡片纯白 */
    --text: #2e3b4e;             /* 深灰蓝文字 */
    --text-light: #5f6b7a;        /* 浅灰蓝 */
    --border: #d9c8b5;            /* 暖灰边框 */
    --primary: #b48b6f;           /* 主色 · 灰褐 */
    --primary-dark: #8c6e58;       /* 深褐 */
    --shadow: 0 12px 28px rgba(90, 70, 50, 0.12);

    /* 三列背景 - 极淡暖色 */
    --time-bg: #fcf6ed;            /* 时段米白 */
    --empire-bg: #edf2f7;           /* 帝国极浅灰蓝 */
    --theme-bg: #f0f5ea;            /* 主题极浅豆绿 */

    /* 高亮时段3边框：橘色 (#e67e22) */
    --highlight-border: #e67e22;
    --highlight-glow: 0 0 0 3px #e67e22, 0 12px 28px rgba(230, 126, 34, 0.2);

    --radius: 28px;
    --transition: 0.2s ease;
}

body.night-mode {
    --bg: #1e262e;
    --surface: #2d3842;
    --text: #d9d2c5;
    --text-light: #a9b1b8;
    --border: #5a5250;
    --primary: #bc9f86;
    --primary-dark: #dbb99b;
    --shadow: 0 12px 28px rgba(0, 0, 0, 0.6);

    --time-bg: #3d3a33;
    --empire-bg: #323e48;
    --theme-bg: #364033;

    --highlight-border: #e67e22;
    --highlight-glow: 0 0 0 3px #e67e22, 0 12px 28px rgba(230, 126, 34, 0.15);
}

body {
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
    transition: background-color 0.3s, color 0.2s;
    padding: 20px;
    min-height: 100vh;
    position: relative;
}

/* 固定按钮 */
.theme-toggle, .back-to-top {
    position: fixed;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: var(--surface);
    border: 2px solid var(--border);
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: var(--shadow);
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-dark);
    transition: transform 0.2s, background-color 0.2s;
}
.theme-toggle { top: 25px; right: 25px; }
.back-to-top { bottom: 25px; right: 25px; font-size: 1.8rem; }
.theme-toggle:hover, .back-to-top:hover {
    transform: scale(1.1);
    background-color: var(--border);
}

.container {
    max-width: 1300px;
    margin: 0 auto;
    background-color: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 30px 40px;
    border: 1px solid var(--border);
}

/* 头部 */
.timeline-header {
    text-align: center;
    margin-bottom: 30px;
    border-bottom: 2px dashed var(--border);
    padding-bottom: 20px;
}
.page-title {
    font-size: 2.8rem;
    font-weight: 700;
    color: var(--primary-dark);
    letter-spacing: 2px;
}
.page-subtitle {
    font-size: 1.3rem;
    color: var(--text-light);
    margin: 12px 0 20px;
}
.header-note {
    background-color: rgba(180, 139, 111, 0.08);
    padding: 14px 28px;
    border-radius: 60px;
    display: inline-block;
    margin: 10px 0;
    color: var(--text);
}
.note-dot {
    display: inline-block;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    margin: 0 5px;
    vertical-align: middle;
}
.time-dot { background-color: var(--time-bg); border: 2px solid var(--border); }
.empire-dot { background-color: var(--empire-bg); border: 2px solid var(--border); }
.theme-dot { background-color: var(--theme-bg); border: 2px solid var(--border); }
.highlight-text { color: #e67e22; font-weight: 600; }

/* 时间线主容器 */
.timeline-main {
    display: flex;
    flex-direction: column;
    gap: 30px;
    margin: 40px 0;
}

/* 每一行三列 - 调整比例使时间列更宽，避免换行 */
.timeline-row {
    display: grid;
    grid-template-columns: 1.8fr 2.2fr 2.0fr; /* 增加时间列宽度 */
    gap: 20px;
    border-radius: 32px;
    padding: 8px;
    transition: all 0.2s;
    border: 2px solid transparent;
}
.timeline-row:hover {
    border-color: var(--border);
    background-color: rgba(217, 200, 181, 0.06);
}
.highlight-period {
    border: 3px solid var(--highlight-border);
    box-shadow: var(--highlight-glow);
    background: rgba(230, 126, 34, 0.04);
    border-radius: 34px;
}

/* 三列卡片公用 */
.time-col, .empire-col, .theme-col {
    background: var(--surface);
    border-radius: 28px;
    padding: 24px 20px;
    box-shadow: 0 6px 16px rgba(0,0,0,0.04);
    border: 1px solid var(--border);
    transition: transform 0.15s, background 0.2s;
}
.time-col { background-color: var(--time-bg); }
.empire-col { background-color: var(--empire-bg); }
.theme-col { background-color: var(--theme-bg); }

.time-col:hover, .empire-col:hover, .theme-col:hover {
    transform: translateY(-3px);
}

/* 时间段列 - 确保文字不换行 */
.time-label {
    font-size: 1.2rem;
    font-weight: 600;
    color: #b45f2e;
    background: rgba(0,0,0,0.04);
    display: inline-block;
    padding: 4px 16px;
    border-radius: 40px;
    margin-bottom: 12px;
}
.time-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-dark);
    line-height: 1.3;
    margin: 8px 0 6px;
    white-space: nowrap;      /* 强制不换行 */
}
.time-range {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text);
    background: rgba(180, 139, 111, 0.1);
    padding: 4px 14px;
    border-radius: 40px;
    display: inline-block;
    margin: 8px 0;
    white-space: nowrap;
}
.time-tag {
    font-size: 1.2rem;
    font-weight: 500;
    color: #9f6e4c;
    border-top: 1px dashed var(--border);
    padding-top: 12px;
    margin-top: 8px;
}

/* 帝国列：两个书籍封面并排 */
.empire-col {
    display: flex;
    gap: 25px;
    align-items: stretch;
    justify-content: center;
    flex-wrap: wrap;
}
.empire-item {
    flex: 1 1 160px;
    min-width: 140px;
    max-width: 200px;
    text-align: center;
    background: rgba(255,255,255,0.2);
    border-radius: 20px;
    padding: 18px 10px 15px;
    transition: background 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.empire-item:hover {
    background: rgba(255,255,255,0.35);
}
.empire-link {
    display: block;
    width: 130px;
    height: 180px;
    border-radius: 12px;
    overflow: hidden;
    border: 3px solid var(--primary);
    box-shadow: 0 8px 16px rgba(0,0,0,0.15);
    transition: transform 0.2s, box-shadow 0.2s;
    margin-bottom: 16px;
}
.empire-link:hover {
    transform: scale(1.03);
    box-shadow: 0 12px 24px rgba(0,0,0,0.2);
}
.empire-link img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.empire-name {
    font-weight: 600;
    font-size: 1.0rem;
    color: var(--primary-dark);
    background: rgba(0,0,0,0.03);
    padding: 6px 10px;
    border-radius: 40px;
    width: 100%;
    word-break: break-word;
}

/* 主题列 - 允许换行 */
.theme-title {
    font-weight: 700;
    font-size: 1.1rem;
    color: #3d6b3d;
    margin-bottom: 15px;
    line-height: 1.5;
    border-bottom: 2px solid var(--border);
    padding-bottom: 10px;
}
.night-mode .theme-title { color: #a5d6a5; }
.theme-desc {
    font-size: 1.0rem;
    color: var(--text);
    line-height: 1.7;
    max-height: 200px;
    overflow-y: auto;
    padding-right: 8px;
}
.theme-desc::-webkit-scrollbar { width: 6px; }
.theme-desc::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

/* 时间流向 */
.time-flow {
    text-align: center;
    margin: 40px 0 20px;
    padding: 20px;
    border-top: 2px dotted var(--border);
    border-bottom: 2px dotted var(--border);
}
.flow-arrow {
    font-size: 1.4rem;
    color: var(--primary-dark);
    display: block;
    margin-bottom: 10px;
}
.flow-line {
    background: rgba(217, 200, 181, 0.2);
    padding: 10px 25px;
    border-radius: 60px;
    font-family: monospace;
    letter-spacing: 1px;
    color: var(--text-light);
}

/* 底部 */
.timeline-footer {
    margin-top: 30px;
    padding: 20px 0;
    text-align: center;
    font-size: 0.96rem;
    color: var(--text-light);
    background: rgba(0,0,0,0.02);
    border-radius: 80px;
}
.timeline-footer code {
    background: var(--border);
    padding: 2px 8px;
    border-radius: 20px;
}

/* 响应式 */
@media (max-width: 1000px) {
    .timeline-row {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    .time-name, .time-range {
        white-space: normal; /* 移动端允许换行 */
    }
    .empire-item { max-width: 180px; }
    .page-title { font-size: 2.2rem; }
}
@media (max-width: 500px) {
    .container { padding: 20px 15px; }
    .empire-col { flex-direction: column; align-items: center; }
    .empire-item { width: 100%; max-width: 260px; }
}