/* ============================================
   mosoon.org — Y2K Futurism Timeline
   ============================================ */

/* --- CSS Custom Properties --- */
/* Fonts: "Space Grotesk" (Google Fonts), "Inter" (Google Fonts), "IBM Plex Mono" (Google Fonts) */
/* IntersectionObserver with a threshold of 0.2 -- elements animate when 20% visible. */
/* IntersectionObserver. Used for all body text and the rotating tagline. */
/* Space Grotesk's stronger character. wide */
:root {
    --bg-deep: #0e0e1a;
    --bg-card: #1a1a2e;
    --bg-node-marker: #1e1e2e;
    --text-primary: #d4d4e0;
    --text-secondary: #9b9bb0;
    --accent-mauve: #c5c0d8;
    --accent-cyan: #5e8a8a;
    --accent-coral: #b07070;
    --spine-grid: #3a3a50;
    --hover-active: #e0daf0;
    --grid-opacity: 0.15;
    --scroll-progress: 0;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', sans-serif;
    font-weight: 300;
    font-size: clamp(0.95rem, 1.8vw, 1.1rem);
    line-height: 1.72;
    letter-spacing: 0.01em;
    color: var(--text-primary);
    background-color: var(--bg-deep);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Grid Overlay (fixed, full-page) --- */
.grid-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    opacity: calc(0.12 + var(--scroll-progress) * 0.08);
    background-image:
        repeating-linear-gradient(0deg, #3a3a50 0, #3a3a50 1px, transparent 1px, transparent 64px),
        repeating-linear-gradient(90deg, #3a3a50 0, #3a3a50 1px, transparent 1px, transparent 64px);
}

/* --- Node Counter (fixed top-right) --- */
.node-counter {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 100;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.14em;
    color: var(--text-secondary);
    text-transform: uppercase;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.node-counter.visible {
    opacity: 1;
}

.node-counter-current {
    transition: opacity 0.2s ease;
}

/* --- Timeline Spine --- */
.timeline-spine {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

.spine-line {
    width: 2px;
    height: 0;
    background-color: var(--text-secondary);
    margin: 0 auto;
    transition: none;
}

.spine-line.animated {
    animation: spineGrow 1.2s cubic-bezier(0.25, 0, 0.25, 1) 0.3s forwards;
}

@keyframes spineGrow {
    from { height: 0; }
    to { height: 100vh; }
}

.spine-line.full {
    height: 100%;
    animation: none;
}

/* --- Hero Section --- */
.hero {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    overflow: hidden;
}

/* Scan-line CRT texture (hero only) */
.hero-scanlines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3;
    background: repeating-linear-gradient(
        0deg,
        transparent 0,
        transparent 2px,
        rgba(14, 14, 26, 0.08) 2px,
        rgba(14, 14, 26, 0.08) 4px
    );
}

.hero-content {
    position: relative;
    z-index: 4;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.hero-content .node-marker {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid var(--accent-mauve);
    background: var(--bg-node-marker);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
    animation: nodePulse 2s infinite;
}

.hero-content .node-marker .node-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.14em;
    color: var(--accent-mauve);
}

/* --- Hero Title (Typewriter) --- */
.hero-title {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(2.2rem, 5vw, 4.2rem);
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}

.typewriter-text {
    display: inline-block;
    overflow: hidden;
    white-space: nowrap;
    width: 0;
    border-right: none;
}

.typewriter-text.typing {
    animation: typewriter 0.8s steps(10) forwards;
}

@keyframes typewriter {
    from { width: 0; }
    to { width: 100%; }
}

.typewriter-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background-color: var(--accent-mauve);
    margin-left: 4px;
    opacity: 0;
    vertical-align: middle;
}

.typewriter-cursor.blinking {
    animation: blink 1.06s step-end infinite;
}

.typewriter-cursor.fade-out {
    animation: cursorFadeOut 0.5s ease forwards;
}

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

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

/* --- Hero Tagline --- */
.hero-tagline {
    font-family: 'Inter', sans-serif;
    font-weight: 300;
    font-size: clamp(0.8rem, 1.5vw, 1rem);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--text-secondary);
    opacity: 0;
    transition: opacity 0.6s ease;
}

.hero-tagline.visible {
    opacity: 1;
}

/* --- Timeline Container --- */
.timeline {
    position: relative;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 60px 24px 120px;
    z-index: 2;
}

/* Central spine for timeline section */
.timeline::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 100%;
    background-color: var(--text-secondary);
    z-index: 0;
}

/* --- Timeline Nodes --- */
.timeline-node {
    position: relative;
    display: flex;
    align-items: flex-start;
    margin-bottom: 120px;
    opacity: 0;
}

.timeline-node.visible {
    opacity: 1;
}

/* Node Marker Wrapper (positions on spine) */
.node-marker-wrapper {
    position: absolute;
    left: 50%;
    top: 24px;
    transform: translateX(-50%);
    z-index: 3;
}

/* Node Marker */
.node-marker {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid var(--node-accent, var(--accent-mauve));
    background: var(--bg-node-marker);
    display: flex;
    align-items: center;
    justify-content: center;
    transform: scale(0);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
}

.timeline-node.visible .node-marker {
    transform: scale(1);
    animation: nodePulse 2s infinite;
}

.node-marker:hover {
    transform: scale(1.15);
}

