/* supplychain.observer - Analysis Purple Dashboard */

:root {
    --deep-bg: #0D0A1A;
    --panel-bg: #1A1330;
    --elevated-surface: #2A1F3D;
    --electric-violet: #7B3FE4;
    --neon-orchid: #B44AFF;
    --pulse-cyan: #00E5CC;
    --warning-amber: #FFB020;
    --text-primary: #E8E4F0;
    --text-secondary: #9088A8;
    --text-tertiary: #5C5475;
    --phantom-line: #241D38;
    --confirm-green: #2ECC71;

    --font-mono: 'IBM Plex Mono', monospace;
    --font-heading: 'Space Grotesk', sans-serif;
    --font-body: 'Inter', sans-serif;

    --ease-mechanical: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    background: var(--deep-bg);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-weight: 400;
    font-feature-settings: "tnum" 1, "zero" 1;
    line-height: 1.5;
    overflow-x: hidden;
    display: flex;
    min-height: 100vh;
}

/* Navigation Rail */
#nav-rail {
    position: fixed;
    left: 0;
    top: 0;
    width: 48px;
    height: 100vh;
    background: var(--panel-bg);
    border-right: 1px solid var(--phantom-line);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 0;
    z-index: 100;
    transition: width 0.3s var(--ease-mechanical);
    overflow: hidden;
}

#nav-rail:hover {
    width: 180px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 32px;
    white-space: nowrap;
    width: 100%;
    padding: 0 12px;
}

.nav-brand-icon {
    color: var(--electric-violet);
    font-size: 20px;
    flex-shrink: 0;
}

.nav-brand-text {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.08em;
    color: var(--text-primary);
    opacity: 0;
    transition: opacity 0.2s var(--ease-mechanical);
}

#nav-rail:hover .nav-brand-text {
    opacity: 1;
}

.nav-items {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    cursor: pointer;
    border-left: 2px solid transparent;
    transition: all 0.2s var(--ease-mechanical);
    white-space: nowrap;
}

.nav-item:hover {
    background: var(--elevated-surface);
    border-left-color: var(--text-tertiary);
}

.nav-item.active {
    border-left-color: var(--electric-violet);
    background: var(--elevated-surface);
}

.nav-item.active .nav-icon {
    stroke: var(--electric-violet);
}

.nav-icon {
    flex-shrink: 0;
    transition: stroke 0.2s var(--ease-mechanical);
}

.nav-label {
    font-family: var(--font-mono);
    font-size: clamp(0.65rem, 1vw, 0.75rem);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-secondary);
    opacity: 0;
    transition: opacity 0.2s var(--ease-mechanical);
}

#nav-rail:hover .nav-label {
    opacity: 1;
}

.nav-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    width: 100%;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 0;
    background: var(--confirm-green);
    flex-shrink: 0;
    animation: pulse-dot 2s infinite var(--ease-mechanical);
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Main Content */
#main-content {
    margin-left: 48px;
    width: calc(100% - 48px);
    min-height: 100vh;
}

.viewport-section {
    position: relative;
    border-bottom: 1px solid var(--phantom-line);
}

/* System Labels */
.system-label {
    font-family: var(--font-mono);
    font-size: clamp(0.7rem, 1vw, 0.85rem);
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.system-sublabel {
    font-family: var(--font-mono);
    font-size: clamp(0.6rem, 0.8vw, 0.72rem);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-tertiary);
}

/* Section Headers */
.section-header {
    padding: 24px 32px 16px;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    border-bottom: 1px solid var(--phantom-line);
}

/* ========================================
   SECTION 1: COMMAND VIEW
   ======================================== */
#command-view {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 360px;
    grid-template-rows: auto 1fr;
    grid-template-areas:
        "header header"
        "network context";
}

.command-header {
    grid-area: header;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 24px 32px;
    border-bottom: 1px solid var(--phantom-line);
}

.command-title-block {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.command-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: clamp(1.8rem, 3.5vw, 3.2rem);
    letter-spacing: -0.02em;
    color: var(--text-primary);
    line-height: 1.1;
}

.title-dot {
    color: var(--electric-violet);
}

