/* ==========================================================
   concurrent.quest - Anti-Design / Z-Pattern / Variable-Fluid
   Palette: #0D0A07 (bg), #1A1209 (bg elevated), #F5E6D3 (text),
            #E87B2F (accent), #BF6A30 (accent2), #8B3A1A (oxide),
            #6B5E52 (muted), #F4A039 (highlight), #FF8C2E (bokeh)
   Fonts: Epilogue (variable), Inclusive Sans, Azeret Mono
   ========================================================== */

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inclusive Sans', sans-serif;
    background-color: #0D0A07;
    color: #F5E6D3;
    overflow-x: hidden;
    position: relative;
    min-height: 600vh;
}

/* =========================================================
   BOKEH BACKGROUND LAYERS
   ========================================================= */
.bokeh-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    overflow: visible;
}

#bokeh-deep {
    opacity: 0;
    animation: bokehFadeIn 1200ms ease-out forwards;
    animation-delay: 600ms;
    z-index: 0;
}

#bokeh-mid {
    opacity: 0;
    animation: bokehFadeIn 1500ms ease-out forwards;
    animation-delay: 1000ms;
    z-index: 1;
}

#bokeh-near {
    opacity: 0;
    z-index: 2;
}

@keyframes bokehFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Bokeh drift animations */
@keyframes bokehDrift1 {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(20px, -15px); }
    50% { transform: translate(-10px, -30px); }
    75% { transform: translate(-25px, -10px); }
}

@keyframes bokehDrift2 {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(-30px, 20px); }
    50% { transform: translate(15px, 35px); }
    75% { transform: translate(25px, -10px); }
}

@keyframes bokehDrift3 {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(15px, 25px); }
    50% { transform: translate(-20px, 10px); }
    75% { transform: translate(10px, -20px); }
}

@keyframes bokehDrift4 {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(-15px, -30px); }
    50% { transform: translate(30px, -15px); }
    75% { transform: translate(-10px, 20px); }
}

/* =========================================================
   LEAF-ORGANIC SVG MOTIFS
   ========================================================= */
#leaf-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3;
}

.leaf {
    position: absolute;
    width: 60px;
    height: 80px;
    opacity: 0;
    transition: opacity 1.2s ease;
}

.leaf.visible {
    opacity: 1;
}

/* Leaf positions at Fibonacci-interval scroll positions.
   Leaves appear at edges of content, rotated 15-75deg, scaled 0.4-1.2 */
.leaf-1 {
    top: 120vh;
    right: 6%;
    transform: rotate(25deg) scale(0.8);
}

.leaf-2 {
    top: 150vh;
    left: 4%;
    transform: rotate(55deg) scale(1.1);
}

.leaf-3 {
    top: 180vh;
    right: 12%;
    transform: rotate(38deg) scale(0.6);
}

.leaf-4 {
    top: 230vh;
    left: 8%;
    transform: rotate(68deg) scale(0.9);
}

.leaf-5 {
    top: 280vh;
    right: 3%;
    transform: rotate(18deg) scale(1.2);
}

.leaf-6 {
    top: 320vh;
    left: 15%;
    transform: rotate(47deg) scale(0.5);
}

.leaf-7 {
    top: 370vh;
    right: 10%;
    transform: rotate(72deg) scale(0.7);
}

.leaf-8 {
    top: 395vh;
    left: 6%;
    transform: rotate(30deg) scale(1.0);
}

/* Convergence zone: leaves closer together (every ~25vh) */
.leaf-9 {
    top: 420vh;
    right: 8%;
    transform: rotate(60deg) scale(0.4);
}

.leaf-10 {
    top: 445vh;
    left: 3%;
    transform: rotate(22deg) scale(0.9);
}

.leaf-11 {
    top: 470vh;
    right: 5%;
    transform: rotate(45deg) scale(0.6);
}

.leaf-12 {
    top: 500vh;
    left: 10%;
    transform: rotate(15deg) scale(1.1);
}

/* =========================================================
   ZONES
   ========================================================= */
.zone {
    position: relative;
    z-index: 10;
}

/* =========================================================
   ZONE 1: TITLE ZONE (0-100vh)
   ========================================================= */
#zone-title {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding: 0;
    position: relative;
}

#z1-anchor {
    position: relative;
    z-index: 10;
    display: flex;
    align-items: flex-start;
    gap: 24px;
    padding: 80px 40px 40px;
    margin-left: -8px; /* deliberately bleeding into the viewport edge */
}

