/* 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/characterBg.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;
    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;
}

/* 故事筛选导航 */
.story-filter-nav {
    position: relative;
    top: 0;
    left: 0;
    right: auto;
    display: flex;
    flex-direction: row; /* Horizontal row */
    flex-wrap: wrap;
    gap: 1rem;
    z-index: 100;
    background: transparent;
    padding: 1rem 0;
    border: none;
    max-height: none;
    overflow-y: visible;
    margin-bottom: 1rem;
    justify-content: center; /* Center align */
}

.story-filter-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    opacity: 0.7;
    background: rgba(42, 31, 21, 1);
    border: 1px solid #8b7355;
}

.story-filter-item:hover {
    transform: translateY(-2px);
    opacity: 1;
}

.story-filter-item.active {
    opacity: 1;
    background: rgba(212, 175, 55, 0.4);
    border-color: #d4af37;
    border-right: 1px solid #d4af37; /* Reset */
}

/* 
.story-badge {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    border: 1px solid #8b7355;
}

.story-badge img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
*/

.story-name {
    font-family: 'Crimson Text', serif;
    font-size: 1rem;
    color: #fdcb66;
}


/* 塔罗牌堆叠索引（左侧） */
.tarot-index {
    position: fixed;
    left: 0.8rem;
    top: 0; /* Align to top */
    transform: none; /* Remove centering transform */
    width: 280px; /* Reduced width slightly */
    height: 100vh; /* Full height */
    max-height: 100vh;
    overflow-y: auto;
    z-index: 50;
    padding-right: 10px;
    padding-left: 10px;
    padding-top: 6rem; /* Reduced top padding as nav is inside now */
    display: flex;
    flex-direction: column;
    align-items: center;
}

.tarot-cards-container {
    position: relative;
    padding: 1rem 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.7rem; /* Reduced spacing */
    width: 100%;
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-100px) translateY(-50px) rotate(-10deg);
    }
    to {
        opacity: 1;
        transform: translateX(0) translateY(0) rotate(0);
    }
}

@keyframes slideOutRight {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100px);
    }
}

.tarot-card {
    position: relative;
    width: 170px; /* Reduced by 15% from 200px */
    height: 298px; /* Reduced by 15% from 350px */
    margin-bottom: -170px; /* Reduced stack margin */
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center center;
    /* Animation defaults */
    animation-duration: 0.6s;
    animation-fill-mode: both;
}

.tarot-card.animate-in {
    animation-name: slideInLeft;
    animation-timing-function: ease-in-out; /* Smooth entry */
}

.tarot-card.animate-out {
    animation-name: slideOutRight;
    animation-timing-function: ease-out;
}

/* Layered Structure */
.tarot-card-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transition: all 0.4s ease;
}

.layer-back {
    background-image: url('../../asset/img/PaperTextureSeamless/tarotBack.png');
    background-size: 100% 100%;
    z-index: 1;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

.layer-mid {
    z-index: 2;
    padding: 10px; /* Inner padding for avatar */
    display: flex;
    justify-content: center;
    align-items: center;
}

.layer-mid img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Full fill */
    border-radius: 4px;
    /* filter: sepia(0.3) contrast(1.1); */
}

.layer-top {
    background-image: url('../../asset/img/PaperTextureSeamless/tarotFront.png');
    background-size: 100% 100%;
    border-radius: 18px;
    z-index: 3;
    pointer-events: none; /* Let clicks pass through */
}

.tarot-card-content {
    position: absolute;
    top: 0px; /* Move to top */
    left: 0;
    width: 100%;
    text-align: center;
    border-radius: 18px;
    z-index: 4;
    padding: 10px 10px 30px 10px; /* Add bottom padding for gradient fade */
    background: linear-gradient(180deg, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.4) 60%, rgba(0,0,0,0) 100%); /* Dark gradient at top */
}

.tarot-card-name-cn {
    font-family: serif;
    font-size: 1.4rem;
    color: #eaddcf; /* Light text for dark gradient */
    text-shadow: 0 0 4px rgba(0,0,0,0.8);
    margin-bottom: 2px;
}

.tarot-card-name-en {
    font-family: 'Crimson Text', serif;
    font-size: 0.9rem;
    color: #c9b896; /* Light gold/parchment for EN name */
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: bold;
    text-shadow: 0 0 4px rgba(0,0,0,0.8);
}

/* Hover State */
.tarot-card:hover {
    transform: translateY(-20px) scale(1.05);
    z-index: 100;
    margin-bottom: -100px; /* Adjust margin on hover to push others down? Or just z-index pop */
}