.command-stats {
    display: flex;
    gap: 32px;
}

.stat-block {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.stat-value {
    font-family: var(--font-mono);
    font-size: clamp(1.2rem, 2vw, 1.8rem);
    font-weight: 600;
    color: var(--text-primary);
    font-feature-settings: "tnum" 1, "zero" 1;
}

.stat-value.anomaly {
    color: var(--warning-amber);
}

.stat-value.success {
    color: var(--confirm-green);
}

.stat-value.highlight {
    color: var(--pulse-cyan);
}

.stat-label {
    font-family: var(--font-mono);
    font-size: clamp(0.6rem, 0.8vw, 0.72rem);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-tertiary);
}

/* Network Container */
.network-container {
    grid-area: network;
    position: relative;
    overflow: hidden;
    background: var(--deep-bg);
    border-right: 1px solid var(--phantom-line);
}

.network-svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* Scan Line */
.scan-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, var(--electric-violet) 50%, transparent 100%);
    opacity: 0.15;
    animation: scan-sweep 8s linear infinite;
    pointer-events: none;
}

@keyframes scan-sweep {
    0% { transform: translateY(0); }
    100% { transform: translateY(calc(100vh - 80px)); }
}

/* Context Panel */
.command-context-panel {
    grid-area: context;
    background: var(--panel-bg);
    padding: 24px;
    overflow-y: auto;
}

.context-header {
    margin-bottom: 12px;
}

.inspector-content {
    padding: 12px;
    background: var(--elevated-surface);
    border: 1px solid var(--phantom-line);
    min-height: 120px;
    margin-bottom: 16px;
}

.inspector-placeholder {
    font-family: var(--font-mono);
    font-size: clamp(0.7rem, 1vw, 0.82rem);
    color: var(--text-tertiary);
    font-style: normal;
}

.inspector-data {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.inspector-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 4px 0;
    border-bottom: 1px solid var(--phantom-line);
}

.inspector-key {
    font-family: var(--font-mono);
    font-size: clamp(0.65rem, 0.9vw, 0.78rem);
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.inspector-val {
    font-family: var(--font-mono);
    font-size: clamp(0.7rem, 1vw, 0.85rem);
    font-weight: 600;
    color: var(--text-primary);
}

.inspector-val.cyan { color: var(--pulse-cyan); }
.inspector-val.amber { color: var(--warning-amber); }
.inspector-val.green { color: var(--confirm-green); }
.inspector-val.violet { color: var(--electric-violet); }

/* Alert Feed */
.alert-feed {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.alert-item {
    display: flex;
    gap: 12px;
    padding: 8px;
    background: var(--elevated-surface);
    border-left: 2px solid var(--phantom-line);
    font-size: clamp(0.65rem, 0.85vw, 0.75rem);
}

.alert-item.alert-warning {
    border-left-color: var(--warning-amber);
}

.alert-item.alert-critical {
    border-left-color: #E63946;
}

.alert-item.alert-info {
    border-left-color: var(--pulse-cyan);
}

.alert-time {
    color: var(--text-tertiary);
    white-space: nowrap;
    font-feature-settings: "tnum" 1;
}

.alert-msg {
    color: var(--text-secondary);
}

/* ========================================
   SECTION 2: SIGNAL FEED
   ======================================== */
#signal-feed {
    padding-bottom: 48px;
    background: var(--deep-bg);
}

.signal-card {
    margin: 32px;
    border: 1px solid var(--phantom-line);
    display: grid;
    transition: border-color 0.3s var(--ease-mechanical);
}

.signal-card:hover {
    border-color: var(--elevated-surface);
}

.signal-card.chart-dominant {
    grid-template-columns: 7fr 3fr;
}

.signal-card.text-dominant {
    grid-template-columns: 7fr 3fr;
}

.signal-viz {
    padding: 24px;
    border-right: 1px solid var(--phantom-line);
    background: var(--panel-bg);
}

.text-dominant .signal-viz {
    border-right: none;
    border-left: 1px solid var(--phantom-line);
}

.signal-viz-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 16px;
}

