/* ============================================
   TECHNICAL DOCS STYLES
   Sphinx/Furo inspired - math, theorems, proofs
   For research papers and technical notes
   ============================================ */

:root {
    --docs-bg: #fcfcfc;
    --docs-bg-sidebar: #f8f8f8;
    --docs-text: #333;
    --docs-text-muted: #666;
    --docs-text-faint: #999;
    --docs-heading: #1a1a1a;
    --docs-link: #0066cc;
    --docs-link-hover: #004499;
    --docs-border: #e0e0e0;
    --docs-code-bg: #f5f5f5;
    --docs-theorem-bg: #f0f7ff;
    --docs-theorem-border: #b3d4fc;
    --docs-proof-bg: #fafafa;
    --docs-definition-bg: #f5fff5;
    --docs-definition-border: #b3e6b3;
    --docs-remark-bg: #fffaf0;
    --docs-remark-border: #f0d080;
    
    /* Dark mode */
    --docs-dark-bg: #1a1a1a;
    --docs-dark-bg-sidebar: #141414;
    --docs-dark-text: #e0e0e0;
    --docs-dark-text-muted: #a0a0a0;
    --docs-dark-text-faint: #707070;
    --docs-dark-heading: #fff;
    --docs-dark-link: #6cb4ff;
    --docs-dark-link-hover: #a0d0ff;
    --docs-dark-border: #333;
    --docs-dark-code-bg: #2a2a2a;
    --docs-dark-theorem-bg: #1a2533;
    --docs-dark-theorem-border: #3366aa;
    --docs-dark-proof-bg: #1f1f1f;
    --docs-dark-definition-bg: #1a2a1a;
    --docs-dark-definition-border: #336633;
    --docs-dark-remark-bg: #2a2518;
    --docs-dark-remark-border: #aa8844;
    
    --docs-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    --docs-font-mono: 'JetBrains Mono', 'SF Mono', 'Consolas', monospace;
    --docs-font-math: 'KaTeX_Main', 'Times New Roman', serif;
    
    --docs-sidebar-width: 280px;
    --docs-content-width: 800px;
    --docs-toc-width: 220px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --docs-bg: var(--docs-dark-bg);
        --docs-bg-sidebar: var(--docs-dark-bg-sidebar);
        --docs-text: var(--docs-dark-text);
        --docs-text-muted: var(--docs-dark-text-muted);
        --docs-text-faint: var(--docs-dark-text-faint);
        --docs-heading: var(--docs-dark-heading);
        --docs-link: var(--docs-dark-link);
        --docs-link-hover: var(--docs-dark-link-hover);
        --docs-border: var(--docs-dark-border);
        --docs-code-bg: var(--docs-dark-code-bg);
        --docs-theorem-bg: var(--docs-dark-theorem-bg);
        --docs-theorem-border: var(--docs-dark-theorem-border);
        --docs-proof-bg: var(--docs-dark-proof-bg);
        --docs-definition-bg: var(--docs-dark-definition-bg);
        --docs-definition-border: var(--docs-dark-definition-border);
        --docs-remark-bg: var(--docs-dark-remark-bg);
        --docs-remark-border: var(--docs-dark-remark-border);
    }
}

[data-theme="dark"] {
    --docs-bg: var(--docs-dark-bg);
    --docs-bg-sidebar: var(--docs-dark-bg-sidebar);
    --docs-text: var(--docs-dark-text);
    --docs-text-muted: var(--docs-dark-text-muted);
    --docs-text-faint: var(--docs-dark-text-faint);
    --docs-heading: var(--docs-dark-heading);
    --docs-link: var(--docs-dark-link);
    --docs-link-hover: var(--docs-dark-link-hover);
    --docs-border: var(--docs-dark-border);
    --docs-code-bg: var(--docs-dark-code-bg);
    --docs-theorem-bg: var(--docs-dark-theorem-bg);
    --docs-theorem-border: var(--docs-dark-theorem-border);
    --docs-proof-bg: var(--docs-dark-proof-bg);
    --docs-definition-bg: var(--docs-dark-definition-bg);
    --docs-definition-border: var(--docs-dark-definition-border);
    --docs-remark-bg: var(--docs-dark-remark-bg);
    --docs-remark-border: var(--docs-dark-remark-border);
}

/* ============================================
   BASE
   ============================================ */

.docs-page {
    font-family: var(--docs-font);
    font-size: 16px;
    line-height: 1.65;
    color: var(--docs-text);
    background: var(--docs-bg);
    min-height: 100vh;
}

/* ============================================
   LAYOUT - Three column
   ============================================ */

.docs-container {
    display: grid;
    grid-template-columns: var(--docs-sidebar-width) minmax(0, 1fr) var(--docs-toc-width);
    min-height: 100vh;
}

@media (max-width: 1200px) {
    .docs-container {
        grid-template-columns: var(--docs-sidebar-width) 1fr;
    }
    .docs-toc {
        display: none;
    }
}

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

