/* Egon Technical Whitepapers - CSS Styling */

/* Align with main site color palette */
:root {
    --primary: #0f0f0f;
    --accent: #d4af37;
    --accent-dark: #b8941f;
    --accent-light: #e6c654;
    --text-primary: #0f0f0f;
    --text-secondary: #4a4a4a;
    --text-tertiary: #8a8a8a;
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #e9ecef;
    --border-primary: rgba(0,0,0,0.08);
    --code-bg: #282C34;
    --code-text: #ABB2BF;
}

/* Body and typography */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    line-height: 1.7;
}

/* Navbar styling */
.bg-gallery-obsidian {
    background-color: var(--primary) !important;
}

.text-gallery-sage {
    color: var(--text-tertiary) !important;
}

.navbar-brand {
    font-size: 1.5rem;
    font-weight: 700;
}

/* Sidebar TOC */
.sidebar {
    position: fixed;
    top: 56px;
    bottom: 0;
    left: 0;
    z-index: 100;
    padding: 48px 0 0;
    box-shadow: inset -1px 0 0 var(--border-primary);
    overflow-y: auto;
}

.toc-header {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
    padding: 0 1rem;
}

.sidebar .nav-link {
    font-size: 0.9rem;
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
}

.sidebar .nav-link:hover {
    color: var(--accent);
    background-color: var(--bg-secondary);
    border-left-color: var(--accent);
}

.sidebar .nav-link.active {
    color: var(--accent);
    font-weight: 600;
    border-left-color: var(--accent);
    background-color: var(--bg-secondary);
}

/* Main content area */
.whitepaper-content {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 0;
}

/* Typography */
h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1rem;
    line-height: 1.2;
}

h2 {
    font-size: 2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 3rem;
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--accent);
}

h3 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 2rem;
    margin-bottom: 1rem;
}

h4 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

.whitepaper-subtitle {
    font-size: 1.25rem;
    color: var(--text-tertiary);
    margin-bottom: 2rem;
}

.whitepaper-abstract {
    background-color: var(--bg-secondary);
    border-left: 4px solid var(--accent);
    padding: 1.5rem;
    margin: 2rem 0;
    font-size: 1.05rem;
    line-height: 1.8;
}

/* Lists */
ul, ol {
    margin-bottom: 1.5rem;
}

li {
    margin-bottom: 0.5rem;
}

/* Links */
a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s ease;
}

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

/* Code blocks */
pre[class*="language-"] {
    border-radius: 8px;
    margin: 1.5rem 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

code {
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 0.9em;
}

:not(pre) > code {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-size: 0.85em;
}

/* Tables */
table {
    width: 100%;
    margin: 2rem 0;
    border-collapse: collapse;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

thead {
    background-color: var(--primary);
    color: white;
}

th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
}

td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-primary);
}

tbody tr:hover {
    background-color: var(--bg-secondary);
}

/* Mermaid diagrams - COLOR CODED AND READABLE */
.mermaid {
    margin: 2rem 0;
    padding: 2rem;
    background-color: #fafbfc;
    border-radius: 8px;
    text-align: center;
    border: 1px solid var(--border-primary);
}

/* Mermaid nodes - distinct colors */
.mermaid .node rect,
.mermaid .node circle,
.mermaid .node ellipse,
.mermaid .node polygon,
.mermaid .cluster rect {
    fill: #ffffff !important;
    stroke: var(--accent) !important;
    stroke-width: 2px !important;
}

/* Primary nodes (start/end) */
.mermaid .node.start rect,
.mermaid .node.end rect {
    fill: #fffbeb !important;
    stroke: var(--accent-dark) !important;
    stroke-width: 3px !important;
}

/* Process nodes */
.mermaid .node.process rect {
    fill: #f0f9ff !important;
    stroke: #0891b2 !important;
}

/* Decision nodes */
.mermaid .node.decision polygon {
    fill: #fef3c7 !important;
    stroke: #f59e0b !important;
}

