/* =============================================
   concurrengine.com - Generative Bioluminescence
   ============================================= */

/* --- CSS Custom Properties --- */
:root {
    --midnight-forest: #0B1A12;
    --deep-canopy: #061208;
    --luminous-lichen: #B7E4C7;
    --mist-green: #8FBFA8;
    --living-jade: #52B788;
    --deep-fern: #2D6A4F;
    --forest-heart: #1B4332;
    --bioluminescent: #95D5B2;
    --spore-gold: #C9AE5D;
    --border-jade: #3A6B5C;
    --forest-jade: #40916C;

    --font-primary: 'Commissioner', sans-serif;
    --font-mono: 'Space Mono', monospace;

    --content-max-width: 680px;
    --horizontal-padding: 10vw;
}

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

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

body {
    background-color: var(--midnight-forest);
    color: var(--luminous-lichen);
    font-family: var(--font-primary);
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.15rem);
    line-height: 1.75;
    letter-spacing: 0.005em;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Scroll Progress Indicator --- */
#scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 2px;
    height: 0%;
    background: var(--living-jade);
    z-index: 1000;
    transition: height 100ms linear;
}

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

/* --- Hexagonal Nodes --- */
#hex-nodes {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

.hex-node {
    position: absolute;
    width: 24px;
    height: 24px;
    opacity: 0.2;
    animation: hex-pulse 3s ease-in-out infinite;
}

.hex-node svg {
    width: 100%;
    height: 100%;
}

@keyframes hex-pulse {
    0%, 100% { transform: scale(1.0); }
    50% { transform: scale(1.08); }
}

/* --- Canopy Layers --- */
.canopy-layer {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 var(--horizontal-padding);
}

.layer-content {
    max-width: var(--content-max-width);
    width: 100%;
    margin: 0 auto;
}

/* --- Layer 1: Emergence --- */
#layer-emergence {
    min-height: 100vh;
    background: var(--midnight-forest);
}

.site-name {
    font-family: var(--font-primary);
    font-weight: 300;
    font-size: clamp(2.2rem, 6vw, 4.8rem);
    letter-spacing: 0.04em;
    line-height: 1.2;
    color: var(--luminous-lichen);
    text-align: center;
    white-space: nowrap;
}

.letter {
    display: inline-block;
    opacity: 0;
    transition: opacity 1200ms cubic-bezier(0.23, 1, 0.32, 1),
                transform 1200ms cubic-bezier(0.23, 1, 0.32, 1);
}

.letter.assembled {
    opacity: 1;
    transform: translate(0, 0) !important;
}

/* --- Breathing Zones --- */
.breathing-zone {
    position: relative;
    z-index: 2;
    height: 30vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.fractal-svg {
    width: 100%;
    height: 100%;
    opacity: 0.4;
}

.fractal-svg line {
    stroke: var(--forest-heart);
    stroke-width: 1px;
    opacity: 0;
    transition: opacity 200ms ease-in;
}

.fractal-svg line.grown {
    opacity: 1;
}

/* --- Layer 2: Branching --- */
#layer-branching {
    min-height: 120vh;
    padding-top: 10vh;
    padding-bottom: 10vh;
    background: linear-gradient(to bottom, var(--midnight-forest), #091610, var(--midnight-forest));
}

#layer-branching .layer-content {
    display: flex;
    flex-direction: column;
    gap: 8vh;
}

/* Card Panel Flip */
.card-panel {
    perspective: 1200px;
    border-radius: 2px;
}

.card-panel.left-offset {
    transform: translateX(-20px);
}

.card-panel.right-offset {
    transform: translateX(20px);
}

.card-inner {
    position: relative;
    transform-style: preserve-3d;
    transform: rotateY(90deg);
    transition: transform 600ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.card-panel.flipped .card-inner {
    transform: rotateY(0deg);
}

.card-front {
    position: relative;
    padding: 3rem 2.5rem;
    border: 1px solid rgba(58, 107, 92, 0.4);
    border-radius: 2px;
    background: rgba(11, 26, 18, 0.85);
    backface-visibility: hidden;
}

.card-back {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--forest-heart);
    border-radius: 2px;
    backface-visibility: hidden;
    transform: rotateY(180deg);
}

.card-front h2 {
    font-family: var(--font-primary);
    font-weight: 300;
    font-size: clamp(1.6rem, 3.5vw, 2.8rem);
    letter-spacing: 0.04em;
    line-height: 1.2;
    color: var(--mist-green);
    margin-bottom: 1.5rem;
    transition: font-weight 800ms ease;
}

