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

body {
    font-family: 'IBM Plex Mono', monospace;
    background: #fafafa;
    color: #1a1a1a;
    overflow: hidden;
    cursor: default;
}

#container {
    width: 100vw;
    height: 100vh;
    position: relative;
}

svg {
    display: block;
}
/*_______________________________________________________________________________ */
.link {
    stroke: #e0e0e0;
    stroke-width: 0.5px;
    /* opacity: 0.4; */
    opacity: 0.8;
}

.link.highlighted {
    stroke: #666;
    stroke-width: 1.5px;
    /* opacity: 0.8; */
    opacity: 1;
}

/*_______________________________________________________________________________ */
.node circle {
    cursor: pointer;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    /* transition: all 0.30s cubic-bezier(0.4, 0, 0.2, 1); */
}

.node:hover circle {
    filter: brightness(0.9);
}

.node.selected circle {
    stroke: #1a1a1a;
    stroke-width: 2px;
}

.node text {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 9px;
    font-weight: 300;
    fill: #666;
    pointer-events: none;
    text-anchor: middle;
    opacity: 0;
    transition: opacity 0.2s;
}

.node:hover text,
.node.selected text,
.node.pinned text {
    opacity: 1;
}
/*_______________________________________________________________________________ */

#sidebar {
    position: fixed;
    top: 0;
    right: 0;
    /* width: 380px; */
    width: 420px;
    height: 100vh;
    background: #fff;
    border-left: 1px solid #e0e0e0;
    padding: 40px 32px;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    z-index: 1000;
}

#sidebar.active {
    transform: translateX(0);
}

#sidebar h2 {
    font-family: 'Newsreader', serif;
    font-size: 18px;
    /* font-size: 24px; */
    font-weight: 400;
    margin-bottom: 8px;
    color: #1a1a1a;
}

#sidebar .type {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #999;
    margin-bottom: 24px;
}

#sidebar .meta {
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid #f0f0f0;
}

#sidebar .meta-item {
    font-size: 11px;
    line-height: 1.8;
    color: #666;
}

#sidebar .meta-label {
    color: #999;
    display: inline-block;
    width: 80px;
}

#sidebar .statement {
    font-size: 12px;
    line-height: 1.7;
    color: #333;
    margin-top: 8px;
    padding: 16px;
    background: #fafafa;
    border-left: 2px solid #e0e0e0;
}

/* KaTeX styling in sidebar */
#sidebar .statement .katex {
    font-size: 1em;
}

#sidebar .statement .katex-display {
    margin: 1em 0;
}

#sidebar .connections {
    font-size: 11px;
    line-height: 1.8;
}

#sidebar .connection-item {
    padding: 4px 0;
    color: #666;
    border-bottom: 1px solid #f5f5f5;
}

#sidebar .close {
    position: absolute;
    top: 32px;
    right: 32px;
    width: 24px;
    height: 24px;
    cursor: pointer;
    opacity: 0.4;
    transition: opacity 0.2s;
    z-index: 10;
}

#sidebar .close:hover {
    opacity: 1;
}

#sidebar .close::before,
#sidebar .close::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 1px;
    background: #1a1a1a;
    top: 50%;
    left: 0;
}

#sidebar .close::before {
    transform: rotate(45deg);
}

#sidebar .close::after {
    transform: rotate(-45deg);
}

/*_______________________________________________________________________________ */

#legend {
    position: fixed;
    bottom: 32px;
    left: 32px;
    background: #fff;
    border: 1px solid #e0e0e0;
    padding: 24px;
    /* padding: 32px; */
    max-width: 240px;
    z-index: 100;
}

#legend h3 {
    font-family: 'Newsreader', serif;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 16px;
    color: #999;
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    font-size: 10px;
    color: #666;
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 12px;
    flex-shrink: 0;
}
/*_______________________________________________________________________________ */

