/* ================================================
   continua.club - Coastal Terminal Timeline
   ================================================ */

:root {
    --abyssal-ink: #0B1A1E;
    --kelp-shadow: #132B30;
    --sea-glass: #7FBFB5;
    --deep-tidal: #4A8B80;
    --driftwood-white: #E8F0ED;
    --sea-mist: #B8CCC6;
    --coastal-amber: #D4A574;
    --signal-blue: #5B9BD5;
    --spine-opacity: 0.4;
    --scan-line-opacity: 0.03;
    --node-spacing: 40vh;
    --glow-spread: 8px;
}

/* ================================================
   Reset & Base
   ================================================ */

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

html {
    scroll-snap-type: y proximity;
    scroll-behavior: smooth;
}

body {
    background-color: var(--abyssal-ink);
    color: var(--driftwood-white);
    font-family: 'Lato', sans-serif;
    font-weight: 300;
    font-size: 17px;
    line-height: 1.85;
    letter-spacing: 0.01em;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ================================================
   CRT Scan Line Overlay
   ================================================ */

.crt-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 1000;
    opacity: 0;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 2px,
        rgba(127, 191, 181, var(--scan-line-opacity)) 2px,
        rgba(127, 191, 181, var(--scan-line-opacity)) 4px
    );
    transition: opacity 400ms ease-in;
}

.crt-overlay.visible {
    opacity: 1;
}

/* ================================================
   Signal Noise Bar
   ================================================ */

#noise-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999;
}

.noise-bar {
    position: absolute;
    left: 0;
    width: 100vw;
    height: 4px;
    background: repeating-linear-gradient(
        to right,
        transparent 0px,
        rgba(127, 191, 181, 0.4) 1px,
        transparent 2px,
        rgba(127, 191, 181, 0.3) 3px,
        transparent 4px,
        rgba(127, 191, 181, 0.5) 5px,
        transparent 7px
    );
    opacity: 0;
    animation: noise-flash 150ms linear forwards;
}

@keyframes noise-flash {
    0% { opacity: 1; }
    80% { opacity: 1; }
    100% { opacity: 0; }
}

/* ================================================
   Delaunay Background Mesh
   ================================================ */

.background-mesh {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.background-mesh svg {
    width: 100%;
    height: 300%;
    position: absolute;
    top: -50%;
    left: 0;
}

.mesh-group {
    animation: mesh-drift 120s ease-in-out infinite;
}

@keyframes mesh-drift {
    0% { transform: translate(0, 0); }
    25% { transform: translate(15px, -25px); }
    50% { transform: translate(-10px, -50px); }
    75% { transform: translate(20px, -20px); }
    100% { transform: translate(0, 0); }
}

/* ================================================
   Timeline Spine
   ================================================ */

.timeline-spine {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 10px;
    height: 100%;
    z-index: 2;
    pointer-events: none;
    overflow: visible;
}

.spine-path {
    opacity: var(--spine-opacity);
    stroke-dasharray: 99999;
    stroke-dashoffset: 99999;
    transition: none;
}

.spine-path.drawn {
    animation: draw-spine 1200ms ease-out forwards;
}

@keyframes draw-spine {
    to {
        stroke-dashoffset: 0;
    }
}

/* ================================================
   Timeline Container
   ================================================ */

.timeline-container {
    position: relative;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 40px;
    z-index: 5;
}

/* ================================================
   Cursor Prompt
   ================================================ */

.cursor-prompt {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    scroll-snap-align: start;
}

.cursor-char {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 24px;
    color: var(--sea-glass);
    text-shadow: 0 0 var(--glow-spread) rgba(127, 191, 181, 0.3);
    opacity: 0;
}

.cursor-char.blinking {
    animation: cursor-blink 1s step-end infinite;
}

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

.bottom-cursor {
    height: 60vh;
}

/* ================================================
   Timeline Nodes
   ================================================ */

.timeline-node {
    position: relative;
    display: flex;
    align-items: flex-start;
    min-height: 80vh;
    padding-top: 10vh;
    padding-bottom: 10vh;
    margin-bottom: var(--node-spacing);
    scroll-snap-align: start;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 600ms ease-out, transform 600ms ease-out;
}

.timeline-node.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Node positioning - Left nodes */
.node-left {
    justify-content: flex-start;
    padding-right: calc(50% + 60px);
}

.node-left .connector {
    position: absolute;
    right: calc(50% - 4px);
    top: calc(10vh + 30px);
    display: flex;
    align-items: center;
    flex-direction: row-reverse;
}

.node-left .connector-line {
    width: 50px;
    height: 1px;
    background: var(--sea-glass);
    opacity: var(--spine-opacity);
    transform-origin: right center;
    transform: scaleX(0);
    transition: transform 400ms ease-out 200ms;
}

.node-left.visible .connector-line {
    transform: scaleX(1);
}

/* Node positioning - Right nodes */
.node-right {
    justify-content: flex-end;
    padding-left: calc(50% + 60px);
}

.node-right .connector {
    position: absolute;
    left: calc(50% - 4px);
    top: calc(10vh + 30px);
    display: flex;
    align-items: center;
}

.node-right .connector-line {
    width: 50px;
    height: 1px;
    background: var(--sea-glass);
    opacity: var(--spine-opacity);
    transform-origin: left center;
    transform: scaleX(0);
    transition: transform 400ms ease-out 200ms;
}

.node-right.visible .connector-line {
    transform: scaleX(1);
}

/* Connector Dot */
.connector-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--sea-glass);
    opacity: 0;
    transform: scale(0);
    transition: opacity 200ms ease-out, transform 200ms ease-out;
    flex-shrink: 0;
}

