/* ============================================
   completengine.com — Seapunk Meditation Terminal
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --abyss-black: #0B1622;
    --trench-navy: #132238;
    --sonar-teal: #00CED1;
    --biolume-aqua: #7FFFD4;
    --ghost-cyan: #E0FFFF;
    --steel-mist: #B0C4DE;
    --deep-violet: #2A1B3D;
    --coral-signal: #CD8B76;
    --electric-green: #00FF7F;
    --electric-cyan: #00FFFF;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--abyss-black);
    color: var(--steel-mist);
    font-family: 'Kalam', cursive;
    font-weight: 300;
    overflow-x: hidden;
    min-height: 100vh;
}

/* --- Typography --- */
.display-font {
    font-family: 'Caveat', cursive;
    font-weight: 700;
    font-size: clamp(1.8rem, 4vw, 3.2rem);
    letter-spacing: 0.02em;
    line-height: 1.2;
    color: var(--biolume-aqua);
}

.body-font {
    font-family: 'Kalam', cursive;
    font-weight: 300;
    font-size: clamp(0.95rem, 1.8vw, 1.15rem);
    line-height: 1.75;
    letter-spacing: 0.01em;
    color: var(--steel-mist);
    opacity: 0.85;
}

.hud-font {
    font-family: 'Special Elite', cursive;
    font-weight: 400;
    font-size: clamp(0.7rem, 1.2vw, 0.9rem);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--sonar-teal);
}

/* --- Particle Canvas --- */
#particle-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

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

#spine-line {
    width: 1px;
    height: 0%;
    background: var(--sonar-teal);
    box-shadow: 0 0 8px var(--sonar-teal), 0 0 20px var(--sonar-teal);
    transition: height 0.1s linear;
    opacity: 0;
}

#spine-line.active {
    opacity: 1;
}

/* --- Depth Gauge --- */
#depth-gauge {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 90px;
    height: 90px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 1s ease;
}

#depth-gauge.visible {
    opacity: 1;
}

.gauge-svg {
    width: 80px;
    height: 80px;
}

.gauge-track {
    fill: none;
    stroke: var(--sonar-teal);
    stroke-width: 1;
    opacity: 0.2;
}

.gauge-fill {
    fill: none;
    stroke: var(--sonar-teal);
    stroke-width: 2;
    stroke-dasharray: 263.89;
    stroke-dashoffset: 263.89;
    stroke-linecap: round;
    transform: rotate(-90deg);
    transform-origin: 50% 50%;
    filter: drop-shadow(0 0 4px var(--sonar-teal));
}

.gauge-needle {
    stroke: var(--biolume-aqua);
    stroke-width: 1.5;
    stroke-linecap: round;
    transform-origin: 50px 50px;
    filter: drop-shadow(0 0 3px var(--biolume-aqua));
}

#depth-text {
    margin-top: 4px;
    font-size: 0.65rem;
    text-align: center;
    text-shadow: 0 0 6px var(--sonar-teal);
}

/* --- Bioluminescence Pulse Animation --- */
@keyframes biolume-pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* --- HUD Reticle --- */
.hud-reticle {
    pointer-events: none;
}

.opening-reticle {
    width: clamp(200px, 40vw, 350px);
    height: clamp(200px, 40vw, 350px);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 1.5s ease;
}

.opening-reticle.visible {
    opacity: 1;
}

.reticle-ring {
    fill: none;
    stroke: var(--sonar-teal);
    stroke-width: 0.5;
    stroke-dasharray: 12 6;
}

.reticle-ring-1 {
    opacity: 0.3;
    animation: spin-slow 120s linear infinite;
}

.reticle-ring-2 {
    opacity: 0.25;
    animation: spin-medium 200s linear infinite reverse;
}

.reticle-ring-3 {
    opacity: 0.2;
    animation: spin-fast 600s linear infinite;
}

@keyframes spin-slow {
    from { transform: rotate(0deg); transform-origin: 150px 150px; }
    to { transform: rotate(360deg); transform-origin: 150px 150px; }
}

@keyframes spin-medium {
    from { transform: rotate(0deg); transform-origin: 150px 150px; }
    to { transform: rotate(360deg); transform-origin: 150px 150px; }
}

@keyframes spin-fast {
    from { transform: rotate(0deg); transform-origin: 150px 150px; }
    to { transform: rotate(360deg); transform-origin: 150px 150px; }
}

/* --- Full Sections --- */
.full-section {
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
}

/* --- Opening Void --- */
#opening-void {
    background: var(--abyss-black);
}

.opening-content {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    z-index: 5;
}

#site-title {
    font-size: clamp(2rem, 5vw, 3.5rem);
    color: var(--biolume-aqua);
    text-shadow: 0 0 8px var(--biolume-aqua), 0 0 20px var(--biolume-aqua), 0 0 40px rgba(127, 255, 212, 0.3);
    min-height: 1.2em;
    position: relative;
    z-index: 6;
}

