/* ===========================================
   algoha.com — Archaeological Excavation Theme
   Warm Glitch | Terracotta + Neon
   =========================================== */

/* Typography: "Space Mono" (Google Fonts) for display,
   "IBM Plex Mono" (Google Fonts) for body.
   IntersectionObserver with simple class toggles for scroll reveals.
   Scan-line overlay begins at (opacity 0.02), gains intensity as
   the central timeline spine fades in from bottom. The domain.
   reads metadata labels describing each stratum. */

/* --- CSS Custom Properties --- */
:root {
    --bleached-sand: #FDF0E2;
    --sun-clay: #F2D5B8;
    --warm-terracotta: #D4956B;
    --amber-glow: #F5A462;
    --primary-terracotta: #D4603A;
    --deep-earth: #8B4A2B;
    --core-earth: #3D1F12;
    --neon-aqua: #00F5D4;
    --neon-coral: #FF6B6B;
    --neon-violet: #BF5AF2;
}

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 16px;
    line-height: 1.7;
    letter-spacing: 0.02em;
    color: var(--core-earth);
    background: var(--bleached-sand);
    overflow-x: hidden;
    position: relative;
}

/* --- Scan Line Overlay --- */
#scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    background: repeating-linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0.03) 0px,
        rgba(0, 0, 0, 0.03) 1px,
        transparent 1px,
        transparent 2px
    );
    opacity: 0.02;
    transition: opacity 0.3s;
}

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

.spine-line {
    width: 100%;
    height: 100%;
    background: var(--primary-terracotta);
    transition: background-color 0.6s ease;
}

.spine-line.spine-glow {
    background: var(--neon-aqua);
    box-shadow: 0 0 8px var(--neon-aqua), 0 0 16px var(--neon-aqua);
}

/* --- Stratum Navigation --- */
#stratum-nav {
    position: fixed;
    bottom: 32px;
    right: 32px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 500;
}

.nav-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--primary-terracotta);
    background: transparent;
    cursor: pointer;
    transition: background-color 0.4s ease, border-color 0.4s ease, box-shadow 0.4s ease;
}

.nav-dot.active {
    background: var(--amber-glow);
    border-color: var(--amber-glow);
}

.nav-dot.deep-active {
    background: var(--neon-aqua);
    border-color: var(--neon-aqua);
    box-shadow: 0 0 6px var(--neon-aqua);
}

/* --- Stratum Sections --- */
.stratum {
    min-height: 100vh;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.stratum-0 { background: var(--bleached-sand); }
.stratum-1 { background: var(--sun-clay); }
.stratum-2 { background: var(--warm-terracotta); }
.stratum-3 { background: var(--deep-earth); }
.stratum-4 { background: var(--core-earth); }

/* Gradient transition zones between strata */
.stratum-0::after,
.stratum-1::after,
.stratum-2::after,
.stratum-3::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 120px;
    pointer-events: none;
    z-index: 2;
}

.stratum-0::after {
    background: linear-gradient(to bottom, transparent, var(--sun-clay));
}
.stratum-1::after {
    background: linear-gradient(to bottom, transparent, var(--warm-terracotta));
}
.stratum-2::after {
    background: linear-gradient(to bottom, transparent, var(--deep-earth));
}
.stratum-3::after {
    background: linear-gradient(to bottom, transparent, var(--core-earth));
}

/* --- Stratum Label Lines --- */
.stratum-label-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 1px;
    border-top: 1px dashed var(--primary-terracotta);
    opacity: 0.4;
    z-index: 10;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.stratum-label {
    font-family: 'Space Mono', monospace;
    font-size: 12px;
    font-weight: 400;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--primary-terracotta);
    background: inherit;
    padding: 4px 12px;
    position: relative;
    top: -10px;
}

.stratum-0 .stratum-label { background: var(--bleached-sand); }
.stratum-1 .stratum-label { background: var(--sun-clay); }
.stratum-2 .stratum-label { background: var(--warm-terracotta); color: var(--bleached-sand); }
.stratum-3 .stratum-label { background: var(--deep-earth); color: var(--amber-glow); }
.stratum-4 .stratum-label { background: var(--core-earth); color: var(--neon-aqua); }

