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

/* 根样式和变量 */
:root {
    --color-sepia-dark: #3e2723;
    --color-sepia-medium: #5d4037;
    --color-sepia-light: #8d6e63;
    --color-sepia-lighter: #bcaaa4;
    --color-paper: #f5f2ed;
    --color-paper-light: #faf8f3;
    --color-accent: #bf9663;
    --color-text: #3e2723;
    --color-text-light: #6d4c41;
    --font-serif: 'Georgia', 'Times New Roman', serif;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --shadow-soft: 0 2px 8px rgba(62, 39, 35, 0.1);
    --shadow-medium: 0 4px 16px rgba(62, 39, 35, 0.15);
    --shadow-deep: 0 8px 32px rgba(62, 39, 35, 0.2);
}

/* 全局样式 */
body {
    font-family: var(--font-serif);
    color: var(--color-text);
    background: linear-gradient(135deg, var(--color-paper) 0%, var(--color-paper-light) 100%);
    min-height: 100vh;
    line-height: 1.6;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        repeating-linear-gradient(
            45deg,
            transparent,
            transparent 10px,
            rgba(142, 110, 99, 0.03) 10px,
            rgba(142, 110, 99, 0.03) 20px
        );
    pointer-events: none;
    z-index: 1;
}

.app-container {
    position: relative;
    z-index: 2;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* 顶部时间轴 */
.time-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 30px;
    padding: 30px 20px;
    background: var(--color-paper-light);
    border-radius: 12px;
    box-shadow: var(--shadow-soft);
    margin-bottom: 30px;
    position: relative;
    overflow: hidden;
}

.time-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, 
        transparent, 
        var(--color-accent), 
        transparent
    );
    animation: shimmer 3s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.nav-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid var(--color-sepia-lighter);
    background: var(--color-paper-light);
    color: var(--color-sepia-medium);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.nav-btn:hover {
    background: var(--color-accent);
    color: white;
    border-color: var(--color-accent);
    transform: scale(1.1);
}

.date-selector {
    text-align: center;
}

.date-input {
    padding: 12px 20px;
    font-size: 18px;
    font-family: var(--font-serif);
    color: var(--color-text);
    background: white;
    border: 2px solid var(--color-sepia-lighter);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.date-input:hover,
.date-input:focus {
    border-color: var(--color-accent);
    outline: none;
    box-shadow: var(--shadow-medium);
}

.date-display {
    margin-top: 10px;
    font-size: 24px;
    font-weight: bold;
    color: var(--color-sepia-dark);
    letter-spacing: 1px;
}

/* 主要内容区 */
.main-content {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 30px;
    margin-top: 30px;
}

/* 故事流 */
.story-flow {
    background: var(--color-paper-light);
    border-radius: 12px;
    padding: 30px;
    min-height: 600px;
    box-shadow: var(--shadow-medium);
    position: relative;
    overflow: hidden;
}

.loading-spinner {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px;
}

.loading-spinner.active {
    display: flex;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid var(--color-sepia-lighter);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-spinner p {
    margin-top: 20px;
    color: var(--color-text-light);
    font-style: italic;
}

/* 事件容器 */
.events-container {
    display: none;
    flex-direction: column;
    gap: 20px;
    animation: fadeIn 0.5s ease;
}

.events-container.active {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 事件卡片 */
.event-card {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: var(--shadow-soft);
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    border-left: 4px solid var(--color-accent);
}

.event-card:hover {
    transform: translateX(5px);
    box-shadow: var(--shadow-deep);
}

.event-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, transparent 50%, rgba(191, 150, 99, 0.05));
    border-radius: 8px;
    pointer-events: none;
}

.event-year {
    font-size: 14px;
    color: var(--color-accent);
    font-weight: bold;
    font-family: var(--font-sans);
    margin-bottom: 8px;
}

.event-title {
    font-size: 20px;
    color: var(--color-sepia-dark);
    margin-bottom: 12px;
    line-height: 1.4;
}

.event-description {
    color: var(--color-text-light);
    line-height: 1.8;
    font-size: 16px;
}

.event-expanded {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--color-sepia-lighter);
    display: none;
}

.event-expanded.show {
    display: block;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from { 
        opacity: 0;
        max-height: 0;
    }
    to { 
        opacity: 1;
        max-height: 500px;
    }
}

/* 侧边栏 */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.date-info,
.controls,
.milestone-dates {
    background: var(--color-paper-light);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow-soft);
}

.date-info h3,
.milestone-dates h3 {
    font-size: 18px;
    color: var(--color-sepia-dark);
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--color-sepia-lighter);
}

.info-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    padding: 8px 0;
}

.info-label {
    color: var(--color-text-light);
    font-size: 14px;
}

.info-value {
    color: var(--color-sepia-dark);
    font-weight: bold;
    font-family: var(--font-sans);
}

/* 控制按钮 */
.control-btn {
    width: 100%;
    padding: 12px 20px;
    background: white;
    border: 2px solid var(--color-sepia-lighter);
    border-radius: 8px;
    color: var(--color-sepia-medium);
    font-size: 16px;
    font-family: var(--font-serif);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 10px;
}

.control-btn:hover {
    background: var(--color-accent);
    color: white;
    border-color: var(--color-accent);
}

.control-btn.active {
    background: var(--color-accent);
    color: white;
    border-color: var(--color-accent);
}

/* 里程碑列表 */
.milestone-list {
    list-style: none;
}

.milestone-list li {
    padding: 10px;
    margin-bottom: 8px;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    color: var(--color-text-light);
}

.milestone-list li:hover {
    background: var(--color-accent);
    color: white;
    transform: translateX(5px);
}

/* 模态框 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--color-paper-light);
    border-radius: 12px;
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--shadow-deep);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--color-sepia-lighter);
    background: white;
    color: var(--color-sepia-medium);
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: var(--color-accent);
    color: white;
    border-color: var(--color-accent);
}

.modal-body {
    padding: 40px;
    line-height: 1.8;
    color: var(--color-text);
}

.modal-body h2 {
    color: var(--color-sepia-dark);
    margin-bottom: 20px;
    font-size: 28px;
}

.modal-body p {
    margin-bottom: 15px;
    text-align: justify;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .time-header {
        flex-direction: column;
        gap: 15px;
    }
    
    .nav-btn {
        position: absolute;
    }
    
    .prev-day {
        left: 20px;
        top: 50%;
        transform: translateY(-50%);
    }
    
    .next-day {
        right: 20px;
        top: 50%;
        transform: translateY(-50%);
    }
    
    .sidebar {
        order: -1;
    }
}