/* Reset & Global */
@font-face {
    font-family: 'RosmarinusText';
    src: url('../../asset/fonts/textFonts.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: #1a1410; /* 深色羊皮纸背景 */
    background-image: url('../../asset/img/PaperTextureSeamless/timelineBg.webp');
    background-attachment: fixed;
    background-position: center;
    background-size: cover;
    
    color: #c9b896;
    font-family: 'Crimson Text', serif;
    line-height: 1.6;
    overflow-x: hidden;
}

/* Navigation */
.site-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(20, 15, 10, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(139, 115, 85, 0.3);
    z-index: 1000;
    padding: 0; /* Let container handle padding */
    transition: all 0.3s ease;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 2rem; /* Vertical padding here */
}

.main-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    /* Assuming fonts are loaded in html or inherited */
    font-family: 'Old English Text MT regular', serif; /* Use custom title font */
    font-size: 2rem;
    color: #d4af37;
    letter-spacing: 0.1em;
    text-decoration: none;
    /* font-weight: bold; */
}

.nav-links {
    display: flex;
    gap: 2rem;
    list-style: none;
}

.nav-links a {
    font-family: 'RosmarinusText', serif; /* Use custom text font */
    font-size: 1.6rem;
    color: #c9b896;
    text-decoration: none;
    position: relative;
    transition: color 0.3s ease;
}

.nav-links a::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 1px;
    background: #d4af37;
    transition: width 0.3s ease;
}

.nav-links a:hover, .nav-links a.active {
    color: #d4af37;
}

.nav-links a:hover::after, .nav-links a.active::after {
    width: 100%;
}

.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: #c9b896;
    font-size: 1.5rem;
    cursor: pointer;
}

@media (max-width: 830px) {
    .nav-links {
        display: none;
    }
    
    .mobile-menu-toggle {
        display: block;
        z-index: 1001;
    }

    .nav-links {
        display: flex;
        position: fixed;
        top: 0;
        right: -100%;
        width: 250px;
        height: 100vh;
        background: rgba(20, 15, 10, 0.98);
        flex-direction: column;
        justify-content: center;
        align-items: center;
        transition: right 0.3s ease;
        z-index: 1000;
        box-shadow: -5px 0 15px rgba(0,0,0,0.5);
        padding-top: 60px;
    }

    .nav-links.active {
        right: 0;
    }
    
    .nav-links li {
        margin: 1.5rem 0;
    }
}

/* 标题区 */
.timeline-header {
    text-align: center;
    padding: 8rem 4rem 2rem;
    background: linear-gradient(180deg, 
      rgba(30, 25, 20, 1) 0%, 
      rgba(25, 20, 15, 1) 100%);
}
  
.timeline-title {
    font-family: 'Crimson Text', serif;
    font-size: clamp(2.5rem, 6vw, 4rem);
    color: #d4af37;
    letter-spacing: 0.15em;
    margin: 1rem 0;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}
  
.timeline-subtitle {
    font-family: 'Crimson Text', serif;
    font-size: 1.2rem;
    color: #a0896d;
    font-style: italic;
}
  
.decorative-line {
    width: 300px;
    height: 2px;
    margin: 1.5rem auto;
    background: linear-gradient(90deg, 
      transparent 0%, 
      #8b7355 50%, 
      transparent 100%);
}

/* 故事筛选卷签 */
.story-filter-tabs {
    display: flex;
    justify-content: center;
    gap: 1rem;
    padding: 2rem;
    flex-wrap: wrap;
    background: rgba(26, 20, 16, 0.95);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid #3d2f1f;
}
  
