/* Ecosystem Specific Styles */
:root {
    --eco-bg: #050a14;
    --eco-primary: #2563eb;
    --eco-accent: #60a5fa;
    --eco-text: #f1f5f9;
    --eco-text-muted: #94a3b8;
    --eco-glow: rgba(37, 99, 235, 0.5);
    --eco-transition: all 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

body.ecosystem-page {
    background-color: var(--eco-bg);
    color: var(--eco-text);
    overflow-x: hidden;
    background-image:
        linear-gradient(rgba(37, 99, 235, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(37, 99, 235, 0.05) 1px, transparent 1px);
    background-size: 50px 50px;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 10px;
}
::-webkit-scrollbar-track {
    background: var(--eco-bg);
}
::-webkit-scrollbar-thumb {
    background: #1e293b;
    border-radius: 5px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--eco-primary);
}

/* --- The Path (SVG Background) --- */
.ecosystem-path-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: visible;
}

.ecosystem-path-base {
    stroke: var(--eco-primary);
    stroke-width: 2;
    fill: none;
    stroke-linecap: round;
    opacity: 0.15;
}

.ecosystem-path-active {
    stroke: url(#pathGradient);
    stroke-width: 3;
    fill: none;
    stroke-linecap: round;
    filter: drop-shadow(0 0 10px var(--eco-accent));
    transition: stroke-dashoffset 0.1s linear;
}

/* Ensure Main Content is above the path */
main {
    position: relative;
    z-index: 1;
}

/* --- Nodes & Hubs --- */
.node-wrapper {
    position: relative;
    padding: 6rem 0;
    min-height: 60vh;
    display: flex;
    align-items: center;
}

.central-hub-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 60vh;
    width: 100%;
}

.central-hub {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #3b82f6, #1d4ed8);
    box-shadow: 0 0 60px var(--eco-glow), inset 0 0 20px rgba(255,255,255,0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    position: relative;
    cursor: pointer;
    transition: transform 0.3s ease;
    animation: pulse 4s infinite ease-in-out;
    z-index: 2;
}

.central-hub:hover {
    transform: scale(1.05);
}

.hub-label {
    font-weight: 800;
    font-size: 1.5rem;
    color: white;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    z-index: 3;
}

/* Orbit Animation */
.orbit-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 50%;
    pointer-events: none;
}
.orbit-1 { width: 300px; height: 300px; animation: spin 20s linear infinite; }
.orbit-2 { width: 450px; height: 450px; animation: spin-reverse 25s linear infinite; }

.orbit-dot {
    position: absolute;
    top: 0;
    left: 50%;
    width: 8px;
    height: 8px;
    background: var(--eco-accent);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--eco-accent);
}

/* --- Tech Evolution (Compact Nodes) --- */
#tech-evolution {
    padding: 4rem 0;
}

.compact-node-row {
    display: flex;
    width: 100%;
    margin-bottom: 2rem;
    position: relative;
    z-index: 2;
}

/* Positioning for desktop wide branching */
.compact-node-row.layout-left {
    justify-content: flex-start;
    padding-left: 10%; /* Push to edge */
    padding-right: 0;
}

.compact-node-row.layout-right {
    justify-content: flex-end;
    padding-right: 10%; /* Push to edge */
    padding-left: 0;
}

.node-compact {
    background: rgba(5, 10, 20, 0.8);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(37, 99, 235, 0.3);
    padding: 0.5rem 1.2rem;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    color: var(--eco-accent);
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
    cursor: default;
}

.node-compact i {
    font-size: 1.1rem;
}

.node-compact:hover {
    transform: scale(1.1);
    border-color: var(--eco-accent);
    box-shadow: 0 0 15px var(--eco-glow);
    color: white;
}

/* --- History Milestones --- */
#history-milestones {
    padding: 4rem 0;
}

.milestone-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 5rem;
    position: relative;
    z-index: 2;
}

.milestone-wrapper.layout-left {
    justify-content: flex-start;
    padding-left: 10%;
}

.milestone-wrapper.layout-right {
    justify-content: flex-end;
    padding-right: 10%;
}

