/* =============================================
   layer-2.quest — Ocean-Deep Strata Architecture
   ============================================= */

:root {
    --bedrock: #0B1A1F;
    --abyssal: #132E38;
    --deep-current: #1B4050;
    --surface-water: #2A6070;
    --signal-cyan: #3A8FA8;
    --foam: #D8E2E6;
    --compression-orange: #D4784A;
    --annotation-teal: #3A6B7E;
    --ease-arch: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

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

html {
    scroll-behavior: smooth;
}

body {
    background: var(--bedrock);
    color: var(--foam);
    font-family: 'IBM Plex Serif', Georgia, serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.2vw, 1.15rem);
    line-height: 1.75;
    overflow-x: hidden;
}

/* ---- Layer Nav ---- */
.layer-nav {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 100;
    padding: 8px 0;
}

.layer-nav-indicator {
    display: block;
    width: 12px;
    height: 24px;
    background: var(--annotation-teal);
    opacity: 0.25;
    transition: opacity 0.4s var(--ease-arch), background 0.4s var(--ease-arch);
    text-decoration: none;
}

.layer-nav-indicator.active {
    opacity: 1;
    background: var(--signal-cyan);
}

/* ---- Layer Sections ---- */
.layer-section {
    position: relative;
    min-height: 120vh;
    padding: 120px 12% 120px 12%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
}

.layer-0 { background: var(--bedrock); }
.layer-1 { background: var(--abyssal); }
.layer-2 { background: var(--deep-current); min-height: 160vh; }
.layer-3 { background: var(--surface-water); min-height: 80vh; }

/* ---- Isometric Grid Planes ---- */
.iso-grid-plane {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(90deg, rgba(27,64,80,0.3) 1px, transparent 1px),
        linear-gradient(180deg, rgba(27,64,80,0.3) 1px, transparent 1px);
    background-size: 40px 40px;
    transform: perspective(800px) rotateX(55deg) rotateZ(-45deg) scale(2);
    transform-origin: center center;
    opacity: 0.15;
    pointer-events: none;
}

.layer-1 .iso-grid-plane {
    background:
        linear-gradient(90deg, rgba(42,96,112,0.3) 1px, transparent 1px),
        linear-gradient(180deg, rgba(42,96,112,0.3) 1px, transparent 1px);
    background-size: 40px 40px;
    opacity: 0.12;
}

.layer-2 .iso-grid-plane {
    background:
        linear-gradient(90deg, rgba(58,143,168,0.2) 1px, transparent 1px),
        linear-gradient(180deg, rgba(58,143,168,0.2) 1px, transparent 1px);
    background-size: 40px 40px;
    opacity: 0.1;
}

.layer-3 .iso-grid-plane {
    background:
        linear-gradient(90deg, rgba(216,226,230,0.15) 1px, transparent 1px),
        linear-gradient(180deg, rgba(216,226,230,0.15) 1px, transparent 1px);
    background-size: 40px 40px;
    opacity: 0.08;
}

