@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;700&family=Noto+Sans+JP:wght@300;400;500;700&family=Shippori+Mincho:wght@400;600&display=swap');

:root {
    /* Sparkling Archive Theme */
    --color-kobo-bg-top: #ffdde1;    /* Peach Pink */
    --color-kobo-bg-mid: #eeffdd;    /* Lime Mint */
    --color-kobo-bg-bottom: #ddf3ff; /* Sky Blue */
    --color-kobo-primary: #51bb9b;   /* Soda Green */
    --color-kobo-accent: #ff8e8e;    /* Cherry Red */
    --color-kobo-glass-bg: rgba(255, 255, 255, 0.7); /* Creamy/Milky */
    --color-kobo-glass-border: rgba(255, 255, 255, 0.4);
    --color-kobo-text: #444;
    --color-kobo-muted: #777;
    
    /* Layout */
    --timeline-width: 3px;
}

body.kobo-body {
    background: linear-gradient(135deg, 
        #ffd1d1 0%, 
        #fff9d1 25%, 
        #d1ffd1 50%, 
        #d1f9ff 75%, 
        #d1d1ff 100%
    );
    background-attachment: fixed;
    color: var(--color-kobo-text);
    font-family: 'Noto Sans JP', sans-serif;
    line-height: 1.8;
    margin: 0;
    overflow-x: hidden;
}

.kobo-body a {
    color: var(--color-kobo-primary);
    text-decoration: none;
    transition: 0.3s;
}

.kobo-body a:visited {
    color: var(--color-kobo-primary);
}

.kobo-body a:hover {
    color: var(--color-kobo-accent);
}

.kobo-body h1, .kobo-body h2, .kobo-body h3 {
    font-family: 'Shippori Mincho', serif;
    scroll-margin-top: 100px; /* Offset for fixed header/menu */
}

.en-title {
    font-family: 'Cinzel', serif;
}

/* --- Hero Section --- */
.kobo-hero {
    height: 60vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    position: relative;
    padding: 0 20px;
}

.kobo-hero-title {
    font-size: 4rem;
    letter-spacing: 0.3em;
    margin: 0;
    color: var(--color-kobo-accent);
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
}

.kobo-hero-sub {
    font-size: 1.2rem;
    color: var(--color-kobo-muted);
    margin-top: 10px;
    letter-spacing: 0.5em;
    text-transform: uppercase;
}

/* --- Timeline Structure --- */
.kobo-timeline {
    position: relative;
    max-width: 900px;
    margin: 0 auto;
    padding: 100px 20px;
}

.kobo-timeline::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: var(--timeline-width);
    height: 100%;
    background: linear-gradient(to bottom, 
        rgba(255,142,142,0.3), 
        rgba(224,255,221,0.5), 
        rgba(209,249,255,0.5),
        rgba(209,209,255,0.3)
    );
}

/* --- Era Header --- */
.kobo-era-header {
    position: relative;
    text-align: center;
    margin: 80px 0 40px;
    z-index: 2;
}

.era-label {
    display: inline-block;
    padding: 10px 40px;
    background: var(--color-kobo-glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 2px solid var(--color-kobo-glass-border);
    border-radius: 50px;
    font-size: 1rem;
    letter-spacing: 0.1em;
    color: var(--color-kobo-primary);
    font-weight: bold;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
}

/* --- Card Styles --- */
.kobo-card {
    position: relative;
    width: 45%;
    margin-bottom: 50px;
    padding: 30px;
    background: var(--color-kobo-glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--color-kobo-glass-border);
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    transition: transform 0.3s ease, background 0.3s ease;
}

.kobo-card:hover {
    transform: translateY(-5px);
    background: rgba(255,255,255,0.08);
}

/* Alternate Left/Right */
.kobo-card.left { float: left; clear: right; text-align: right; }
.kobo-card.right { float: right; clear: left; text-align: left; }

/* Connection Dots */
.kobo-card::after {
    content: '';
    position: absolute;
    top: 30px;
    width: 12px;
    height: 12px;
    background: var(--color-kobo-primary);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--color-kobo-primary);
}

.kobo-card.left::after { right: -30px; transform: translateX(50%); }
.kobo-card.right::after { left: -30px; transform: translateX(-50%); }

.kobo-card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 0.8rem;
}