/* TECH NODE TRANSFORMATION (Milestone) */
.milestone-card {
    /* Base State: Compact & Transparent */
    background: rgba(5, 10, 20, 0.4);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(37, 99, 235, 0.2); /* Subtle tech border */
    border-radius: 50px; /* Pill shape initially */
    padding: 1rem 2rem; /* Compact padding */
    max-width: 300px; /* Smaller width initially */
    width: auto;
    text-align: left; /* Align left for tech feel */
    display: flex;
    align-items: center;
    gap: 1.5rem;

    /* Animation & Transition */
    transition: all 0.5s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: 0 0 15px rgba(37, 99, 235, 0.1);

    /* Floating Physics */
    animation: float-node 6s ease-in-out infinite;
    position: relative;
    overflow: hidden; /* Hide expanded content */

    /* Entrance State */
    opacity: 0;
    transform: translateY(30px);
}

.milestone-card.visible {
    opacity: 1;
    transform: translate(var(--px, 0px), var(--py, 0px));
}

/* Stagger floats for variety */
.milestone-wrapper:nth-child(odd) .milestone-card { animation-delay: 0s; }
.milestone-wrapper:nth-child(even) .milestone-card { animation-delay: 3s; }

/* HOVER STATE: Expand & Activate */
.milestone-card:hover {
    background: rgba(15, 23, 42, 0.95);
    border-color: var(--eco-accent);
    box-shadow: 0 0 30px var(--eco-glow), inset 0 0 20px rgba(37, 99, 235, 0.1);
    border-radius: 20px; /* Return to card shape */
    padding: 2rem;
    max-width: 450px;
    transform: scale(1.05);
    z-index: 10;
    display: block; /* Stack content vertically */
    text-align: center;
}

.milestone-icon {
    font-size: 2rem;
    margin-bottom: 0; /* No margin in compact mode */
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    background: rgba(37, 99, 235, 0.1);
    border-radius: 50%;
    border: 1px solid rgba(37, 99, 235, 0.3);
    flex-shrink: 0;
    transition: all 0.4s ease;
}

.milestone-card:hover .milestone-icon {
    margin: 0 auto 1.5rem auto; /* Center and add margin on hover */
    font-size: 3rem;
    width: 80px;
    height: 80px;
    background: rgba(37, 99, 235, 0.2);
    box-shadow: 0 0 20px var(--eco-primary);
}

.milestone-content {
    flex-grow: 1;
}

.milestone-year {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--eco-accent);
    margin-bottom: 0.2rem;
    font-weight: 700;
}

.milestone-content h3 {
    font-size: 1.1rem; /* Smaller initially */
    margin-bottom: 0;
    color: white;
    transition: font-size 0.3s ease;
}

.milestone-card:hover .milestone-content h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    text-shadow: 0 0 10px rgba(255,255,255,0.5);
}

/* Hide details initially */
.milestone-content p,
.milestone-content .btn-link,
.milestone-content .badge {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    margin: 0;
    transition: all 0.4s ease 0.1s; /* Slight delay */
}

/* Reveal details on hover */
.milestone-card:hover .milestone-content p,
.milestone-card:hover .milestone-content .btn-link,
.milestone-card:hover .milestone-content .badge {
    max-height: 200px; /* Arbitrary large height */
    opacity: 1;
    margin-bottom: 1rem;
}

.btn-link {
    color: var(--eco-primary);
    text-decoration: none;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: center; /* Center on card */
}

.btn-link:hover {
    color: var(--eco-accent);
    text-shadow: 0 0 8px var(--eco-accent);
}


/* --- Content Branches (Current Ecosystem) --- */
/* TECH NODE TRANSFORMATION (Branch) */
.branch-content {
    /* Base State: Compact Tech Strip */
    background: rgba(5, 10, 20, 0.6);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.05);
    border-left: 3px solid var(--eco-primary); /* Tech accent on left */
    border-radius: 12px;
    padding: 1rem 1.5rem;
    max-width: 300px; /* Compact width */
    opacity: 0; /* Handled by JS assembly */
    transform: translateY(20px);
    transition: var(--eco-transition);
    position: relative;
    z-index: 2;

    display: flex;
    align-items: center;
    gap: 1rem;

    animation: float-node 7s ease-in-out infinite reverse; /* Reverse float for variety */
}

.branch-content:hover {
    background: rgba(15, 23, 42, 0.95);
    border-color: var(--eco-accent);
    box-shadow: 0 0 40px rgba(0,0,0,0.5), inset 0 0 20px rgba(37, 99, 235, 0.1);
    max-width: 500px; /* Expand width */
    padding: 2.5rem;
    display: block; /* Stack */
    border-radius: 20px;
    z-index: 20; /* Pop to front */
}

