/* ==========================================================
   Global
========================================================== */

:root {

    --bg: #050505;
    --surface: #0b0b0b;
    --surface-light: #111111;

    --border: rgba(255,255,255,.08);
    --border-hover: rgba(255,255,255,.18);

    --text: #ffffff;
    --text-secondary: #9d9d9d;

    --blur: 18px;

}

* {

    margin: 0;
    padding: 0;
    box-sizing: border-box;

}

html,
body {

    width: 100%;
    height: 100%;

    overflow: hidden;

    background: var(--bg);

    color: var(--text);

    font-family: "Inter", sans-serif;

}

body {

    background:
        radial-gradient(circle at top, rgba(255,255,255,.025), transparent 55%),
        radial-gradient(circle at bottom right, rgba(255,255,255,.02), transparent 45%),
        var(--bg);

}

/* ==========================================================
   Main Layout
========================================================== */

main {

    --markdown-width: 420px;
    --sidebar-width: 320px;

    display: grid;

    grid-template-columns:
        var(--markdown-width)
        6px
        minmax(0, 1fr)
        var(--sidebar-width);

    grid-template-areas:
        "markdown resizer graph sidebar";

    /*
       The global header is fixed and therefore removed
       from normal document flow.

       header-offset.js dynamically sets --header-height.
       The main layout starts immediately below the header
       and occupies all remaining viewport height.
    */


    height: calc(100dvh - var(--header-height, 80px));

    min-height: 0;

    transition: grid-template-columns .25s ease;

}

main.is-collapsed {

    --markdown-width: 0px;

    grid-template-columns:
        0px
        0px
        minmax(0, 1fr)
        var(--sidebar-width);

}

/* ==========================================================
   Top Bar
========================================================== */

.topbar {

    height: 70px;

    display: flex;

    align-items: center;
    justify-content: space-between;

    padding: 0 2rem;

    border-bottom: 1px solid var(--border);

    background: rgba(5,5,5,.75);

    backdrop-filter: blur(var(--blur));

    position: sticky;

    top: 0;

    z-index: 1000;

}

.logo {

    color: white;

    text-decoration: none;

    font-size: 1.1rem;

    font-weight: 700;

    letter-spacing: -.02em;

}

.topbar nav {

    display: flex;

    align-items: center;

    gap: 1.5rem;

}

.topbar nav a {

    color: var(--text-secondary);

    text-decoration: none;

    transition: color .25s ease;

}

.topbar nav a:hover {

    color: white;

}

/* ==========================================================
   Markdown Panel
========================================================== */

#markdown-panel {

    grid-area: markdown;

    display: flex;

    flex-direction: column;

    overflow-y: auto;

    padding: 2rem;

    background: rgba(10,10,10,.92);

    backdrop-filter: blur(var(--blur));

    border-right: 1px solid var(--border);

    min-width: 0;
    width: 100%;

    transition: opacity .25s ease, transform .25s ease;

}

#markdown-panel.hidden {

    opacity: 0;
    transform: translateX(-16px);
    pointer-events: none;

}

.panel-resizer {

    grid-area: resizer;

    width: 6px;
    cursor: ew-resize;
    position: relative;
    background: transparent;
    transition: background-color .2s ease, opacity .25s ease;

}

.panel-resizer::before {

    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
    opacity: .8;

}

.panel-resizer:hover,
.panel-resizer.is-dragging {

    background: rgba(255,255,255,.12);

}

main.is-collapsed .panel-resizer {

    opacity: 0;
    pointer-events: none;

}

#markdown-content {

    line-height: 1.7;

    color: var(--text);

}

#markdown-content h1 {

    font-size: 2rem;
    margin: 1.5rem 0 1.25rem;

}

#markdown-content h2 {

    font-size: 1.6rem;
    margin: 2.5rem 0 1rem;

}

#markdown-content h3 {

    font-size: 1.3rem;
    margin: 2rem 0 0.75rem;

}

#markdown-content h4 {

    font-size: 1.1rem;
    margin: 1.5rem 0 0.5rem;

}

#markdown-content h5 {

    font-size: 1rem;
    margin: 1.25rem 0 0.5rem;

}

#markdown-content h6 {

    font-size: .9rem;
    margin: 1rem 0 0.5rem;

}

#markdown-content p {

    margin-bottom: 1.25rem;
    line-height: 1.8;

}

#markdown-content pre {

    overflow-x: auto;

    padding: 1rem;

    border-radius: 12px;

    background: #0d1117;

}

#markdown-content code {

    font-family: monospace;

}

/* ==========================================================
   Graph Area
========================================================== */

.graph-container {

    grid-area: graph;

    position: relative;

    z-index: 1;

    overflow: hidden;

    min-width: 0;
    min-height: 0;

    padding: 0;

    background:
        radial-gradient(
            circle at center,
            rgba(255,255,255,.03),
            transparent 65%
        );

}

#cy {

    z-index: 2;

    position: absolute;
    inset: 0;


}

/* ==========================================================
   Sidebar
========================================================== */

