/**
 * COMPONENT: Interactive Analysis Pipeline + Trust Architecture
 * Replaces the static ASCII pipeline box with clickable steps,
 * expandable detail panels, and a 3-layer trust section.
 *
 * Light/Dark mode support via data-theme attribute.
 * Mobile-first responsive — stacks at 768px.
 */

/* =========================================
   PIPELINE FLOW — 4-step horizontal
   ========================================= */
.pipeline-flow {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    margin-bottom: 12px;
    position: relative;
}

/* Connecting line behind the step nodes */
.pipeline-flow::before {
    content: '';
    position: absolute;
    top: 28px;
    left: 40px;
    right: 40px;
    height: 2px;
    background: var(--border-subtle);
    z-index: 0;
}

.pl-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 1;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.pl-step-num {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono, 'IBM Plex Mono', monospace);
    font-size: 0.8rem;
    font-weight: 700;
    border: 2px solid var(--border-subtle);
    background: var(--bg-card);
    color: var(--text-tertiary);
    margin-bottom: 14px;
    transition: all 0.25s ease;
    position: relative;
}

.pl-step:hover .pl-step-num {
    border-color: var(--gpt-color);
    color: var(--gpt-color);
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.08);
}

.pl-step.active .pl-step-num {
    border-color: var(--gpt-color);
    background: var(--gpt-color);
    color: #fff;
    box-shadow: 0 0 16px rgba(16, 185, 129, 0.2);
}

/* Pulse ring on active node */
.pl-step.active .pl-step-num::after {
    content: '';
    position: absolute;
    inset: -6px;
    border: 2px solid var(--gpt-color);
    opacity: 0;
    animation: plStepPing 2s ease-out infinite;
}
@keyframes plStepPing {
    0%   { opacity: 0.5; transform: scale(0.92); }
    100% { opacity: 0;   transform: scale(1.15); }
}

.pl-step-title {
    font-family: var(--font-display, 'Space Grotesk', sans-serif);
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: -0.01em;
    color: var(--text-primary);
    margin-bottom: 4px;
    text-align: center;
    transition: color 0.25s;
}
.pl-step.active .pl-step-title { color: var(--gpt-color); }

.pl-step-sub {
    font-family: var(--font-mono, monospace);
    font-size: 0.65rem;
    color: var(--text-tertiary);
    text-align: center;
    line-height: 1.4;
    max-width: 160px;
}

/* =========================================
   DETAIL PANEL — expands under selected step
   ========================================= */
.pl-detail-panel {
    margin-top: 8px;
    margin-bottom: 48px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-card);
    overflow: hidden;
}

.pl-detail-header {
    padding: 14px 24px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-input);
}

.pl-detail-tag {
    font-family: var(--font-mono, monospace);
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--gpt-color);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    background: rgba(16, 185, 129, 0.1);
    padding: 3px 8px;
    white-space: nowrap;
}

