/* markdown-academic Documentation Styles */

:root {
    --parchment: #fdfbf7;
    --ink: #1a1a1a;
    --accent: #8b2332;
    --accent-hover: #6b1a28;
    --muted: #6b6b6b;
    --border: #e5e5e5;
    --code-bg: #f4f4f4;
    --pre-bg: #1a1a1a;
    --pre-fg: #e5e5e5;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Crimson Pro', Georgia, 'Times New Roman', serif;
    background-color: var(--parchment);
    color: var(--ink);
    line-height: 1.6;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

code, pre {
    font-family: 'JetBrains Mono', Consolas, monospace;
}

/* Navigation */
.nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(253, 251, 247, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    z-index: 50;
}

.nav-container {
    max-width: 72rem;
    margin: 0 auto;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-brand {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.025em;
    text-decoration: none;
    color: var(--ink);
}

.nav-brand span {
    color: var(--accent);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 2rem;
    font-size: 0.875rem;
}

.nav-link {
    color: var(--ink);
    text-decoration: none;
    transition: color 0.15s ease;
}

.nav-link:hover {
    color: var(--accent);
}

.nav-link.active {
    color: var(--accent);
    font-weight: 500;
}

.nav-link-icon {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.nav-link-icon svg {
    width: 1rem;
    height: 1rem;
}

/* Mobile nav toggle */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
}

@media (max-width: 768px) {
    .nav-links {
        display: none;
    }
    
    .nav-links.open {
        display: flex;
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--parchment);
        border-bottom: 1px solid var(--border);
        padding: 1rem 1.5rem;
        gap: 1rem;
    }
    
    .nav-toggle {
        display: block;
    }
}

/* Hero Section */
.hero {
    padding-top: 8rem;
    padding-bottom: 5rem;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
    text-align: center;
}

.hero-container {
    max-width: 48rem;
    margin: 0 auto;
}

.hero-version {
    color: var(--accent);
    font-weight: 500;
    text-transform: uppercase;
    font-size: 0.875rem;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}

.hero-title {
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    margin-bottom: 1.5rem;
    line-height: 1.1;
}

@media (min-width: 768px) {
    .hero-title {
        font-size: 3.75rem;
    }
}

.hero-subtitle {
    font-size: 1.25rem;
    color: var(--muted);
    line-height: 1.6;
    margin-bottom: 2rem;
}

@media (min-width: 768px) {
    .hero-subtitle {
        font-size: 1.5rem;
    }
}

.hero-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    justify-content: center;
}

@media (min-width: 640px) {
    .hero-buttons {
        flex-direction: row;
    }
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.15s ease;
    font-size: 1rem;
}

.btn-primary {
    background: var(--ink);
    color: white;
}

.btn-primary:hover {
    background: #333;
}

.btn-secondary {
    border: 1px solid #ccc;
    color: var(--ink);
    background: transparent;
}

.btn-secondary:hover {
    border-color: #999;
}

/* Main Content */
.main {
    max-width: 56rem;
    margin: 0 auto;
    padding: 0 1.5rem 6rem;
}

.main-with-sidebar {
    max-width: 72rem;
    display: grid;
    grid-template-columns: 1fr;
    gap: 3rem;
}

@media (min-width: 1024px) {
    .main-with-sidebar {
        grid-template-columns: 16rem 1fr;
    }
}

/* Sidebar */
.sidebar {
    display: none;
}

@media (min-width: 1024px) {
    .sidebar {
        display: block;
        position: sticky;
        top: 6rem;
        align-self: start;
        max-height: calc(100vh - 8rem);
        overflow-y: auto;
        padding-right: 1rem;
    }
}

.sidebar-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin-bottom: 0.75rem;
}

.sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav li {
    margin-bottom: 0.25rem;
}

.sidebar-link {
    display: block;
    padding: 0.375rem 0;
    color: var(--ink);
    text-decoration: none;
    font-size: 0.875rem;
    border-left: 2px solid transparent;
    padding-left: 0.75rem;
    margin-left: -0.75rem;
    transition: all 0.15s ease;
}

