/* ============================================
   STAGE 2: HOW IT WORKS - BTrade AI Brain
   ============================================ */

.btrade-how-it-works {
    position: relative;
    width: 100%;
    padding: 40px 40px 20px;
    background: var(--btrade-bg-dark, #0a0a0f);
    overflow: hidden;
    font-family: "Inter", "IBM Plex Sans Arabic", sans-serif;
}

.hiw-container {
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    z-index: 2;
}

/* Header */
.hiw-header {
    text-align: center;
    margin-bottom: 60px;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.hiw-header.visible {
    opacity: 1;
    transform: translateY(0);
}

.hiw-badge {
    display: inline-block;
    padding: 8px 16px;
    border: 1px solid rgba(33, 150, 243, 0.3);
    border-radius: 20px;
    font-family: "Inter", sans-serif;
    font-size: 13px;
    font-weight: 500;
    color: #2196F3;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 20px;
    background: rgba(33, 150, 243, 0.05);
}

.hiw-title {
    font-family: "Poppins", "Cairo", sans-serif;
    font-size: 42px;
    font-weight: 800;
    color: #ffffff;
    margin-bottom: 16px;
    line-height: 1.2;
    background: linear-gradient(135deg, #ffffff 0%, #2196F3 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hiw-subtitle {
    font-family: "Inter", sans-serif;
    font-size: 18px;
    color: #8b949e;
    max-width: 600px;
    margin: 0 auto;
}

/* Main Grid */
.hiw-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 60px;
    align-items: center;
    margin-bottom: 50px;
}

/* Left: Visual */
.hiw-visual {
    opacity: 0;
    transform: translateX(-30px);
    transition: all 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.2s;
}

.hiw-visual.visible {
    opacity: 1;
    transform: translateX(0);
}

.cpu-wrapper {
    position: relative;
    background: rgba(22, 27, 34, 0.4);
    border: 1px solid rgba(48, 54, 61, 0.5);
    border-radius: 24px;
    padding: 30px;
    backdrop-filter: blur(10px);
}

.cpu-svg {
    width: 100%;
    height: auto;
    max-height: 300px;
}

/* SVG Animations */
.node {
    cursor: pointer;
    transition: all 0.3s ease;
    filter: url(#glow);
}

.node:hover {
    r: 12;
    filter: brightness(1.3);
}

.node.active {
    animation: pulse-node 2s ease-in-out infinite;
}

@keyframes pulse-node {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.2); }
}

.cpu-brain {
    cursor: pointer;
    transition: transform 0.3s ease;
}

.cpu-brain:hover {
    transform: translate(200px, 150px) scale(1.05);
}

.brain-circle {
    animation: rotate 10s linear infinite;
}

.brain-waves {
    animation: pulse-waves 2s ease-in-out infinite;
}

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

@keyframes pulse-waves {
    0%, 100% { opacity: 0.5; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.1); }
}

/* Particles */
.particle {
    opacity: 0;
    pointer-events: none;
}

.particle.active {
    animation: flow-particle 3s ease-in-out infinite;
}

@keyframes flow-particle {
    0% { opacity: 0; offset-distance: 0%; }
    20% { opacity: 1; }
    80% { opacity: 1; }
    100% { opacity: 0; offset-distance: 100%; }
}

/* Step Indicators */
.step-indicators {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 30px;
}