/* Selected State */
.tarot-card.selected {
    transform: translateX(20px) translateY(-20px) scale(1.05); /* Shift right & up, scale up */
    /* z-index: 100 !important; Ensure on top of hover state */
    margin-bottom: -150px; /* Give it more space */
    filter: drop-shadow(0 0 20px rgba(212, 175, 55, 0.8)); /* Stronger glow */
}

.tarot-card.selected .layer-mid img {
    /* filter: sepia(0) contrast(1.1) brightness(1.1); Restore color & enhance */
}

/* Scrollbar for tarot index */
.tarot-index::-webkit-scrollbar {
    width: 4px;
}
.tarot-index::-webkit-scrollbar-track {
    background: transparent;
}
.tarot-index::-webkit-scrollbar-thumb {
    background: rgba(139, 115, 85, 0.5);
    border-radius: 2px;
}


/* 角色主体内容区 */
.character-content {
    margin-left: 300px; /* Reduced margin */
    margin-right: 2rem;
    padding: 6rem 2rem 2rem;
    max-width: 1400px; /* Increased max-width */
    opacity: 1;
    transition: opacity 0.3s ease;
    min-height: 100vh;
}

.character-content.loading {
    opacity: 0;
}

/* Upper Section: Portrait + Info */
.character-upper {
    display: grid;
    grid-template-columns: 350px 1fr; /* Increased width for portrait */
    gap: 2rem;
    margin-bottom: 4rem;
    align-items: start;
}

.character-portrait {
    position: relative;
    border-radius: 80px;
    width: 100%;
    aspect-ratio: 4/7; /* Match tarot card ratio or similar */
    /* overflow: hidden; Removed to allow decoration to pop out if needed, but layers are absolute */
    /* border: 3px solid #8b7355; Removed simple border */
    /* box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6); Removed simple shadow */
    /* background: #000; */
}

/* Reusing tarot-card-layer logic but specific to portrait */
.character-portrait .layer-back {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-image: url('../../asset/img/PaperTextureSeamless/tarotBack.png');
    background-size: 100% 100%;
    z-index: 1;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.6);
}

.character-portrait .layer-mid {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 2;
    padding: 15px; /* Inner padding */
    display: flex;
    justify-content: center;
    align-items: center;
}

.character-portrait .layer-mid img {
    width: 100%;
    height: 100%;
    object-fit: contain; /* Full body, no crop */
    /* filter: sepia(0.1) contrast(1.05); Optional filter */
}

.character-portrait .layer-top {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-image: url('../../asset/img/PaperTextureSeamless/tarotFront.png');
    background-size: 100% 100%;
    z-index: 3;
    pointer-events: none;
}

/* Remove old img style */
.character-portrait img {
    /* width: 100%; height: 100%; object-fit: cover; */
}

.character-basic-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-top: 1rem;
}

.character-header {
    background: rgba(42, 31, 21, 0.8);
    border: 1px solid #8b7355;
    border-radius: 12px;
    padding: 1.5rem 2rem;
    margin-bottom: 2rem;
    position: relative;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    text-align: center; /* Center align text */
}

.character-header::after {
    content: '';
    display: block;
    width: 60%;
    height: 1px;
    background: linear-gradient(90deg, transparent, #d4af37, transparent);
    margin: 1rem auto; /* Divider line */
}

.character-story-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    margin-bottom: 0.5rem;
    background: rgba(189, 147, 84, 0.15);
    border: 1px solid #d4af37;
    color: #d4af37;
    font-family: 'RosmarinusText', serif;
    font-size: 1.1rem;
    letter-spacing: 0.05em;
    border-radius: 4px;
    align-self: flex-start;
}

.character-name {
    font-family: serif;
    font-size: 3rem;
    color: #d4af37;
    margin-bottom: 0.2rem;
    line-height: 1.2;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.character-subtitle {
    font-family: 'Crimson Text', serif;
    font-size: 1.5rem;
    color: #a0896d;
    font-style: italic;
    margin-bottom: 0;
}

.character-attributes {
    /* display: grid; */
    /* grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); */
    /* gap: 1.5rem; */
    background: rgba(20, 15, 10, 0.6);
    padding: 1.5rem;
    border: 1px solid rgba(139, 115, 85, 0.3);
    border-radius: 4px;
    font-size: 1.1rem; /* Adjust font size for markdown text */
    color: #c9b896;
}

.character-attributes p {
    margin-bottom: 0.5rem;
}

/* 
.attribute-item {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.attribute-label {
    font-size: 0.9rem;
    color: #8b7355;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.attribute-value {
    font-size: 1.2rem;
    color: #c9b896;
    font-family: 'RosmarinusText', serif;
}
*/

/* Lower Section: Markdown & Timeline */
.character-lower {
    background: rgba(30, 25, 20, 0.95); /* Dark solid background */
    padding: 3rem;
    border-radius: 4px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.6);
    position: relative;
    color: #eaddcf; /* Light text color */
    margin-bottom: 4rem;
    border: 1px solid #8b7355;
}