.branch-content.visible {
    opacity: 1;
    transform: translate(var(--px, 0px), var(--py, 0px));
}

.branch-icon {
    font-size: 1.5rem;
    margin-bottom: 0;
    color: var(--eco-accent);
    background: transparent;
    width: auto;
    height: auto;
    display: block;
    transition: all 0.3s ease;
}

.branch-content:hover .branch-icon {
    font-size: 2.5rem;
    margin-bottom: 1.5rem;
    width: 60px;
    height: 60px;
    background: rgba(37, 99, 235, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
}

.branch-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 0;
    color: white;
    white-space: nowrap; /* Keep on one line initially */
    transition: font-size 0.3s ease;
}

.branch-content:hover .branch-title {
    font-size: 1.75rem;
    margin-bottom: 0.75rem;
    white-space: normal;
}

/* Hide details initially */
.branch-desc,
.branch-content ul,
.branch-content .counter,
.branch-content .btn,
.branch-opportunity,
.branch-stats {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    margin: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    transition: all 0.4s ease;
}

/* Reveal details on hover */
.branch-content:hover .branch-desc,
.branch-content:hover ul,
.branch-content:hover .btn,
.branch-content:hover .branch-opportunity {
    max-height: 500px; /* Allow enough height */
    opacity: 1;
    margin-bottom: 1.5rem !important;
}

/* Restore padding for opportunity box when visible */
.branch-content:hover .branch-opportunity {
    padding: 1rem !important;
}

/* Special case for counters div which is flex */
.branch-content:hover .branch-stats {
    display: flex; /* Restore flex */
    max-height: 100px;
    opacity: 1;
    margin-bottom: 1.5rem !important;
}

/* Node Icons (The anchors for the path) */
.node-icon-large {
    position: relative;
    z-index: 2;
    transition: transform 0.3s ease;
}
.node-icon-large:hover {
    transform: scale(1.1);
}

/* Badges */
.badge {
    display: inline-block;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 6px 16px;
    border-radius: 50px;
    font-size: 0.75rem;
    transition: all 0.3s ease;
}

.badge:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.badge-practical {
    background: rgba(37, 99, 235, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(37, 99, 235, 0.3);
}

.badge-community {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-innovation {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

/* Layout Variations using Grid Order */
@media (min-width: 900px) {
    /* For alternating layout, we can use CSS Grid ordering or simply trust the HTML structure */
    /* If we want to force specific sides: */

    /* Right Layout: Image/Icon on Right, Text on Left */
    /* Current HTML has [Icon] [Content]. So that's Left Layout. */

    /* To flip it for Right Layout: */
    .layout-right .grid-2 .branch-content {
        order: 1; /* First */
    }
    .layout-right .grid-2 div:not(.branch-content) {
        order: 2; /* Second */
    }
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    .central-hub {
        width: 150px;
        height: 150px;
    }

    .orbit-1 { width: 220px; height: 220px; }
    .orbit-2 { display: none; }

    .node-wrapper {
        padding: 4rem 0;
        min-height: auto;
    }

    .branch-content {
        width: 100%;
    }

    /* Compact Nodes Mobile */
    .compact-node-row.layout-left,
    .compact-node-row.layout-right {
        justify-content: center;
        padding-right: 0;
        padding-left: 0;
    }

    .milestone-wrapper.layout-left,
    .milestone-wrapper.layout-right {
        justify-content: center;
        padding-right: 0;
        padding-left: 0;
    }

    .node-compact {
        font-size: 0.8rem;
        padding: 0.4rem 1rem;
    }
}

/* Keyframes */
@keyframes pulse {
    0% { box-shadow: 0 0 40px var(--eco-glow); }
    50% { box-shadow: 0 0 80px var(--eco-glow), 0 0 20px var(--eco-primary); }
    100% { box-shadow: 0 0 40px var(--eco-glow); }
}

@keyframes float-node {
    0%, 100% { translate: 0 0; }
    50% { translate: 0 -12px; }
}

@keyframes spin {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

@keyframes spin-reverse {
    from { transform: translate(-50%, -50%) rotate(360deg); }
    to { transform: translate(-50%, -50%) rotate(0deg); }
}
