/* =========================================
   EMLOG TIMELINE V5.8 - TRUE GRUNGE EDITION
   特色：不规则手撕边缘 + 胶带修复
========================================= */

:root {
    --tl-primary: #5d4037; 
    --tl-accent: #a1887f;
    --tl-text: #2c1b18;
    --paper-bg: #fdf5e6; 
    
    --font-title: 'Ma Shan Zheng', cursive;
    --font-body: 'Long Cang', 'Kaiti', serif;
    --font-eng: 'Caveat', cursive;
    
    --ease-elastic: cubic-bezier(0.34, 1.56, 0.64, 1);
}

.timeline-plugin-container {
    min-height: 100vh;
    font-family: var(--font-body);
    color: var(--tl-text);
    padding-bottom: 150px;
    overflow-x: hidden;
}

/* 颗粒蒙版 */
.timeline-mask {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.12'/%3E%3C/svg%3E");
    z-index: 1; pointer-events: none; mix-blend-mode: multiply;
}

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

/* 头部 */
.timeline-header { text-align: center; margin-bottom: 80px; }
.timeline-title {
    font-family: var(--font-title); font-size: 4rem; color: #3e2723;
    margin-bottom: 10px; text-shadow: 1px 1px 0 rgba(255,255,255,0.5);
}
.timeline-subtitle {
    font-family: var(--font-eng); font-size: 1.5rem; color: #795548;
    border-top: 1px solid #a1887f; border-bottom: 1px solid #a1887f;
    display: inline-block; padding: 5px 30px; letter-spacing: 2px;
}

/* 筛选 */
.timeline-filter { margin-top: 40px; display: flex; justify-content: center; gap: 15px; flex-wrap: wrap; }
.filter-sticky {
    background: var(--bg); border: none; padding: 10px 20px;
    font-family: var(--font-body); font-size: 18px; color: #4e342e;
    cursor: pointer; box-shadow: 1px 2px 4px rgba(0,0,0,0.15);
    transform: rotate(var(--rot)); 
    transition: transform 0.4s var(--ease-elastic);
    background-image: linear-gradient(rgba(0,0,0,0.03), rgba(0,0,0,0.03));
}
.filter-sticky:hover, .filter-sticky.active {
    transform: rotate(0deg) scale(1.1); box-shadow: 0 5px 10px rgba(0,0,0,0.2); z-index: 5;
    filter: brightness(1.05);
}

.timeline { position: relative; padding: 20px 0; }
.timeline::before {
    content: ''; position: absolute; left: 50%; top: 0; height: 100%; width: 0;
    border-left: 2px dashed #bcaaa4; transform: translateX(-50%); opacity: 0.6;
}