.step-dot {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(33, 150, 243, 0.1);
    border: 2px solid rgba(33, 150, 243, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.step-dot:hover {
    background: rgba(33, 150, 243, 0.2);
    transform: scale(1.1);
}

.step-dot.active {
    background: #2196F3;
    border-color: #2196F3;
    box-shadow: 0 0 20px rgba(33, 150, 243, 0.5);
}

.step-dot.active .step-number {
    color: #ffffff;
    font-weight: 700;
}

.step-number {
    font-family: "Poppins", sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: #8b949e;
    transition: color 0.3s;
}

/* Connection line between dots */
.step-dot:not(:last-child)::after {
    content: '';
    position: absolute;
    right: -22px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 2px;
    background: rgba(33, 150, 243, 0.2);
}

.step-dot.active:not(:last-child)::after {
    background: linear-gradient(90deg, #2196F3, rgba(33, 150, 243, 0.2));
}

/* Right: Content */
.hiw-content {
    opacity: 0;
    transform: translateX(30px);
    transition: all 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.4s;
}

.hiw-content.visible {
    opacity: 1;
    transform: translateX(0);
}

.dynamic-header {
    margin-bottom: 30px;
}

.step-title {
    font-family: "Poppins", sans-serif;
    font-size: 28px;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 12px;
    transition: all 0.3s ease;
}

.step-progress {
    width: 100%;
    height: 4px;
    background: rgba(48, 54, 61, 0.5);
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #2196F3, #00BCD4);
    width: 25%;
    transition: width 0.5s ease;
    border-radius: 2px;
}

/* Marketing Text */
.marketing-text-container {
    margin-bottom: 30px;
    min-height: 120px;
}

.marketing-prefix {
    font-family: "Inter", sans-serif;
    font-size: 14px;
    color: #6e7681;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 8px;
}

.typewriter-wrapper {
    font-family: "Poppins", sans-serif;
    font-size: 24px;
    font-weight: 600;
    color: #ffffff;
    line-height: 1.4;
}

.typewriter-cursor {
    color: #2196F3;
    animation: blink 1s step-end infinite;
}

@keyframes blink {
    50% { opacity: 0; }
}

/* Highlight Box */
.highlight-box {
    display: flex;
    align-items: center;
    gap: 16px;
    background: rgba(33, 150, 243, 0.1);
    border: 1px solid rgba(33, 150, 243, 0.3);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 30px;
    transition: all 0.3s ease;
}

.highlight-box:hover {
    background: rgba(33, 150, 243, 0.15);
    transform: translateX(5px);
}

.highlight-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #2196F3, #00BCD4);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    flex-shrink: 0;
}

.highlight-icon svg {
    width: 24px;
    height: 24px;
}

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

.highlight-label {
    font-family: "Inter", sans-serif;
    font-size: 12px;
    color: #8b949e;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.highlight-text {
    font-family: "Poppins", sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: #2196F3;
}

/* Features Loop */
.features-loop {
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: "Inter", sans-serif;
    font-size: 15px;
    color: #8b949e;
}

.loop-prefix {
    color: #6e7681;
    white-space: nowrap;
}

.text-loop-container {
    position: relative;
    height: 24px;
    overflow: hidden;
    flex: 1;
}

.loop-item {
    display: block;
    color: #ffffff;
    font-weight: 500;
    animation: text-loop 8s ease-in-out infinite;
    opacity: 0;
    transform: translateY(20px);
    position: absolute;
    width: 100%;
}

.loop-item:nth-child(1) { animation-delay: 0s; }
.loop-item:nth-child(2) { animation-delay: 2s; }
.loop-item:nth-child(3) { animation-delay: 4s; }
.loop-item:nth-child(4) { animation-delay: 6s; }

@keyframes text-loop {
    0%, 20% { opacity: 0; transform: translateY(20px); }
    25%, 45% { opacity: 1; transform: translateY(0); }
    50%, 100% { opacity: 0; transform: translateY(-20px); }
}

/* Stats Bar */
.hiw-stats {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 40px;
    padding: 30px;
    background: rgba(22, 27, 34, 0.4);
    border: 1px solid rgba(48, 54, 61, 0.5);
    border-radius: 16px;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.8s ease 0.6s;
}

.hiw-stats.visible {
    opacity: 1;
    transform: translateY(0);
}

.stat-item {
    text-align: center;
    position: relative;
}

.stat-item:not(:last-child)::after {
    content: '';
    position: absolute;
    right: -20px;
    top: 50%;
    transform: translateY(-50%);
    width: 1px;
    height: 30px;
    background: rgba(48, 54, 61, 0.5);
}

.stat-text {
    font-family: "Poppins", sans-serif;
    font-size: 16px;
    font-weight: 600;
    color: #ffffff;
    background: linear-gradient(135deg, #ffffff, #2196F3);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* CTA */
.hiw-cta {
    text-align: center;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.8s ease 0.8s;
}

.hiw-cta.visible {
    opacity: 1;
    transform: translateY(0);
}

.cta-button {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 18px 40px;
    background: linear-gradient(135deg, #2196F3, #00BCD4);
    color: #ffffff;
    font-family: "Poppins", sans-serif;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    border-radius: 12px;
    transition: all 0.3s ease;
    box-shadow: 0 10px 30px rgba(33, 150, 243, 0.3);
    margin-bottom: 16px;
}

.cta-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 40px rgba(33, 150, 243, 0.4);
}

.cta-arrow {
    width: 20px;
    height: 20px;
    transition: transform 0.3s ease;
}

.cta-button:hover .cta-arrow {
    transform: translateX(5px);
}

.cta-subtext {
    font-family: "Inter", sans-serif;
    font-size: 14px;
    color: #6e7681;
}

/* Background Glow */
.btrade-how-it-works::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 800px;
    height: 800px;
    background: radial-gradient(circle, rgba(33, 150, 243, 0.05), transparent 70%);
    pointer-events: none;
    z-index: 1;
}

/* Responsive */
@media (max-width: 1024px) {
    .hiw-grid {
        grid-template-columns: 1fr;
        gap: 40px;
    }
    
    .hiw-visual {
        order: 2;
    }
    
    .hiw-content {
        order: 1;
        text-align: center;
    }
    
    .highlight-box {
        justify-content: center;
    }
    
    .features-loop {
        justify-content: center;
    }
    
    .hiw-title {
        font-size: 32px;
    }
    
    .typewriter-wrapper {
        font-size: 20px;
    }
}

@media (max-width: 768px) {
    .btrade-how-it-works {
        padding: 60px 20px;
    }
    
    .hiw-stats {
        flex-direction: column;
        gap: 20px;
    }
    
    .stat-item:not(:last-child)::after {
        display: none;
    }
    
    .step-indicators {
        gap: 15px;
    }
    
    .step-dot {
        width: 35px;
        height: 35px;
    }
    
    .step-dot:not(:last-child)::after {
        width: 15px;
        right: -17px;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .node, .brain-circle, .brain-waves, .particle, .loop-item {
        animation: none;
    }
    
    .hiw-header, .hiw-visual, .hiw-content, .hiw-stats, .hiw-cta {
        opacity: 1;
        transform: none;
        transition: none;
    }
}