/* --- Stratum 0: Hero --- */
.stratum-0-content {
    text-align: center;
    position: relative;
    z-index: 10;
}

.hero-title {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: 56px;
    letter-spacing: 0.06em;
    line-height: 1.1;
    text-transform: uppercase;
    color: var(--core-earth);
    text-shadow: 2px 2px 0px var(--primary-terracotta);
    margin-bottom: 24px;
}

.hero-title .letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.hero-title .letter.visible {
    opacity: 1;
    transform: translateY(0);
}

.hero-subtitle {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 16px;
    font-weight: 400;
    color: var(--deep-earth);
    opacity: 0;
    transition: opacity 0.8s ease 0.6s;
}

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

/* --- Content Blocks --- */
.stratum-content {
    width: 100%;
    max-width: 960px;
    position: relative;
    z-index: 10;
    padding: 60px 20px;
}

.content-block {
    max-width: 420px;
    padding: 32px;
    position: relative;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.15);
    margin-bottom: 60px;
}

.block-left {
    margin-right: auto;
    margin-left: 0;
}

.block-right {
    margin-left: auto;
    margin-right: 0;
}

/* Corner Glyphs */
.corner-glyph {
    position: absolute;
    top: -8px;
    left: -8px;
    font-size: 16px;
    color: var(--primary-terracotta);
    transform: rotate(45deg);
    opacity: 0.7;
    line-height: 1;
}

/* Block Titles */
.block-title {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: 20px;
    letter-spacing: 0.06em;
    line-height: 1.1;
    text-transform: uppercase;
    margin-bottom: 16px;
    text-shadow: 2px 2px 0px var(--primary-terracotta);
}

.block-text {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 16px;
    font-weight: 400;
    line-height: 1.7;
    letter-spacing: 0.02em;
    margin-bottom: 12px;
}

.block-text:last-of-type {
    margin-bottom: 0;
}

/* --- Stratum 1 Block Styles --- */
.stratum-1 .content-block {
    border: 1px solid var(--primary-terracotta);
    background: rgba(253, 240, 226, 0.3);
}

.stratum-1 .block-title {
    color: var(--core-earth);
}

.stratum-1 .block-text {
    color: var(--core-earth);
}

/* --- Stratum 2 Block Styles --- */
.stratum-2 .content-block {
    border-left: 4px solid var(--neon-aqua);
    background: rgba(61, 31, 18, 0.25);
}

.stratum-2 .block-title {
    color: var(--bleached-sand);
}

.stratum-2 .block-text {
    color: var(--bleached-sand);
}

/* --- Stratum 3 Block Styles --- */
.stratum-3 .content-block {
    border: 2px solid var(--neon-aqua);
    box-shadow: 0 0 12px var(--neon-aqua), inset 0 2px 8px rgba(0, 0, 0, 0.15);
    background: rgba(61, 31, 18, 0.5);
}

.stratum-3 .block-title {
    color: var(--bleached-sand);
}

.stratum-3 .block-text {
    color: var(--bleached-sand);
}

.stratum-3 .corner-glyph {
    color: var(--neon-aqua);
}

/* --- Stratum 4 Block Styles --- */
.stratum-4 .content-block.block-full {
    max-width: 800px;
    margin: 0 auto;
    border: 2px solid var(--neon-aqua);
    background: rgba(61, 31, 18, 0.6);
    animation: borderGradient 4s linear infinite, glitchTremor 4s ease-in-out infinite;
}

.stratum-4 .block-title {
    color: var(--bleached-sand);
    font-size: 36px;
}

.stratum-4 .block-text {
    color: var(--bleached-sand);
}

.stratum-4 .corner-glyph {
    color: var(--neon-violet);
}

.stratum-4-content {
    text-align: center;
}

/* --- Chromatic Aberration --- */
.chromatic-2 {
    text-shadow:
        2px 2px 0px var(--primary-terracotta),
        2px 0 0 var(--neon-aqua),
        -2px 0 0 var(--neon-coral);
}

.chromatic-3 {
    text-shadow:
        2px 2px 0px var(--primary-terracotta),
        3px 0 0 var(--neon-aqua),
        -3px 0 0 var(--neon-coral),
        0 3px 0 var(--neon-violet);
}