#controls {
    position: fixed;
    top: 32px;
    left: 32px;
    display: flex;
    gap: 16px;
    z-index: 100;
}

button {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 10px 16px;
    background: #fff;
    border: 1px solid #e0e0e0;
    color: #666;
    cursor: pointer;
    transition: all 0.15s;
}

button:hover {
    background: #1a1a1a;
    color: #fff;
    border-color: #1a1a1a;
}

button.active {
    background: #1a1a1a;
    color: #fff;
    border-color: #1a1a1a;
}
/*_______________________________________________________________________________ */
#stats {
    position: fixed;
    top: 32px;
    right: 32px;
    font-size: 10px;
    color: #999;
    text-align: right;
    line-height: 1.6;
    z-index: 100;
}

.stat-value {
    color: #1a1a1a;
    font-weight: 500;
}

/* RESPONSIVENESS */
/*_______________________________________________________________________________ */
/* Tablet (768px - 1024px) */
@media (max-width: 1024px) and (min-width: 768px) {
    #sidebar {
        width: 340px;
    }

    #legend {
        bottom: 20px;
        left: 20px;
        padding: 20px;
    }

    #controls {
        top: 20px;
        left: 20px;
        gap: 12px;
    }

    button {
        padding: 8px 14px;
        font-size: 9px;
    }

    #stats {
        top: 20px;
        right: 20px;
    }
}

/*_______________________________________________________________________________ */
/* Mobile (< 768px)*/
@media (max-width: 768px) {

    /* sidebar slides from bottom instead*/
    #sidebar {
        top: auto;
        bottom: 0;
        right: 0;
        left: 0;
        width: 100vw;
        height: 70vh;
        max-height: 70vh;
        border-left: none;
        border-top: 1px solid #e0e0e0;
        padding: 24px 20px;
        transform: translateY(100%);
        border-radius: 16px 16px 0 0;
    }

    #sidebar.active {
        transform: translateY(0);
    }

    #sidebar .close {
        top: 20px;
        right: 20px;
    }

    #sidebar h2 {
        font-size: 16px;
        padding-right: 30px;
    }

    #sidebar .type {
        font-size: 9px;
        margin-bottom: 16px;
    }

    #sidebar .meta-item {
        font-size: 10px;
    }

    #sidebar .meta-label {
        width: 70px;
    }

    #sidebar .statement {
        font-size: 11px;
        padding: 12px;
    }

    #sidebar .connections {
        font-size: 10px;
    }

    /*controls - stack vertically */
    #controls {
        top: 16px;
        left: 16px;
        flex-direction: column;
        gap: 8px;
    }

    button {
        padding: 8px 12px;
        font-size: 9px;
        width: 80px;
        text-align: center;
    }

    /*stats - move to top left under controls */
    #stats {
        top: auto;
        bottom: 16px;
        right: 16px;
        left: auto;
        font-size: 9px;
    }

    /* legend - smaller, top right */
    #legend {
        top: 16px;
        right: 16px;
        bottom: auto;
        left: auto;
        padding: 16px;
        max-width: 160px;
    }

    #legend h3 {
        font-size: 9px;
        margin-bottom: 12px;
    }

    .legend-item {
        margin-bottom: 8px;
        font-size: 9px;
    }

    .legend-dot {
        width: 6px;
        height: 6px;
        margin-right: 8px;
    }

    /*node labels slightly larger on mobile */
    .node text {
        font-size: 10px;
    }

    /* then, improve touch targets */
    .node circle {
        stroke-width: 3px;
    }

    .node.selected circle {
        stroke-width: 4px;
    }
}

/*_______________________________________________________________________________ */
/* Landscape mode on mobile */
@media (max-width: 768px) and (orientation: landscape) {
    #sidebar {
        height: 85vh;
        max-height: 85vh;
    }

    #controls {
        flex-direction: row;
    }

    button {
        width: auto;
        padding: 6px 12px;
    }
}