/* All text in diagrams - HIGH CONTRAST */
.mermaid .nodeLabel,
.mermaid .node .label,
.mermaid text,
.mermaid .label,
.mermaid tspan,
.mermaid .edgeLabel text,
.mermaid .edgeLabel tspan {
    fill: #0f0f0f !important;
    color: #0f0f0f !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 14px !important;
    font-weight: 600 !important;
}

/* Edge labels - WHITE BACKGROUND FOR READABILITY */
.mermaid .edgeLabel {
    background-color: #ffffff !important;
    padding: 6px 10px !important;
    border-radius: 4px !important;
    border: 1px solid #e5e7eb !important;
}

.mermaid .edgeLabel span,
.mermaid .edgeLabel div {
    color: #0f0f0f !important;
    font-weight: 600 !important;
    font-size: 13px !important;
}

/* Ensure edge label backgrounds are opaque */
.mermaid .edgeLabel rect {
    fill: #ffffff !important;
    stroke: #e5e7eb !important;
}

/* Arrows and paths */
.mermaid .edgePath .path,
.mermaid path.relation {
    stroke: #4a4a4a !important;
    stroke-width: 2px !important;
}

.mermaid .marker {
    fill: #4a4a4a !important;
    stroke: #4a4a4a !important;
}

.diagram-caption {
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-tertiary);
    margin-top: 0.5rem;
    font-style: italic;
}

/* Highlight boxes */
.highlight-box {
    background-color: #fffbeb;
    border-left: 4px solid var(--accent);
    padding: 1.5rem;
    margin: 2rem 0;
    border-radius: 4px;
}

.highlight-box h4 {
    margin-top: 0;
    color: var(--accent-dark);
}

/* Metric boxes */
.metric-box {
    background-color: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 8px;
    margin: 1rem 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.metric-label {
    font-size: 0.85rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.metric-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.metric-description {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

/* Whitepaper cards - VERTICAL LAYOUT */
.whitepaper-card {
    border: 1px solid var(--border-primary);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    height: 100%;
    overflow: hidden;
    background: white;
}

.whitepaper-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
    border-color: var(--accent);
}

.whitepaper-card-header {
    background: linear-gradient(135deg, var(--primary) 0%, #2a2a2a 100%);
    color: white;
    padding: 2rem 1.5rem;
    border-radius: 12px 12px 0 0;
}

.whitepaper-card-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: white;
}

.whitepaper-card-subtitle {
    font-size: 1rem;
    color: var(--accent-light);
    margin: 0;
}

.whitepaper-card-body {
    padding: 1.5rem;
}

.read-time {
    color: var(--text-tertiary);
    font-size: 0.9rem;
    font-weight: 500;
}

.topic-list {
    list-style: none;
    padding: 0;
}

.topic-list li {
    padding-left: 1.5rem;
    position: relative;
    margin-bottom: 0.75rem;
    color: var(--text-secondary);
}

.topic-list li::before {
    content: "→";
    position: absolute;
    left: 0;
    color: var(--accent);
    font-weight: 700;
}

/* Buttons - Gallery aesthetic with gold accent */
.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #2a2a2a 100%);
    border: 2px solid var(--accent);
    color: white;
    font-weight: 600;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(212, 175, 55, 0.2);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #2a2a2a 0%, var(--primary) 100%);
    border-color: var(--accent-light);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(212, 175, 55, 0.3);
}

.btn-primary:active,
.btn-primary:focus {
    background: var(--primary);
    border-color: var(--accent-dark);
    color: white;
    box-shadow: 0 2px 8px rgba(212, 175, 55, 0.4);
}

/* Footer */
.footer {
    margin-top: auto;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .sidebar {
        position: static;
        top: auto;
        padding: 1rem 0;
    }

    h1 {
        font-size: 2rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    .whitepaper-content {
        padding: 1rem;
    }
}

/* Print styles */
@media print {
    .navbar,
    .sidebar,
    .footer {
        display: none;
    }

    .whitepaper-content {
        max-width: 100%;
    }

    h2 {
        page-break-after: avoid;
    }

    pre, .mermaid {
        page-break-inside: avoid;
    }
}
