/* ==========================================================================
   Notes + graph view. Consumes the design tokens defined in style.css.
   ========================================================================== */

/* Node colours: a colourblind-safe categorical set, stepped separately for
   the dark surface rather than flipped automatically. */
:root {
    --graph-bio: #2a78d6;
    --graph-research: #4a3aa7;
    --graph-project: #eb6834;
    --graph-concept: #008300;
    --graph-edge: #c3c8d2;
    --graph-label: #475467;
}

[data-theme="dark"] {
    --graph-bio: #3987e5;
    --graph-research: #9085e9;
    --graph-project: #d95926;
    --graph-concept: #1f9d4d;
    --graph-edge: #38424f;
    --graph-label: #93a0b4;
}

.topbar-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    flex: none;
}

.graph-toggle svg {
    display: block;
}

.graph-toggle[aria-pressed="true"] {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--surface-alt);
}

/* The whole panel is opt-in. */
[data-graph="off"] .graph-panel {
    display: none;
}

.graph-panel {
    margin: 2.5rem 0 3rem;
    padding: 1.25rem 1.25rem 1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.graph-head {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.graph-head h2 {
    margin: 0 0 0.15rem;
    font-size: 1.05rem;
}

.graph-sub {
    margin: 0;
    color: var(--muted);
    font-size: 0.87rem;
}

.graph-sub a {
    color: var(--accent-2);
    text-decoration: underline;
}

.graph-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem;
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 0.8rem;
    color: var(--muted);
}

.graph-legend li {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.dot {
    display: inline-block;
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 999px;
    flex: none;
}

.dot-bio { background: var(--graph-bio); }
.dot-research { background: var(--graph-research); }
.dot-project { background: var(--graph-project); }
.dot-concept { background: var(--graph-concept); }

.graph-stage {
    position: relative;
    height: 520px;
    border-radius: var(--radius-sm);
    background: var(--surface-alt);
    overflow: hidden;
}

#graph-canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
}

.graph-tooltip {
    position: absolute;
    z-index: 2;
    max-width: 15rem;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    box-shadow: var(--shadow);
    pointer-events: none;
    font-size: 0.82rem;
    line-height: 1.4;
}

.graph-tooltip strong {
    display: block;
    color: var(--text);
}

.graph-tooltip span {
    display: block;
    margin-top: 0.15rem;
    color: var(--muted);
}

.graph-fallback,
.graph-small-screen {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 1.5rem;
    text-align: center;
    color: var(--muted);
    font-size: 0.9rem;
}

.graph-fallback a,
.graph-small-screen a {
    color: var(--accent-2);
    text-decoration: underline;
}

.graph-fallback:not([hidden]) {
    display: flex;
}

/* Below the breakpoint the canvas is unusable: drag fights the scroll
   gesture and labels collide. Route to the list instead. */
@media (max-width: 767px) {
    #graph-canvas,
    .graph-legend {
        display: none;
    }

    .graph-small-screen {
        display: flex;
    }

    .graph-stage {
        height: 8rem;
    }
}

/* ------------------------------------------------------------ notes index */

.notes-page,
.note-page {
    padding: 2.5rem 0 4rem;
}

.notes-header h1,
.note-header h1 {
    margin: 0 0 0.5rem;
    font-size: clamp(1.8rem, 3vw, 2.4rem);
    letter-spacing: -0.02em;
}

.notes-intro {
    max-width: 62ch;
    color: var(--muted);
    margin: 0 0 0.5rem;
}

.notes-hint {
    color: var(--muted);
    font-size: 0.9rem;
    margin: 0;
}

.linklike {
    border: 0;
    background: none;
    padding: 0;
    font: inherit;
    color: var(--accent-2);
    text-decoration: underline;
    cursor: pointer;
}

/* The topbar is position:sticky, so an anchored jump would otherwise land the
   first heading underneath it. */
#all-notes {
    scroll-margin-top: 5.5rem;
}

/* style.css sets scroll-behavior: smooth globally. Honour the reduced-motion
   preference for the anchored jumps introduced here. */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
}

.notes-group {
    margin-top: 2.25rem;
}

.notes-groups > .notes-group:first-child {
    margin-top: 1.75rem;
}

.notes-group h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin: 0 0 0.85rem;
}

.notes-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr));
    gap: 0.75rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.notes-list a {
    display: block;
    height: 100%;
    padding: 0.9rem 1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    transition: border-color 0.2s ease, transform 0.2s ease;
}

.notes-list a:hover {
    border-color: var(--accent-2);
    transform: translateY(-1px);
}

.notes-list strong {
    display: block;
    color: var(--text);
}

.notes-list span {
    display: block;
    margin-top: 0.2rem;
    color: var(--muted);
    font-size: 0.85rem;
    line-height: 1.45;
}

/* ------------------------------------------------------------ single note */

.note-breadcrumb {
    margin-bottom: 1.25rem;
    font-size: 0.88rem;
}

.note-breadcrumb a {
    color: var(--muted);
}

.note-breadcrumb a:hover {
    color: var(--accent-2);
}

.note {
    max-width: 68ch;
}

.note-type {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--muted);
}

.note-summary {
    margin: 0.35rem 0 0;
    color: var(--muted);
    font-size: 1.02rem;
}

.note-header {
    padding-bottom: 1.25rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--line);
}

.note-body {
    font-size: 1.02rem;
    line-height: 1.75;
}

.note-body h2 {
    margin: 2rem 0 0.6rem;
    font-size: 1.2rem;
    letter-spacing: -0.01em;
}

.note-body p {
    margin: 0 0 1.1rem;
}

.note-body blockquote {
    margin: 0 0 1.4rem;
    padding: 0.75rem 1.1rem;
    border-left: 3px solid var(--accent-2);
    background: var(--muted-section-bg);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--muted);
}

.note-body blockquote p:last-child {
    margin-bottom: 0;
}

.note-body ul {
    margin: 0 0 1.2rem;
    padding-left: 1.2rem;
}

.note-body li {
    margin-bottom: 0.4rem;
}

.note-body a {
    color: var(--accent-2);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.note-body code {
    padding: 0.1rem 0.35rem;
    border-radius: 5px;
    background: var(--surface-alt);
    font-size: 0.9em;
}

/* A link pointing at a note that does not exist. Visible on purpose. */
.wikilink-missing {
    color: var(--muted);
    text-decoration: underline dotted;
    cursor: help;
}

.note-links {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
    gap: 1.5rem;
    max-width: 68ch;
    margin-top: 2.75rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--line);
}

.note-links h2 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--muted);
    margin: 0 0 0.65rem;
}

.note-links ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.note-links li {
    margin-bottom: 0.4rem;
}

.note-links a {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    color: var(--text);
    font-size: 0.92rem;
}

.note-links a:hover {
    color: var(--accent-2);
}