.kobo-card-num {
    color: var(--color-kobo-primary);
    font-weight: bold;
    letter-spacing: 0.1em;
}

.kobo-card-date {
    font-family: 'Cinzel', serif;
    color: var(--color-kobo-muted);
}

.kobo-card-img {
    margin: 15px 0;
    width: 100%;
    overflow: hidden;
    border-radius: 4px;
    background: rgba(0,0,0,0.2);
    /* Memory shard feel */
    padding: 8px;
    background: #fff;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.kobo-card.left .kobo-card-img { transform: rotate(-2deg); }
.kobo-card.right .kobo-card-img { transform: rotate(2deg); }

.kobo-card-img img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
    border-radius: 2px;
}

.kobo-card-title {
    font-size: 1.4rem;
    margin: 0 0 15px;
}

.kobo-card-title a {
    color: inherit;
    text-decoration: none;
}

.kobo-card-desc {
    font-size: 0.9rem;
    color: var(--color-kobo-muted);
}

/* --- Afterword Section --- */
.kobo-afterword-container {
    max-width: 800px;
    margin: 0 auto 30px; /* Reduced bottom margin for top position */
    position: relative;
    z-index: 2;
    clear: both;
}

.kobo-afterword-card {
    background: var(--color-kobo-glass-bg);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid var(--color-kobo-glass-border);
    border-radius: 30px;
    padding: 40px; /* Restored to 40px for better breathing room */
    box-shadow: 0 15px 40px rgba(0,0,0,0.06);
}

/* Hide Redundant Original VT Controller */
.kobo-afterword-card .vt-controler,
.kobo-afterword-card .vt-controler-ctl,
.kobo-afterword-card .vt-cover {
    display: none !important;
}

/* --- Novel Controller --- */
.novel-controller {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.nc-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nc-label {
    font-size: 0.75rem;
    color: var(--color-kobo-muted);
    font-family: 'Inter', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.nc-btn {
    background: rgba(255,255,255,0.4);
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 0.85rem;
    cursor: pointer;
    color: var(--color-kobo-text);
    transition: all 0.2s ease;
}

.nc-btn:hover {
    background: rgba(255,255,255,0.7);
    transform: translateY(-1px);
}

.vt-controler-active {
    background: var(--color-kobo-accent);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.kobo-afterword-content {
    font-size: 1.05rem;
    color: var(--color-kobo-text);
    line-height: 2;
}

/* Revised Novel Body Alignment Strategy & Transparency Reverted */
.kobo-afterword-card {
    background: var(--color-kobo-glass-bg) !important;
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid var(--color-kobo-glass-border);
    border-radius: 30px;
    padding: 40px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.06);
    z-index: 10;
    position: relative;
}

.kobo-afterword-card .novel-body {
    display: flex !important;
    max-width: none !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 30px 0 0 0 !important;
}

/* Horizontal Mode: Left Anchored & Left Aligned */
.novel-body.horizontal-text {
    justify-content: flex-start !important;
}

.novel-body.horizontal-text .kobo-afterword-content {
    writing-mode: horizontal-tb !important;
    -webkit-writing-mode: horizontal-tb !important;
    text-align: left !important;
    width: 100%;
    background: transparent;
    padding: 0;
}

/* Vertical Mode: Right Anchored & Top Aligned */
.novel-body.vertical-text {
    justify-content: flex-end !important; /* Anchors the content block to the right */
}

.novel-body.vertical-text .kobo-afterword-content {
    writing-mode: vertical-rl !important;
    -webkit-writing-mode: vertical-rl !important;
    -ms-writing-mode: tb-rl !important;
    text-align: left !important; /* In vertical-rl, 'left' aligns to the TOP of the column */
    
    height: 500px; /* Slightly reduced height for better fit */
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 30px 40px;
    border-radius: 20px;
    background: rgba(255,255,255,0.5); /* Semi-transparent inner box for focus */
    box-shadow: inset 0 0 20px rgba(0,0,0,0.03);
    scroll-behavior: smooth;
    text-orientation: mixed;
}

/* Force children to inherit alignment from parent mode */
.novel-body.horizontal-text .kobo-afterword-content * { text-align: left !important; }
.novel-body.vertical-text .kobo-afterword-content * { text-align: left !important; }

/* Markdown Heading Adjustments in Afterword */
.kobo-afterword-content h1, 
.kobo-afterword-content h2, 
.kobo-afterword-content h3 {
    margin-top: 1.5em;
    margin-bottom: 0.8em;
    color: var(--color-kobo-primary);
    line-height: 1.4;
}

.kobo-afterword-content h1 { font-size: 1.8rem; border-bottom: 1px solid rgba(0,0,0,0.05); padding-bottom: 5px; }
.kobo-afterword-content h2 { font-size: 1.5rem; }
.kobo-afterword-content h3 { font-size: 1.3rem; }

.kobo-afterword-content p {
    margin-bottom: 2em;
    line-height: 2.2 !important;
    color: var(--color-kobo-text) !important;
}

/* Ensure no system-injected margins stay */
.kobo-clean {
    margin: 0 !important;
    padding: 0 !important;
}

/* Clearfix for Float */
.kobo-timeline::after {
    content: '';
    display: table;
    clear: both;
}

/* --- Mobile Responsive --- */
@media (max-width: 768px) {
    .kobo-timeline::before { left: 30px; }
    .kobo-card { width: calc(100% - 70px); float: right !important; text-align: left !important; }
    .kobo-card.left::after, .kobo-card.right::after { left: -46px; right: auto; transform: none; }
}

/* Bubble Particles */
.kobo-bubbles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
    overflow: hidden;
}

.bubble {
    position: absolute;
    bottom: -100px;
    background: radial-gradient(circle at 35% 35%, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0.2) 60%, rgba(255, 255, 255, 0) 75%);
    border: 1.5px solid rgba(255, 255, 255, 0.7);
    border-radius: 50%;
    opacity: 0.8;
    animation: rise var(--duration) infinite ease-in;
    filter: drop-shadow(0 0 1px rgba(255, 255, 255, 0.5));
    z-index: -1;
    box-shadow: inset -2px -2px 5px rgba(255, 255, 255, 0.1);
}