.card-panel.flipped .card-front h2 {
    font-weight: 500;
}

.card-front p {
    color: var(--luminous-lichen);
    margin-bottom: 0;
}

.card-front p + p {
    text-indent: 1.5em;
}

.marginalia {
    position: absolute;
    right: -180px;
    top: 1rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--border-jade);
    opacity: 0.6;
    white-space: nowrap;
}

@media (max-width: 1100px) {
    .marginalia {
        display: none;
    }
}

/* --- Layer 3: Convergence --- */
#layer-convergence {
    min-height: 100vh;
    background: var(--midnight-forest);
}

.convergence-content {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
}

#convergence-svg {
    width: 100%;
    max-width: 800px;
    height: auto;
    min-height: 400px;
}

#convergence-svg path {
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
}

.convergence-text {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.poetic-fragment {
    position: absolute;
    font-family: var(--font-primary);
    font-weight: 300;
    font-size: clamp(0.9rem, 1.5vw, 1.1rem);
    color: var(--mist-green);
    opacity: 0;
    transition: opacity 1200ms ease;
    letter-spacing: 0.02em;
}

.poetic-fragment.visible {
    opacity: 0.8;
}

.fragment-top-left {
    top: 10%;
    left: 5%;
}

.fragment-top-right {
    top: 15%;
    right: 5%;
    text-align: right;
}

.fragment-bottom-left {
    bottom: 20%;
    left: 8%;
}

.fragment-bottom-right {
    bottom: 12%;
    right: 3%;
    text-align: right;
}

/* --- Layer 4: Depth --- */
#layer-depth {
    min-height: 100vh;
    padding-top: 10vh;
    padding-bottom: 10vh;
    background: linear-gradient(to bottom, var(--midnight-forest), var(--deep-canopy));
}

.depth-content {
    display: flex;
    flex-direction: column;
}

.depth-heading {
    font-family: var(--font-primary);
    font-weight: 300;
    font-size: clamp(1.6rem, 3.5vw, 2.8rem);
    letter-spacing: 0.04em;
    line-height: 1.2;
    color: var(--mist-green);
    margin-bottom: 6vh;
    transition: font-weight 800ms ease;
}

.depth-heading.weight-shift {
    font-weight: 500;
    color: #40916C;
}

.depth-paragraph {
    color: var(--luminous-lichen);
    margin-bottom: 3vh;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 800ms ease-out, transform 800ms ease-out;
}

.depth-paragraph.revealed {
    opacity: 1;
    transform: translateY(0);
}

.depth-paragraph + .depth-paragraph {
    text-indent: 1.5em;
}

/* --- Layer 5: Echo --- */
#layer-echo {
    min-height: 80vh;
    background: linear-gradient(to bottom, var(--deep-canopy), var(--midnight-forest));
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.echo-content {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.echo-text {
    font-family: var(--font-primary);
    font-weight: 700;
    font-size: clamp(2.2rem, 6vw, 4.8rem);
    letter-spacing: 0.04em;
    line-height: 1.2;
    color: var(--spore-gold);
    transition: opacity 600ms ease;
}

.echo-text span {
    display: inline-block;
    transition: transform 1500ms ease-out, opacity 1500ms ease-out;
}

.echo-text.dissolving span {
    opacity: 0;
}

.echo-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 120px;
    height: 120px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(201, 174, 93, 0.3) 0%, transparent 70%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 1500ms ease;
}

.echo-glow.visible {
    opacity: 1;
}

/* --- Silence Zone --- */
.silence-zone {
    height: 20vh;
    background: var(--midnight-forest);
    position: relative;
    z-index: 2;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    :root {
        --horizontal-padding: 6vw;
    }

    .card-panel.left-offset,
    .card-panel.right-offset {
        transform: translateX(0);
    }

    .card-front {
        padding: 2rem 1.5rem;
    }

    .poetic-fragment {
        font-size: 0.85rem;
    }

    .fragment-top-left {
        top: 5%;
        left: 3%;
    }

    .fragment-top-right {
        top: 8%;
        right: 3%;
    }

    .fragment-bottom-left {
        bottom: 12%;
        left: 3%;
    }

    .fragment-bottom-right {
        bottom: 5%;
        right: 3%;
    }
}

@media (max-width: 480px) {
    .site-name {
        white-space: normal;
        word-break: break-word;
    }

    .echo-text {
        font-size: clamp(1.6rem, 5vw, 2.4rem);
    }
}
