/* ============================================================
   transactology.net - Styles
   Flat-design, scholarly-intellectual, dark analogous palette
   ============================================================ */

:root {
    --bg-primary: #1a1d23;
    --bg-sidebar: #14171c;
    --text-primary: #c8cdd3;
    --text-secondary: #7a8594;
    --accent-teal: #2ec4b6;
    --accent-cerulean: #3a86c4;
    --accent-seafoam: #48c78e;
    --rule-cobalt: #2a3a52;
    --hover-aqua: #5eddd5;
    --code-bg: #12141a;
    --error-coral: #d4726a;
    --sidebar-width: 280px;
    --content-max: 680px;
    --base-grid: 8px;
}

/* ---- Reset & Base ---- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 15px;
    scroll-behavior: smooth;
}

body {
    font-family: 'IBM Plex Mono', monospace;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.72;
    display: flex;
    min-height: 100vh;
}

/* ---- Dot Grid Background ---- */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: radial-gradient(circle, var(--rule-cobalt) 1px, transparent 1px);
    background-size: 24px 24px;
    pointer-events: none;
    z-index: 0;
    opacity: 0.4;
}

/* ---- Sidebar ---- */
#sidebar {
    position: sticky;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100vh;
    background-color: var(--bg-sidebar);
    overflow-y: auto;
    padding: calc(var(--base-grid) * 4) calc(var(--base-grid) * 3);
    z-index: 10;
    border-right: 1px solid var(--rule-cobalt);
}

.sidebar-header {
    margin-bottom: calc(var(--base-grid) * 5);
}

.site-title {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 20px;
    color: var(--text-primary);
    display: block;
    margin-bottom: calc(var(--base-grid) * 1);
    letter-spacing: -0.5px;
}

.cursor {
    animation: blink 1s step-end infinite;
    color: var(--accent-teal);
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.site-subtitle {
    font-family: 'Crimson Pro', serif;
    font-style: italic;
    font-size: 13px;
    color: var(--text-secondary);
    display: block;
}

/* ---- Table of Contents ---- */
.toc {
    list-style: none;
}

.toc-item {
    border-left: 3px solid transparent;
    transition: border-color 0.25s ease, color 0.25s ease;
}

.toc-item a {
    display: block;
    padding: calc(var(--base-grid) * 1) calc(var(--base-grid) * 2);
    color: var(--text-secondary);
    text-decoration: none;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 13px;
    font-weight: 500;
    transition: color 0.25s ease;
}

.toc-item a:hover {
    color: var(--hover-aqua);
}

.toc-item.active {
    border-left-color: var(--accent-teal);
}

.toc-item.active a {
    color: var(--text-primary);
}

.toc-sub a {
    padding-left: calc(var(--base-grid) * 4);
    font-size: 12px;
}

.toc-num {
    display: inline-block;
    width: 32px;
    color: var(--accent-cerulean);
    font-weight: 600;
    font-size: 11px;
    font-family: 'IBM Plex Mono', monospace;
}

/* ---- Mobile Navigation ---- */
#mobile-nav {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background-color: var(--bg-sidebar);
    border-bottom: 1px solid var(--rule-cobalt);
    z-index: 100;
    padding: 0 calc(var(--base-grid) * 2);
    align-items: center;
    justify-content: space-between;
}

.mobile-title {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 18px;
    color: var(--text-primary);
}

#mobile-menu-toggle {
    background: none;
    border: 1px solid var(--rule-cobalt);
    padding: 8px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
}

.menu-bar {
    display: block;
    width: 18px;
    height: 2px;
    background-color: var(--text-primary);
}

/* ---- Main Content ---- */
#content {
    flex: 1;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: calc(var(--base-grid) * 6) calc(var(--base-grid) * 4);
    padding-bottom: calc(var(--base-grid) * 12);
    position: relative;
    z-index: 1;
}

/* ---- Section Rules ---- */
.section-rule {
    position: relative;
    height: 1px;
    background-color: var(--rule-cobalt);
    margin: calc(var(--base-grid) * 6) 0 calc(var(--base-grid) * 4) 0;
}

.rule-node {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--bg-primary);
    border: 1px solid var(--accent-cerulean);
}

.doc-section:first-child .section-rule {
    margin-top: 0;
}

/* ---- Headings ---- */
.section-heading {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: calc(var(--base-grid) * 3);
    letter-spacing: -0.3px;
}

h1.section-heading {
    font-size: 28px;
}

h2.section-heading {
    font-size: 22px;
}

h3.section-heading {
    font-size: 18px;
    color: var(--accent-cerulean);
}

/* ---- Body Text ---- */
.body-text {
    margin-bottom: calc(var(--base-grid) * 3);
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.72;
}

.body-text strong {
    font-weight: 600;
    color: var(--accent-seafoam);
}

.body-text em {
    font-style: italic;
    color: var(--text-primary);
}

/* ---- Annotations ---- */
.annotation-text {
    font-family: 'Crimson Pro', serif;
    font-style: italic;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: calc(var(--base-grid) * 3);
    padding-left: calc(var(--base-grid) * 3);
    border-left: 2px solid var(--rule-cobalt);
}

/* ---- Margin Notes ---- */
.margin-note {
    display: flex;
    gap: calc(var(--base-grid) * 2);
    align-items: flex-start;
    margin: calc(var(--base-grid) * 3) 0;
    padding: calc(var(--base-grid) * 2);
    border: 1px solid var(--rule-cobalt);
    background-color: var(--bg-sidebar);
    cursor: pointer;
}

