/* Base structural styles - independent of theme */

:root {
    /* Layout widths for sidebars */
    --sidebar-left-width: 15%;
    --sidebar-right-width: 15%;
}

body {
    margin: 0;
    padding: 0;
    font-family:
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
        Arial, sans-serif;
    line-height: 1.6;
    background: var(--bg-primary);
    color: var(--text-primary);

    /* Always use 3-column grid layout */
    display: grid;
    grid-template-columns: var(--sidebar-left-width) 1fr var(
            --sidebar-right-width
        );
    gap: 2rem;
    padding: 2rem;
    min-height: 100vh;
    align-items: start;
}

.left-sidebar {
    position: sticky;
    top: 30vh;
    align-self: start;
    max-height: calc(100vh - 4rem);
}

.main-content {
    width: 100%;
    max-width: 1200px;
    padding: 1rem;
    margin: 0 auto;
    box-sizing: border-box;
}

/* File explorer in left sidebar */
.file-explorer {
    padding: 1rem;
    font-family:
        "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.85em;
    border: 1px solid var(--border-secondary);
    background: var(--bg-primary);
    max-height: calc(100vh - 60vh - 4rem);
    overflow-y: auto;
    box-sizing: border-box;
}

.toc {
    padding: 1em;
    background: var(--bg-tertiary);
    border-radius: 5px;
    border: 1px solid var(--border-secondary);
}

.toc summary {
    list-style: none;
    /*margin-bottom: 0.3em;*/
}

.toc summary::-webkit-details-marker {
    display: none;
}

.toc ul {
    margin-top: 0;
    margin-bottom: 0;
    padding-left: 1.5em;
}

.toc li {
    margin: 0.2em 0;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    line-height: 1.3;
    color: var(--heading-primary);
}

h1 {
    font-size: 2em;
    border-bottom: 2px solid var(--border-primary);
    padding-bottom: 0.3em;
}

h2 {
    font-size: 1.5em;
}
h3 {
    font-size: 1.25em;
}
h4 {
    font-size: 1.15em;
}
h5 {
    font-size: 1.1em;
}
h6 {
    font-size: 1.05em;
}

