/* ========================================
   Knowledge Graph Styles
   ======================================== */

/* Hide date hero when knowledge-graph tab is active */
.hide-date-hero .date-hero {
    display: none !important;
}

/* Graph container */
#knowledgeGraphTab {
    position: relative;
    min-height: 80vh;
}

#graphCanvas {
    width: 100%;
    height: 70vh;
    min-height: 400px;
    background:
        radial-gradient(circle at 50% 45%, rgba(125, 211, 192, 0.14), transparent 38%),
        linear-gradient(180deg, rgba(12, 14, 20, 0.82), rgba(7, 9, 14, 0.96));
    border-radius: var(--radius);
    border: 1px solid rgba(125, 211, 192, 0.12);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
    overflow: hidden;
    position: relative;
}

.graph-hud {
    position: absolute;
    left: 20px;
    bottom: 20px;
    width: min(420px, calc(100% - 40px));
    padding: 14px;
    border-radius: 16px;
    background: rgba(8, 10, 15, 0.76);
    border: 1px solid rgba(125, 211, 192, 0.16);
    backdrop-filter: blur(16px);
    z-index: 8;
}

.graph-hud-title {
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent-teal);
    margin-bottom: 8px;
}

.graph-hud-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.graph-hud-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.graph-hud-chip {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 8px 10px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    cursor: pointer;
}

.graph-hud-chip-name {
    font-size: 12px;
    font-weight: 600;
}

.graph-hud-chip-meta {
    font-size: 10px;
    color: var(--text-muted);
}

/* Loading overlay */
.graph-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border-radius: var(--radius);
    z-index: 10;
}

.graph-loading-text {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 16px;
}

.graph-loading-spinner {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid rgba(125, 211, 192, 0.16);
    border-top-color: var(--accent-teal);
    animation: graph-spin 0.9s linear infinite;
}

.graph-progress {
    width: 200px;
    height: 4px;
    background: var(--bg-glass);
    border-radius: 2px;
    margin-top: 12px;
    overflow: hidden;
}

.graph-progress-bar {
    height: 100%;
    background: var(--accent-teal);
    width: 0%;
    transition: width 0.3s ease;
}

@keyframes graph-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Controls panel - left side */
.graph-controls {
    position: absolute;
    top: 80px;
    left: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 16px;
    backdrop-filter: blur(12px);
    max-width: 240px;
    z-index: 50;
}

.control-group {
    margin-bottom: 14px;
}

.control-group:last-child {
    margin-bottom: 0;
}

.control-label {
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    margin-bottom: 8px;
    display: block;
    font-weight: 500;
}

/* Filter chips */
.control-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.filter-chip {
    display: inline-flex;
    padding: 5px 10px;
    background: var(--bg-glass);
    color: var(--text-secondary);
    border: 1px solid var(--border-glass);
    border-radius: 100px;
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
}

.filter-chip:hover {
    border-color: var(--accent-teal-dim);
    color: var(--text-primary);
}

.filter-chip.active {
    background: rgba(125, 211, 192, 0.15);
    border-color: var(--accent-teal);
    color: var(--accent-teal);
}

/* Toggle switches */
.control-toggles {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-secondary);
}

.toggle-label input {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-teal);
}

.toggle-label:hover {
    color: var(--text-primary);
}

/* Control button */
.control-btn {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
}

.control-btn:hover {
    background: var(--accent-teal);
    border-color: var(--accent-teal);
    color: #fff;
}

/* Legend - bottom right */
.graph-legend {
    position: absolute;
    bottom: 100px;
    right: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 12px 16px;
    backdrop-filter: blur(12px);
    z-index: 50;
}

.graph-inspector {
    position: absolute;
    top: 80px;
    right: 20px;
    width: min(320px, calc(100vw - 40px));
    background: rgba(12, 14, 20, 0.82);
    border: 1px solid rgba(125, 211, 192, 0.2);
    border-radius: var(--radius);
    padding: 18px;
    backdrop-filter: blur(18px);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.18);
    z-index: 50;
}

[data-theme="light"] .graph-inspector {
    background: rgba(255, 252, 247, 0.9);
    border-color: rgba(45, 122, 106, 0.16);
}

.inspector-eyebrow {
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent-teal);
    margin-bottom: 10px;
}

.inspector-title {
    font-size: 22px;
    line-height: 1.15;
    margin: 0 0 10px;
    color: var(--text-primary);
}