#domain-title {
    font-family: 'Epilogue', sans-serif;
    font-weight: 900;
    font-style: italic;
    font-size: clamp(48px, 10vw + 16px, 160px);
    color: #E87B2F;
    line-height: 0.95;
    letter-spacing: -0.03em;
    overflow: hidden;
    transform: rotate(-0.5deg);
}

#domain-title .char {
    display: inline-block;
    opacity: 0;
    font-variation-settings: 'wght' 100;
    transition: font-variation-settings 400ms ease-out, opacity 80ms ease;
}

#domain-title .char.revealed {
    opacity: 1;
    font-variation-settings: 'wght' 900;
}

/* Rotating leaf next to title (Lottie substitute) */
#title-leaf-spin {
    width: 60px;
    height: 60px;
    flex-shrink: 0;
    margin-top: 20px;
    animation: leafSpin 12s linear infinite;
}

#title-leaf-spin svg {
    width: 100%;
    height: 100%;
}

@keyframes leafSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Z2: Top-right terminus - Fragmented text */
#z2-fragments {
    position: absolute;
    top: 100px;
    right: 40px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 10;
}

.z2-frag {
    font-family: 'Inclusive Sans', sans-serif;
    font-size: 13px;
    font-weight: 400;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    display: inline-block;
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 300ms ease-out, transform 300ms ease-out;
}

.z2-frag.visible {
    opacity: 1;
    transform: translateX(0) rotate(var(--frag-rotate, 0deg));
}

/* =========================================================
   ZONE 2: FIRST NARRATIVE (100-200vh)
   ========================================================= */
#zone-narrative-1 {
    min-height: 100vh;
    padding: 80px 40px;
    display: flex;
    flex-direction: column;
    gap: 80px;
}

.narrative-block {
    max-width: 500px;
    position: relative;
    opacity: 0;
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.narrative-block.in-view {
    opacity: 1;
    transform: translate(0, 0) rotate(var(--nb-rotate, 0deg));
}

.nb-1 {
    align-self: flex-start;
    margin-left: 5%;
    --nb-rotate: -2deg;
    transform: translateX(-40px) rotate(-2deg);
}

.nb-2 {
    align-self: flex-end;
    margin-right: 8%;
    --nb-rotate: 1.5deg;
    transform: translateX(40px) rotate(1.5deg);
}

.nb-3 {
    align-self: flex-start;
    margin-left: 12%;
    --nb-rotate: -0.8deg;
    transform: translateX(-40px) rotate(-0.8deg);
}

.narrative-text {
    font-family: 'Epilogue', sans-serif;
    font-size: clamp(20px, 3vw + 6px, 48px);
    font-weight: 300;
    font-style: italic;
    line-height: 1.4;
    color: #F5E6D3;
    letter-spacing: -0.02em;
    font-variation-settings: 'wght' 300;
    transition: font-variation-settings 0.6s ease-out;
}

.in-view .narrative-text {
    font-variation-settings: 'wght' 600;
}

.data-label {
    font-family: 'Inclusive Sans', sans-serif;
    font-size: 11px;
    font-weight: 400;
    color: #BF6A30;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    margin-bottom: 16px;
    display: inline-block;
}

.body-text {
    font-family: 'Inclusive Sans', sans-serif;
    font-size: 16px;
    font-weight: 400;
    line-height: 1.65;
    color: #F5E6D3;
}

/* =========================================================
   ZONE 3: DISRUPTION ZONE (200-350vh)
   ========================================================= */
#zone-disruption {
    min-height: 150vh;
    padding: 60px 40px;
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 0;
    position: relative;
}

.disruption-block {
    position: relative;
    padding: 32px 36px;
    max-width: 420px;
    opacity: 0;
    transition: opacity 0.7s ease-out, transform 0.7s ease-out;
}

.disruption-block.in-view {
    opacity: 1;
}

/* Irregular column placement per anti-grid design */
.db-1 {
    grid-column: 2 / 6;
    grid-row: 1;
    transform: rotate(-3deg) translateY(30px);
    margin-top: 0;
}
.db-1.in-view {
    transform: rotate(-3deg) translateY(0);
}

.db-2 {
    grid-column: 7 / 11;
    grid-row: 2;
    transform: rotate(2deg) translateY(30px);
    margin-top: 40px;
}
.db-2.in-view {
    transform: rotate(2deg) translateY(0);
}