.timeline-node.visible .connector-dot {
    opacity: 0.8;
    transform: scale(1);
}

/* Sonar Arcs */
.sonar-arcs {
    position: absolute;
    width: 200px;
    height: 200px;
    pointer-events: none;
    z-index: 1;
}

.node-left .sonar-arcs {
    right: calc(50% - 104px);
    top: calc(10vh - 66px);
}

.node-right .sonar-arcs {
    left: calc(50% - 104px);
    top: calc(10vh - 66px);
}

.sonar-ring {
    opacity: 0;
}

.timeline-node.visible .sonar-ring:nth-child(1) {
    animation: sonar-pulse 800ms ease-out 100ms forwards;
}

.timeline-node.visible .sonar-ring:nth-child(2) {
    animation: sonar-pulse 800ms ease-out 250ms forwards;
}

.timeline-node.visible .sonar-ring:nth-child(3) {
    animation: sonar-pulse 800ms ease-out 400ms forwards;
}

@keyframes sonar-pulse {
    0% {
        r: 10;
        opacity: 0.15;
    }
    100% {
        r: 80;
        opacity: 0;
    }
}

/* ================================================
   Node Content
   ================================================ */

.node-content {
    background: var(--kelp-shadow);
    border: 1px solid rgba(74, 139, 128, 0.3);
    border-radius: 3px;
    padding: 40px 48px;
    max-width: 560px;
    width: 100%;
    position: relative;
}

.timestamp {
    display: block;
    margin-bottom: 16px;
    font-size: 11px;
    letter-spacing: 0.05em;
    color: var(--deep-tidal);
}

.node-heading {
    font-family: 'Playfair Display', serif;
    font-weight: 900;
    font-size: clamp(2.5rem, 6vw, 5rem);
    letter-spacing: -0.02em;
    line-height: 1.05;
    color: var(--driftwood-white);
    margin-bottom: 24px;
}

.node-body {
    font-family: 'Lato', sans-serif;
    font-weight: 300;
    font-size: 17px;
    line-height: 1.85;
    letter-spacing: 0.01em;
    color: var(--sea-mist);
    margin-bottom: 32px;
}

/* ================================================
   Readout Block
   ================================================ */

.readout {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 24px;
    padding-top: 20px;
    border-top: 1px solid rgba(74, 139, 128, 0.2);
}

.readout .system-text {
    font-size: 12px;
    color: var(--sea-glass);
    opacity: 0.8;
}

/* ================================================
   System Text (Monospace)
   ================================================ */

.system-text {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    letter-spacing: 0.05em;
    line-height: 1.6;
    color: var(--sea-glass);
    text-shadow: 0 0 var(--glow-spread) rgba(127, 191, 181, 0.3);
}