.sidebar {

    grid-area: sidebar;

    display: flex;

    flex-direction: column;

    gap: 1rem;

    padding: 1.2rem;

    background: rgba(10,10,10,.92);

    backdrop-filter: blur(var(--blur));

    border-left: 1px solid var(--border);

    overflow-y: auto;

    min-width: 0;

}

.sidebar h2 {

    font-size: 1.35rem;

    font-weight: 700;

}

.sidebar p {

    color: var(--text-secondary);

    line-height: 1.6;

}

.sidebar hr {

    border: none;

    border-top: 1px solid var(--border);

}

#node-info {

    display: flex;

    flex-direction: column;

    gap: .85rem;

}

.sidebar-card {

    background: rgba(255,255,255,.025);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.2rem;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.03);

}

.hero-card {

    background: linear-gradient(135deg, rgba(255,255,255,.045), rgba(255,255,255,.02));

}

.sidebar-title {

    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: .25rem;

}

.sidebar-subtitle {

    color: var(--text-secondary);
    font-size: .95rem;

}

.sidebar-section-title {

    font-size: .78rem;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: .9rem;

}

.sidebar-metrics-grid {

    display: grid;
    gap: 1rem;

}

.sidebar-metric {

    display: flex;
    flex-direction: column;
    gap: .35rem;

}

.sidebar-metric span {

    font-size: .74rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .08em;

}

.sidebar-metric strong {

    font-size: .95rem;
    font-weight: 600;
    line-height: 1.45;
    color: var(--text);

}

.sidebar-breadcrumb {

    display: flex;
    flex-direction: column;
    gap: .5rem;
    font-size: .92rem;
    color: var(--text-secondary);
    line-height: 1.65;

}

.sidebar-breadcrumb-root {

    color: var(--text);
    font-weight: 600;
    margin-bottom: .3rem;

}

.sidebar-breadcrumb-item {

    padding-left: 1rem;
    border-left: 2px solid rgba(255,255,255,.12);
    margin-left: 0;

}

.sidebar-actions {

    display: flex;
    flex-direction: column;
    gap: .6rem;

}

.sidebar-actions a {

    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: .7rem .9rem;
    border-radius: 10px;
    background: rgba(255,255,255,.06);
    color: var(--text);
    text-decoration: none;
    border: 1px solid rgba(255,255,255,.08);
    transition: background .2s ease, transform .2s ease;

}

.sidebar-actions a:hover {

    background: rgba(255,255,255,.1);
    transform: translateY(-1px);

}

#node-info h3 {

    font-size: 1.2rem;

}

#node-info p {

    color: var(--text-secondary);

}

/* ==========================================================
   Responsive
========================================================== */

@media (max-width: 1000px) {

    main,
    main.is-collapsed {

        grid-template-columns: 1fr;

        grid-template-areas: "graph";

    }

    .sidebar {

        display: none;

    }

}

/* ==========================================================
   Mobile Layout (phones / small tablets)
========================================================== */

.mobile-toggle {

    display: none;

    position: fixed;

    bottom: 1.1rem;

    z-index: 1200;

    width: 52px;
    height: 52px;

    border-radius: 50%;

    align-items: center;
    justify-content: center;

    background: rgba(20,20,20,.9);
    backdrop-filter: blur(var(--blur));

    border: 1px solid var(--border-hover);

    color: var(--text);

    font-size: 1.3rem;
    line-height: 1;

    box-shadow: 0 12px 30px rgba(0,0,0,.45);

    cursor: pointer;

}

.mobile-toggle--notes { left: 1.1rem; }
.mobile-toggle--info  { right: 1.1rem; }
.mobile-toggle.is-active {
    border-color: var(--border-hover);
    background: rgba(255,255,255,.12);
}

.panel-backdrop {

    display: none;

    position: fixed;
    inset: 0;

    background: rgba(0,0,0,.55);
    backdrop-filter: blur(2px);

    z-index: 1050;

    opacity: 0;
    transition: opacity .25s ease;

}

.panel-backdrop.is-visible {

    opacity: 1;

}

.panel-close {

    display: none;

    align-self: flex-end;

    width: 36px;
    height: 36px;

    border-radius: 50%;

    align-items: center;
    justify-content: center;

    background: rgba(255,255,255,.06);
    border: 1px solid var(--border);
    color: var(--text);

    font-size: 1.1rem;

    margin-bottom: 1rem;

}