.iso-grid-plane.frosted {
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

/* ---- Strata Lines ---- */
.strata-lines {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        repeating-linear-gradient(
            to bottom,
            transparent,
            transparent 30px,
            rgba(58,107,126,0.1) 30px,
            rgba(58,107,126,0.1) 31px,
            transparent 31px,
            transparent 80px,
            rgba(58,107,126,0.2) 80px,
            rgba(58,107,126,0.2) 81px,
            transparent 81px,
            transparent 150px,
            rgba(58,107,126,0.15) 150px,
            rgba(58,107,126,0.15) 151px
        );
}

/* ---- Node Constellation ---- */
.node-constellation {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0.5;
}

.node-link {
    stroke: var(--annotation-teal);
    stroke-width: 0.5;
    opacity: 0.4;
}

.node-dot {
    fill: var(--signal-cyan);
    opacity: 0.5;
}

.node-dot:nth-child(9) { animation: nodePulse 3.2s ease-in-out infinite; animation-delay: 0s; }
.node-dot:nth-child(10) { animation: nodePulse 3.2s ease-in-out infinite; animation-delay: 0.4s; }
.node-dot:nth-child(11) { animation: nodePulse 3.2s ease-in-out infinite; animation-delay: 0.8s; }
.node-dot:nth-child(12) { animation: nodePulse 3.2s ease-in-out infinite; animation-delay: 1.2s; }
.node-dot:nth-child(13) { animation: nodePulse 3.2s ease-in-out infinite; animation-delay: 1.6s; }
.node-dot:nth-child(14) { animation: nodePulse 3.2s ease-in-out infinite; animation-delay: 2.0s; }
.node-dot:nth-child(15) { animation: nodePulse 3.2s ease-in-out infinite; animation-delay: 2.4s; }
.node-dot:nth-child(16) { animation: nodePulse 3.2s ease-in-out infinite; animation-delay: 2.8s; }

@keyframes nodePulse {
    0%, 100% { opacity: 0.3; r: 3; }
    50% { opacity: 1; r: 5; }
}

/* ---- Layer Content ---- */
.layer-content {
    position: relative;
    z-index: 2;
    max-width: 680px;
}

.layer-label {
    font-family: 'Chakra Petch', sans-serif;
    font-weight: 600;
    font-size: clamp(2rem, 5vw, 4.5rem);
    letter-spacing: 0.35em;
    text-transform: uppercase;
    color: var(--annotation-teal);
    margin-bottom: 24px;
    line-height: 1.1;
}

.layer-opening {
    font-family: 'IBM Plex Serif', Georgia, serif;
    font-size: 1.3rem;
    color: var(--foam);
    margin-bottom: 32px;
}

.layer-body p {
    max-width: 42ch;
    margin-bottom: 1.5em;
    color: var(--foam);
}

.layer-body p:last-child {
    margin-bottom: 0;
}

/* ---- Fade Up Animation ---- */
.fade-up {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 1s var(--ease-arch), transform 1s var(--ease-arch);
}

.fade-up.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ---- Trust Boundaries ---- */
.trust-boundary {
    position: relative;
    padding: 24px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: transparent;
}

.wave-divider {
    width: 100%;
    height: 24px;
    overflow: visible;
}

.wave-path {
    fill: none;
    stroke: var(--annotation-teal);
    stroke-width: 1;
}

.wave-slow {
    animation: waveShift 8s linear infinite;
}

.wave-fast {
    animation: waveShift 4s linear infinite;
}

@keyframes waveShift {
    0% { transform: translateX(0); }
    100% { transform: translateX(-200px); }
}

.boundary-label {
    font-family: 'Overpass Mono', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    color: var(--annotation-teal);
    text-transform: uppercase;
    margin-top: 8px;
}

/* ---- Z-Pattern Layout (Layer 2) ---- */
.z-row {
    display: flex;
    align-items: flex-start;
    gap: 60px;
    max-width: 100%;
    margin-bottom: 80px;
}

.z-row-reverse {
    flex-direction: row-reverse;
}

.z-text {
    flex: 1;
    max-width: 42ch;
}

.z-text p {
    color: var(--foam);
    margin-bottom: 1.5em;
}

.z-text p:last-child {
    margin-bottom: 0;
}

.sub-heading {
    font-family: 'Chakra Petch', sans-serif;
    font-weight: 300;
    font-size: clamp(1rem, 2vw, 1.5rem);
    letter-spacing: 0.35em;
    text-transform: uppercase;
    color: var(--compression-orange);
    margin-bottom: 20px;
}

.z-diagram {
    flex-shrink: 0;
    width: 320px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.z-diagram canvas {
    display: block;
    border: 1px solid rgba(58,143,168,0.2);
}

.z-diagram svg {
    width: 240px;
    height: 180px;
}

.channel-line {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    transition: stroke-dashoffset 1.5s var(--ease-arch);
}

.channel-line.drawn {
    stroke-dashoffset: 0;
}

/* ---- Floating Cubes (Layer 3) ---- */
.floating-cubes {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
}

.iso-cube {
    position: absolute;
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--signal-cyan), var(--deep-current));
    opacity: 0.15;
    transform: rotate(45deg);
}

.cube-1 { top: 15%; left: 20%; width: 30px; height: 30px; opacity: 0.12; }
.cube-2 { top: 30%; right: 25%; width: 50px; height: 50px; opacity: 0.1; }
.cube-3 { top: 55%; left: 60%; width: 25px; height: 25px; opacity: 0.18; }
.cube-4 { top: 70%; left: 15%; width: 45px; height: 45px; opacity: 0.08; }
.cube-5 { top: 40%; right: 10%; width: 35px; height: 35px; opacity: 0.14; }

/* ---- Surface Fragments (Layer 3) ---- */
.surface-fragments p {
    max-width: 48ch;
    margin-bottom: 1.5em;
    color: var(--foam);
}

.final-line {
    font-family: 'IBM Plex Serif', Georgia, serif;
    font-style: italic;
    font-size: 1.5rem;
    color: var(--foam);
    text-align: center;
    margin-top: 80px;
    opacity: 0.8;
}

/* ---- Ripple Effect ---- */
.ripple {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(58,143,168,0.15), transparent 70%);
    pointer-events: none;
    z-index: 1;
    animation: rippleExpand 1.5s ease-out forwards;
}

@keyframes rippleExpand {
    0% {
        width: 0;
        height: 0;
        opacity: 1;
    }
    100% {
        width: 300px;
        height: 300px;
        opacity: 0;
    }
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .layer-section {
        padding: 80px 6% 80px 6%;
        min-height: 100vh;
    }

    .layer-2 {
        min-height: auto;
    }

    .z-row,
    .z-row-reverse {
        flex-direction: column;
    }

    .z-diagram {
        width: 100%;
        max-width: 280px;
    }

    .layer-label {
        font-size: clamp(1.5rem, 4vw, 2.5rem);
        letter-spacing: 0.2em;
    }

    .floating-cubes {
        display: none;
    }

    .layer-nav {
        display: none;
    }
}