/* ============================================
   SIDEBAR (left)
   ============================================ */

.docs-sidebar {
    background: var(--docs-bg-sidebar);
    border-right: 1px solid var(--docs-border);
    padding: 1.5rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.docs-sidebar .site-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--docs-heading);
    text-decoration: none;
    display: block;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--docs-border);
}

.docs-sidebar nav {
    font-size: 14px;
}

.docs-sidebar .nav-section {
    margin-bottom: 1.25rem;
}

.docs-sidebar .nav-section-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--docs-text-faint);
    margin-bottom: 0.5rem;
}

.docs-sidebar nav a {
    display: block;
    padding: 0.35rem 0;
    color: var(--docs-text-muted);
    text-decoration: none;
    transition: color 0.15s;
}

.docs-sidebar nav a:hover,
.docs-sidebar nav a.active {
    color: var(--docs-link);
}

.docs-sidebar nav ul {
    list-style: none;
    margin: 0;
    padding: 0 0 0 1rem;
}

.docs-sidebar nav ul li {
    margin: 0.25rem 0;
}

/* ============================================
   MAIN CONTENT
   ============================================ */

.docs-main {
    padding: 2rem 3rem;
    max-width: var(--docs-content-width);
}

.docs-header {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--docs-border);
}

.docs-header h1 {
    font-size: 2rem;
    font-weight: 600;
    color: var(--docs-heading);
    margin: 0 0 0.5rem;
    line-height: 1.3;
}

.docs-subtitle {
    font-size: 1.1rem;
    color: var(--docs-text-muted);
    margin: 0;
}

.docs-meta {
    font-size: 14px;
    color: var(--docs-text-faint);
    margin-top: 0.75rem;
}

.docs-meta a {
    color: var(--docs-link);
    text-decoration: none;
}

/* ============================================
   TABLE OF CONTENTS (right sidebar)
   ============================================ */

.docs-toc {
    padding: 2rem 1rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    font-size: 13px;
}

.docs-toc .toc-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--docs-text-faint);
    margin-bottom: 0.75rem;
}

.docs-toc ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.docs-toc li {
    margin: 0.4rem 0;
}

.docs-toc a {
    color: var(--docs-text-muted);
    text-decoration: none;
    transition: color 0.15s;
}

.docs-toc a:hover,
.docs-toc a.active {
    color: var(--docs-link);
}

.docs-toc ul ul {
    padding-left: 0.75rem;
    margin-top: 0.25rem;
}

.docs-toc ul ul a {
    font-size: 12px;
}

/* ============================================
   CONTENT TYPOGRAPHY
   ============================================ */

.docs-content p {
    margin: 0 0 1rem;
}

.docs-content h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--docs-heading);
    margin: 2.5rem 0 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--docs-border);
}

.docs-content h2:first-child {
    border-top: none;
    padding-top: 0;
    margin-top: 0;
}

.docs-content h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--docs-heading);
    margin: 2rem 0 0.75rem;
}

.docs-content h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--docs-heading);
    margin: 1.5rem 0 0.5rem;
}

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

.docs-content a:hover {
    text-decoration: underline;
}

/* Heading anchors */
.docs-content h2 .anchor,
.docs-content h3 .anchor,
.docs-content h4 .anchor {
    color: var(--docs-text-faint);
    text-decoration: none;
    margin-left: 0.5rem;
    opacity: 0;
    transition: opacity 0.15s;
}

.docs-content h2:hover .anchor,
.docs-content h3:hover .anchor,
.docs-content h4:hover .anchor {
    opacity: 1;
}

/* ============================================
   MATH (KaTeX)
   ============================================ */

.docs-content .math {
    font-family: var(--docs-font-math);
}

.docs-content .math-display {
    display: block;
    margin: 1.5rem 0;
    overflow-x: auto;
    text-align: center;
}

.docs-content .math-inline {
    font-size: 0.95em;
}

/* Equation numbers */
.docs-content .equation-number {
    float: right;
    color: var(--docs-text-faint);
    font-size: 14px;
}

/* ============================================
   THEOREM ENVIRONMENTS
   ============================================ */

.theorem-env {
    margin: 1.5rem 0;
    padding: 1rem 1.25rem;
    border-radius: 4px;
    border-left: 4px solid;
}

.theorem-env .theorem-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.theorem-env .theorem-title .theorem-number {
    font-weight: 400;
}

/* Theorem */
.theorem {
    background: var(--docs-theorem-bg);
    border-color: var(--docs-theorem-border);
}

/* Definition */
.definition {
    background: var(--docs-definition-bg);
    border-color: var(--docs-definition-border);
}

/* Lemma, Proposition, Corollary */
.lemma, .proposition, .corollary {
    background: var(--docs-theorem-bg);
    border-color: var(--docs-theorem-border);
}

