/* ============================================
   kaigenrei.com - Ethereal Martial Law Documentary
   Fonts: Cormorant Garamond, Noto Sans JP, Space Mono" (Google Fonts)
   Interior padding uses clamp() for responsive spacing
   All timeline entry elements use IntersectionObserver
   Color Palette:
     Aurora deep:    #0d1b2a
     Aurora mid:     #1b3a5c
     Aurora light:   #3a5c7c
     Aurora violet:  #7c3aed
     Aurora green:   #34d399
     Warm ground:    #f8f5f0
     Text on light:  #1a1a2e
     Text on dark:   #e0ddf0
     Crystalline:    #a78bfa
   ============================================ */

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    background: #0d1b2a;
    color: #e0ddf0;
    font-family: 'Noto Sans JP', sans-serif;
    font-weight: 400;
    font-size: clamp(15px, 1.5vw, 18px);
    line-height: 1.8;
    overflow-x: hidden;
}

/* ============================================
   Aurora Gradient Animation
   ============================================ */

@keyframes auroraShift {
    0% {
        background-position: 0% 50%;
    }
    25% {
        background-position: 50% 100%;
    }
    50% {
        background-position: 100% 50%;
    }
    75% {
        background-position: 50% 0%;
    }
    100% {
        background-position: 0% 50%;
    }
}

@keyframes dividerDraw {
    from {
        height: 0;
    }
    to {
        height: 100%;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes dividerPulse {
    0%, 100% {
        opacity: 0.6;
    }
    50% {
        opacity: 1;
    }
}

@keyframes crystalFloat {
    0%, 100% {
        transform: translate3d(var(--tx), var(--ty), var(--tz)) rotate(var(--rot));
    }
    50% {
        transform: translate3d(var(--tx), calc(var(--ty) - 18px), var(--tz)) rotate(var(--rot));
    }
}

@keyframes markerGlow {
    0%, 100% {
        box-shadow: 0 0 8px rgba(124, 58, 237, 0.3);
    }
    50% {
        box-shadow: 0 0 16px rgba(124, 58, 237, 0.6);
    }
}

/* ============================================
   Split-Screen Base
   ============================================ */

.split-screen {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    overflow: hidden;
}

.split-left,
.split-right {
    position: relative;
    width: 50%;
    height: 100%;
    overflow: hidden;
}

.split-divider {
    position: absolute;
    left: 50%;
    top: 0;
    width: 2px;
    height: 0;
    background: #7c3aed;
    z-index: 10;
    transform: translateX(-50%);
    animation: dividerPulse 3s ease-in-out infinite;
}

.split-divider.drawn {
    animation: dividerDraw 800ms ease-out forwards, dividerPulse 3s ease-in-out 800ms infinite;
}

/* ============================================
   Aurora Background
   ============================================ */

.aurora-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        135deg,
        #0d1b2a 0%,
        #1b3a5c 25%,
        #3a5c7c 40%,
        #7c3aed 60%,
        #34d399 75%,
        #1b3a5c 90%,
        #0d1b2a 100%
    );
    background-size: 400% 400%;
    animation: auroraShift 18s ease-in-out infinite;
    opacity: 0;
    transition: opacity 1.2s ease;
}

.aurora-bg.visible {
    opacity: 1;
}

.aurora-closing {
    background: linear-gradient(
        225deg,
        #0d1b2a 0%,
        #1b3a5c 30%,
        #3a5c7c 50%,
        #7c3aed 70%,
        #0d1b2a 100%
    );
    background-size: 400% 400%;
    animation: auroraShift 20s ease-in-out infinite;
}

/* ============================================
   Hero Section
   ============================================ */

#heroRight {
    background: #f8f5f0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 1.2s ease;
}

#heroRight.visible {
    opacity: 1;
}

#heroLeft {
    opacity: 0;
    transition: opacity 1.2s ease;
}

#heroLeft.visible {
    opacity: 1;
}

.hero-content {
    padding: clamp(32px, 5vw, 80px);
    max-width: 560px;
}

.hero-title {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 700;
    font-size: clamp(32px, 6vw, 80px);
    color: #1a1a2e;
    line-height: 1.1;
    margin-bottom: 0.25em;
    letter-spacing: -0.02em;
}

.hero-subtitle {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: clamp(20px, 3vw, 40px);
    color: #1b3a5c;
    margin-bottom: 1em;
    line-height: 1.3;
}

.hero-definition {
    font-family: 'Noto Sans JP', sans-serif;
    font-weight: 400;
    font-size: clamp(15px, 1.5vw, 18px);
    color: #1a1a2e;
    line-height: 1.8;
    opacity: 0.85;
}

/* Magnetic pull effect for characters */
.hero-title .char,
.hero-subtitle .char {
    display: inline-block;
    transition: transform 600ms cubic-bezier(0.23, 1, 0.32, 1), opacity 600ms ease;
}

.hero-title .char.scattered,
.hero-subtitle .char.scattered {
    opacity: 0;
}

/* ============================================
   Timeline Section
   ============================================ */

.timeline-section {
    position: relative;
    min-height: 100vh;
    background: #0d1b2a;
}