.sidebar-link:hover {
    color: var(--accent);
}

.sidebar-link.active {
    color: var(--accent);
    border-left-color: var(--accent);
    font-weight: 500;
}

.sidebar-link-sub {
    padding-left: 1.5rem;
    margin-left: -0.75rem;
    font-size: 0.8125rem;
}

/* Content/Prose Styles */
.content {
    min-width: 0;
}

.content h1 {
    font-size: 2.25rem;
    font-weight: 700;
    margin-bottom: 1rem;
    letter-spacing: -0.025em;
}

.content h2 {
    font-size: 1.875rem;
    font-weight: 600;
    margin-top: 3rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.content h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
}

.content h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

.content p {
    margin-bottom: 1rem;
}

.content p.lead {
    font-size: 1.125rem;
    color: var(--muted);
}

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

.content a:hover {
    color: var(--accent-hover);
}

.content code {
    background: var(--code-bg);
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.875em;
}

.content pre {
    background: var(--pre-bg);
    color: var(--pre-fg);
    padding: 1.25rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    font-size: 0.875rem;
    line-height: 1.7;
    margin-bottom: 1.5rem;
}

.content pre code {
    background: none;
    padding: 0;
    font-size: inherit;
}

.content blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 1.25rem;
    margin-left: 0;
    margin-right: 0;
    font-style: italic;
    color: var(--muted);
}

.content ul, .content ol {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}

.content li {
    margin-bottom: 0.5rem;
}

.content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.5rem;
}

.content th, .content td {
    border: 1px solid var(--border);
    padding: 0.75rem 1rem;
    text-align: left;
}

.content th {
    background: #f9f9f9;
    font-weight: 600;
}

.content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2rem 0;
}

/* Section anchors */
.section-anchor {
    scroll-margin-top: 6rem;
}

/* Feature Grid */
.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.feature-box {
    background: var(--parchment);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1.5rem;
}

.feature-box h4 {
    font-weight: 600;
    margin-bottom: 0.5rem;
    margin-top: 0;
}

.feature-box p {
    color: var(--muted);
    font-size: 0.875rem;
    margin-bottom: 0;
}

/* Page Header */
.page-header {
    padding-top: 6rem;
    padding-bottom: 2rem;
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    letter-spacing: -0.025em;
}

.page-header p {
    font-size: 1.125rem;
    color: var(--muted);
    margin: 0;
}

/* Breadcrumb */
.breadcrumb {
    font-size: 0.875rem;
    color: var(--muted);
    margin-bottom: 0.5rem;
}

.breadcrumb a {
    color: var(--muted);
    text-decoration: none;
}

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

/* Footer */
.footer {
    margin-top: 5rem;
    padding-top: 2.5rem;
    border-top: 1px solid var(--border);
}

.footer-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--muted);
}

@media (min-width: 768px) {
    .footer-container {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
}

.footer a {
    color: var(--muted);
    text-decoration: underline;
}

.footer a:hover {
    color: var(--accent);
}

/* Card Links */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin: 2rem 0;
}

.card-link {
    display: block;
    padding: 1.5rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    text-decoration: none;
    color: var(--ink);
    transition: all 0.15s ease;
}

.card-link:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.card-link h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0 0 0.5rem 0;
    color: var(--accent);
}

.card-link p {
    font-size: 0.875rem;
    color: var(--muted);
    margin: 0;
}

/* Note/Warning boxes */
.note {
    background: #f0f7ff;
    border-left: 4px solid #3b82f6;
    padding: 1rem 1.25rem;
    border-radius: 0 0.5rem 0.5rem 0;
    margin-bottom: 1.5rem;
}

.note-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.warning {
    background: #fffbeb;
    border-left: 4px solid #f59e0b;
    padding: 1rem 1.25rem;
    border-radius: 0 0.5rem 0.5rem 0;
    margin-bottom: 1.5rem;
}

/* Description lists */
.content dl {
    margin-bottom: 1.5rem;
}