/* Remark, Example */
.remark, .example {
    background: var(--docs-remark-bg);
    border-color: var(--docs-remark-border);
}

/* Proof */
.proof {
    background: var(--docs-proof-bg);
    border-left: 2px solid var(--docs-border);
    margin: 1rem 0;
    padding: 0.75rem 1rem;
}

.proof .proof-title {
    font-style: italic;
    margin-bottom: 0.5rem;
}

.proof .qed {
    float: right;
    font-size: 14px;
}

/* ============================================
   CODE
   ============================================ */

.docs-content code {
    font-family: var(--docs-font-mono);
    font-size: 0.875em;
    background: var(--docs-code-bg);
    padding: 0.15em 0.4em;
    border-radius: 3px;
}

.docs-content pre {
    background: var(--docs-code-bg);
    padding: 1rem 1.25rem;
    overflow-x: auto;
    border-radius: 4px;
    margin: 1rem 0;
    border: 1px solid var(--docs-border);
}

.docs-content pre code {
    background: none;
    padding: 0;
    font-size: 13px;
    line-height: 1.5;
}

/* ============================================
   TABLES
   ============================================ */

.docs-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 14px;
}

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

.docs-content th {
    background: var(--docs-code-bg);
    font-weight: 600;
}

.docs-content tr:nth-child(even) {
    background: rgba(0,0,0,0.02);
}

/* ============================================
   LISTS
   ============================================ */

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

.docs-content li {
    margin-bottom: 0.35rem;
}

.docs-content li > ul,
.docs-content li > ol {
    margin-top: 0.35rem;
    margin-bottom: 0;
}

/* ============================================
   BLOCKQUOTES
   ============================================ */

.docs-content blockquote {
    margin: 1rem 0;
    padding: 0.75rem 1rem;
    background: var(--docs-code-bg);
    border-left: 3px solid var(--docs-border);
    color: var(--docs-text-muted);
}

.docs-content blockquote p {
    margin-bottom: 0;
}

/* ============================================
   FIGURES
   ============================================ */

.docs-content figure {
    margin: 2rem 0;
    text-align: center;
}

.docs-content figure img {
    max-width: 100%;
    height: auto;
}

.docs-content figcaption {
    font-size: 14px;
    color: var(--docs-text-muted);
    margin-top: 0.5rem;
    font-style: italic;
}

/* ============================================
   ADMONITIONS
   ============================================ */

.admonition {
    margin: 1.5rem 0;
    padding: 1rem 1.25rem;
    border-radius: 4px;
    border-left: 4px solid;
}

.admonition-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.admonition.note {
    background: var(--docs-theorem-bg);
    border-color: var(--docs-theorem-border);
}

.admonition.warning {
    background: #fff8e6;
    border-color: #f0c000;
}

.admonition.important {
    background: #fff0f0;
    border-color: #e05050;
}

/* ============================================
   REFERENCES / BIBLIOGRAPHY
   ============================================ */

.references {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--docs-border);
}

.references h2 {
    border-top: none;
    padding-top: 0;
}

.reference-list {
    font-size: 14px;
}

.reference-item {
    margin-bottom: 1rem;
    padding-left: 2.5rem;
    text-indent: -2.5rem;
}

.reference-item .ref-id {
    font-weight: 600;
    color: var(--docs-text-muted);
}

/* Citation links */
.docs-content .citation {
    color: var(--docs-link);
    text-decoration: none;
    font-size: 0.9em;
    vertical-align: super;
}

.docs-content .citation:hover {
    text-decoration: underline;
}

/* ============================================
   MOBILE HEADER
   ============================================ */

.docs-mobile-header {
    display: none;
    padding: 1rem;
    background: var(--docs-bg-sidebar);
    border-bottom: 1px solid var(--docs-border);
    justify-content: space-between;
    align-items: center;
}

@media (max-width: 900px) {
    .docs-mobile-header {
        display: flex;
    }
    
    .docs-main {
        padding: 1.5rem;
    }
}

.docs-mobile-header .site-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--docs-heading);
    text-decoration: none;
}

/* ============================================
   BACK TO TOP
   ============================================ */

.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 40px;
    height: 40px;
    background: var(--docs-bg-sidebar);
    border: 1px solid var(--docs-border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--docs-text-muted);
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.back-to-top.visible {
    opacity: 1;
    pointer-events: auto;
}

.back-to-top:hover {
    background: var(--docs-border);
}

/* ============================================
   PRINT
   ============================================ */

@media print {
    .docs-sidebar,
    .docs-toc,
    .docs-mobile-header,
    .back-to-top {
        display: none;
    }
    
    .docs-container {
        display: block;
    }
    
    .docs-page {
        background: white;
        color: black;
    }
    
    .docs-main {
        max-width: none;
        padding: 0;
    }
    
    .theorem-env {
        border: 1px solid #ccc;
        background: #f9f9f9;
    }
}