.db-3 {
    grid-column: 1 / 5;
    grid-row: 3;
    transform: rotate(4deg) translateY(30px);
    margin-top: 80px;
}
.db-3.in-view {
    transform: rotate(4deg) translateY(0);
}

.db-4 {
    grid-column: 6 / 10;
    grid-row: 4;
    transform: rotate(-1.5deg) translateY(30px);
    margin-top: 24px;
}
.db-4.in-view {
    transform: rotate(-1.5deg) translateY(0);
}

.db-5 {
    grid-column: 3 / 7;
    grid-row: 5;
    transform: rotate(5deg) translateY(30px);
    margin-top: 64px;
}
.db-5.in-view {
    transform: rotate(5deg) translateY(0);
}

.db-6 {
    grid-column: 8 / 12;
    grid-row: 6;
    transform: rotate(-2.5deg) translateY(30px);
    margin-top: 16px;
}
.db-6.in-view {
    transform: rotate(-2.5deg) translateY(0);
}

/* System output fragments (Azeret Mono) */
.system-output {
    font-family: 'Azeret Mono', monospace;
    font-size: 13px;
    line-height: 1.5;
    font-weight: 400;
    color: #E87B2F;
    opacity: 0;
    border-left: 2px solid #BF6A30;
    padding: 8px 16px;
    transition: opacity 0.5s ease-out;
    white-space: nowrap;
    overflow: hidden;
}

.system-output.in-view {
    opacity: 0.6;
}

/* System output positions in the disruption grid */
#zone-disruption .system-output:nth-of-type(1) {
    grid-column: 5 / 10;
    grid-row: 1;
    margin-top: 120px;
    align-self: end;
    transform: rotate(0.5deg);
}

#zone-disruption .system-output:nth-of-type(2) {
    grid-column: 2 / 8;
    grid-row: 2;
    margin-top: 100px;
    align-self: end;
    transform: rotate(-0.3deg);
}

#zone-disruption .system-output:nth-of-type(3) {
    grid-column: 5 / 12;
    grid-row: 3;
    margin-top: 60px;
    align-self: end;
    transform: rotate(0.8deg);
}

#zone-disruption .system-output:nth-of-type(4) {
    grid-column: 1 / 7;
    grid-row: 4;
    margin-top: 80px;
    align-self: end;
    transform: rotate(-0.5deg);
}

#zone-disruption .system-output:nth-of-type(5) {
    grid-column: 6 / 12;
    grid-row: 5;
    margin-top: 40px;
    align-self: end;
    transform: rotate(0.3deg);
}

.sys-cursor {
    display: inline-block;
    width: 8px;
    height: 14px;
    background: #E87B2F;
    margin-left: 2px;
    animation: cursorBlink 0.8s step-end infinite;
    vertical-align: text-bottom;
}

@keyframes cursorBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Pull quotes */
.pull-quote {
    font-family: 'Epilogue', sans-serif;
    font-weight: 300;
    font-style: italic;
    font-size: clamp(20px, 3vw + 6px, 48px);
    color: #FF8C2E;
    line-height: 1.35;
    letter-spacing: -0.02em;
}

/* =========================================================
   ZONE 4: CONVERGENCE ZONE (350-500vh)
   ========================================================= */
#zone-convergence {
    min-height: 150vh;
    padding: 80px 40px;
    display: flex;
    flex-direction: column;
    gap: 60px;
}

.convergence-block {
    max-width: 600px;
    position: relative;
    opacity: 0;
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.convergence-block.in-view {
    opacity: 1;
    transform: rotate(0deg) translateY(0);
}

/* Convergence: rotation angles decrease toward 0, positions regularize */
.cb-1 {
    align-self: flex-start;
    margin-left: 10%;
    transform: rotate(-1deg) translateY(20px);
}

.cb-2 {
    align-self: center;
    transform: rotate(0.5deg) translateY(20px);
}

.cb-3 {
    align-self: flex-end;
    margin-right: 10%;
    transform: rotate(-0.3deg) translateY(20px);
}

.cb-4 {
    align-self: center;
    transform: rotate(0deg) translateY(20px);
}

#zone-convergence .system-output {
    align-self: center;
    max-width: 500px;
}

/* =========================================================
   ZONE 5: EXIT / FINALE (500-600vh)
   ========================================================= */
