/* 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: #1a120b; /* 纯色兜底 */
    background-image: url('../../asset/img/PaperTextureSeamless/storyBg.webp');
    background-attachment: fixed;
    background-position: center;
    background-size: cover;
    
    color: #c9b896;
    font-family: 'Crimson Text', serif;
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
}

/* Navigation (Reused from Timeline) */
.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;
    transition: all 0.3s ease;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 2rem;
}

.main-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-family: 'Old English Text MT regular', serif;
    font-size: 2rem;
    color: #d4af37;
    letter-spacing: 0.1em;
    text-decoration: none;
}

.nav-links {
    display: flex;
    gap: 2rem;
    list-style: none;
}

.nav-links a {
    font-family: 'RosmarinusText', serif;
    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;
    }
}

/* Story Archive Page Specific Styles */
.story-archive-page {
    position: relative;
    min-height: 100vh;
    padding-top: 80px; /* Space for fixed nav */
}

/* Night Lighting Layer */
.night-lighting-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(
        ellipse 800px 1200px at 0% 50%,
        rgba(255, 140, 60, 0.15) 0%,
        rgba(255, 100, 30, 0.08) 30%,
        transparent 60%
    );
    pointer-events: none;
    z-index: 1;
}

/* Ember Particle Layer */
.ember-particle-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
    overflow: hidden;
}

.particle {
    position: absolute;
    background-color: #ffb347;
    border-radius: 50%;
    opacity: 0;
    bottom: -10px; /* Start from below visible area */
    box-shadow: 0 0 4px #ff8c3c;
    animation: float-up var(--duration) linear infinite;
    animation-delay: var(--delay);
}

@keyframes float-up {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: var(--particle-opacity);
    }
    50% {
        opacity: calc(var(--particle-opacity) * 1.5);
    }
    100% {
        transform: translate(var(--drift-x), -100vh) scale(0.5);
        opacity: 0;
    }
}

/* Story List Container */
.story-list-container {
    position: relative;
    z-index: 2; /* Above lighting/particles */
    max-width: 1200px;
    margin: 0 auto;
    padding: 120px 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 80px;
}

/* Loading State */
.loading-state {
    text-align: center;
    font-family: 'Lora', serif;
    font-style: italic;
    font-weight: bold;
    color: #ff7322;
    font-size: 3rem;
    margin-top: 100px;
}