.filter-tab {
    position: relative;
    padding: 0.8rem 2rem;
    background: linear-gradient(180deg, #3d2f1f 0%, #2a1f15 100%);
    border: 2px solid #8b7355;
    color: #c9b896;
    font-family: 'Crimson Text', serif;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    clip-path: polygon(10% 0%, 90% 0%, 100% 50%, 90% 100%, 10% 100%, 0% 50%);
}
  
.filter-tab.active {
    background: linear-gradient(180deg, #4d3f2f 0%, #3a2f25 100%);
    border-color: #d4af37;
    color: #d4af37;
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.3);
}
  
.filter-tab:hover:not(.active) {
    border-color: #a0896d;
    transform: translateY(-2px);
}

/* 时间轴主线 */
.timeline-main {
    position: relative;
    max-width: 1400px;
    margin: 0 auto;
    padding: 4rem 2rem;
    min-height: 80vh;
}
  
.timeline-line {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 6px; /* 加宽线条 */
    background: linear-gradient(180deg,
      transparent 0%,
      #8b7355 5%,
      #8b7355 95%,
      transparent 100%);
    transform: translateX(-50%);
    z-index: 1;
    /* 时间刻度 */
    background-image: 
        repeating-linear-gradient(
            180deg,
            transparent,
            transparent 19px,
            rgba(139, 115, 85, 0.6) 19px,
            rgba(139, 115, 85, 0.6) 20px
        ),
        repeating-linear-gradient(
            180deg,
            transparent,
            transparent 98px,
            #8b7355 98px,
            #8b7355 100px
        );
    background-size: 100% 100%, 150% 100%;
    background-position: center, center;
}
  
.timeline-events-container {
    position: relative;
    z-index: 2;
}

/* 加载占位符 */
.loading-placeholder {
    text-align: center;
    color: #a0896d;
    font-style: italic;
    padding: 2rem;
}

/* 节点卡片容器 - 负责布局 */
.timeline-event-wrapper {
    position: relative;
    margin-bottom: 4rem;
    width: 45%;
}

/* 左侧节点布局 */
.timeline-event-wrapper[data-side="left"] {
    margin-right: auto;
    margin-left: 0;
    padding-right: 80px;
}

/* 右侧节点布局 */
.timeline-event-wrapper[data-side="right"] {
    margin-left: auto;
    margin-right: 0;
    padding-left: 80px;
}

/* 节点卡片 - 负责动画 */
.timeline-event {
    position: relative;
    width: 100%;
    
    /* 初始状态：透明且有偏移 */
    opacity: 0;
    transform: translateX(0);
    /* 默认状态下的 transition */
    /* 进场：从屏幕外进入，使用 ease-out (减速进入，像刹车) */
    transition: opacity 0.6s ease-out, transform 0.6s ease-out; 
}

/* 左侧卡片初始向左偏移 */
.timeline-event[data-side="left"] {
    transform: translateX(-100vw); /* 从屏幕左侧外进入 */
    /* 由于父级负责布局，这里不需要 margin 和 padding */
}

/* 右侧卡片初始向右偏移 */
.timeline-event[data-side="right"] {
    transform: translateX(100vw); /* 从屏幕右侧外进入 */
    /* 由于父级负责布局，这里不需要 margin 和 padding */
}

/* 进入视窗后的状态 */
.timeline-event.in-view {
    opacity: 1;
    transform: translateX(0);
    /* 进场动画：ease-out (减速进入，着陆感) */
    transition: all 0.6s ease-out; 
}

/* 消失动效：左侧滑出 */
.timeline-event.slide-out-left {
    opacity: 0;
    transform: translateX(-100vw); /* 滑出屏幕外 */
    /* 离场动画：ease-in (加速离开，飞出感) */
    transition: all 0.5s ease-in; 
}

/* 消失动效：右侧滑出 */
.timeline-event.slide-out-right {
    opacity: 0;
    transform: translateX(100vw); /* 滑出屏幕外 */
    /* 离场动画：ease-in (加速离开，飞出感) */
    transition: all 0.5s ease-in; 
}
  
/* 火漆节点图标 */
.timeline-node {
    position: absolute;
    top: 2rem;
    width: 60px; /* 增大尺寸以适应图片 */
    height: 60px;
    z-index: 10;
    /* 居中定位修正 */
    transform: translateX(50%); 
}

/* 左侧节点的火漆应该向右偏移50%以居中于时间线，但由于父容器是相对定位，这里的定位是相对于父容器边缘 */
.timeline-event[data-side="left"] .timeline-node {
    right: -33px; /* 微调以对齐中心线 (60px/2 + 3px线宽) */
    transform: none;
}
.timeline-event[data-side="right"] .timeline-node {
    left: -33px;
    transform: none;
}
  
.wax-seal {
    width: 100%;
    height: 100%;
    background: url('../../asset/img/PaperTextureSeamless/waxSeal.png') no-repeat center center;
    background-size: contain;
    /* 移除原有CSS样式 */
    border-radius: 0;
    border: none;
    box-shadow: none;
    /* 添加图片自带阴影滤镜 */
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
    
    transition: transform 0.3s ease, filter 0.3s ease;
}
  
.timeline-node:hover .wax-seal {
    transform: scale(1.1);
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.6));
    cursor: pointer;
}
  