.character-lower::before {
    /* Removed pseudo-element for parchment texture border effect if not needed, 
       or keep it simple. Let's remove it as requested "pure color background" */
    display: none;
}

.markdown-content {
    font-family: 'Crimson Text', serif;
    font-size: 1.25rem; /* Slightly larger font */
    line-height: 2.0; /* Increased line height */
    color: #eaddcf;
}

.markdown-content h2 {
    font-family: serif;
    color: #d4af37; /* Gold color for headers */
    border-bottom: 1px solid #8b7355;
    padding-bottom: 0.5rem;
    margin-top: 2rem;
    margin-bottom: 1.5rem;
}

.markdown-content p {
    margin-bottom: 1.5rem; /* Increased paragraph spacing */
}

/* Character Timeline */
.character-timeline {
    position: relative;
    padding-left: 2rem;
}

.character-timeline .timeline-title {
    font-family: serif;
    font-size: 2rem;
    color: #d4af37;
    margin-bottom: 2rem;
    padding-left: 1rem;
    border-left: 4px solid #8b7355;
}

.timeline-events {
    border-left: 2px solid rgba(139, 115, 85, 0.5);
    padding-left: 2rem;
    margin-left: 1rem;
}

.timeline-event-item {
    position: relative;
    margin-bottom: 2rem;
}

.timeline-event-item::before {
    content: '';
    position: absolute;
    left: -2.6rem; /* Adjust based on padding/border */
    top: 0.5rem;
    width: 12px;
    height: 12px;
    background: #d4af37;
    border-radius: 50%;
    box-shadow: 0 0 0 4px rgba(212, 175, 55, 0.2);
}

.event-year {
    font-family: 'UnifrakturMaguntia', cursive;
    font-size: 1.5rem;
    color: #d4af37;
    margin-bottom: 0.5rem;
}

.event-title {
    font-size: 1.3rem;
    font-weight: bold;
    color: #c9b896;
    margin-bottom: 0.5rem;
}

.event-description {
    font-size: 1rem;
    color: #a0896d;
}

/* Responsive */
@media (max-width: 1200px) {
    .character-content {
        margin-right: 2rem; /* Hide story filter or move it */
    }
    /* 
    .story-filter-nav {
        display: none; 
    } 
    Removed display:none to always show nav
    */
}

@media (max-width: 1020px) {
    .tarot-index {
        position: relative;
        width: 100%;
        height: auto;
        left: 0;
        top: 0;
        transform: none;
        margin-top: 5rem;
        padding: 1rem;
        overflow-x: visible; /* Changed from auto to visible for vertical stack */
        white-space: normal; /* Changed from nowrap */
        display: flex;
        flex-direction: column; /* Stack vertically */
        align-items: center;
        max-height: none;
        background: rgba(20, 15, 10, 0.9); /* Add bg for readability */
    }
    
    .story-filter-nav {
        width: 100%;
        justify-content: center;
        margin-bottom: 2rem;
        position: relative;
    }

    .tarot-cards-container {
        flex-direction: row; /* Keep cards in row */
        width: 100%;
        padding: 2rem 1rem 4rem 1rem; /* Add bottom padding for selected card drop */
        overflow-x: auto; /* Scroll horizontally for cards */
        justify-content: flex-start; /* Start from left */
        gap: 1rem;
        min-height: 320px; /* Ensure space for cards */
    }
    
    .tarot-card {
        margin-bottom: 0;
        margin-right: -80px; /* Overlap horizontally */
        width: 140px; /* Reduced size for small screen */
        height: 245px;
        flex-shrink: 0; /* Don't shrink */
    }
    
    .tarot-card.selected {
        margin-right: 20px;
        transform: translateY(20px) scale(1.1); /* Drop down instead of up */
        margin-bottom: 0;
        z-index: 100 !important;
    }
    
    .character-content {
        margin-left: 0;
        margin-right: 0;
        padding-top: 2rem;
    }
    
    .character-upper {
        grid-template-columns: 1fr;
    }
    
    .character-portrait {
        width: 80%; /* Increased width */
        margin: 0 auto;
    }
    
    .character-basic-info {
        text-align: center;
    }
}

@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;
    }
}