/* Story Item */
.story-item {
    --rotate-value: 0deg; /* Default, will be set by JS/HTML */
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.story-item[data-offset="left"] {
    transform: translateX(-40px) rotate(var(--rotate-value));
}

.story-item[data-offset="right"] {
    transform: translateX(40px) rotate(var(--rotate-value));
}

.story-item[data-offset="left"]:hover {
    transform: translateX(-40px) translateY(-7px) rotate(var(--rotate-value));
}

.story-item[data-offset="right"]:hover {
    transform: translateX(40px) translateY(-7px) rotate(var(--rotate-value));
}

.story-item:hover {
    z-index: 10;
}

/* Parchment Stack */
.parchment-stack {
    position: relative;
    width: 900px;
    height: 400px;
}

.parchment-layer {
    position: absolute;
    width: 100%;
    height: 100%;
    /* border: 1px solid #7c6f50; */
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.05);
    border-radius: 2px;
    /* 应用扭曲滤镜 */
    filter: url(#parchment-filter);
}

.parchment-layer::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background-image: url('../../asset/img/PaperTextureSeamless/parchment.webp');
    background-size: cover;
    opacity: 0.3;
    mix-blend-mode: multiply;
    pointer-events: none;
    /* 应用扭曲滤镜 */
    filter: url(#parchment-filter);
}

.layer-bottom {
    background: #a7946d;
    transform: translate(8px, 8px) rotate(-1.5deg);
        box-shadow: 
        0 4px 8px rgba(0, 0, 0, 0.1),
        0 8px 16px rgba(0, 0, 0, 0.08),
        inset 0 0 30px rgba(0, 0, 0, 0.5);
    z-index: 1;
}

.layer-middle {
    background: #d3be93;
    transform: translate(4px, 4px) rotate(0.8deg);
    z-index: 2;
}

.layer-top {
    /* 移除背景和阴影，通过伪元素实现 */
    background: transparent;
    transform: translate(0, 0) rotate(0deg);
    z-index: 3;
    display: flex; /* For ContentLayer */
    filter: none;
    box-shadow: none; /* 阴影移至伪元素 */
}

.layer-top::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    /* 背景色 + 纹理 */
    background-color: #f4e4bc;
    background-image: url('../../asset/img/PaperTextureSeamless/parchment.webp');
    background-size: cover;
    background-blend-mode: multiply;
    
    /* 核心：只对这个背景层应用 SVG 滤镜 */
    filter: url(#parchment-filter);
    
    /* 阴影也加在这里，让阴影跟随扭曲的边缘 */
    box-shadow: 
        0 4px 8px rgba(0, 0, 0, 0.1),
        0 8px 16px rgba(0, 0, 0, 0.08),
        inset 0 0 30px rgba(0, 0, 0, 0.03);
        
    border-radius: 2px;
    z-index: -1; /* 置于内容之下 */
    pointer-events: none;
}

/* Content Layer */
.content-layer {
    display: flex;
    gap: 40px;
    padding: 40px;
    height: 100%;
    width: 100%;
    align-items: center;
    position: relative;
    z-index: 4;
}

.cover-image-container {
    flex: 0 0 280px;
    aspect-ratio: 3 / 4;
    position: relative;
    /* 投影效果 */
    filter: drop-shadow(2px 4px 6px rgba(0,0,0,0.4));
}

.cover-image-bg {
    position: absolute;
    inset: 0;
    background-color: #2a1f15;
    background-image: url('../../asset/img/PaperTextureSeamless/parchment.webp');
    background-size: cover;
    background-blend-mode: multiply;
    /* 不规则羊皮纸形状遮罩 */
    clip-path: polygon(
        5% 0%, 95% 2%, 100% 10%, 98% 90%, 
        90% 100%, 10% 98%, 0% 90%, 2% 10%
    );
    z-index: 1;
}

.cover-image-img {
    position: absolute;
    inset: 5px;
    width: calc(100% - 10px);
    height: calc(100% - 10px);
    object-fit: cover;
    clip-path: polygon(
        5% 0%, 95% 2%, 100% 10%, 98% 90%, 
        90% 100%, 10% 98%, 0% 90%, 2% 10%
    );
    z-index: 2;
    filter: sepia(0.1) contrast(1.1);
    transition: filter 0.3s ease;
}

.story-item:hover .cover-image-img {
    filter: sepia(0) contrast(1.05);
}

.text-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
    justify-content: center;
    /* 对文字内容应用扭曲滤镜 */
    filter: url(#parchment-filter);
}


/* Typography */
.story-title {
    font-family: 'Cinzel', 'Georgia', serif;
    font-size: 2.5rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: #3a2a1a;
    line-height: 1.2;
}

.story-title::first-letter {
    font-size: 3.5rem;
    color: #8b6914;
    float: left;
    margin-right: 8px;
    line-height: 0.9;
}

.story-hook {
    font-family: 'Lora', 'Georgia', serif;
    font-size: 1.1rem;
    font-style: italic;
    line-height: 1.6;
    color: #5a4a3a;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Seal Button */
.seal-button {
    background: none;
    border: none;
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: #8b6914;
    cursor: pointer;
    padding: 12px 24px;
    position: relative;
    text-shadow: 
        1px 1px 2px rgba(0, 0, 0, 0.3),
        0 0 1px rgba(139, 105, 20, 0.5);
    transition: all 0.3s ease;
    align-self: flex-start; /* Don't stretch */
    margin-top: 1rem;
}

.seal-button::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: linear-gradient(
        to right,
        transparent,
        #8b6914,
        transparent
    );
    opacity: 0.6;
    transition: opacity 0.3s ease;
}

.seal-button:hover {
    color: #b8860b;
    text-shadow: 
        1px 1px 3px rgba(0, 0, 0, 0.4),
        0 0 8px rgba(184, 134, 11, 0.6);
}

.seal-button:hover::after {
    opacity: 1;
}

/* Error State */
.error-state {
    text-align: center;
    color: #8b2e2e;
    padding: 2rem;
    background: rgba(139, 46, 46, 0.1);
    border: 1px solid #8b2e2e;
    border-radius: 4px;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    .parchment-stack {
        width: 100%;
        height: auto;
        min-height: 400px;
    }
    
    /* 修复背景高度塌陷问题 (适用于平板和移动端) */
    .layer-top {
        position: relative;
        height: auto;
        min-height: 100%;
    }
    
    .content-layer {
        gap: 30px;
        padding: 30px;
        height: auto;
    }
    
    .cover-image {
        flex: 0 0 240px;
    }
}

@media (max-width: 768px) {
    /* 小于 769px 时切换为竖向布局 */
    .content-layer {
        flex-direction: column;
    }
    
    .cover-image {
        flex: 0 0 auto;
        width: 200px;
    }
    
    .text-content {
        align-items: center;
        text-align: center;
    }
    
    .seal-button {
        align-self: center;
    }
}