/* 上层纸样式 */
.event-upper-paper {
    padding: 2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    z-index: 1; /* Ensure content is above the pseudo-element */
    border-radius: 2px;
}
  
.event-upper-paper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -1;

    background: linear-gradient(135deg, #f4e8d0 0%, #e8dcc8 100%);
    /* Texture Image */
    background-image: url('../../asset/img/PaperTextureSeamless/parchment.webp'), linear-gradient(135deg, #f4e8d0 0%, #e8dcc8 100%);
    background-size: cover;
    background-blend-mode: multiply;
    
    border: 2px solid #8b7355;
    
    /* 增加明显的阴影，使其浮在背景之上 */
    box-shadow: 0 10px 20px rgba(0,0,0,0.5), 0 6px 6px rgba(0,0,0,0.3);
    
    /* Apply SVG Filter for rough edges/texture */
    filter: url(#parchment-filter);
    
    transition: all 0.3s ease;
}
  
.event-upper-paper:hover {
    transform: translateY(-4px);
}

.event-upper-paper:hover::before {
    box-shadow: 0 14px 28px rgba(0,0,0,0.5), 0 10px 10px rgba(0,0,0,0.3);
    border-color: #a0896d;
}
  
.event-year {
    font-family: 'UnifrakturMaguntia', cursive;
    font-size: 2.5rem;
    color: #8b2e2e;
    margin-bottom: 1rem;
    text-align: center;
    letter-spacing: 0.05em;
    text-shadow: 1px 1px 0 rgba(255,255,255,0.5);
    transition: color 0.3s ease;
}
  
.event-title {
    font-family: 'Crimson Text', serif;
    font-size: 1.8rem;
    color: #2c2416;
    margin-bottom: 1rem;
    font-weight: 700;
}
  
.event-summary {
    font-family: 'Crimson Text', serif;
    font-size: 1.1rem;
    color: #3d2f1f;
    line-height: 1.8;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
  
/* 下层纸样式（初始隐藏） */
.event-lower-paper {
    max-height: 0;
    overflow: hidden;
    padding: 0 2rem;
    margin-top: -2px; /* 紧贴上层纸 */
    position: relative;
    z-index: 0;
    
    transition: max-height 500ms ease-in-out, padding 300ms ease-in-out;
}

.event-lower-paper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -1;

    background: linear-gradient(135deg, #faf6ed 0%, #f0e8d8 100%);
    /* Texture Image */
    background-image: url('../../asset/img/PaperTextureSeamless/parchment.webp'), linear-gradient(135deg, #faf6ed 0%, #f0e8d8 100%);
    background-size: cover;
    background-blend-mode: multiply;

    border: 2px solid #8b7355;
    border-top: none;
    
    /* 增加明显的阴影，使其浮在背景之上 */
    box-shadow: 0 10px 20px rgba(0,0,0,0.5), 0 6px 6px rgba(0,0,0,0.3);
    
    /* Apply SVG Filter for rough edges/texture */
    filter: url(#parchment-filter);
}

.event-lower-paper.expanded::before {
    border-top: 2px dashed #8b7355;
}

.event-lower-paper.expanded {
    max-height: 2000px; /* 足够大以容纳内容 */
    padding: 2rem;
}
  
.markdown-content {
    font-family: 'Crimson Text', serif;
    font-size: 1.1rem;
    line-height: 1.9;
    color: #2c2416;
    margin-bottom: 1.5rem;
}
  
.markdown-content h2 {
    font-size: 1.6rem;
    color: #8b2e2e;
    margin: 1.5rem 0 1rem;
    border-bottom: 1px solid rgba(139, 115, 85, 0.3);
    padding-bottom: 0.5rem;
}
  
.markdown-content p {
    margin: 1rem 0;
}

.chapter-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.8rem 1.5rem;
    background: transparent;
    border: 2px solid #8b7355;
    color: #3d2f1f;
    font-family: 'Crimson Text', serif;
    font-size: 1rem;
    text-decoration: none;
    transition: all 0.3s ease;
    clip-path: polygon(5% 0%, 95% 0%, 100% 50%, 95% 100%, 5% 100%, 0% 50%);
    margin-top: 1rem;
}
  
.chapter-link:hover {
    background: rgba(139, 115, 85, 0.2);
    border-color: #d4af37;
    color: #8b2e2e;
    transform: translateX(4px);
}
  
.event-images {
    margin-top: 2rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.event-image-container {
    border: 2px solid #8b7355;
    padding: 0.5rem;
    background: #fff;
    box-shadow: 2px 2px 6px rgba(0,0,0,0.2);
    transform: rotate(-1deg);
    transition: transform 0.3s ease;
}

.event-image-container:nth-child(even) {
    transform: rotate(1deg);
}

.event-image-container:hover {
    transform: scale(1.02) rotate(0);
    z-index: 10;
}
  
.event-images img {
    width: 100%;
    height: auto;
    display: block;
    filter: sepia(0.2) contrast(1.05);
}

.image-caption {
    font-size: 0.9rem;
    color: #665;
    text-align: center;
    margin-top: 0.5rem;
    font-style: italic;
}

/* 错误提示 */
.error-message {
    text-align: center;
    color: #d4af37;
    padding: 2rem;
    background: rgba(139, 46, 46, 0.1);
    border: 1px solid #8b2e2e;
    border-radius: 4px;
}

.retry-btn {
    margin-top: 1rem;
    padding: 0.5rem 1.5rem;
    background: #8b2e2e;
    color: #f4e8d0;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 1rem;
}

/* 响应式设计 - 平板/移动端 */
@media (max-width: 1023px) {
    .timeline-main {
        padding: 2rem 1rem;
    }

    .timeline-line {
        left: 40px;
        transform: none;
    }
    
    .timeline-events-container {
        /* 不需要 padding-left，因为 .timeline-event 已经有了 margin/padding */
    }

    .timeline-event-wrapper {
        width: 100%;
        padding-left: 80px !important; /* 强制所有节点左侧留空给时间线 */
        padding-right: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    .timeline-event-wrapper[data-side="left"],
    .timeline-event-wrapper[data-side="right"] {
        padding-left: 80px;
        padding-right: 0;
    }
    
    .timeline-node {
        left: 20px !important; /* 调整到时间线位置 (40px) 的中心 */
        right: auto !important;
        transform: translateX(-50%) !important; /* 居中 */
    }
    
    .timeline-event[data-side="left"] .timeline-node {
        right: auto;
    }
    
    .timeline-event[data-side="right"] .timeline-node {
        left: 20px !important;
    }
    
    .event-year {
        font-size: 2rem;
    }
    
    .event-title {
        font-size: 1.5rem;
    }
}