.bubble::after {
    content: '';
    position: absolute;
    top: 15%;
    left: 15%;
    width: 25%;
    height: 25%;
    background: #fff;
    border-radius: 50%;
    /* Sharper highlight */
}

@keyframes rise {
    0% {
        transform: translateY(0) translateX(0) scale(0.4);
        opacity: 0;
    }
    10% {
        opacity: 0.8;
        transform: translateY(-10vh) translateX(var(--sway)) scale(0.5);
    }
    50% {
        opacity: 0.6;
        transform: translateY(-50vh) translateX(calc(var(--sway) * -1)) scale(0.8);
    }
    90% {
        opacity: 0.4;
        transform: translateY(-90vh) translateX(var(--sway)) scale(1.1);
    }
    100% {
        transform: translateY(-120vh) translateX(0) scale(1.5);
        opacity: 0; /* Pop! */
    }
}

/* Updated floating ornaments for soda theme */
.hero-circle {
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.4;
    z-index: -2;
    pointer-events: none;
    animation: float-soda 25s infinite ease-in-out;
}

@keyframes float-soda {
    0%, 100% { transform: translate(0,0) scale(1); }
    33% { transform: translate(50px, 30px) scale(1.2); }
    66% { transform: translate(-30px, 50px) scale(0.9); }
}

/* --- PC Menu & Sidebar (Kobo Theme) --- */
.pc-menu-container {
    display: none; /* Hidden by default (Mobile) */
    position: fixed;
    top: 100px; /* Below header */
    left: 20px;
    width: 260px;
    height: calc(100vh - 120px);
    overflow-y: auto;
    
    /* Kobo Specific Glassmorphism */
    background: var(--color-kobo-glass-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--color-kobo-glass-border);
    border-radius: 12px;
    padding: 20px;
    z-index: 900;
    box-shadow: 0 10px 30px rgba(0,0,0,0.05);
    scrollbar-width: thin;
    scrollbar-color: var(--color-kobo-primary) transparent;
}

.pc-menu-title {
    font-family: 'Shippori Mincho', serif;
    font-size: 1.1rem;
    color: var(--color-kobo-primary);
    border-bottom: 2px solid var(--color-kobo-primary);
    padding-bottom: 10px;
    margin-bottom: 20px;
    text-align: center;
    letter-spacing: 0.1em;
}

/* Accordion Styles */
.accordion-item {
    margin-bottom: 10px;
    border-bottom: 1px dashed rgba(0,0,0,0.1);
}

