/* Graph View Styles - D3.js Dark Theme */

/* Graph container takes full space */
#graph-view {
    background: linear-gradient(160deg, #0a0a12 0%, #12121f 40%, #1a1a28 70%, #0d1117 100%);
    cursor: grab;
}

#graph-view:active {
    cursor: grabbing;
}

#graph-container {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    opacity: 0;
    transition: opacity 0.6s ease;
}

#graph-container.loaded {
    opacity: 1;
}

/* Disable pointer events when graph is hidden (page is open) */
#graph-container.page-open {
    pointer-events: none;
}

/* D3.js SVG canvas */
#graph-container svg {
    display: block;
    width: 100%;
    height: 100%;
}

/* Graph loading state */
#graph-view .loading-overlay {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: transparent;
    z-index: 5;
    transition: opacity 0.4s ease;
}

#graph-view .loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

#graph-view .loading-spinner {
    width: 40px;
    height: 40px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top-color: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

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

#graph-view .loading-text {
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.9rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ========== D3 Graph Elements ========== */

/* Links (arrows) */
.link {
    stroke: rgba(255, 255, 255, 0.31);
    stroke-width: 3px;
    stroke-linecap: round;
    fill: none;
}

.link.chapter-link {
    stroke: rgba(255, 255, 255, 0.31);
}

.link.container-link {
    stroke: rgba(255, 255, 255, 0.25);
}

.link.highlighted {
    stroke: rgba(160, 218, 0, 0.6);
    stroke-width: 4px;
}

/* Container nodes */
.container-node circle {
    fill: none;
    stroke: rgba(255, 255, 255, 0.2);
    stroke-width: 3px;
}

.container-node.subject-container circle {
    stroke: rgba(255, 255, 255, 0.1);
    stroke-dasharray: 10 5;
}

.container-node text {
    fill: rgba(255, 255, 255, 0.4);
    font-family: CMSerif, serif;
    font-size: 16px;
    text-anchor: middle;
}

/* Chapter nodes */
.node {
    cursor: pointer;
}

.node .highlight-ring {
    fill: none;
    stroke: transparent;
    stroke-width: 3px;
    transition: stroke 0.2s ease;
}

.node.selected .highlight-ring,
.node.hovered .highlight-ring {
    stroke: rgb(160, 218, 0);
}

.node .glow {
    pointer-events: none;
}

.node .main-circle {
    transition: filter 0.2s ease;
}

.node.hovered .main-circle {
    filter: brightness(1.2);
}

.node image {
    pointer-events: none;
}

.node text {
    fill: white;
    font-family: CMSerif, serif;
    font-size: 13px;
    text-anchor: middle;
    pointer-events: none;
    line-height: 1.15;
}

.node text tspan {
    text-anchor: middle;
}

/* Bubble hover tooltip (if needed) */
.bubble-tooltip {
    position: fixed;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    pointer-events: none;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.2s;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.bubble-tooltip.visible {
    opacity: 1;
}

/* Graph controls overlay */
.graph-controls {
    position: absolute;
    right: 30px;
    bottom: 30px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 10;
}

.graph-control-btn {
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    color: white;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.graph-control-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Responsive adjustments */
@media (max-width: 900px) {
    .graph-header {
        left: 100px;
    }
}

@media (max-width: 600px) {
    .graph-header {
        left: 20px;
        top: 20px;
    }

    .graph-header h1 {
        font-size: 1.8rem;
    }

    .graph-controls {
        right: 20px;
        bottom: 90px;
    }
}