.typewriter-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: var(--biolume-aqua);
    animation: cursor-blink 1s step-end infinite;
    vertical-align: middle;
    margin-left: 2px;
    opacity: 0;
    position: absolute;
}

#title-cursor {
    top: 50%;
    transform: translateY(-50%);
    right: -8px;
}

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

/* --- Timeline Sections --- */
.timeline-section {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

/* --- Spine Nodes --- */
.spine-node {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    z-index: 10;
}

.node-reticle {
    width: 60px;
    height: 60px;
}

.node-ring {
    fill: none;
    stroke: var(--sonar-teal);
    stroke-width: 1;
    stroke-dasharray: 4 3;
    opacity: 0.3;
    transition: opacity 0.6s ease, stroke 0.6s ease;
}

.node-ring-outer {
    animation: node-spin-1 30s linear infinite;
}

.node-ring-mid {
    animation: node-spin-2 20s linear infinite reverse;
}

.node-ring-inner {
    animation: node-spin-3 15s linear infinite;
}

@keyframes node-spin-1 {
    from { transform: rotate(0deg); transform-origin: 30px 30px; }
    to { transform: rotate(360deg); transform-origin: 30px 30px; }
}

@keyframes node-spin-2 {
    from { transform: rotate(0deg); transform-origin: 30px 30px; }
    to { transform: rotate(360deg); transform-origin: 30px 30px; }
}

@keyframes node-spin-3 {
    from { transform: rotate(0deg); transform-origin: 30px 30px; }
    to { transform: rotate(360deg); transform-origin: 30px 30px; }
}

.spine-node.active .node-ring {
    stroke: var(--biolume-aqua);
    opacity: 0.8;
    filter: drop-shadow(0 0 6px var(--electric-green));
}

.spine-node.active .node-ring-inner {
    stroke: var(--electric-cyan);
    opacity: 0.6;
}

/* --- Sonar Ping --- */
.sonar-ping {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 240px;
    height: 240px;
    pointer-events: none;
    z-index: 9;
}

.ping-ring {
    fill: none;
    stroke: var(--sonar-teal);
    stroke-width: 1;
    opacity: 0;
}

.spine-node.active .ping-ring.ping-1 {
    animation: sonar-expand 1.5s ease-out 0s forwards;
}

.spine-node.active .ping-ring.ping-2 {
    animation: sonar-expand 1.5s ease-out 0.3s forwards;
}

.spine-node.active .ping-ring.ping-3 {
    animation: sonar-expand 1.5s ease-out 0.6s forwards;
}

@keyframes sonar-expand {
    0% {
        r: 0;
        opacity: 0.4;
        stroke-width: 2;
    }
    100% {
        r: 120;
        opacity: 0;
        stroke-width: 0.5;
    }
}

/* --- Connector Lines --- */
.connector-line {
    position: absolute;
    top: 50%;
    height: 1px;
    background: var(--steel-mist);
    opacity: 0;
    z-index: 5;
    transform: scaleX(0);
    transition: transform 0.6s ease-out 0.3s, opacity 0.4s ease;
    box-shadow: 0 0 4px var(--sonar-teal);
}

.connector-left {
    left: calc(50% - 5% - 45%);
    width: calc(5% + 45% - 30px);
    right: auto;
    transform-origin: right center;
}

.connector-right {
    left: calc(50% + 30px);
    width: calc(5% + 45% - 30px);
    transform-origin: left center;
}

.timeline-section.in-view .connector-line {
    opacity: 0.3;
    transform: scaleX(1);
}

/* --- Timeline Panels --- */
.timeline-panel {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 45%;
    max-width: 520px;
    padding: 32px 28px;
    background: rgba(19, 34, 56, 0.7);
    border: 1px solid rgba(0, 206, 209, 0.3);
    border-radius: 6px;
    box-shadow: 0 0 12px rgba(0, 206, 209, 0.08);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.4s ease-out 0.5s, transform 0.4s ease-out 0.5s;
    z-index: 5;
}

.panel-left {
    right: calc(50% + 5%);
    transform: translateY(-50%) translateX(-30px);
}

.panel-right {
    left: calc(50% + 5%);
    transform: translateY(-50%) translateX(30px);
}

.timeline-section.in-view .panel-left {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

.timeline-section.in-view .panel-right {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

.panel-label {
    display: block;
    margin-bottom: 12px;
    opacity: 0.7;
}

.panel-heading {
    margin-bottom: 16px;
    color: var(--biolume-aqua);
    text-shadow: 0 0 8px rgba(127, 255, 212, 0.4);
    font-size: clamp(1.5rem, 3vw, 2.4rem);
}

.panel-body {
    opacity: 0;
    transition: opacity 0.6s ease 0.2s;
}

.timeline-section.in-view .panel-body {
    opacity: 0.85;
}

/* --- Coral Accent --- */
.coral-accent {
    color: var(--coral-signal);
    text-shadow: 0 0 6px rgba(205, 139, 118, 0.4);
}

/* --- Deep Zone --- */
#deep-zone {
    background: radial-gradient(ellipse at center, var(--trench-navy) 0%, var(--abyss-black) 70%);
    position: relative;
    overflow: hidden;
}

#deep-zone::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, rgba(19, 34, 56, 0.5) 0%, rgba(11, 22, 34, 0) 60%);
    animation: deep-breathe 8s ease-in-out infinite;
    pointer-events: none;
}

@keyframes deep-breathe {
    0%, 100% { transform: translate(-50%, -50%) scale(0.8); opacity: 0.4; }
    50% { transform: translate(-50%, -50%) scale(1.3); opacity: 0.7; }
}

.deep-zone-content {
    position: relative;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    max-width: 600px;
    padding: 0 20px;
}

.deep-reticle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: clamp(300px, 60vw, 600px);
    height: clamp(300px, 60vw, 600px);
    pointer-events: none;
    z-index: 4;
}

