/* ============================================================
   Custom Properties — tweak these to restyle everything
   ============================================================ */
:root {
    --bg:          #0f0f13;
    --surface:     #16161e;
    --surface-2:   #1e1e2a;
    --border:      #2a2a3a;
    --text:        #c9d1d9;
    --text-muted:  #8b949e;
    --accent:      #7c8cf8;
    --accent-dim:  #3d4475;
    --code-bg:     #13131a;
    --nav-h:       56px;
    --max-w:       860px;
    --font-body:   system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-mono:   "Cascadia Code", "Fira Code", "Consolas", monospace;
}

/* ============================================================
   Reset
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; scrollbar-gutter: stable; }
body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    line-height: 1.65;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ============================================================
   Navigation
   ============================================================ */
.nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    height: var(--nav-h);
}
.nav-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1.5rem;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.nav-brand {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.nav-brand:hover { color: var(--accent); }

.nav-links {
    list-style: none;
    display: flex;
    gap: 2rem;
}
.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.875rem;
    letter-spacing: 0.04em;
    transition: color 0.15s;
    padding-bottom: 2px;
}
.nav-links a:hover { color: var(--text); }
.nav-links a.active {
    color: var(--accent);
    border-bottom: 1px solid var(--accent);
}

/* ============================================================
   Layout
   ============================================================ */
.main {
    flex: 1;
    padding: 3rem 1.5rem;
}
.container {
    max-width: var(--max-w);
    margin: 0 auto;
}
.container-wide {
    max-width: 1100px;
    margin: 0 auto;
}

/* ============================================================
   Base Typography
   ============================================================ */
h1, h2, h3, h4, h5 {
    color: #e6edf3;
    line-height: 1.3;
    font-weight: 600;
}
h1 { font-size: 2rem;   margin-bottom: 0.75rem; }
h2 { font-size: 1.4rem; margin: 2rem 0 0.6rem; }
h3 { font-size: 1.1rem; margin: 1.5rem 0 0.4rem; }
p  { margin-bottom: 1rem; }
a  { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================================================
   Prose — applied to rendered article/wiki content
   ============================================================ */
.prose { max-width: var(--max-w); }

.prose h1 {
    font-size: 1.85rem;
    margin: 0 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}
.prose h2 {
    font-size: 1.35rem;
    margin: 2.5rem 0 0.75rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--border);
}
.prose h3 { font-size: 1.1rem;  margin: 2rem 0 0.5rem; }
.prose h4 { font-size: 1rem;    margin: 1.5rem 0 0.4rem; }
.prose p  { margin-bottom: 1.1rem; }

/* Inline code */
.prose code, code {
    font-family: var(--font-mono);
    font-size: 0.875em;
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.15em 0.4em;
}

/* Code blocks */
.prose pre, pre {
    background: var(--code-bg) !important;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1.25rem;
    overflow-x: auto;
    margin: 1.25rem 0;
    line-height: 1.6;
}
.prose pre code, pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: 0.875rem;
}

/* Tables */
.prose table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.9rem;
}
.prose th {
    background: var(--surface-2);
    color: #e6edf3;
    font-weight: 600;
    text-align: left;
    padding: 0.6rem 0.9rem;
    border: 1px solid var(--border);
}
.prose td {
    padding: 0.55rem 0.9rem;
    border: 1px solid var(--border);
    vertical-align: top;
}
.prose tr:nth-child(even) td { background: var(--surface); }

/* Blockquotes */
.prose blockquote {
    border-left: 3px solid var(--accent-dim);
    padding: 0.4rem 0 0.4rem 1.25rem;
    margin: 1.25rem 0;
    color: var(--text-muted);
    font-style: italic;
}

/* Lists */
.prose ul, .prose ol { margin: 0.75rem 0 1rem 1.5rem; }
.prose li            { margin-bottom: 0.35rem; }
.prose li > ul,
.prose li > ol       { margin-top: 0.35rem; }

/* Horizontal rule */
.prose hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2.5rem 0;
}

/* KaTeX display math spacing */
.prose .katex-display { overflow-x: auto; padding: 0.5rem 0; margin: 1.25rem 0; }

/* ============================================================
   Footer
   ============================================================ */
.footer {
    border-top: 1px solid var(--border);
    padding: 1.25rem 1.5rem;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ============================================================
   Home — Hero
   ============================================================ */
.hero {
    max-width: var(--max-w);
    margin: 5rem auto 0;
    text-align: center;
}
.hero h1 {
    font-size: 2.75rem;
    font-weight: 300;
    letter-spacing: 0.06em;
    margin-bottom: 1rem;
    color: #e6edf3;
}
.hero p { color: var(--text-muted); font-size: 1.05rem; max-width: 500px; margin: 0 auto; }

/* ============================================================
   Page header (used on Wiki, Academics index pages)
   ============================================================ */
.page-header {
    margin-bottom: 2.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}
.page-header h1 { margin-bottom: 0.35rem; }
.page-header p  { color: var(--text-muted); margin: 0; }

/* ============================================================
   Tags / badges
   ============================================================ */
.tag {
    display: inline-block;
    font-size: 0.72rem;
    font-family: var(--font-mono);
    background: var(--surface-2);
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.15em 0.55em;
    vertical-align: middle;
    white-space: nowrap;
}
.tag-accent {
    background: var(--accent-dim);
    color: var(--accent);
    border-color: var(--accent-dim);
}

/* ============================================================
   Search bar
   ============================================================ */
.search-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
}
.search-input {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-family: var(--font-body);
    font-size: 0.9rem;
    padding: 0.55rem 0.85rem;
    outline: none;
    transition: border-color 0.15s;
}
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus { border-color: var(--accent); }