.signal-timestamp {
    font-family: var(--font-mono);
    font-size: clamp(0.6rem, 0.8vw, 0.7rem);
    color: var(--text-tertiary);
    letter-spacing: 0.04em;
}

.signal-chart {
    width: 100%;
    height: 180px;
    display: block;
}

.signal-text {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.signal-headline {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: clamp(1.1rem, 1.8vw, 1.5rem);
    letter-spacing: -0.02em;
    color: var(--text-primary);
    line-height: 1.3;
}

.signal-body {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(0.85rem, 1.1vw, 1rem);
    line-height: 1.65;
    color: var(--text-secondary);
}

/* Histogram Group */
.histogram-group {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 180px;
    padding-top: 16px;
}

.histogram-bar {
    width: 4px;
    background: linear-gradient(to top, var(--electric-violet), var(--neon-orchid));
    transition: height 1.2s var(--ease-mechanical);
}

/* Risk Matrix */
.risk-matrix {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding: 16px 0;
}

.risk-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 8px;
    background: var(--elevated-surface);
    border: 1px solid var(--phantom-line);
}

.risk-cell-label {
    font-family: var(--font-mono);
    font-size: clamp(0.55rem, 0.7vw, 0.65rem);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-tertiary);
    text-align: center;
}

.risk-cell-value {
    font-family: var(--font-mono);
    font-size: clamp(1rem, 1.5vw, 1.3rem);
    font-weight: 600;
}

.risk-high { color: var(--warning-amber); }
.risk-extreme { color: #E63946; }
.risk-moderate { color: var(--pulse-cyan); }
.risk-low { color: var(--confirm-green); }

/* ========================================
   SECTION 3: DEPENDENCY GRAPH
   ======================================== */
#dependency-graph {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--deep-bg);
}

.graph-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    min-height: 600px;
}

.dep-graph-svg {
    width: 100%;
    height: 100%;
    display: block;
    position: absolute;
    top: 0;
    left: 0;
}

.graph-legend {
    display: flex;
    gap: 24px;
    padding: 16px 32px;
    border-top: 1px solid var(--phantom-line);
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-dot {
    width: 10px;
    height: 10px;
}

.legend-label {
    font-family: var(--font-mono);
    font-size: clamp(0.6rem, 0.8vw, 0.72rem);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-tertiary);
}

/* ========================================
   SECTION 4: TIMELINE CORRIDOR
   ======================================== */
#timeline-corridor {
    min-height: 80vh;
    display: flex;
    flex-direction: column;
    background: var(--panel-bg);
}

.timeline-scroll-container {
    flex: 1;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    display: flex;
    flex-direction: column;
    position: relative;
}

.timeline-track {
    display: flex;
    min-width: max-content;
    flex: 1;
}

.timeline-epoch {
    width: 420px;
    min-width: 420px;
    scroll-snap-align: start;
    padding: 48px 32px 64px;
    border-right: 1px solid var(--phantom-line);
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.epoch-marker {
    width: 12px;
    height: 12px;
    background: var(--electric-violet);
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
}

.epoch-year {
    font-family: var(--font-mono);
    font-size: clamp(0.7rem, 1vw, 0.85rem);
    font-weight: 600;
    color: var(--electric-violet);
    letter-spacing: 0.08em;
}

.epoch-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: clamp(1.2rem, 2vw, 1.6rem);
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.epoch-desc {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(0.85rem, 1vw, 0.95rem);
    line-height: 1.65;
    color: var(--text-secondary);
}

.epoch-metric {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 8px;
    padding: 12px;
    background: var(--elevated-surface);
    border: 1px solid var(--phantom-line);
}

.metric-value {
    font-family: var(--font-mono);
    font-size: clamp(1.4rem, 2.5vw, 2rem);
    font-weight: 600;
    color: var(--text-primary);
    font-feature-settings: "tnum" 1;
}

.metric-value.anomaly { color: var(--warning-amber); }
.metric-value.success { color: var(--confirm-green); }
.metric-value.highlight { color: var(--pulse-cyan); }

.metric-label {
    font-family: var(--font-mono);
    font-size: clamp(0.6rem, 0.8vw, 0.7rem);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-tertiary);
}