.accordion-header {
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    padding: 10px 5px;
    font-family: 'Cinzel', 'Noto Sans JP', sans-serif;
    font-size: 0.95rem;
    color: var(--color-kobo-text);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: 0.3s;
}

.accordion-header:hover {
    color: var(--color-kobo-primary);
    padding-left: 5px;
}

.accordion-header::after {
    content: '+';
    font-weight: bold;
    color: var(--color-kobo-primary);
}

.accordion-header.active::after {
    content: '-';
}

.accordion-content {
    display: none;
    padding: 10px;
    font-size: 0.85rem;
    color: var(--color-kobo-muted);
}

.accordion-header.active + .accordion-content {
    display: block;
    animation: fadeIn 0.3s ease;
}

/* TOC in Sidebar */
#pc-toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

#pc-toc-list li {
    margin-bottom: 8px;
}

#pc-toc-list a {
    display: block;
    color: var(--color-kobo-muted);
    text-decoration: none;
    transition: 0.2s;
    line-height: 1.4;
}


    /* Home Menu Styles (PC Sidebar Override) */
    .accordion-content .home_menu {
        list-style: none;
        padding: 0;
        margin-top: 10px;
        border-top: 1px dashed rgba(0,0,0,0.1);
        padding-top: 10px;
    }
    .accordion-content .home_menu li {
        margin-bottom: 8px;
    }
/* --- Mobile Menu Styles (Kobo Theme) --- */
/* Moved out of min-width:1200px query to be visible on mobile */
.menu-toggle {
    display: block; /* Visible by default (Mobile/Tablet) */
    width: 40px;
    height: 40px;
    position: fixed;
    top: 20px;
    right: 20px;
    cursor: pointer;
    z-index: 10002; /* Above Admin Bar */
    background: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    box-shadow: 0 0 5px rgba(255,255,255,0.5);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.menu-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--color-kobo-primary);
    position: absolute;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.menu-toggle span:nth-child(1) { transform: translateY(-7px); }
.menu-toggle span:nth-child(2) { transform: translateY(0); }
.menu-toggle span:nth-child(3) { transform: translateY(7px); }

.menu-toggle.active span:nth-child(1) { transform: rotate(45deg); background: var(--color-kobo-primary); }
.menu-toggle.active span:nth-child(2) { opacity: 0; }
.menu-toggle.active span:nth-child(3) { transform: rotate(-45deg); background: var(--color-kobo-primary); }

.nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.nav-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.nav-overlay ul {
    list-style: none;
    text-align: center;
    padding: 0;
}

.nav-overlay li {
    margin: 20px 0;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
}

.nav-overlay.active li {
    opacity: 1;
    transform: translateY(0);
}
.nav-overlay.active li:nth-child(1) { transition-delay: 0.1s; }
.nav-overlay.active li:nth-child(2) { transition-delay: 0.2s; }
.nav-overlay.active li:nth-child(3) { transition-delay: 0.3s; }
.nav-overlay.active li:nth-child(4) { transition-delay: 0.4s; }

.nav-overlay a {
    font-family: 'Cinzel', serif;
    font-size: 1.5rem;
    color: var(--color-kobo-primary);
    text-decoration: none;
    position: relative;
}

.nav-overlay .home_menu { width: 100%; }
.nav-overlay .home_menu li { margin: 15px 0; transition-delay: 0.3s; }
.nav-overlay .home_menu a { font-size: 1.2rem; color: var(--color-kobo-text); }
.nav-overlay a:hover { color: var(--color-kobo-accent); }

/* Kobo specific layout adjustment for PC Menu */
@media (min-width: 1200px) {
    .pc-menu-container {
        display: block;
    }

    .kobo-timeline, .kobo-afterword-container, .story-container {
        /* Center content but ensure at least 350px left margin to clear sidebar */
        margin-left: max(350px, calc(50vw - 450px)) !important;
        margin-right: auto !important; 
        width: auto !important;
        max-width: 900px !important;
    }
    
    /* Center bubble container shouldn't shift, but it's fixed so it's fine */
    
    /* --- Mobile Menu Styles (Kobo Theme) --- */
    /* Moved to global scope */

    /* Hide Inline TOC on PC */
    #kobo-toc-container, 
    #kobo-story-toc {
        display: none !important;
    }

    /* Hide Mobile Menu on PC */
    .menu-toggle, .nav-overlay {
        display: none !important;
    }
}