.timeline-top {
    position: sticky;
    top: 0;
    z-index: 20;
    background: linear-gradient(to bottom, #0d1b2a 60%, transparent);
    padding: clamp(32px, 5vw, 80px) clamp(32px, 5vw, 80px) 40px;
}

.timeline-ribbon {
    position: relative;
    width: 100%;
    height: 60px;
    display: flex;
    align-items: center;
}

.timeline-line {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: #7c3aed;
    transform: translateY(-50%);
}

.timeline-markers {
    position: relative;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 2;
}

.timeline-marker {
    position: relative;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #7c3aed;
    border: none;
    cursor: pointer;
    transition: all 400ms ease-out;
    padding: 0;
}

.timeline-marker.active {
    width: 12px;
    height: 12px;
    background: linear-gradient(135deg, #7c3aed, #34d399);
    animation: markerGlow 2s ease-in-out infinite;
}

.marker-year {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Space Mono', monospace;
    font-weight: 400;
    font-size: 13px;
    letter-spacing: 0.05em;
    color: #e0ddf0;
    white-space: nowrap;
    opacity: 0.5;
    transition: opacity 300ms ease, color 300ms ease;
}

.timeline-marker.active .marker-year {
    opacity: 1;
    color: #a78bfa;
}

/* Timeline Content */
.timeline-bottom {
    position: relative;
    padding: 20px clamp(32px, 5vw, 80px) clamp(60px, 10vw, 120px);
    min-height: 60vh;
}

.timeline-entry {
    display: none;
    opacity: 0;
    transition: opacity 300ms ease;
    max-width: 680px;
    margin: 0 auto;
}

.timeline-entry.active {
    display: block;
    opacity: 1;
}

.entry-meta {
    font-family: 'Space Mono', monospace;
    font-weight: 400;
    font-size: 13px;
    letter-spacing: 0.05em;
    color: #34d399;
    text-transform: uppercase;
    display: block;
    margin-bottom: 12px;
}

.entry-title {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 700;
    font-size: clamp(28px, 4vw, 56px);
    color: #e0ddf0;
    line-height: 1.2;
    margin-bottom: 0.6em;
}

.entry-body {
    font-family: 'Noto Sans JP', sans-serif;
    font-weight: 400;
    font-size: clamp(15px, 1.5vw, 18px);
    color: #e0ddf0;
    line-height: 1.8;
    opacity: 0.85;
}

/* ============================================
   Atmosphere / Crystalline Section
   ============================================ */

.atmosphere-section {
    position: relative;
    width: 100%;
    min-height: 100vh;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.atmosphere-aurora {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        160deg,
        #0d1b2a 0%,
        #1b3a5c 20%,
        #7c3aed 40%,
        #3a5c7c 55%,
        #34d399 70%,
        #7c3aed 85%,
        #0d1b2a 100%
    );
    background-size: 400% 400%;
    animation: auroraShift 20s ease-in-out infinite;
}

.crystalline-container {
    position: relative;
    width: 80vw;
    height: 70vh;
    perspective: 1200px;
    z-index: 2;
}

.crystal-fragment {
    position: absolute;
    top: 50%;
    left: 50%;
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: clamp(16px, 2.5vw, 28px);
    color: #a78bfa;
    white-space: nowrap;
    opacity: 0;
    transform: translate3d(var(--tx), var(--ty), var(--tz)) rotate(var(--rot));
    animation: crystalFloat var(--dur) ease-in-out var(--delay) infinite alternate;
    transition: opacity 0.8s ease, transform 0.3s ease;
    text-shadow: 0 0 20px rgba(167, 139, 250, 0.3);
    pointer-events: none;
}

.crystal-fragment.visible {
    opacity: 0.65;
}

.crystal-fragment:nth-child(3n) {
    color: #e0ddf0;
    text-shadow: 0 0 20px rgba(224, 221, 240, 0.2);
    opacity: 0;
}

.crystal-fragment:nth-child(3n).visible {
    opacity: 0.45;
}

.crystal-fragment:nth-child(5n) {
    color: #34d399;
    text-shadow: 0 0 20px rgba(52, 211, 153, 0.3);
}

/* ============================================
   Closing Section (Inverted Split-Screen)
   ============================================ */

.split-screen.inverted .split-left {
    background: #f8f5f0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.split-screen.inverted .split-right {
    background: #0d1b2a;
}

.closing-content {
    padding: clamp(32px, 5vw, 80px);
    max-width: 560px;
}

.closing-title {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 700;
    font-size: clamp(28px, 5vw, 64px);
    color: #1a1a2e;
    line-height: 1.2;
    margin-bottom: 0.15em;
}

.closing-subtitle {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: clamp(20px, 3vw, 36px);
    color: #1b3a5c;
    margin-bottom: 1em;
    line-height: 1.3;
}

.closing-body {
    font-family: 'Noto Sans JP', sans-serif;
    font-weight: 400;
    font-size: clamp(15px, 1.5vw, 18px);
    color: #1a1a2e;
    line-height: 1.8;
    opacity: 0.85;
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 768px) {
    .split-screen {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }

    .split-left,
    .split-right {
        width: 100%;
        height: 50vh;
    }

    .split-divider {
        left: 0;
        top: 50%;
        width: 100%;
        height: 2px !important;
        transform: translateY(-50%);
    }

    .split-screen.inverted {
        flex-direction: column-reverse;
    }

    .hero-title {
        font-size: clamp(28px, 10vw, 56px);
    }

    .timeline-top {
        position: relative;
    }

    .timeline-markers {
        overflow-x: auto;
        gap: 20px;
        justify-content: flex-start;
        padding: 0 10px;
    }

    .timeline-marker {
        flex-shrink: 0;
    }

    .crystalline-container {
        width: 95vw;
        height: 80vh;
    }

    .crystal-fragment {
        font-size: clamp(14px, 4vw, 20px);
    }
}