#zone-exit {
    min-height: 100vh;
    padding: 80px 40px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    position: relative;
}

/* Process tree animation */
#process-tree {
    width: 400px;
    height: 400px;
    position: relative;
    opacity: 0;
    transition: opacity 2000ms ease-out;
}

#process-tree.in-view {
    opacity: 1;
}

#process-tree-svg {
    width: 100%;
    height: 100%;
}

/* Node pulse animation */
.node-pulse {
    animation: nodePulse 4s ease-in-out infinite;
}

.node-pulse-delay {
    animation: nodePulse 4s ease-in-out infinite;
    animation-delay: 1s;
}

@keyframes nodePulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

/* Branch drawing animation */
.branch {
    stroke-dasharray: 120;
    stroke-dashoffset: 120;
    animation: drawBranch 2s ease-out forwards;
    animation-delay: 0.5s;
}

.branch-1 { animation-delay: 0.5s; }
.branch-2 { animation-delay: 0.8s; }
.branch-3 { animation-delay: 1.1s; }
.branch-4 { animation-delay: 1.4s; }

@keyframes drawBranch {
    to { stroke-dashoffset: 0; }
}

.sub-branch {
    stroke-dasharray: 80;
    stroke-dashoffset: 80;
    animation: drawBranch 1.5s ease-out forwards;
    animation-delay: 2s;
}

.merge-line {
    stroke-dasharray: 4 4;
    opacity: 0;
    animation: mergeAppear 1.5s ease-out forwards;
    animation-delay: 3s;
}

@keyframes mergeAppear {
    from { opacity: 0; }
    to { opacity: 0.6; }
}

/* Branch opacity pulse cycle repeating every 4s */
#process-tree-svg .branch,
#process-tree-svg .sub-branch {
    animation: drawBranch 2s ease-out forwards, branchPulse 4s ease-in-out 3s infinite;
}

@keyframes branchPulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

/* Final narrative */
#final-narrative {
    margin-top: 80px;
    text-align: center;
    align-self: center;
    opacity: 0;
    transition: opacity 1.5s ease-out;
}

#final-narrative.in-view {
    opacity: 1;
}

.final-text {
    font-family: 'Epilogue', sans-serif;
    font-weight: 200;
    font-size: 36px;
    color: #F5E6D3;
    letter-spacing: 0.02em;
}

#exit-brand {
    margin-top: 60px;
    align-self: flex-end;
}

.exit-domain {
    font-family: 'Epilogue', sans-serif;
    font-weight: 900;
    font-style: italic;
    font-size: clamp(24px, 4vw + 8px, 64px);
    color: #F4A039;
    letter-spacing: -0.02em;
    opacity: 0.6;
}

/* =========================================================
   SCROLL-REVEAL GENERAL
   ========================================================= */
.scroll-reveal {
    will-change: opacity, transform;
}

/* Font-variation-settings breathing on scroll */
.in-view .pull-quote,
.in-view .body-text {
    font-variation-settings: 'wght' 500;
}

/* =========================================================
   NEAR-LAYER BOKEH (scroll firefly effect)
   ========================================================= */
.bokeh-firefly {
    position: fixed;
    border-radius: 50%;
    pointer-events: none;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.3s ease-in;
    animation: fireflyFade 2s ease-out forwards;
}

@keyframes fireflyFade {
    0% { opacity: 0.3; }
    20% { opacity: 0.25; }
    100% { opacity: 0; }
}

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 768px) {
    #z1-anchor {
        padding: 40px 20px 20px;
        flex-direction: column;
    }

    #z2-fragments {
        position: relative;
        top: auto;
        right: auto;
        margin-top: 32px;
        padding-left: 20px;
    }

    #zone-narrative-1 {
        padding: 40px 20px;
        gap: 60px;
    }

    .narrative-block {
        max-width: 100%;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    #zone-disruption {
        display: flex;
        flex-direction: column;
        gap: 40px;
        padding: 40px 20px;
    }

    .disruption-block {
        max-width: 100%;
    }

    .system-output {
        white-space: normal;
    }

    #zone-convergence {
        padding: 40px 20px;
        gap: 40px;
    }

    .convergence-block {
        max-width: 100%;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    #zone-exit {
        padding: 40px 20px;
        align-items: center;
    }

    #process-tree {
        width: 240px;
        height: 240px;
    }

    .final-text {
        font-size: 24px;
    }
}