.pl-detail-title {
    font-family: var(--font-display, 'Space Grotesk', sans-serif);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.pl-detail-body {
    padding: 24px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.pl-detail-col h4 {
    font-family: var(--font-mono, monospace);
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-tertiary);
    margin-bottom: 12px;
    font-weight: 700;
}

.pl-detail-col ul { list-style: none; margin: 0; padding: 0; }

.pl-detail-col li {
    font-family: var(--font-mono, monospace);
    font-size: 0.78rem;
    color: var(--text-secondary);
    padding: 6px 0;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: flex-start;
    gap: 8px;
    line-height: 1.5;
}
.pl-detail-col li:last-child { border-bottom: none; }

.pl-li-marker {
    color: var(--gpt-color);
    font-weight: 700;
    flex-shrink: 0;
    font-size: 0.7rem;
    margin-top: 2px;
}
.pl-li-marker.warn { color: var(--accent-orange, #f97316); }
.pl-li-marker.info { color: var(--accent-cyan, #06b6d4); }

/* =========================================
   TRUST ARCHITECTURE — 3 verification layers
   ========================================= */
.trust-section {
    margin-bottom: 60px;
}

.trust-layers {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
    border: 1px solid var(--border-subtle);
    background: var(--bg-card);
}

.trust-layer {
    padding: 28px 24px;
    border-right: 1px solid var(--border-subtle);
    position: relative;
    transition: background 0.2s;
}
.trust-layer:last-child { border-right: none; }
.trust-layer:hover { background: var(--bg-input); }

/* Connector arrow between layers */
.trust-layer:not(:last-child)::after {
    content: '▸';
    position: absolute;
    right: -7px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.9rem;
    color: var(--border-focus);
    z-index: 2;
    background: var(--bg-card);
    padding: 2px 0;
}

.tl-badge {
    font-family: var(--font-mono, monospace);
    font-size: 0.55rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 3px 8px;
    margin-bottom: 14px;
    display: inline-block;
}
.tl-badge.runtime {
    color: var(--accent-green-deep, #166534);
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.25);
}
.tl-badge.reasoning {
    color: #7c3aed;
    background: rgba(124, 58, 237, 0.08);
    border: 1px solid rgba(124, 58, 237, 0.2);
}
.tl-badge.post {
    color: var(--accent-orange, #f97316);
    background: rgba(249, 115, 22, 0.08);
    border: 1px solid rgba(249, 115, 22, 0.2);
}

.tl-layer-ref {
    font-family: var(--font-mono, monospace);
    font-size: 0.6rem;
    color: var(--text-tertiary);
    margin-bottom: 10px;
    font-weight: 600;
}

.tl-title {
    font-family: var(--font-display, 'Space Grotesk', sans-serif);
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.tl-desc {
    font-family: var(--font-mono, monospace);
    font-size: 0.72rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 16px;
}

.tl-catches { list-style: none; margin: 0; padding: 0; }
.tl-catches li {
    font-family: var(--font-mono, monospace);
    font-size: 0.68rem;
    color: var(--text-tertiary);
    padding: 4px 0;
    display: flex;
    align-items: center;
    gap: 6px;
}
.tl-catches li::before {
    content: '→';
    color: var(--border-focus);
    font-weight: 600;
}

/* =========================================
   DARK MODE OVERRIDES
   ========================================= */
html[data-theme="dark"] .pl-step.active .pl-step-num {
    color: #060d1b;
}
html[data-theme="dark"] .pl-detail-tag {
    background: rgba(52, 211, 153, 0.12);
}
html[data-theme="dark"] .tl-badge.reasoning {
    color: #a78bfa;
    background: rgba(167, 139, 250, 0.1);
    border-color: rgba(167, 139, 250, 0.25);
}
html[data-theme="dark"] .trust-layer:not(:last-child)::after {
    background: var(--bg-card);
}

/* =========================================
   RESPONSIVE — Mobile
   ========================================= */
@media (max-width: 768px) {
    /* Pipeline: 2x2 grid on tablet, remove the connecting line */
    .pipeline-flow {
        grid-template-columns: repeat(2, 1fr);
        gap: 28px 0;
    }
    .pipeline-flow::before { display: none; }

    /* Detail panel: single column */
    .pl-detail-body {
        grid-template-columns: 1fr;
        padding: 16px;
    }
    .pl-detail-header { padding: 12px 16px; }

    /* Trust: stack vertically */
    .trust-layers { grid-template-columns: 1fr; }
    .trust-layer {
        border-right: none;
        border-bottom: 1px solid var(--border-subtle);
        padding: 22px 20px;
    }
    .trust-layer:last-child { border-bottom: none; }
    .trust-layer:not(:last-child)::after { display: none; }
}

@media (max-width: 480px) {
    /* Pipeline: still 2x2 but tighter */
    .pl-step-num {
        width: 46px;
        height: 46px;
        font-size: 0.7rem;
    }
    .pl-step-title { font-size: 0.75rem; }
    .pl-step-sub { font-size: 0.58rem; max-width: 130px; }

    .pl-detail-col li { font-size: 0.72rem; }
    .pl-detail-tag { font-size: 0.58rem; }
    .pl-detail-title { font-size: 0.85rem; }

    .tl-title { font-size: 0.9rem; }
    .tl-desc { font-size: 0.68rem; }
    .tl-catches li { font-size: 0.62rem; }
}