@media (max-width: 760px) {

    main,
    main.is-collapsed {

        grid-template-columns: 1fr;

        grid-template-areas: "graph";

        height: calc(100dvh - var(--header-height, 60px));

    }

    .panel-resizer {

        display: none;

    }

    .topbar {

        height: 60px;

        padding: 0 1rem;

    }

    /* Markdown panel becomes a left-side drawer */
    #markdown-panel {

        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;

        width: min(88vw, 380px);

        z-index: 1100;

        border-right: 1px solid var(--border);

        transform: translateX(-100%);
        opacity: 1;
        pointer-events: auto;

        padding: 1.25rem;
        padding-top: calc(60px + 1rem);

    }

    #markdown-panel.mobile-open {

        transform: translateX(0);

    }

    #markdown-panel.hidden {

        /* on mobile "hidden" is controlled by mobile-open, not the desktop opacity rule */
        transform: translateX(-100%);
        opacity: 1;

    }

    /* Sidebar becomes a bottom sheet */
    .sidebar {

        display: flex;

        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;

        width: 100%;

        max-height: 75vh;

        border-left: none;
        border-top: 1px solid var(--border);

        border-radius: 20px 20px 0 0;

        z-index: 1100;

        transform: translateY(100%);
        transition: transform .28s ease;

    }

    .sidebar.mobile-open {

        transform: translateY(0);

    }

    .mobile-toggle {

        display: flex;

    }

    .panel-backdrop.is-visible {

        display: block;

    }

    .panel-close {

        display: flex;

    }

    .graph-container {

        grid-area: graph;

    }

    #cy {

        height: 100%;

    }

}

@media (max-width: 420px) {

    #markdown-panel {

        width: 100vw;

    }

    .sidebar-metrics-grid {

        grid-template-columns: 1fr;

    }

}

/* ==========================================================
   Cytoscape Visual Theme
========================================================== */

#cy canvas {

    cursor: grab;

}

#cy canvas:active {

    cursor: grabbing;

}

/* ==========================================================
   Sidebar Cards
========================================================== */

#node-info {

    padding: 1.25rem;

    border: 1px solid var(--border);

    border-radius: 16px;

    background: linear-gradient(
        180deg,
        rgba(255,255,255,.025),
        rgba(255,255,255,.01)
    );

    transition:
        border-color .25s ease,
        transform .25s ease,
        background .25s ease;

}

#node-info:hover {

    border-color: var(--border-hover);

    transform: translateY(-2px);

}

#node-info h3 {

    font-size: 1.2rem;

    font-weight: 700;

    color: white;

}

#node-info strong {

    color: white;

}

/* ==========================================================
   Scrollbar
========================================================== */

.sidebar::-webkit-scrollbar {

    width: 8px;

}

.sidebar::-webkit-scrollbar-track {

    background: transparent;

}

.sidebar::-webkit-scrollbar-thumb {

    background: rgba(255,255,255,.12);

    border-radius: 999px;

}

.sidebar::-webkit-scrollbar-thumb:hover {

    background: rgba(255,255,255,.25);

}

/* ==========================================================
   Selection
========================================================== */

::selection {

    background: rgba(255,255,255,.15);

    color: white;

}

/* ==========================================================
   Node Type Colors
========================================================== */

.root-node {

    color: #ffffff;

}

.category-node {

    color: #dcdcdc;

}

.note-node {

    color: #a8a8a8;

}

/* ==========================================================
   Glass Panels
========================================================== */

.sidebar,
.topbar {

    box-shadow:

        inset 0 1px 0 rgba(255,255,255,.03),

        0 20px 50px rgba(0,0,0,.35);

}



/* ==========================================================
   Fade In
========================================================== */

body {

    animation: pageFade .6s ease;

}

@keyframes pageFade {

    from {

        opacity: 0;

    }

    to {

        opacity: 1;

    }

}


/* ==========================================================
   Accessibility
========================================================== */

a:focus-visible,
button:focus-visible {

    outline: 2px solid rgba(255,255,255,.9);
    outline-offset: 4px;

    border-radius: 8px;

}

/* ==========================================================
   Smooth Rendering
========================================================== */

body,
.topbar,
.sidebar,
.graph-container {

    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;

}

/* ==========================================================
   Links
========================================================== */

a {

    transition:

        color .2s ease,
        opacity .2s ease;

}

a:hover {

    opacity: .95;

}

/* ==========================================================
   Images
========================================================== */

img {

    display: block;

    max-width: 100%;

    height: auto;

}

/* ==========================================================
   Horizontal Rules
========================================================== */

hr {

    opacity: .6;

}

/* ==========================================================
   Reduced Motion
========================================================== */

@media (prefers-reduced-motion: reduce) {

    * {

        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;

    }

}

/* ==========================================================
   High Contrast
========================================================== */

@media (prefers-contrast: more) {

    :root {

        --border: rgba(255,255,255,.22);
        --border-hover: rgba(255,255,255,.4);

        --text-secondary: #d5d5d5;

    }

}

/* ==========================================================
   Print
========================================================== */

@media print {

    .topbar,
    .sidebar {

        display: none;

    }

    main {

        display: block;

    }

    #cy {

        height: 100vh;

    }

}

.empty-note {
    min-height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 3rem;
    box-sizing: border-box;
}

.empty-note img {
    width: 120px;
    height: 120px;
    object-fit: contain;
    margin-bottom: 1.5rem;
    opacity: 0.85;
}

.empty-note h2 {
    margin: 0 0 0.6rem;
    font-size: 1.25rem;
    font-weight: 600;
}

.empty-note p {
    margin: 0;
    max-width: 420px;
    color: rgba(255, 255, 255, 0.55);
    line-height: 1.6;
}