.note-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    min-width: 20px;
    border-radius: 50%;
    border: 1px solid var(--accent-cerulean);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    color: var(--accent-cerulean);
}

.note-text {
    font-family: 'Crimson Pro', serif;
    font-style: italic;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ---- Taxonomy List ---- */
.taxonomy-list {
    margin: calc(var(--base-grid) * 3) 0;
}

.taxonomy-entry {
    padding: calc(var(--base-grid) * 2) 0;
    border-bottom: 1px solid var(--rule-cobalt);
}

.taxonomy-entry:last-child {
    border-bottom: none;
}

.taxonomy-label {
    display: block;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    font-size: 14px;
    color: var(--accent-teal);
    margin-bottom: calc(var(--base-grid) * 1);
}

.taxonomy-desc {
    display: block;
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.65;
}

/* ---- Code Blocks ---- */
.code-block {
    background-color: var(--code-bg);
    border: 1px solid var(--rule-cobalt);
    padding: calc(var(--base-grid) * 3);
    margin: calc(var(--base-grid) * 3) 0;
    overflow-x: auto;
}

.code-block pre {
    margin: 0;
}

.code-block code {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 13px;
    color: var(--accent-seafoam);
    line-height: 1.6;
}

/* ---- Generative Art Panels ---- */
.generative-panel {
    margin: calc(var(--base-grid) * 4) 0;
    padding: calc(var(--base-grid) * 2) 0;
}

.transaction-graph {
    width: 100%;
    height: auto;
}

.graph-edge {
    stroke: var(--rule-cobalt);
    stroke-width: 1;
}

.graph-edge.dashed {
    stroke-dasharray: 4, 4;
    stroke-opacity: 0.5;
}

.graph-node {
    fill: var(--accent-teal);
    fill-opacity: 0.7;
    stroke: var(--accent-cerulean);
    stroke-width: 1;
}

.graph-node.pulse-1 {
    animation: nodePulse 4s ease-in-out infinite;
}

.graph-node.pulse-2 {
    animation: nodePulse 4s ease-in-out 1.3s infinite;
}

.graph-node.pulse-3 {
    animation: nodePulse 4s ease-in-out 2.6s infinite;
}

@keyframes nodePulse {
    0%, 100% { fill-opacity: 0.4; r: attr(r); }
    50% { fill-opacity: 0.9; }
}

/* ---- Canvas Section ---- */
.canvas-section {
    margin: calc(var(--base-grid) * 6) 0;
}

#flow-field {
    width: 100%;
    height: 400px;
    display: block;
    pointer-events: none;
}

.figure-caption {
    font-family: 'Crimson Pro', serif;
    font-style: italic;
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: calc(var(--base-grid) * 2);
    padding-top: calc(var(--base-grid) * 1);
    border-top: 1px solid var(--rule-cobalt);
}

/* ---- Voronoi Divider ---- */
.voronoi-divider {
    margin: calc(var(--base-grid) * 4) 0;
}

.voronoi-svg {
    width: 100%;
    height: auto;
}

/* ---- Footnote Popover ---- */
.footnote-popover {
    position: absolute;
    width: 240px;
    background-color: var(--bg-sidebar);
    border: 1px solid var(--rule-cobalt);
    padding: calc(var(--base-grid) * 2);
    z-index: 50;
    pointer-events: auto;
}

.footnote-popover.hidden {
    display: none;
}

.footnote-content {
    font-family: 'Crimson Pro', serif;
    font-style: italic;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ---- Document Footer ---- */
.doc-footer {
    margin-top: calc(var(--base-grid) * 8);
    padding-bottom: calc(var(--base-grid) * 4);
}

.footer-text {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: calc(var(--base-grid) * 3);
}

.footer-version {
    font-size: 11px;
    color: var(--rule-cobalt);
    margin-top: calc(var(--base-grid) * 1);
}

/* ---- Stagger Animation ---- */
.stagger-group > * {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.4s ease-out, transform 0.4s ease-out;
}

.stagger-group > *.visible {
    opacity: 1;
    transform: translateY(0);
}

.section-heading {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.4s ease-out, transform 0.4s ease-out;
}

.section-heading.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ---- Responsive: Tablet / Below 900px ---- */
@media (max-width: 900px) {
    #sidebar {
        display: none;
    }

    #sidebar.mobile-open {
        display: block;
        position: fixed;
        top: 56px;
        left: 0;
        width: 100%;
        height: calc(100vh - 56px);
        z-index: 99;
    }

    #mobile-nav {
        display: flex;
    }

    body {
        flex-direction: column;
    }

    #content {
        margin-top: 56px;
        padding: calc(var(--base-grid) * 4) calc(var(--base-grid) * 3);
    }
}

/* ---- Responsive: Phone / Below 600px ---- */
@media (max-width: 600px) {
    html {
        font-size: 14px;
    }

    h1.section-heading {
        font-size: 24px;
    }

    h2.section-heading {
        font-size: 19px;
    }

    h3.section-heading {
        font-size: 16px;
    }

    #content {
        padding: calc(var(--base-grid) * 3) calc(var(--base-grid) * 2);
    }

    .code-block {
        padding: calc(var(--base-grid) * 2);
    }

    .code-block code {
        font-size: 12px;
    }

    #flow-field {
        height: 250px;
    }
}

/* ---- Scrollbar Styling ---- */
#sidebar::-webkit-scrollbar {
    width: 4px;
}

#sidebar::-webkit-scrollbar-track {
    background: var(--bg-sidebar);
}

#sidebar::-webkit-scrollbar-thumb {
    background: var(--rule-cobalt);
}
