/**
 * COMPONENT: Pundit Neural Link
 * "Hardware connection" style button with sequential bot activation
 * Light/Dark mode support via data-theme attribute
 */

/* =========================================
   CONTAINER
   ========================================= */

.neural-link-wrapper {
    display: flex;
    align-items: center;
    background: var(--bg-card, #fafafa);
    border: 1px solid var(--border-subtle, #ddd);
    padding: 10px 14px;
    border-radius: 4px;
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
}

html[data-theme="dark"] .neural-link-wrapper {
    background: var(--bg-card, #1a1a1a);
    border-color: var(--border-subtle, #333);
}

/* =========================================
   THE BUTTON - matches live-terminal-badge
   ========================================= */

.btn-neural {
    position: relative;
    overflow: hidden;
    cursor: pointer;
    
    /* Clean brutalist look — no glow */
    background-color: var(--bg-main, #fff);
    color: #166534;
    border: 2px solid #16a34a;
    
    font-family: var(--font-mono, 'JetBrains Mono', 'Fira Code', 'Courier New', monospace);
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    border-radius: 3px;
    
    user-select: none;
    white-space: nowrap;
    transition: background-color 0.15s, border-color 0.15s;
}

html[data-theme="dark"] .btn-neural {
    background-color: #09090b;
    color: #4ade80;
    border-color: #22c55e;
}

.btn-neural:hover:not(.loading):not(:disabled) {
    background-color: #f0fdf4;
    border-color: #15803d;
}

html[data-theme="dark"] .btn-neural:hover:not(.loading):not(:disabled) {
    background-color: rgba(34, 197, 94, 0.1);
    border-color: #4ade80;
}

/* Ensure no weird outlines or shadows on text */
.btn-neural .btn-content,
.btn-neural .btn-text,
.btn-neural .bracket,
.btn-neural .cursor {
    text-shadow: none;
    outline: none;
    -webkit-text-stroke: 0;
    border: none;
    background: none;
    box-shadow: none;
}

.btn-neural:focus {
    outline: none;
}

.btn-neural:focus-visible {
    outline: 2px solid #16a34a;
    outline-offset: 2px;
}

/* Light mode specific - ensure clean text */
.btn-neural .btn-text {
    color: inherit;
}

.btn-neural:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-neural.loading {
    cursor: wait;
}

.btn-neural .btn-content {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 0;
}

.btn-neural .bracket {
    opacity: 0.7;
}

.btn-neural .btn-text {
    margin: 0 4px;
}

/* Blinking terminal cursor */
@keyframes cursorBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.btn-neural .cursor {
    animation: cursorBlink 1s step-end infinite;
}

.btn-neural .power-fill {
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: 0%;
    background: #16a34a;
    opacity: 0.12;
    z-index: 1;
}

html[data-theme="dark"] .btn-neural .power-fill {
    background: #22c55e;
    opacity: 0.18;
}

.btn-neural.loading .power-fill {
    width: 100%;
    transition: width var(--neural-duration, 10s) linear;
}

/* Progress track — thin bar along the bottom edge */
.btn-neural::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0;
    height: 3px;
    width: 0%;
    background: #16a34a;
    z-index: 3;
    border-radius: 0 0 2px 2px;
}

html[data-theme="dark"] .btn-neural::after {
    background: #4ade80;
}

.btn-neural.loading::after {
    width: 100%;
    transition: width var(--neural-duration, 10s) linear;
}

/* =========================================
   THE CONNECTOR LINE
   ========================================= */

.neural-connector {
    width: 40px;
    height: 2px;
    background: var(--border-subtle, #ddd);
    position: relative;
    overflow: hidden;
}

html[data-theme="dark"] .neural-connector {
    background: #333;
}

.neural-connector .signal-pulse {
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: var(--accent-green);
    opacity: 0;
}

/* =========================================
   THE AVATAR NODES
   ========================================= */

.node-cluster {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-left: 10px;
    border-left: 2px solid var(--border-subtle, #ddd);
}

html[data-theme="dark"] .node-cluster {
    border-left-color: #333;
}

.node-wrapper {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-input, #eee);
    padding: 3px;
    transition: all 0.3s var(--ease-snap);
    filter: grayscale(100%) opacity(0.4);
}

html[data-theme="dark"] .node-wrapper {
    background: #222;
}

.node-wrapper .avatar-svg {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
}

.node-wrapper.active {
    filter: grayscale(0%) opacity(1);
    background: #fff;
    border: 2px solid #16a34a;
    padding: 1px;
}

html[data-theme="dark"] .node-wrapper.active {
    background: #111;
    border-color: #22c55e;
}

@keyframes pulseNode {
    0% { transform: scale(1); }
    50% { transform: scale(1.12); }
    100% { transform: scale(1); }
}

.node-wrapper.processing {
    animation: pulseNode 1.2s ease-in-out infinite;
}

/* =========================================
   STATUS NOTE
   ========================================= */

.pundit-note {
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 0.68rem;
    color: var(--text-tertiary, #888);
    margin-left: 12px;
}

.pundit-note.success {
    color: var(--judge-color);
}

html[data-theme="dark"] .pundit-note.success {
    color: #22c55e;
}

/* =========================================
   CONTROLS LAYOUT
   ========================================= */

.pundit-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0 0 14px 0;
}

/* =========================================
   MOBILE RESPONSIVE
   ========================================= */

@media (max-width: 540px) {
    /* Stack the neural link vertically on mobile */
    .neural-link-wrapper {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 12px;
    }
    
    /* Button takes full width */
    .btn-neural {
        width: 100%;
        justify-content: center;
    }
    
    /* Hide the connector line on mobile */
    .neural-connector {
        display: none;
    }
    
    /* Node cluster: center and remove left border */
    .node-cluster {
        justify-content: center;
        border-left: none;
        padding-left: 0;
        gap: 12px;
    }
    
    /* Slightly larger touch targets on mobile */
    .node-wrapper {
        width: 36px;
        height: 36px;
    }
    
    /* Controls stack vertically */
    .pundit-controls {
        flex-direction: column;
        align-items: stretch;
    }
}