/* ================================================
   Chromatic Shift Glitch
   ================================================ */

.timeline-node.chromatic-shift .node-heading {
    animation: chromatic-glitch 300ms ease-out forwards;
}

@keyframes chromatic-glitch {
    0% {
        text-shadow:
            -2px 0 rgba(212, 165, 116, 0.4),
            2px 0 rgba(91, 155, 213, 0.4);
    }
    50% {
        text-shadow:
            -1px 0 rgba(212, 165, 116, 0.3),
            1px 0 rgba(91, 155, 213, 0.3);
    }
    100% {
        text-shadow: none;
    }
}

/* ================================================
   Text Flicker
   ================================================ */

.system-text.flickering {
    animation: text-flicker 50ms linear forwards;
}

@keyframes text-flicker {
    0% { opacity: 0.6; }
    100% { opacity: 0.6; }
}

/* ================================================
   Waveform Dividers
   ================================================ */

.waveform-divider {
    position: relative;
    width: 100%;
    height: 80px;
    margin: 0 auto;
    z-index: 3;
    pointer-events: none;
}

.waveform-divider svg {
    width: 100%;
    height: 100%;
}

/* ================================================
   Depth Contours
   ================================================ */

.depth-contours {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.contour {
    position: absolute;
    width: 300px;
    height: 220px;
}

.contour-1 {
    top: 15%;
    right: 8%;
    animation: contour-float-1 90s ease-in-out infinite;
}

.contour-2 {
    top: 40%;
    left: 5%;
    animation: contour-float-2 110s ease-in-out infinite;
}

.contour-3 {
    top: 65%;
    right: 12%;
    animation: contour-float-3 100s ease-in-out infinite;
}

.contour-4 {
    top: 85%;
    left: 10%;
    animation: contour-float-4 95s ease-in-out infinite;
}

@keyframes contour-float-1 {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    33% { transform: translate(10px, -15px) rotate(2deg); }
    66% { transform: translate(-8px, 10px) rotate(-1deg); }
}

@keyframes contour-float-2 {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    33% { transform: translate(-12px, 8px) rotate(-2deg); }
    66% { transform: translate(6px, -12px) rotate(1.5deg); }
}

@keyframes contour-float-3 {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    33% { transform: translate(8px, 12px) rotate(1.5deg); }
    66% { transform: translate(-10px, -8px) rotate(-2deg); }
}

@keyframes contour-float-4 {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    33% { transform: translate(-6px, -10px) rotate(-1deg); }
    66% { transform: translate(12px, 6px) rotate(2deg); }
}

/* ================================================
   Opening Animation States
   ================================================ */

body.loading .timeline-container {
    opacity: 0;
}

body.loading .crt-overlay {
    opacity: 0;
}

/* ================================================
   Responsive - Mobile (<768px)
   ================================================ */

@media (max-width: 768px) {
    .timeline-spine {
        left: 15%;
        transform: translateX(-50%);
    }

    .node-left,
    .node-right {
        justify-content: flex-end;
        padding-left: calc(15% + 50px);
        padding-right: 20px;
    }

    .node-left .connector,
    .node-right .connector {
        left: calc(15% - 4px);
        right: auto;
        flex-direction: row;
    }

    .node-left .connector-line,
    .node-right .connector-line {
        width: 40px;
        transform-origin: left center;
    }

    .node-left .sonar-arcs,
    .node-right .sonar-arcs {
        left: calc(15% - 104px);
        right: auto;
    }

    .node-content {
        padding: 28px 32px;
        max-width: none;
    }

    .node-heading {
        font-size: clamp(2rem, 8vw, 3.5rem);
    }

    .timeline-container {
        padding: 0 16px;
    }

    .contour {
        width: 200px;
        height: 150px;
    }
}

@media (max-width: 480px) {
    .node-left,
    .node-right {
        padding-left: calc(15% + 35px);
        padding-right: 12px;
    }

    .node-content {
        padding: 20px 24px;
    }

    .node-heading {
        font-size: clamp(1.8rem, 10vw, 3rem);
    }

    .node-body {
        font-size: 15px;
    }

    .readout {
        gap: 6px 16px;
    }

    .readout .system-text {
        font-size: 11px;
    }
}
