/* ============================================
   CONCENGINE.COM — Abyssal Observation Interface
   ============================================ */

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

:root {
    --abyss: #040d14;
    --substrate: #061520;
    --grid-steel: #0b3d5b;
    --border-teal: #1a6b8a;
    --body-text: #8fb8cc;
    --heading-ice: #c8e6f0;
    --accent-teal: #2ee8c4;
    --alert-coral: #e84a2e;
    --substrate-92: rgba(6, 21, 32, 0.92);
    --substrate-85: rgba(6, 21, 32, 0.85);
    --substrate-70: rgba(6, 21, 32, 0.70);
    --code-bg: rgba(10, 31, 45, 0.6); /* #0a1f2d at 60% opacity */
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--abyss);
    color: var(--body-text);
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    font-size: 1.05rem;
    line-height: 1.72;
    overflow-x: hidden;
    position: relative;
    min-height: 100vh;
}

/* --- DEPTH PARTICLE CANVAS --- */
#depth-particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    pointer-events: none;
}

/* --- PERSISTENT 12-COLUMN GRID --- */
#grid-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
    pointer-events: none;
    display: flex;
}

.grid-line {
    height: 100%;
    border-right: 1px solid var(--grid-steel);
    opacity: 0;
    transition: opacity 0.3s ease;
    animation: gridPulse 4s ease-in-out infinite;
}

/* Non-uniform column widths: cols 1-3: 6%, cols 4-9: 10%, cols 10-12: 8%, + 1 final edge */
.grid-line[data-col="1"] { width: 6%; animation-delay: 0s; }
.grid-line[data-col="2"] { width: 6%; animation-delay: 0.33s; }
.grid-line[data-col="3"] { width: 6%; animation-delay: 0.66s; }
.grid-line[data-col="4"] { width: 10%; animation-delay: 1s; }
.grid-line[data-col="5"] { width: 10%; animation-delay: 1.33s; }
.grid-line[data-col="6"] { width: 10%; animation-delay: 1.66s; }
.grid-line[data-col="7"] { width: 10%; animation-delay: 2s; }
.grid-line[data-col="8"] { width: 10%; animation-delay: 2.33s; }
.grid-line[data-col="9"] { width: 10%; animation-delay: 2.66s; }
.grid-line[data-col="10"] { width: 8%; animation-delay: 3s; }
.grid-line[data-col="11"] { width: 8%; animation-delay: 3.33s; }
.grid-line[data-col="12"] { width: 8%; animation-delay: 3.66s; }
.grid-line[data-col="13"] { width: 0; }

.grid-line.active {
    opacity: 0;
}

.grid-line.sonar-highlight {
    opacity: 0.8 !important;
    transition: opacity 0.1s ease;
}

@keyframes gridPulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.6; }
}

/* Horizontal grid lines */
#hgrid-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
    pointer-events: none;
    background-image: repeating-linear-gradient(
        to bottom,
        transparent,
        transparent 119px,
        rgba(11, 61, 91, 0.15) 119px,
        rgba(11, 61, 91, 0.15) 120px
    );
}

/* --- SONAR RINGS --- */
#sonar-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 2;
    pointer-events: none;
    overflow: hidden;
}

.sonar-ring {
    position: absolute;
    border: 1px solid var(--accent-teal);
    border-radius: 50%;
    pointer-events: none;
    opacity: 0.6;
    transform: translate(-50%, -50%);
    animation: sonarExpand 1.5s ease-out forwards;
}

@keyframes sonarExpand {
    0% {
        width: 0;
        height: 0;
        opacity: 0.6;
    }
    100% {
        width: 400px;
        height: 400px;
        opacity: 0;
    }
}

/* --- SECTION: THE DESCENT (HERO) --- */
.section-descent {
    position: relative;
    z-index: 3;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-left: 12%;
    padding-right: 12%;
}

.title-assembly {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 2rem;
    flex-wrap: nowrap;
}

.title-frag {
    font-family: 'Playfair Display', serif;
    font-weight: 900;
    font-size: clamp(2.5rem, 6vw, 5.5rem);
    color: var(--heading-ice);
    letter-spacing: -0.02em;
    opacity: 0;
    display: inline-block;
}

.title-conc {
    transform: translateX(-60px) translateY(-12px);
}

.title-engine {
    transform: translateX(60px) translateY(20px);
}