.content dt {
    font-weight: 600;
    margin-top: 1rem;
}

.content dd {
    margin-left: 1.5rem;
    color: var(--muted);
}

/* Whitepaper-specific styles (for rendered .mda content) */
.mda-document {
    max-width: 800px;
    margin: 0 auto;
    padding: 2em;
    font-family: 'Crimson Pro', Georgia, serif;
    line-height: 1.6;
}

.mda-section-number {
    color: var(--muted);
    margin-right: 0.5em;
}

.mda-equation {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 1em 0;
}

.mda-equation-number {
    color: var(--muted);
}

.mda-theorem-like {
    margin: 1.5em 0;
    padding: 1em;
    background: #f8f8f8;
    border-left: 3px solid #333;
}

.mda-proof {
    margin: 1em 0;
    padding: 1em;
    font-style: italic;
}

.mda-qed {
    float: right;
}

.mda-figure {
    margin: 2em 0;
    text-align: center;
}

.mda-figure img {
    max-width: 100%;
}

.mda-table {
    border-collapse: collapse;
    margin: 1em auto;
}

.mda-table th, .mda-table td {
    border: 1px solid #ddd;
    padding: 0.5em 1em;
}

.mda-table th {
    background: #f0f0f0;
}

.mda-toc {
    background: #fafafa;
    padding: 1em 2em;
    margin: 2em 0;
    border-radius: 4px;
}

.mda-toc ul {
    list-style: none;
    padding-left: 1.5em;
}

.mda-toc > ul {
    padding-left: 0;
}

.mda-citation {
}

.mda-ref {
    color: var(--accent);
    text-decoration: none;
}

.mda-ref:hover {
    text-decoration: underline;
}

.mda-footnotes {
    font-size: 0.9em;
    color: var(--muted);
}

.mda-footnote-ref {
    font-size: 0.8em;
}

.mda-bibliography {
    margin-top: 3em;
}

.mda-bibliography ol {
    padding-left: 2em;
}

.mda-env-header {
    font-weight: bold;
}

.mda-env-content {
    margin-top: 0.5em;
}

/* ========================================
   Live Demo Section
   ======================================== */

.demo-status {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.demo-status.loading {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffc107;
}

.demo-status.ready {
    background: #d4edda;
    color: #155724;
    border: 1px solid #28a745;
}

.demo-status.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #dc3545;
}

.demo-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin: 1.5rem 0;
}

@media (max-width: 900px) {
    .demo-container {
        grid-template-columns: 1fr;
    }
}

.demo-editor,
.demo-preview {
    display: flex;
    flex-direction: column;
}

.demo-label {
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin-bottom: 0.5rem;
}

#demo-input {
    width: 100%;
    height: 450px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
    resize: vertical;
    tab-size: 2;
}

#demo-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(139, 35, 50, 0.1);
}

#demo-output {
    flex: 1;
    min-height: 450px;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: white;
    overflow: auto;
    line-height: 1.6;
}

#demo-output h1 {
    font-size: 1.5rem;
    margin-top: 0;
}

#demo-output h2 {
    font-size: 1.25rem;
    margin-top: 1.5rem;
}

#demo-output h3 {
    font-size: 1.1rem;
}

#demo-output .mda-theorem,
#demo-output .mda-definition,
#demo-output .mda-lemma {
    background: #f0f7ff;
    border-left: 4px solid #3b82f6;
    padding: 1rem;
    margin: 1rem 0;
    border-radius: 0 var(--radius) var(--radius) 0;
}

#demo-output .mda-proof {
    background: var(--surface);
    padding: 1rem;
    margin: 1rem 0;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

#demo-output .mda-ref {
    color: var(--accent);
    text-decoration: none;
}

#demo-output .mda-ref:hover {
    text-decoration: underline;
}

#demo-output .mda-section-number {
    color: var(--muted);
    margin-right: 0.5rem;
}

.demo-note {
    font-size: 0.95rem;
    color: var(--muted);
    margin-top: 1.5rem;
}

.demo-note strong {
    color: var(--ink);
}