.chromatic-4 {
    text-shadow:
        2px 2px 0px var(--primary-terracotta),
        4px 0 0 var(--neon-aqua),
        -4px 0 0 var(--neon-coral),
        0 4px 0 var(--neon-violet);
}

/* --- Neon Fissure SVGs --- */
.neon-fissure {
    width: 100%;
    height: 6px;
    margin-top: 16px;
    filter: drop-shadow(0 0 6px var(--neon-aqua));
    opacity: 0.7;
}

.neon-fissure-bright {
    opacity: 1;
    filter: drop-shadow(0 0 10px var(--neon-aqua));
}

.fissure-top {
    position: absolute;
    top: 8px;
    left: 32px;
    right: 32px;
    width: auto;
}

/* --- Reveal Animations --- */
.reveal-block {
    opacity: 0;
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal-block.block-left {
    transform: translateX(-60px);
}

.reveal-block.block-right {
    transform: translateX(60px);
}

.reveal-block.revealed {
    opacity: 1;
    transform: translateX(0);
}

/* Stagger delays for alternating blocks */
.stratum-content .reveal-block:nth-child(2) {
    transition-delay: 0.2s;
}

/* --- Data Bubbles --- */
.data-bubbles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 5;
}

.data-bubble {
    position: absolute;
    bottom: -80px;
    left: var(--left);
    width: var(--size);
    height: var(--size);
    border-radius: 50%;
    background: rgba(245, 164, 98, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Space Mono', monospace;
    font-size: 10px;
    color: rgba(245, 164, 98, 0.4);
    animation: bubbleDrift var(--dur) var(--delay) ease-in-out infinite;
}

.data-bubble.neon-bubble {
    background: rgba(0, 245, 212, 0.15);
    color: rgba(0, 245, 212, 0.4);
}

.data-bubbles-dense .data-bubble {
    animation-duration: calc(var(--dur) * 0.7);
}

@keyframes bubbleDrift {
    0% {
        transform: translateY(0);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(calc(-100vh - 80px));
        opacity: 0;
    }
}

/* --- Timeline Nodes --- */
.timeline-node {
    position: absolute;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 60;
}

.node-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--amber-glow);
    position: relative;
    z-index: 2;
}

.node-cluster {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
}

.node-bubble {
    position: absolute;
    top: 50%;
    left: 50%;
    width: var(--nb-size, 12px);
    height: var(--nb-size, 12px);
    border-radius: 50%;
    opacity: 0.3;
    transform: translate(
        calc(-50% + var(--nb-x, 0px)),
        calc(-50% + var(--nb-y, 0px))
    );
    animation: nodePulse 3s ease-in-out infinite;
}

.node-bubble.nb-aqua {
    background: var(--neon-aqua);
    --nb-x: 12px;
    --nb-y: -8px;
}

.node-bubble.nb-coral {
    background: var(--neon-coral);
    --nb-x: -10px;
    --nb-y: 10px;
}

.node-bubble.nb-violet {
    background: var(--neon-violet);
    --nb-x: 8px;
    --nb-y: 14px;
}

@keyframes nodePulse {
    0%, 100% { transform: translate(calc(-50% + var(--nb-x, 0px)), calc(-50% + var(--nb-y, 0px))) scale(1); }
    50% { transform: translate(calc(-50% + var(--nb-x, 0px)), calc(-50% + var(--nb-y, 0px))) scale(1.2); }
}

/* --- Terminal Node (Stratum 4) --- */
.terminal-node {
    position: relative;
    width: 32px;
    height: 32px;
    margin: 60px auto 0;
}

.terminal-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--amber-glow);
    position: relative;
    z-index: 2;
    animation: terminalPulse 2s ease-in-out infinite;
}

.terminal-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    border-radius: 50%;
    border: 2px solid transparent;
    transform: translate(-50%, -50%);
    animation: ringPulse 3s ease-in-out infinite;
}

.ring-1 {
    width: 56px;
    height: 56px;
    border-color: var(--neon-aqua);
    opacity: 0.6;
    animation-delay: 0s;
}