.timeline-axis {
    height: 1px;
    background: var(--phantom-line);
    position: relative;
    margin: 0 32px;
    flex-shrink: 0;
}

/* ========================================
   SECTION 5: TERMINAL FOOTER
   ======================================== */
#terminal-footer {
    background: var(--deep-bg);
    padding: 32px;
}

.terminal-block {
    background: var(--panel-bg);
    border: 1px solid var(--phantom-line);
    padding: 24px;
    max-width: 800px;
}

.terminal-header {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--phantom-line);
}

.terminal-prompt {
    color: var(--confirm-green);
    font-family: var(--font-mono);
    font-size: clamp(0.7rem, 1vw, 0.85rem);
    font-weight: 600;
}

.terminal-cmd {
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: clamp(0.7rem, 1vw, 0.85rem);
}

.terminal-output {
    margin-bottom: 16px;
}

.terminal-output p {
    font-family: var(--font-mono);
    font-size: clamp(0.65rem, 0.9vw, 0.78rem);
    color: var(--text-secondary);
    line-height: 1.7;
}

.terminal-copyright {
    color: var(--text-tertiary);
}

.terminal-cursor-line {
    display: flex;
    gap: 8px;
    align-items: center;
}

.terminal-cursor {
    color: var(--confirm-green);
    font-family: var(--font-mono);
    font-size: clamp(0.7rem, 1vw, 0.85rem);
    animation: cursor-blink 1s step-end infinite;
}

@keyframes cursor-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* ========================================
   DOT MATRIX BACKGROUND
   ======================================== */
.network-container::before,
.graph-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: radial-gradient(circle, var(--phantom-line) 1px, transparent 1px);
    background-size: 20px 20px;
    pointer-events: none;
    z-index: 0;
}

.network-svg,
.dep-graph-svg {
    position: relative;
    z-index: 1;
}

/* ========================================
   SVG STYLES
   ======================================== */
.node-circle {
    transition: r 0.3s var(--ease-mechanical), fill-opacity 0.3s var(--ease-mechanical);
    cursor: pointer;
}

.node-circle:hover {
    fill-opacity: 1;
}

.edge-line {
    transition: stroke 0.3s ease-out, stroke-width 0.3s ease-out;
}

.edge-line.active {
    stroke: var(--electric-violet);
    stroke-width: 2;
}

/* Flow animation on edges */
.edge-flow {
    stroke-dasharray: 8 4;
    animation: flow-dash 2s linear infinite;
}

@keyframes flow-dash {
    to { stroke-dashoffset: -24; }
}

/* Node pulse animation */
@keyframes node-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

/* ========================================
   DATA VIZ DRAW ANIMATIONS
   ======================================== */
.chart-line {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 2s var(--ease-mechanical);
}

.chart-line.drawn {
    stroke-dashoffset: 0;
}

.chart-area {
    opacity: 0;
    transition: opacity 1.5s var(--ease-mechanical);
}

.chart-area.drawn {
    opacity: 1;
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 1024px) {
    #command-view {
        grid-template-columns: 1fr;
        grid-template-areas:
            "header"
            "network"
            "context";
    }

    .command-context-panel {
        border-top: 1px solid var(--phantom-line);
    }

    .network-container {
        border-right: none;
        min-height: 50vh;
    }

    .signal-card.chart-dominant,
    .signal-card.text-dominant {
        grid-template-columns: 1fr;
    }

    .signal-viz {
        border-right: none;
        border-bottom: 1px solid var(--phantom-line);
    }

    .text-dominant .signal-viz {
        border-left: none;
        border-top: 1px solid var(--phantom-line);
        border-bottom: none;
        order: 2;
    }

    .command-header {
        flex-direction: column;
        gap: 16px;
    }

    .command-stats {
        align-self: flex-start;
    }
}

@media (max-width: 768px) {
    #nav-rail {
        display: none;
    }

    #main-content {
        margin-left: 0;
        width: 100%;
    }

    .signal-card {
        margin: 16px;
    }

    .timeline-epoch {
        width: 320px;
        min-width: 320px;
        padding: 32px 24px 48px;
    }
}