.deep-ring {
    fill: none;
    stroke: var(--sonar-teal);
    stroke-width: 0.5;
    stroke-dasharray: 8 4;
    opacity: 0;
}

#deep-zone.in-view .deep-ring-1 {
    animation: deep-expand 2s ease-out 0s forwards, spin-slow 90s linear infinite;
}

#deep-zone.in-view .deep-ring-2 {
    animation: deep-expand 2s ease-out 0.5s forwards, spin-medium 120s linear infinite reverse;
}

#deep-zone.in-view .deep-ring-3 {
    animation: deep-expand 2s ease-out 1s forwards, spin-fast 200s linear infinite;
}

#deep-zone.in-view .deep-ring-4 {
    animation: deep-expand 2s ease-out 1.5s forwards, spin-slow 150s linear infinite reverse;
}

#deep-zone.in-view .deep-ring-5 {
    animation: deep-expand 2s ease-out 2s forwards, spin-medium 180s linear infinite;
}

@keyframes deep-expand {
    0% { opacity: 0; stroke-width: 2; }
    50% { opacity: 0.3; }
    100% { opacity: 0.15; stroke-width: 0.5; }
}

#deep-message {
    font-size: clamp(1.4rem, 3.5vw, 2.6rem);
    color: var(--ghost-cyan);
    text-shadow: 0 0 10px rgba(224, 255, 255, 0.4), 0 0 30px rgba(0, 206, 209, 0.2);
    min-height: 1.5em;
    position: relative;
    z-index: 6;
}

#deep-cursor {
    display: inline;
    position: relative;
}

/* --- Waveform Border Effect (subtle sine-wave via SVG background) --- */
.timeline-panel::before {
    content: '';
    position: absolute;
    top: -1px;
    left: -1px;
    right: -1px;
    bottom: -1px;
    border-radius: 7px;
    background:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 4px,
            rgba(0, 206, 209, 0.06) 4px,
            rgba(0, 206, 209, 0.06) 5px
        );
    pointer-events: none;
    opacity: 0.3;
    animation: wave-shift 6s ease-in-out infinite;
}

@keyframes wave-shift {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(2px); }
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .typewriter-cursor {
        animation: none;
        opacity: 1;
    }

    #spine-line {
        transition: none;
    }

    .reticle-ring,
    .node-ring,
    .deep-ring {
        animation: none !important;
        opacity: 0.2;
    }

    .spine-node.active .node-ring {
        opacity: 0.6;
    }

    .ping-ring {
        animation: none !important;
    }
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .timeline-panel {
        width: 80%;
        max-width: none;
    }

    .panel-left {
        right: auto;
        left: 10%;
        transform: translateY(-50%) translateX(-20px);
    }

    .panel-right {
        left: 10%;
        transform: translateY(-50%) translateX(20px);
    }

    .timeline-section.in-view .panel-left,
    .timeline-section.in-view .panel-right {
        transform: translateY(-50%) translateX(0);
    }

    .connector-line {
        display: none;
    }

    .spine-node {
        left: 10%;
    }

    #sonar-spine {
        left: 10%;
    }

    #depth-gauge {
        bottom: 12px;
        right: 12px;
        width: 70px;
        height: 70px;
    }

    .gauge-svg {
        width: 60px;
        height: 60px;
    }

    #depth-text {
        font-size: 0.55rem;
    }
}

@media (max-width: 480px) {
    .timeline-panel {
        width: 85%;
        left: 7.5% !important;
        right: auto !important;
        padding: 20px 16px;
    }

    .panel-heading {
        font-size: clamp(1.2rem, 5vw, 1.8rem);
    }

    #site-title {
        font-size: clamp(1.6rem, 7vw, 2.5rem);
    }
}
