/* --- System Logic Flow Diagram --- */
.system-flow-section {
    background-color: #050505;
    padding: 80px 0;
    display: flex;
    justify-content: center;
    border-bottom: 1px solid #111;
}

.flow-container {
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 1200px;
    padding: 0 20px;
}

/* Nodes */
.flow-node {
    background-color: #0f0f0f;
    border: 1px solid #222;
    border-radius: 8px;
    padding: 20px 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    min-width: 140px;
    text-align: center;
    position: relative;
    z-index: 2;
    transition: transform 0.3s, border-color 0.3s;
}

.flow-node i {
    font-size: 1.5rem;
    color: #666;
}

.flow-node span {
    font-family: 'Fira Code', monospace;
    font-size: 0.85rem;
    color: #aaa;
}

/* Highlighted Core Node */
.core-node {
    border: 2px solid var(--primary-orange);
    background-color: #1a1a1a;
    box-shadow: 0 0 20px rgba(0, 229, 255, 0.15);
    padding: 30px 40px; /* Larger */
}

.core-node i {
    color: var(--primary-orange);
    font-size: 2rem;
}

.core-node span {
    color: white;
    font-weight: 700;
}

/* Connecting Lines */
.flow-line {
    flex-grow: 1;
    height: 2px;
    background-color: #222;
    position: relative;
    margin: 0 10px;
    z-index: 1;
}

/* --- "Color Transfer" Synchronized Flow --- */

/* 1. The Lines */
.flow-line {
    flex-grow: 1;
    height: 3px;
    background: #1a1a1a; /* Darker base to let packets pop */
    position: relative;
    margin: 0 10px;
    z-index: 1;
    overflow: visible; /* Allow glow to spill */
}

/* 2. The Data Burst (Cluster of Packets) */
.packet {
    opacity: 0;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    box-shadow: 0 0 15px currentColor;
}

/* 
   TIMING LOGIC:
   Total Cycle: 6 seconds.
   0s - 2s: Client -> Edge (White)
   2s - 4s: Edge -> Core (Green)
   4s - 6s: Core -> DB (Blue)
*/

/* --- Line 1: White Burst (0s start) --- */
.white-dot {
    background: white; color: white;
    animation: burstTravel 6s linear infinite;
}
.white-dot.pkt1 { animation-delay: 0.0s; }
.white-dot.pkt2 { animation-delay: 0.1s; }
.white-dot.pkt3 { animation-delay: 0.2s; }

/* --- Line 2: Green Burst (Starts at 2s) --- */
.green-dot {
    background: #27c93f; color: #27c93f;
    animation: burstTravel 6s linear infinite;
}
/* Fixed Selectors: Target the dot class directly */
.green-dot.pkt1 { animation-delay: 2.0s; }
.green-dot.pkt2 { animation-delay: 2.1s; }
.green-dot.pkt3 { animation-delay: 2.2s; }

/* --- Line 3: Blue Burst (Starts at 4s) --- */
.blue-dot {
    background: #00e5ff; color: #00e5ff;
    animation: burstTravel 6s linear infinite;
}
.blue-dot.pkt1 { animation-delay: 4.0s; }
.blue-dot.pkt2 { animation-delay: 4.1s; }
.blue-dot.pkt3 { animation-delay: 4.2s; }

@keyframes burstTravel {
    0% { left: 0; opacity: 1; transform: translateY(-50%) scale(1); }
    30% { left: 100%; opacity: 1; transform: translateY(-50%) scale(1); } /* Travel time approx 1.8s (30% of 6s) */
    31% { opacity: 0; }
    100% { opacity: 0; }
}


/* 3. Reactive Nodes (The "Impact") */

/* Edge Server (Hit at ~1.8s) 
   - Flashes White (Incoming)
   - Then turns Green (Processed)
*/
.flow-node:nth-child(3) {
    animation: edgeImpact 6s ease-out infinite;
}

@keyframes edgeImpact {
    0% { border-color: #333; box-shadow: none; color: #666; }
    28% { border-color: #333; box-shadow: none; transform: scale(1); }
    30% { border-color: white; box-shadow: 0 0 30px white; color: white; transform: scale(1.1); } /* HIT! */
    35% { border-color: #27c93f; box-shadow: 0 0 15px #27c93f; color: #27c93f; transform: scale(1); } /* Processed */
    90% { border-color: #333; box-shadow: none; color: #666; }
}

/* Core Server (Hit at ~3.8s) 
   - Flashes Green (Incoming)
   - Then turns Orange (Core Power)
*/
.flow-node:nth-child(5) {
    animation: coreImpact 6s ease-out infinite;
}

@keyframes coreImpact {
    0% { border-color: var(--primary-orange); box-shadow: none; }
    60% { border-color: var(--primary-orange); box-shadow: none; transform: scale(1); }
    63% { border-color: #27c93f; box-shadow: 0 0 40px #27c93f; transform: scale(1.15); } /* HIT by Green! */
    68% { border-color: var(--primary-orange); box-shadow: 0 0 30px var(--primary-orange); transform: scale(1); } /* Processing */
    100% { border-color: var(--primary-orange); }
}

/* DB Server (Hit at ~5.8s)
   - Flashes Blue (Incoming)
*/
.flow-node:nth-child(7) {
    animation: dbImpact 6s ease-out infinite;
}

@keyframes dbImpact {
    0% { border-color: #333; }
    93% { border-color: #333; transform: scale(1); }
    96% { border-color: #00e5ff; box-shadow: 0 0 30px #00e5ff; color: #00e5ff; transform: scale(1.1); } /* HIT by Blue! */
    100% { border-color: #333; color: #666; transform: scale(1); }
}

/* Responsive */
@media (max-width: 768px) {
    .packet { animation-name: burstTravelVertical !important; }
}

@keyframes burstTravelVertical {
    0% { top: 0; opacity: 1; }
    30% { top: 100%; opacity: 1; }
    31% { opacity: 0; }
    100% { opacity: 0; }
}