.btn {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.875rem;
    padding: 0.55rem 1.1rem;
    transition: border-color 0.15s, color 0.15s;
    white-space: nowrap;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary {
    background: var(--accent-dim);
    border-color: var(--accent-dim);
    color: var(--accent);
}
.btn-primary:hover { border-color: var(--accent); }

/* ============================================================
   Cards
   ============================================================ */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
    transition: border-color 0.15s;
    text-decoration: none;
    color: var(--text);
    display: block;
}
.card:hover { border-color: var(--accent); text-decoration: none; }
.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: #e6edf3;
    margin-bottom: 0.4rem;
}
.card-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.6rem;
}
.card-excerpt {
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* ============================================================
   Article list (wiki index)
   ============================================================ */
.article-list { list-style: none; }
.article-item {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}
.article-item:first-child { border-top: 1px solid var(--border); }
.article-item a {
    font-size: 0.95rem;
    color: var(--text);
    flex: 1;
}
.article-item a:hover { color: var(--accent); text-decoration: none; }
.article-item-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
    white-space: nowrap;
    font-family: var(--font-mono);
}

/* ============================================================
   Accordion (academics collapsible sections)
   ============================================================ */
.accordion {
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 0.75rem;
    overflow: hidden;
}
.accordion[open] { border-color: var(--accent-dim); }

.accordion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    cursor: pointer;
    background: var(--surface);
    user-select: none;
    list-style: none;          /* hide default triangle in Firefox */
}
.accordion-header::-webkit-details-marker { display: none; } /* hide in Chrome */

.accordion-header::after {
    content: "+";
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-left: auto;
    transition: transform 0.2s;
    flex-shrink: 0;
}
.accordion[open] .accordion-header::after { content: "−"; }

.accordion-header:hover { background: var(--surface-2); }

.accordion-title {
    font-weight: 600;
    color: #e6edf3;
    font-size: 0.95rem;
}

.accordion-body {
    padding: 1rem 1.25rem 1.25rem;
    border-top: 1px solid var(--border);
}

/* ============================================================
   Project list (inside accordion)
   ============================================================ */
.project-list { list-style: none; margin-top: 0.75rem; }
.project-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}
.project-item:last-child { border-bottom: none; }
.project-title { font-size: 0.9rem; flex: 1; }

/* ============================================================
   Tag filters (wiki index)
   ============================================================ */
.tag-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1.75rem;
}
.tag-filter {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-muted);
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    padding: 0.25em 0.7em;
    transition: border-color 0.15s, color 0.15s;
}
.tag-filter:hover        { border-color: var(--accent); color: var(--accent); }
.tag-filter.active       { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

/* ============================================================
   Category sections (wiki index)
   ============================================================ */
.category-section { margin-bottom: 2.5rem; }
.category-heading {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0 0 0.6rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--border);
}

/* ============================================================
   Article list item (right-side meta)
   ============================================================ */
.article-item-right {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* ============================================================
   Table of contents
   ============================================================ */
.toc {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    display: inline-block;
    margin-bottom: 2rem;
    min-width: 200px;
    max-width: 100%;
    padding: 1rem 1.25rem 1.1rem;
}
.toc-title {
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    margin-bottom: 0.65rem;
    text-transform: uppercase;
}
.toc-list  { list-style: none; margin: 0; padding: 0; }
.toc-item  { margin-bottom: 0.3rem; line-height: 1.4; }
.toc-item a { color: var(--text-muted); font-size: 0.875rem; }
.toc-item a:hover { color: var(--accent); text-decoration: none; }
.toc-h2    { padding-left: 0; }
.toc-h3    { padding-left: 1rem; font-size: 0.82rem; }

/* ============================================================
   Breadcrumb
   ============================================================ */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1.75rem;
    font-family: var(--font-mono);
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--accent); text-decoration: none; }
.breadcrumb-sep { color: var(--border); }
.breadcrumb span:last-child { color: var(--text); }

/* ============================================================
   Article header (wiki article page)
   ============================================================ */
.article-header { margin-bottom: 2rem; }
.article-header h1 {
    font-size: 1.85rem;
    margin-bottom: 0.6rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}
.article-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* ============================================================
   Utilities
   ============================================================ */
.text-muted  { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-small  { font-size: 0.85rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