.ring-2 {
    width: 80px;
    height: 80px;
    border-color: var(--neon-coral);
    opacity: 0.4;
    animation-delay: 0.5s;
}

.ring-3 {
    width: 104px;
    height: 104px;
    border-color: var(--neon-violet);
    opacity: 0.3;
    animation-delay: 1s;
}

@keyframes terminalPulse {
    0%, 100% { box-shadow: 0 0 12px var(--amber-glow), 0 0 24px var(--neon-aqua); }
    50% { box-shadow: 0 0 20px var(--amber-glow), 0 0 40px var(--neon-aqua), 0 0 60px var(--neon-violet); }
}

@keyframes ringPulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.4; }
    50% { transform: translate(-50%, -50%) scale(1.15); opacity: 0.7; }
}

/* --- Glitch Tremor (Stratum 4) --- */
@keyframes glitchTremor {
    0%, 97%, 100% { transform: translateX(0); }
    97.5% { transform: translateX(-2px); }
    98% { transform: translateX(1px); }
    98.5% { transform: translateX(-1px); }
    99% { transform: translateX(2px); }
    99.5% { transform: translateX(0); }
}

/* --- Animated Border Gradient (Stratum 4) --- */
@keyframes borderGradient {
    0% { border-color: var(--neon-aqua); box-shadow: 0 0 12px var(--neon-aqua), inset 0 2px 8px rgba(0,0,0,0.15); }
    33% { border-color: var(--neon-coral); box-shadow: 0 0 12px var(--neon-coral), inset 0 2px 8px rgba(0,0,0,0.15); }
    66% { border-color: var(--neon-violet); box-shadow: 0 0 12px var(--neon-violet), inset 0 2px 8px rgba(0,0,0,0.15); }
    100% { border-color: var(--neon-aqua); box-shadow: 0 0 12px var(--neon-aqua), inset 0 2px 8px rgba(0,0,0,0.15); }
}

/* --- Hover Burst Container --- */
.hover-burst {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 100;
    animation: burstOut 0.6s ease-out forwards;
}

@keyframes burstOut {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(var(--bx), var(--by)) scale(0);
        opacity: 0;
    }
}

/* --- Spine Depth Labels (rotated) --- */
.spine-depth-label {
    position: absolute;
    left: 50%;
    transform: translateX(-50%) rotate(-90deg);
    font-family: 'Space Mono', monospace;
    font-size: 12px;
    font-weight: 400;
    color: var(--primary-terracotta);
    opacity: 0.7;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
    pointer-events: none;
    z-index: 55;
}

/* --- Mobile Responsive --- */
@media (max-width: 768px) {
    .hero-title {
        font-size: 36px;
    }

    .stratum-4 .block-title {
        font-size: 24px;
    }

    .block-title {
        font-size: 18px;
    }

    .content-block {
        max-width: 100%;
        margin-left: 40px !important;
        margin-right: 20px !important;
    }

    .block-left,
    .block-right {
        margin-left: 40px !important;
        margin-right: 20px !important;
    }

    .stratum-4 .content-block.block-full {
        max-width: 100%;
        margin-left: 20px !important;
        margin-right: 20px !important;
    }

    #timeline-spine {
        left: 24px;
        transform: none;
    }

    .timeline-node {
        left: 24px;
        transform: none;
    }

    .stratum-label-line {
        justify-content: flex-start;
        padding-left: 48px;
    }

    #stratum-nav {
        bottom: 20px;
        right: 20px;
    }

    .node-cluster {
        display: none;
    }
}

/* --- Prefers Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
    .data-bubble {
        animation: none;
        opacity: 0.3;
        bottom: 50%;
    }

    .node-bubble {
        animation: none;
    }

    .terminal-dot {
        animation: none;
        box-shadow: 0 0 12px var(--amber-glow), 0 0 24px var(--neon-aqua);
    }

    .terminal-ring {
        animation: none;
    }

    .reveal-block {
        opacity: 1;
        transform: none;
    }

    .stratum-4 .content-block.block-full {
        animation: borderGradient 4s linear infinite;
    }

    .hero-title .letter {
        opacity: 1;
        transform: none;
    }

    .hero-subtitle {
        opacity: 1;
    }
}