.inspector-summary {
    margin: 0;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary);
}

.inspector-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.inspector-pill {
    display: inline-flex;
    align-items: center;
    padding: 5px 10px;
    border-radius: 999px;
    background: rgba(125, 211, 192, 0.12);
    color: var(--text-secondary);
    font-size: 12px;
    border: 1px solid rgba(125, 211, 192, 0.18);
}

.inspector-actions {
    display: flex;
    gap: 10px;
    margin-top: 14px;
}

.inspector-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    border-radius: 8px;
    background: var(--accent-teal);
    color: #fff;
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
}

.inspector-link:hover {
    opacity: 0.9;
}

.inspector-section {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

[data-theme="light"] .inspector-section {
    border-top-color: rgba(0, 0, 0, 0.08);
}

.inspector-section-title {
    font-size: 11px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.inspector-metrics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.inspector-metric {
    padding: 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

[data-theme="light"] .inspector-metric {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.05);
}

.inspector-metric-label {
    display: block;
    font-size: 10px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.inspector-metric-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

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

.inspector-relation {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

[data-theme="light"] .inspector-relation {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.05);
}

.inspector-relation-main {
    min-width: 0;
}

.inspector-relation-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.inspector-relation-meta {
    margin-top: 2px;
    font-size: 11px;
    color: var(--text-muted);
}

.inspector-relation-weight {
    font-size: 12px;
    font-weight: 700;
    color: var(--accent-teal);
    flex-shrink: 0;
}

.inspector-empty {
    font-size: 12px;
    color: var(--text-muted);
}

.legend-title {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-weight: 500;
}

.legend-items {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

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

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.legend-label {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Tooltip - follows cursor */
.graph-tooltip {
    position: fixed;
    background: var(--bg-card);
    border: 1px solid var(--accent-teal);
    border-radius: var(--radius-xs);
    padding: 12px 16px;
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow-hover);
    z-index: 100;
    display: none;
    pointer-events: none;
    max-width: 200px;
}

.graph-tooltip.visible {
    display: block;
}

.tooltip-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.tooltip-type {
    font-size: 10px;
    padding: 2px 6px;
    background: rgba(125, 211, 192, 0.1);
    color: var(--accent-teal);
    border-radius: 4px;
    text-transform: uppercase;
}

.tooltip-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.tooltip-stats {
    display: flex;
    gap: 16px;
}

.tooltip-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tooltip-stat .stat-label {
    font-size: 10px;
    color: var(--text-muted);
}

.tooltip-stat .stat-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--accent-teal);
}

/* Stats bar */
.graph-stats {
    display: flex;
    justify-content: center;
    gap: 32px;
    padding: 20px;
    background: var(--bg-glass);
    border-radius: var(--radius-xs);
    margin-top: 20px;
    border: 1px solid var(--border-glass);
}

.stat-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.stat-number {
    font-family: var(--font-serif);
    font-size: 28px;
    font-weight: 700;
    color: var(--accent-teal);
}

.stat-desc {
    font-size: 12px;
    color: var(--text-muted);
}

/* Node labels rendered via CSS2DRenderer */
.graph-node-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-primary);
    background: rgba(10, 10, 15, 0.7);
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
    pointer-events: none;
    text-shadow: 0 0 4px rgba(0,0,0,0.5);
}

[data-theme="light"] .graph-node-label {
    background: rgba(255, 255, 255, 0.85);
    color: var(--text-primary);
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .graph-controls {
        position: relative;
        top: 0;
        left: 0;
        max-width: none;
        margin-bottom: 16px;
        padding: 12px;
    }

    .graph-legend {
        position: relative;
        bottom: 0;
        right: 0;
        margin-top: 16px;
        padding: 10px 12px;
    }

    .graph-inspector {
        position: relative;
        top: 0;
        right: 0;
        width: auto;
        margin-top: 16px;
    }

    #graphCanvas {
        height: 50vh;
        min-height: 300px;
    }

    .graph-stats {
        gap: 20px;
        padding: 16px;
    }

    .stat-number {
        font-size: 22px;
    }

    .graph-tooltip {
        max-width: 160px;
        padding: 10px 12px;
    }
}

@media (max-width: 480px) {
    .control-chips {
        gap: 4px;
    }

    .filter-chip {
        padding: 4px 8px;
        font-size: 11px;
    }
}