.title-conc.animate-in {
    animation: slideConc 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.title-engine.animate-in {
    animation: slideEngine 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideConc {
    to {
        opacity: 1;
        transform: translateX(0) translateY(-12px);
    }
}

@keyframes slideEngine {
    to {
        opacity: 1;
        transform: translateX(0) translateY(20px);
    }
}

.title-link-line {
    width: 80px;
    height: 40px;
    flex-shrink: 0;
    opacity: 0;
}

.title-link-line.animate-in {
    opacity: 1;
}

.link-pulse {
    stroke-dasharray: 120;
    stroke-dashoffset: 120;
    animation: linkDraw 3s ease-in-out infinite;
}

@keyframes linkDraw {
    0% { stroke-dashoffset: 120; }
    40% { stroke-dashoffset: 0; }
    60% { stroke-dashoffset: 0; }
    100% { stroke-dashoffset: -120; }
}

.hero-subtitle {
    max-width: 700px;
}

.hero-line {
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 300;
    font-size: 1.1rem;
    line-height: 1.72;
    color: var(--body-text);
    opacity: 0;
    transform: translateY(8px);
    margin-bottom: 0.5rem;
}

.hero-line.animate-in {
    animation: lineReveal 0.5s ease-out forwards;
}

@keyframes lineReveal {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.nav-anchor {
    color: var(--heading-ice);
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: 0.95rem;
    text-decoration: underline;
    text-decoration-color: var(--border-teal);
    text-underline-offset: 3px;
    cursor: pointer;
    transition: color 0.3s, text-decoration-color 0.3s, text-shadow 0.3s;
}

.nav-anchor:hover {
    color: var(--accent-teal);
    text-decoration-color: var(--accent-teal);
    text-shadow: 0 0 12px rgba(46, 232, 196, 0.4);
}

/* --- SECTION: PROCESS VISUALIZATION ZONE --- */
.section-process {
    position: relative;
    z-index: 3;
    padding: 6rem 4% 6rem 4%;
    min-height: 100vh;
    display: grid;
    grid-template-columns: 6% 6% 6% 10% 10% 10% 10% 10% 10% 8% 8% 8%;
    grid-template-rows: auto auto;
    gap: 2rem 0;
}

.panel {
    background: var(--substrate-92);
    border: 1px solid var(--border-teal);
    padding: 2.5rem 2rem;
    position: relative;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.3s;
}

.panel-main {
    grid-column: 3 / 11;
    grid-row: 1 / 2;
    z-index: 4;
}

.panel-overlay {
    grid-column: 8 / 13;
    grid-row: 1 / 2;
    z-index: 5;
    margin-top: 4rem;
    align-self: start;
}

.panel-secondary {
    grid-column: 2 / 10;
    grid-row: 2 / 3;
    z-index: 4;
}

.panel.panel-hover {
    border-color: var(--accent-teal);
}

/* --- SECTION HEADINGS --- */
.section-heading {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: clamp(2rem, 4vw, 3.5rem);
    color: var(--heading-ice);
    letter-spacing: -0.02em;
    margin-bottom: 1.5rem;
    line-height: 1.2;
}

.panel-heading {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    color: var(--heading-ice);
    letter-spacing: -0.02em;
    margin-bottom: 1rem;
    line-height: 1.3;
}

/* --- BODY TEXT --- */
.body-text {
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    font-size: 1.05rem;
    line-height: 1.72;
    color: var(--body-text);
    margin-bottom: 1.2rem;
    max-width: 72ch;
}

.body-text.secondary {
    color: #5a8a9e;
    font-weight: 300;
}

/* --- CODE BLOCKS --- */
.code-block {
    background: var(--code-bg);
    border-left: 1px solid var(--border-teal);
    padding: 1.2rem 1.5rem;
    margin: 1.5rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.code-line {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 0.875rem;
    color: var(--accent-teal);
    line-height: 1.6;
    white-space: pre;
}

.code-kw {
    color: var(--heading-ice);
}

.code-type {
    color: var(--alert-coral);
}

.code-inline {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 0.875rem;
    color: var(--accent-teal);
    background: var(--code-bg);
    border-left: 1px solid var(--border-teal);
    padding: 0.15rem 0.5rem;
}

/* --- SVG THREAD DIAGRAMS --- */
.thread-diagram {
    width: 100%;
    max-width: 600px;
    height: auto;
    margin: 2rem 0;
    overflow: visible;
}

.thread-diagram-sm {
    max-width: 300px;
}

.thread-line {
    stroke: var(--border-teal);
    stroke-width: 1.5;
    fill: none;
}

.draw-line {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 1.5s ease;
}

.draw-line.animated {
    stroke-dashoffset: 0;
}

.waiting-line {
    stroke: var(--border-teal);
    stroke-width: 1.5;
    stroke-dasharray: 4 8;
    fill: none;
    animation: waitingFlow 2s linear infinite;
}

@keyframes waitingFlow {
    to {
        stroke-dashoffset: -24;
    }
}

.fork-point {
    fill: var(--accent-teal);
    r: 4;
    transform: scale(0);
    transform-origin: center;
    transform-box: fill-box;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.fork-point.animated {
    transform: scale(1);
}

.join-point {
    fill: var(--heading-ice);
    width: 8px;
    height: 8px;
    transform: rotate(0deg) scale(0);
    transform-origin: center;
    transform-box: fill-box;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.join-point.animated {
    transform: rotate(45deg) scale(1);
}

.conflict-x {
    opacity: 0;
    transition: opacity 0.1s;
}

.conflict-x.animated {
    animation: conflictFlash 0.6s ease forwards;
}

@keyframes conflictFlash {
    0% { opacity: 1; }
    25% { opacity: 0; }
    50% { opacity: 1; }
    75% { opacity: 0; }
    100% { opacity: 1; }
}

.diagram-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    fill: var(--body-text);
    font-weight: 400;
}

.conflict-label {
    fill: var(--alert-coral);
}

/* --- TIMELINE AXIS --- */
.timeline-axis {
    stroke: var(--border-teal);
    stroke-width: 2;
}

.tick {
    stroke: var(--body-text);
    stroke-width: 1;
}

/* --- SECTION: THREAD TIMELINE --- */
.section-timeline {
    position: relative;
    z-index: 3;
    padding: 6rem 4% 4rem 4%;
    min-height: 50vh;
}

.timeline-heading {
    margin-bottom: 2rem;
    padding-left: 12%;
}

.timeline-container {
    width: 100%;
    overflow: hidden;
    padding: 1rem 0;
}

.timeline-svg {
    width: 100%;
    height: auto;
    min-height: 200px;
}

/* --- SECTION: DEEP ZONE --- */
.section-deep {
    position: relative;
    z-index: 3;
    padding: 8rem 4% 12rem 4%;
    min-height: 100vh;
    display: grid;
    grid-template-columns: 6% 6% 6% 10% 10% 10% 10% 10% 10% 8% 8% 8%;
    grid-template-rows: auto;
    gap: 6rem 0;
}

.deep-node {
    background: var(--substrate-92);
    border: 1px solid var(--grid-steel);
    padding: 2.5rem 2rem;
    transition: border-color 0.3s;
}

.deep-node-1 {
    grid-column: 4 / 10;
}

.deep-node-2 {
    grid-column: 2 / 8;
}

.deep-node-3 {
    grid-column: 5 / 12;
}

.deep-node-4 {
    grid-column: 3 / 9;
}

.deep-node-5 {
    grid-column: 4 / 11;
    background: transparent;
    border: none;
    text-align: center;
    padding: 4rem 2rem;
}

.deep-node-5 .body-text {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: 1.3rem;
    color: #5a8a9e;
    font-style: italic;
    max-width: none;
}

/* --- RESPONSIVE --- */
@media (max-width: 900px) {
    .section-process {
        display: flex;
        flex-direction: column;
        padding: 4rem 6%;
        gap: 2rem;
    }

    .panel-overlay {
        margin-top: 0;
    }

    .section-deep {
        display: flex;
        flex-direction: column;
        padding: 4rem 6%;
        gap: 3rem;
    }

    .section-descent {
        padding-left: 6%;
        padding-right: 6%;
    }

    .title-assembly {
        flex-wrap: wrap;
    }

    .title-link-line {
        display: none;
    }

    .timeline-heading {
        padding-left: 0;
    }
}

@media (max-width: 600px) {
    .title-frag {
        font-size: clamp(2rem, 10vw, 3rem);
    }

    .section-heading {
        font-size: clamp(1.5rem, 5vw, 2.5rem);
    }

    .thread-diagram {
        max-width: 100%;
    }
}