@keyframes nodePulse {
    0% { box-shadow: 0 0 0 0 rgba(197, 192, 216, 0.4); }
    70% { box-shadow: 0 0 0 8px rgba(197, 192, 216, 0); }
    100% { box-shadow: 0 0 0 0 rgba(197, 192, 216, 0); }
}

.node-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.14em;
    color: var(--node-accent, var(--accent-mauve));
    text-transform: uppercase;
}

/* Node Connector Line */
.node-connector {
    position: absolute;
    top: 35px;
    height: 1px;
    width: 0;
    background-color: var(--text-secondary);
    z-index: 1;
}

.timeline-node.visible .node-connector {
    transition: width 0.4s ease-out;
    width: 48px;
}

/* Left node connector */
.node-left .node-connector {
    right: 50%;
    margin-right: 12px;
    transform-origin: right;
}

/* Right node connector */
.node-right .node-connector {
    left: 50%;
    margin-left: 12px;
    transform-origin: left;
}

/* --- Node Cards --- */
.node-card {
    width: 42%;
    max-width: 520px;
    background: rgba(26, 26, 46, 0.94);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    padding: 32px;
    position: relative;
    z-index: 2;
}

/* Left-side cards: positioned left, connector edge on right */
.node-left .node-card {
    margin-right: auto;
    margin-left: 0;
    border-right: 1px solid rgba(197, 192, 216, 0.2);
    transform: translateX(-30px);
    opacity: 0;
    transition: transform 0.5s ease-out, opacity 0.5s ease-out;
}

.node-left.visible .node-card {
    transform: translateX(0);
    opacity: 1;
}

/* Right-side cards: positioned right, connector edge on left */
.node-right .node-card {
    margin-left: auto;
    margin-right: 0;
    border-left: 1px solid rgba(197, 192, 216, 0.2);
    transform: translateX(30px);
    opacity: 0;
    transition: transform 0.5s ease-out, opacity 0.5s ease-out;
}

.node-right.visible .node-card {
    transform: translateX(0);
    opacity: 1;
}

/* --- Card Inner Typography --- */
.node-timestamp {
    display: block;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--node-accent, var(--accent-mauve));
    margin-bottom: 16px;
}

.node-title {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: clamp(1.3rem, 3vw, 2rem);
    letter-spacing: 0.08em;
    color: var(--text-primary);
    margin-bottom: 20px;
    overflow: hidden;
    white-space: nowrap;
}

.node-title.typewriter-node {
    width: 0;
}

.timeline-node.visible .node-title.typewriter-node {
    animation: nodeTypewriter 0.6s steps(20) 0.3s forwards;
}

@keyframes nodeTypewriter {
    from { width: 0; }
    to { width: 100%; }
}

.node-body {
    color: var(--text-primary);
    margin-bottom: 0;
}

.node-body-secondary {
    color: var(--text-secondary);
    margin-top: 16px;
}

.node-divider {
    border: none;
    height: 1px;
    background-color: var(--spine-grid);
    margin: 20px 0;
}

/* --- Spine End Cap (Diamond) --- */
.spine-endcap {
    width: 12px;
    height: 12px;
    background-color: var(--accent-mauve);
    transform: rotate(45deg);
    margin: 0 auto;
    position: relative;
    z-index: 2;
}

/* --- Footer --- */
.site-footer {
    position: relative;
    z-index: 2;
    padding: 48px 24px;
    text-align: center;
    border-top: 1px solid var(--spine-grid);
}

.footer-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.footer-domain {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.footer-separator {
    color: var(--spine-grid);
}

.footer-tagline {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

/* ============================================
   Responsive: Mobile (< 768px)
   ============================================ */
@media (max-width: 768px) {

    /* Spine shifts to left edge */
    .timeline-spine {
        left: 24px;
        transform: none;
    }

    .timeline::before {
        left: 24px;
        transform: none;
    }

    /* All node markers shift to left */
    .node-marker-wrapper {
        left: 24px;
        transform: translateX(-50%);
    }

    /* All connectors go right from spine */
    .node-connector {
        left: 24px !important;
        right: auto !important;
        margin-left: 12px !important;
        margin-right: 0 !important;
        transform-origin: left !important;
    }

    /* All cards stack to the right */
    .node-card {
        width: calc(100% - 80px);
        max-width: none;
        margin-left: 72px !important;
        margin-right: 0 !important;
        border-left: 1px solid rgba(197, 192, 216, 0.2) !important;
        border-right: none !important;
    }

    .node-left .node-card,
    .node-right .node-card {
        transform: translateX(30px);
    }

    .node-left.visible .node-card,
    .node-right.visible .node-card {
        transform: translateX(0);
    }

    /* Hero adjustments */
    .hero-title {
        font-size: clamp(1.8rem, 8vw, 2.8rem);
    }

    .node-counter {
        top: 16px;
        right: 16px;
    }

    .node-card {
        padding: 24px;
    }

    .timeline-node {
        margin-bottom: 80px;
    }
}

/* ============================================
   Small mobile (< 480px)
   ============================================ */
@media (max-width: 480px) {
    .hero-title {
        font-size: clamp(1.5rem, 10vw, 2.2rem);
        letter-spacing: 0.15em;
    }

    .hero-tagline {
        font-size: 0.7rem;
        letter-spacing: 0.1em;
    }

    .node-card {
        padding: 20px;
        margin-left: 56px !important;
    }

    .node-title {
        font-size: clamp(1.1rem, 4vw, 1.5rem);
        white-space: normal;
    }
}