/* Links */
a {
    color: var(--link-primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
    color: var(--link-hover);
}

.internal-link.unresolved {
    color: var(--link-primary);
    opacity: 0.4;
    cursor: default;
    text-decoration: none;
}

.internal-link.unresolved:hover {
    text-decoration: underline;
    color: var(--link-hover);
    opacity: 0.4;
}

/* Code blocks */
code {
    background: var(--bg-secondary);
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-family:
        "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.9em;
    color: var(--code-text);
}

pre {
    background: var(--bg-tertiary);
    padding: 1em;
    border-radius: 5px;
    overflow-x: auto;
    border: 1px solid var(--border-secondary);
}

pre code {
    background: none;
    padding: 0;
}

/* Blockquotes */
blockquote {
    border-left: 4px solid var(--blockquote-border);
    padding-left: 1em;
    margin-left: 0;
    color: var(--text-secondary);
}

/* Horizontal rule */
hr {
    border: none;
    border-top: 2px solid var(--border-primary);
    margin: 2em 0;
}

/* Backlinks */
.backlinks {
    margin-top: 2em;
    padding: 1em;
    background: var(--bg-secondary);
    border-radius: 5px;
    border: 1px solid var(--border-secondary);
}

.backlinks h5 {
    margin-top: 0;
    font-size: 1em;
    color: var(--backlinks-heading);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.backlinks ul {
    list-style: none;
    padding: 0;
}

.backlinks li {
    margin: 0.5em 0;
}

/* Top navigation */
.top-nav {
    margin-bottom: 1em;
    padding-bottom: 0.5em;
    border-bottom: 1px solid var(--border-primary);
}

.breadcrumb {
    font-size: 1.2em;
    opacity: 0.8;
}

.breadcrumb:hover {
    opacity: 1;
}

/* File tree - Home page */
.home-page.file-tree {
    line-height: 1.4;
    list-style: none;
}

.home-page.file-tree details summary {
    list-style: none;
}

.home-page.file-tree details summary::-webkit-details-marker {
    display: none;
}

.home-page.file-tree details summary::marker {
    display: none;
}

/* Tree items - Sidebar */
.tree-item {
    margin: 0;
    white-space: pre;
}

.tree-item.file .connector-prefix,
.tree-item.directory .connector-prefix {
    color: var(--text-secondary);
    opacity: 0.5;
    display: inline-block;
    vertical-align: top;
}

.tree-item.directory details {
    display: inline;
}

.tree-item.directory summary {
    cursor: pointer;
    user-select: none;
    color: var(--heading-primary);
    list-style: none;
    display: inline;
}

.tree-item.directory summary::-webkit-details-marker {
    display: none;
}

.tree-item.directory summary::marker {
    display: none;
}

.tree-item.directory summary:hover {
    color: var(--summary-hover);
}

.tree-item.file {
    display: block;
    line-height: 1.4;
}

.tree-item.file a {
    color: var(--text-primary);
    text-decoration: none;
    display: inline;
}

.tree-item.file a:hover {
    color: var(--link-hover);
    background: var(--bg-secondary);
}

/* Frontmatter table */
.frontmatter {
    width: 100%;
    margin: 1em 0;
    border-collapse: collapse;
    border: 1px solid var(--border-secondary);
}

.frontmatter td:first-child {
    padding: 0.5em;
    font-weight: bold;
    background: var(--bg-secondary);
    border: 1px solid var(--border-secondary);
    white-space: nowrap;
    width: 1%;
}

.frontmatter td:last-child {
    padding: 0.5em 0.5em 0.5em 0.5em;
    border: 1px solid var(--border-secondary);
}

.frontmatter-tag {
    display: inline-block;
    background: var(--bg-secondary);
    padding: 0.2em 0.6em;
    border-radius: 3px;
    font-size: 0.85em;
    margin-right: 0.3em;
}

/* Embedded images */
.embed-file.image {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1em 0;
}

/* Mermaid diagrams */
.mermaid-diagram {
    background: var(--bg-tertiary);
    padding: 1em;
    border-radius: 5px;
    border: 1px solid var(--border-secondary);
    overflow-x: auto;
    display: block;
    margin: 1em 0;
}

.mermaid-diagram svg {
    max-width: 100%;
    height: auto;
    display: block;
}

/* TikZ diagrams */
.tikz-diagram {
    background: var(--bg-tertiary);
    padding: 1em;
    border-radius: 5px;
    border: 1px solid var(--border-secondary);
    overflow-x: auto;
    display: block;
    margin: 1em 0;
}

.tikz-diagram svg {
    max-width: 100%;
    height: auto;
    display: block;
    filter: invert(1) hue-rotate(180deg);
}

/* Quiver diagrams */
.quiver-diagram {
    background: var(--bg-tertiary);
    padding: 1em;
    border-radius: 5px;
    border: 1px solid var(--border-secondary);
    overflow-x: auto;
    display: block;
    margin: 1em 0;
}

.quiver-diagram svg {
    max-width: 100%;
    height: auto;
    display: block;
    filter: invert(1) hue-rotate(180deg);
}

/* Embedded files */
.embed-file.note,
.embed-file.heading,
.embed-file.block,
.embed-file.max-embed-depth {
    background: var(--bg-secondary);
    border-radius: 5px;
    margin: 0rem;
}

.embed-file.note .header,
.embed-file.heading .header,
.embed-file.block .header {
    padding: 0rem;
    margin: 0rem;
}

.embed-file.note .header > *,
.embed-file.heading .header > *,
.embed-file.block .header > * {
    margin: 0;
}

.embed-file.note .content,
.embed-file.heading .content,
.embed-file.block .content {
    border-left: 3px solid var(--accent-secondary);
    padding-left: 1rem;
    /*
       Claude Code: This tiny padding prevents margin collapse, which is what's causing the gap.
       When a child element's margin would normally "escape" its parent container, adding even
       a tiny bit of padding keeps the margin contained.
    */
    padding-top: 0.1px;
    padding-bottom: 0rem;
    margin: 0rem;
}

.embed-file.note .content > *:first-child,
.embed-file.heading .content > *:first-child,
.embed-file.block .content > *:first-child {
    margin-top: 0;
}