/* 悬挂日历 (修复年份显示) */
.hanging-calendar {
    position: absolute; top: 0; width: 60px; height: 80px;
    background: #fdf5e6; border-radius: 4px; text-align: center;
    box-shadow: 0 4px 8px rgba(0,0,0,0.15); z-index: 20;
    border-top: 4px solid #5d4037;
    transform-origin: 50% -10px;
    animation: pendulum 3.5s ease-in-out infinite alternate;
    display: flex; flex-direction: column; justify-content: space-between; overflow: hidden;
}
@keyframes pendulum { from { transform: rotate(-3deg); } to { transform: rotate(3deg); } }
.hanging-calendar::before { 
    content: ''; position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
    width: 12px; height: 12px; border-radius: 50%; border: 2px solid #5d4037;
}
.hole { width: 6px; height: 6px; background: #3e2723; border-radius: 50%; margin: 6px auto 0; opacity: 0.2; }
.cal-month { font-family: "Noto Serif SC", serif; font-weight: bold; color: #8d6e63; font-size: 12px; line-height: 1; margin-top: 2px; }
.cal-day { font-family: var(--font-eng); font-size: 32px; line-height: 1; font-weight: 700; color: #3e2723; margin-top: -2px; }
.cal-year { background-color: #8d6e63; color: #fff; font-size: 12px; padding: 3px 0; width: 100%; font-weight: bold; letter-spacing: 1px; font-family: "Arial", sans-serif; }

.timeline-event { display: flex; margin-bottom: 100px; position: relative; width: 100%; }
.timeline-event:nth-child(odd) { justify-content: flex-start; }
.timeline-event:nth-child(even) { justify-content: flex-end; }
.timeline-content { width: 45%; position: relative; }
.timeline-event:nth-child(odd) .timeline-content { padding-right: 45px; }
.timeline-event:nth-child(even) .timeline-content { padding-left: 45px; }
.timeline-event:nth-child(odd) .hanging-calendar { right: -32px; animation-delay: 0s; }
.timeline-event:nth-child(even) .hanging-calendar { left: -32px; animation-delay: 1.5s; }

/* --- 信封容器 --- */
.envelope {
    position: relative; 
    transition: transform 0.5s var(--ease-elastic);
    /* 关键：允许子元素(胶带、红丝带)溢出 */
    overflow: visible; 
    filter: drop-shadow(0 5px 15px rgba(62, 39, 35, 0.1));
}
.envelope:hover { 
    transform: translateY(-5px) scale(1.01) rotate(0deg) !important; 
    z-index: 10;
}

/* --- 核心：4种随机手撕信纸 --- */
.letter {
    position: relative; z-index: 1; padding: 35px 25px;
    background-color: #fffdf5;
    background-image: 
        linear-gradient(rgba(0,0,0,0.03) 1px, transparent 1px),
        url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.08'/%3E%3C/svg%3E");
    background-size: 100% 30px, auto;
    min-height: 200px;
    transform: rotate(-0.5deg); transition: transform 0.4s ease;
}
.envelope:hover .letter { transform: rotate(0deg); }

/* 样式1：右上角撕裂 (Missing Corner) */
.paper-style-1 {
    clip-path: polygon(
        0% 0%, 
        85% 2%, 
        90% 8%, /* 撕裂点 */
        100% 25%, 
        98% 100%, 
        2% 98%
    );
}

/* 样式2：顶部粗糙撕痕 (Rough Top) */
.paper-style-2 {
    clip-path: polygon(
        0% 10px, 
        5% 2px, 10% 8px, 15% 0px, 20% 5px, 25% 2px, 30% 8px, 35% 0px, 40% 5px, 
        45% 2px, 50% 8px, 55% 0px, 60% 6px, 65% 1px, 70% 9px, 75% 2px, 80% 6px, 
        85% 0px, 90% 7px, 95% 3px, 100% 8px,
        100% 100%, 0% 100%
    );
}

/* 样式3：底部波浪撕痕 (Rough Bottom) */
.paper-style-3 {
    clip-path: polygon(
        0% 0%, 100% 0%,
        100% 95%, 
        95% 100%, 90% 96%, 85% 99%, 80% 95%, 75% 98%, 70% 94%, 
        65% 99%, 60% 95%, 55% 98%, 50% 94%, 45% 99%, 40% 95%, 
        35% 98%, 30% 94%, 25% 99%, 20% 95%, 15% 98%, 10% 94%, 
        5% 99%, 0% 95%
    );
}

/* 样式4：左侧大缺口 (Big Bite) */
.paper-style-4 {
    clip-path: polygon(
        0% 0%, 100% 0%, 100% 100%, 0% 100%,
        2% 80%, 0% 70%, 5% 60%, 0% 50%, 3% 40%, 0% 30%
    );
}

/* --- 胶带 (Tape) --- */
.washi-tape {
    position: absolute; top: -15px; left: 50%;
    transform: translateX(-50%) rotate(-1deg);
    width: 140px; height: 35px;
    background-color: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(2px);
    /* 胶带两侧的微锯齿 */
    clip-path: polygon(0% 0%, 100% 0%, 98% 100%, 2% 100%);
    /* 光泽纹理 */
    background-image: linear-gradient(90deg, rgba(255,255,255,0.4) 0%, transparent 20%, transparent 80%, rgba(255,255,255,0.4) 100%);
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.15));
    z-index: 25; /* 确保在最上层 */
    transition: transform 0.4s ease;
}
.envelope:hover .washi-tape { 
    transform: translateX(-50%) scaleX(1.02) rotate(0deg); 
    filter: drop-shadow(0 4px 5px rgba(0,0,0,0.2)); 
}

/* 特殊事件：金箔胶带 */
.special-event .washi-tape {
    background-color: rgba(255, 223, 0, 0.4);
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.2'/%3E%3C/svg%3E");
    filter: drop-shadow(0 2px 3px rgba(184, 134, 11, 0.3));
}

/* 红丝带 */
.ribbon {
    position: absolute; top: -5px; right: -5px;
    z-index: 30; overflow: hidden; width: 75px; height: 75px; text-align: right; pointer-events: none;
}
.ribbon span {
    font-size: 10px; font-weight: bold; color: #FFF; text-transform: uppercase; text-align: center;
    line-height: 20px; transform: rotate(45deg); -webkit-transform: rotate(45deg);
    width: 100px; display: block;
    background: linear-gradient(#e53935 0%, #c62828 100%);
    box-shadow: 0 3px 10px -5px rgba(0, 0, 0, 1);
    position: absolute; top: 19px; right: -21px;
}

/* 邮戳 */
.post-stamp {
    position: absolute; top: 10px; right: 10px; width: 55px; height: 55px;
    border: 3px double rgba(93, 64, 55, 0.3); border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: rgba(93, 64, 55, 0.4); font-size: 12px; font-weight: bold; 
    transform: rotate(15deg); mix-blend-mode: multiply; z-index: 5;
    transition: transform 0.6s var(--ease-elastic);
}
.envelope:hover .post-stamp { transform: rotate(0deg) translateX(-5px); }
.special-event .post-stamp { color: rgba(198, 40, 40, 0.5); border-color: rgba(198, 40, 40, 0.3); }

/* 内容区域 */
.letter-header {
    margin-bottom: 25px; border-bottom: 2px dashed #d7ccc8; padding-bottom: 10px;
    display: flex; justify-content: space-between; align-items: baseline;
}
.event-title {
    margin: 0; font-family: var(--font-title); font-size: 1.8rem; color: #3e2723;
    font-weight: normal; text-shadow: 1px 1px 0 rgba(0,0,0,0.05);
}
.event-description {
    font-size: 1.25rem; line-height: 1.7; color: #4e342e; text-align: justify; margin-top: 15px;
}

/* 图片样式 */
.letter-content { overflow: visible; }
.event-description img {
    max-width: 100% !important; height: auto !important;
    display: block; margin: 15px auto; 
    background: #fff; padding: 6px 6px 30px 6px; 
    box-shadow: 0 4px 8px rgba(0,0,0,0.15); border: 1px solid #f0f0f0;
    filter: sepia(0.4) contrast(0.95) brightness(0.95);
    transition: filter 0.6s ease, transform 0.4s ease;
    transform: rotate(-1deg); /* 图片也随机微歪 */
}
.envelope:hover .event-description img { filter: sepia(0) contrast(1.05) brightness(1); transform: rotate(0deg); }

.letter-footer {
    margin-top: 30px; border-top: 2px dotted #bcaaa4; padding-top: 10px;
    display: flex; justify-content: space-between;
}
.like-wrapper {
    cursor: pointer; font-family: var(--font-eng); font-size: 1.6rem; color: #a1887f; 
    transition: transform 0.3s var(--ease-elastic), color 0.3s;
}
.like-wrapper:hover, .like-wrapper.liked { color: #bf360c; transform: scale(1.2); }
.signature { font-family: var(--font-eng); font-size: 1.8rem; color: #8d6e63; }

#btn-loadmore {
    background: #fdf5e6; border: none; padding: 15px 30px; cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1); 
    transition: transform 0.4s var(--ease-elastic), box-shadow 0.3s;
    background-image: radial-gradient(transparent 0px, transparent 4px, #fdf5e6 4px, #fdf5e6);
    background-size: 20px 20px; background-position: -10px -10px; color: #5d4037;
}
#btn-loadmore .stamp-inner {
    border: 2px solid #a1887f; padding: 8px 20px; display: block;
    font-family: var(--font-title); font-size: 1.2rem;
}
#btn-loadmore:hover { transform: translateY(-5px) rotate(2deg) scale(1.05); box-shadow: 0 10px 20px rgba(0,0,0,0.15); }

#time-balloon {
    position: fixed; bottom: 50px; right: 40px; width: 60px; height: 80px;
    cursor: pointer; z-index: 99; opacity: 0; pointer-events: none; transition: opacity 0.4s;
    filter: drop-shadow(0 5px 5px rgba(0,0,0,0.2));
    animation: balloonFloat 3s ease-in-out infinite alternate;
}
#time-balloon.show { opacity: 1; pointer-events: auto; }
.balloon-body {
    width: 50px; height: 60px; background: repeating-linear-gradient(90deg, #ef9a9a, #ef9a9a 10px, #ffcccb 10px, #ffcccb 20px);
    border-radius: 50% 50% 50% 50% / 40% 40% 60% 60%; margin: 0 auto; position: relative; opacity: 0.9;
}
.balloon-basket { width: 16px; height: 12px; background: #5d4037; margin: 5px auto 0; border-radius: 2px; position: relative; }
.balloon-string {
    position: absolute; top: 58px; left: 50%; transform: translateX(-50%);
    width: 20px; height: 8px; border-left: 1px solid #5d4037; border-right: 1px solid #5d4037;
}
@keyframes balloonFloat { from { transform: translateY(0); } to { transform: translateY(-10px); } }
#time-balloon.flying {
    transition: transform 1.2s cubic-bezier(0.55, 0.055, 0.675, 0.19);
    transform: translateY(-800px); opacity: 0;
}

@media (max-width: 768px) {
    .timeline::before { left: 15px; }
    .timeline-event { flex-direction: column; }
    .timeline-content { width: 100%; padding: 0 0 0 45px !important; }
    .hanging-calendar { right: auto !important; left: -12px !important; top: -10px; transform: scale(0.85); }
    .timeline-title { font-size: 3rem; }
    #time-balloon { right: 20px; bottom: 30px; transform: scale(0.8); }
}

.js-ready { opacity: 0; transform: translateY(50px); }
.js-visible { opacity: 1; transform: translateY(0); transition: 0.6s ease-out; }
.force-hidden { display: none !important; }