/* Custom styles for articles */
:root {
  --code-bg: #0f172a;
  --code-border: #1e293b;
  --code-muted: #cbd5e1;
  --code-accent: #38bdf8;
}

pre, code, kbd, samp {
  font-family: "Fira Code", Consolas, "Liberation Mono", Menlo, monospace;
}

/* Enforce Fira Code in markdown render */
.markdown-body code,
.markdown-body pre,
.single-page code,
.single-page pre {
  font-family: "Fira Code", Consolas, "Liberation Mono", Menlo, monospace;
}

/* Collapsible code blocks */
.code-block {
  border: 1px solid var(--code-border);
  border-radius: 12px;
  overflow: hidden;
  margin: 16px 0;
  background: var(--code-bg);
  color: var(--code-muted);
  box-shadow: 0 10px 28px rgba(0,0,0,0.12);
}
.code-block summary {
  cursor: pointer;
  padding: 10px 14px;
  background: rgba(255,255,255,0.02);
  display: flex;
  align-items: center;
  gap: 8px;
  color: #e2e8f0;
  font-weight: 600;
  letter-spacing: 0.2px;
}
.code-block summary::-webkit-details-marker { display: none; }
.code-block summary:before {
  content: "›";
  display: inline-block;
  transform: rotate(90deg);
  transition: transform 0.18s ease;
}
.code-block[open] summary:before {
  transform: rotate(270deg);
}
.code-block pre {
  margin: 0;
  padding: 12px 14px 14px 14px;
  overflow-x: auto;
  background: transparent;
  border: none;
  font-size: 0.95rem;
  line-height: 1.5;
}
.code-block pre code {
  background: transparent;
  padding: 0;
}

/* Inline code */
code:not(pre code) {
  background: #e5e7eb;
  padding: 0.15rem 0.35rem;
  border-radius: 6px;
  font-size: 0.95em;
}

/* Article TOC sidebar */
.article-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 24px;
  align-items: start;
  max-width: 72vw;
  margin: 0 auto;
}
/* When no TOC sidebar exists, article is only child - make it full width */
.article-shell:has(.article-main:only-child) {
  grid-template-columns: 1fr;
}
.article-main {
  background: #fff;
  padding: 32px 40px;
  width: 100%;
  min-height: 60vh;
}
/* Override .single card styles for article pages */
article.single.article-main {
  border: none;
  border-radius: 0;
  box-shadow: none;
  max-width: none;
}
.toc-sidebar {
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  padding: 16px 12px;
  background: transparent;
  border-right: 1px solid #e5e7eb;
  border-radius: 0;
  box-shadow: none;
}
.toc-sidebar h3 {
  margin: 0 0 12px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.toc-sidebar ul {
  list-style: none;
  padding-left: 0;
  margin: 0;
}
.toc-sidebar li {
  margin: 2px 0;
}
.toc-sidebar a {
  color: #475569;
  text-decoration: none;
  font-size: 0.9rem;
  display: block;
  padding: 6px 10px;
  border-radius: 6px;
  transition: all 0.15s ease;
}
.toc-sidebar a:hover {
  color: #0f172a;
  background: #f1f5f9;
}
.toc-sidebar a.active {
  font-weight: 600;
  color: #0d6efd;
  background: #eff6ff;
}
.toc-sidebar ul ul {
  display: none;
  padding-left: 16px;
  margin-top: 2px;
  border-left: 1px solid #e2e8f0;
  margin-left: 10px;
}
.toc-sidebar li.expanded > ul {
  display: block;
}

@media (max-width: 1200px) {
  .article-shell {
    display: block;
    width: 100%;
    max-width: 100%;
  }
  .article-main {
    width: 100%;
    padding: 24px 20px;
  }
  .toc-sidebar {
    position: relative;
    top: 0;
    max-height: none;
    margin-bottom: 16px;
    width: 100%;
    min-width: auto;
    border-right: none;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 16px;
  }
}

/* Vault layout */
.section-space .content-area {
  max-width: 72vw;
  margin: 0 auto;
}

.vault-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 24px;
  align-items: start;
  max-width: 72vw;
  margin: 0 auto;
}
.vault-tree-shell {
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  padding: 14px;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 10px 24px rgba(0,0,0,0.05);
}
.vault-content {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  box-shadow: 0 10px 24px rgba(0,0,0,0.06);
  padding: 26px 30px;
  width: 100%;
}
.vault-breadcrumb-nav ol {
  list-style: none;
  padding: 0;
  margin: 0 0 12px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.95rem;
}
.vault-breadcrumb-nav a { color: #0d6efd; text-decoration: none; }
.vault-breadcrumb-nav li { color: #475569; }

.vault-tree {
  list-style: none;
  padding-left: 0;
  margin: 0;
}
.vault-tree li {
  margin: 4px 0;
}
.vault-tree a {
  color: #334155;
  text-decoration: none;
  display: inline-flex;
  gap: 6px;
  align-items: center;
}
.vault-tree li.active > a { font-weight: 700; color: #0f172a; }
.vault-tree li.ancestor > a { color: #0f172a; }
.vault-tree ul { padding-left: 14px; margin-top: 4px; }
.vault-tree li:not(.expanded) > ul { display: none; }

.vault-folder-list, .vault-note-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.vault-card {
  display: block;
  padding: 12px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 6px 16px rgba(0,0,0,0.04);
  color: #0f172a;
  text-decoration: none;
}
.vault-card-title { font-weight: 600; margin-bottom: 4px; }
.vault-card-meta { color: #64748b; font-size: 0.9rem; }
.vault-empty { color: #94a3b8; font-style: italic; }

@media (max-width: 1200px) {
  .section-space .content-area { max-width: 94vw; }
  .vault-shell { grid-template-columns: 1fr; max-width: 94vw; }
}
@media (max-width: 800px) {
  .section-space .content-area { max-width: 100%; }
  .vault-shell { max-width: 100%; }
  .vault-tree-shell { position: relative; top: 0; max-height: none; }
}

/* Wiki layout */
.section-wiki .content-area {
  max-width: 72vw;
  margin: 0 auto;
}

.wiki-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 24px;
  align-items: start;
  max-width: 72vw;
  margin: 0 auto;
}

/* Wiki Tree Sidebar */
.wiki-tree-shell {
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  padding: 16px 12px;
  background: transparent;
  border-right: 1px solid #e5e7eb;
  border-radius: 0;
  box-shadow: none;
}

.wiki-tree {
  list-style: none;
  padding-left: 0;
  margin: 0;
  font-size: 0.9rem;
}
.wiki-tree li {
  margin: 2px 0;
}
.wiki-tree a {
  color: #475569;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 6px;
  transition: all 0.15s ease;
}
.wiki-tree a:hover {
  color: #0f172a;
  background: #f1f5f9;
}
.wiki-tree li.active > a {
  font-weight: 600;
  color: #0d6efd;
  background: #eff6ff;
}
.wiki-tree li.ancestor > a {
  color: #1e293b;
}
.wiki-tree ul {
  padding-left: 16px;
  margin-top: 2px;
  border-left: 1px solid #e2e8f0;
  margin-left: 10px;
}
.wiki-tree li:not(.expanded) > ul { display: none; }

/* Wiki Tree Icons */
.wiki-tree-icon {
  font-size: 0.85em;
  width: 1em;
  text-align: center;
  flex-shrink: 0;
  opacity: 0.7;
}
.wiki-tree-folder > a .wiki-tree-icon {
  color: #f59e0b;
  opacity: 1;
}
.wiki-tree-article > a .wiki-tree-icon {
  color: #64748b;
}
.wiki-tree li.active > a .wiki-tree-icon {
  opacity: 1;
}
.wiki-tree-article.active > a .wiki-tree-icon {
  color: #0d6efd;
}

/* Wiki Tree Chevron */
.wiki-tree-chevron {
  font-size: 0.7em;
  width: 0.8em;
  text-align: center;
  flex-shrink: 0;
  transition: transform 0.2s ease;
  opacity: 0.5;
}
.wiki-tree li.expanded > a .wiki-tree-chevron,
.wiki-tree li.ancestor > a .wiki-tree-chevron {
  transform: rotate(90deg);
}
.wiki-tree a:hover .wiki-tree-chevron {
  opacity: 0.8;
}

.wiki-tree-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Wiki Tree Folder Summary */
.wiki-tree-summary {
  display: block;
  font-size: 0.8em;
  color: #94a3b8;
  padding: 2px 10px 0 36px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wiki-tree-folder:not(.has-children) > .wiki-tree-summary {
  padding-left: 28px;
}
.wiki-tree-folder {
  margin-bottom: 8px;
}
.wiki-tree-folder:last-child {
  margin-bottom: 0;
}
.wiki-tree-article {
  margin-bottom: 2px;
}

/* Wiki Content Area */
.wiki-content {
  background: #fff;
  padding: 32px 40px;
  width: 100%;
  min-height: 60vh;
}

/* Breadcrumb */
.wiki-breadcrumb-nav {
  margin-bottom: 24px;
}
.wiki-breadcrumb-nav ol {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  font-size: 0.875rem;
}
.wiki-breadcrumb-nav li {
  display: flex;
  align-items: center;
  color: #64748b;
}
.wiki-breadcrumb-nav li::before {
  content: "/";
  margin-right: 8px;
  color: #cbd5e1;
}
.wiki-breadcrumb-nav li:first-child::before {
  content: "";
  margin: 0;
}
.wiki-breadcrumb-nav a {
  color: #64748b;
  text-decoration: none;
  transition: color 0.15s ease;
}
.wiki-breadcrumb-nav a:hover {
  color: #0d6efd;
}
.wiki-breadcrumb-nav li:last-child {
  color: #1e293b;
  font-weight: 500;
}

/* Wiki Header */
.wiki-header h1,
.wiki-article-header h1 {
  margin: 0 0 8px;
  font-size: 2rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.3;
}
.wiki-description {
  margin: 0 0 24px;
  color: #64748b;
  font-size: 1.1rem;
}
.wiki-article-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom: 1px solid #e5e7eb;
  font-size: 0.9rem;
  color: #64748b;
}
.wiki-article-meta time {
  color: #64748b;
}

/* Tags */
.wiki-tags {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
}
.wiki-tag {
  font-size: 0.8rem;
  color: #6366f1;
  background: #eef2ff;
  border-radius: 4px;
  padding: 2px 8px;
  font-weight: 500;
}

/* Wiki Listing (folders & pages) */
.wiki-listing {
  margin-top: 32px;
}
.wiki-section {
  margin-bottom: 32px;
}
.wiki-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e5e7eb;
}
.wiki-section-title svg {
  opacity: 0.7;
}

.wiki-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.wiki-list-item {
  border-bottom: 1px solid #f1f5f9;
}
.wiki-list-item:last-child {
  border-bottom: none;
}
.wiki-list-item a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 8px;
  text-decoration: none;
  color: #1e293b;
  transition: all 0.15s ease;
  border-radius: 6px;
}
.wiki-list-item a:hover {
  background: #f8fafc;
}
.wiki-list-icon {
  flex-shrink: 0;
  color: #94a3b8;
  display: flex;
  align-items: center;
}
.wiki-list-folder .wiki-list-icon {
  color: #f59e0b;
}
.wiki-list-title {
  font-weight: 500;
}
.wiki-list-summary {
  font-size: 0.85rem;
  font-weight: 400;
  color: #94a3b8;
  margin-left: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wiki-list-desc {
  color: #64748b;
  font-size: 0.875rem;
  margin-left: auto;
  max-width: 50%;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wiki-list-meta {
  color: #94a3b8;
  font-size: 0.8rem;
  flex-shrink: 0;
}
.wiki-list-arrow {
  color: #cbd5e1;
  flex-shrink: 0;
  transition: transform 0.15s ease;
}
.wiki-list-item a:hover .wiki-list-arrow {
  transform: translateX(3px);
  color: #94a3b8;
}

.wiki-empty {
  color: #94a3b8;
  font-style: italic;
  padding: 24px 0;
}

/* Wiki Intro content */
.wiki-intro {
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid #e5e7eb;
}
.wiki-intro:empty {
  display: none;
}

/* Wiki Article Body */
.wiki-article-body {
  line-height: 1.75;
}

/* Backlinks */
.wiki-backlinks {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid #e5e7eb;
}
.wiki-backlinks h3 {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 12px;
  color: #64748b;
}
.wiki-backlinks ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.wiki-backlinks li {
  margin: 0;
}
.wiki-backlinks a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #475569;
  text-decoration: none;
  padding: 4px 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 0.875rem;
  transition: all 0.15s ease;
}
.wiki-backlinks a:hover {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #0d6efd;
}
.wiki-backlinks a::before {
  content: "←";
  font-size: 0.75rem;
  opacity: 0.6;
}

/* Wikilinks */
.wikilink {
  color: #0d6efd;
  text-decoration: none;
  border-bottom: 1px dashed #93c5fd;
  transition: all 0.15s ease;
}
.wikilink:hover {
  border-bottom-style: solid;
  background: #eff6ff;
}
.wikilink-broken {
  color: #dc2626;
  border-bottom-color: #fca5a5;
}
.wikilink-broken:hover {
  background: #fef2f2;
}

@media (max-width: 1200px) {
  .section-wiki .content-area { max-width: 94vw; }
  .wiki-shell { grid-template-columns: 1fr; max-width: 94vw; }
  .wiki-tree-shell {
    border-right: none;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 16px;
    margin-bottom: 16px;
  }
}
@media (max-width: 800px) {
  .section-wiki .content-area { max-width: 100%; }
  .wiki-shell { max-width: 100%; }
  .wiki-tree-shell { position: relative; top: 0; max-height: none; }
  .wiki-content { padding: 24px 20px; }
}

/* ========================================
   Series Section - Series Sidebar + Tags
   ======================================== */

.series-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 32px;
  align-items: start;
  max-width: 72vw;
  margin: 0 auto;
}

/* Notes Tag Sidebar */
.series-sidebar {
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  padding: 16px 12px;
  background: transparent;
  border-right: 1px solid #e5e7eb;
}

.series-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #1e293b;
  padding: 8px 10px;
  margin-bottom: 8px;
}

.series-header i {
  color: #64748b;
}

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

.series-item {
  margin: 2px 0;
}

.series-item a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 6px;
  text-decoration: none;
  color: #475569;
  font-size: 0.9rem;
  transition: all 0.15s ease;
}

.series-item a:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.series-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.series-count {
  font-size: 0.75rem;
  font-weight: 600;
  color: #94a3b8;
  background: #f1f5f9;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 8px;
}

.series-item a:hover .series-count {
  background: #e2e8f0;
  color: #64748b;
}

.series-empty {
  color: #94a3b8;
  font-size: 0.85rem;
  padding: 8px 12px;
}

/* Notes Content Area */
.series-content {
  min-width: 0;
}

.series-content .list-header {
  margin-bottom: 24px;
}

.series-content .list-header h1 {
  margin: 0 0 8px 0;
}

.series-content .list-header .lead {
  color: #64748b;
  margin: 0;
}

.series-empty {
  color: #94a3b8;
  font-size: 0.95rem;
}

/* Snippet meta in single view */
.snippet-meta {
  margin-top: 12px;
  padding: 12px 16px;
  background: #f8fafc;
  border-left: 3px solid #0d6efd;
  border-radius: 0 6px 6px 0;
  font-size: 0.95rem;
  color: #334155;
}

.snippet-meta strong {
  color: #1e293b;
}

/* Article tags in meta */
.article-tags {
  margin-left: 12px;
}

.article-tags .tag {
  font-size: 0.85rem;
  color: #64748b;
  text-decoration: none;
  margin-right: 8px;
}

.article-tags .tag:hover {
  color: #0d6efd;
}

/* Series responsive */
@media (max-width: 1200px) {
  .series-shell {
    grid-template-columns: 1fr;
    max-width: 94vw;
  }
  .series-sidebar {
    position: relative;
    top: 0;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 16px;
    margin-bottom: 16px;
  }
  .series-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  .series-item a {
    padding: 6px 12px;
    background: #f1f5f9;
    border-radius: 999px;
  }
}

@media (max-width: 800px) {
  .series-shell {
    max-width: 100%;
  }
}


/* ========================================
   Snippets Search
   ======================================== */

/* Search Wrapper */
.search-wrapper {
  position: relative;
  margin: 16px 0 24px 0;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: #9ca3af;
  pointer-events: none;
  transition: color 0.2s ease;
}

/* Search Input */
.search-input {
  width: 100%;
  padding: 12px 14px 12px 42px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  font-size: 0.95rem;
  background: #ffffff;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.search-input:focus {
  outline: none;
  border-color: #0d6efd;
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.1), 0 2px 8px rgba(0, 0, 0, 0.1);
}

.search-input:focus + .search-icon,
.search-wrapper:focus-within .search-icon {
  color: #0d6efd;
}

.search-input::placeholder {
  color: #9ca3af;
}

/* Search Highlight */
.search-highlight {
  background: #fef08a;
  border-radius: 2px;
  padding: 0 2px;
  font-weight: 600;
}

/* No Results Message */
.no-results {
  padding: 32px;
  text-align: center;
  color: #64748b;
  font-size: 0.95rem;
}

.no-results.hidden {
  display: none;
}

.search-input:focus {
  outline: none;
  border-color: #0d6efd;
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.1);
}

.search-input::placeholder {
  color: #9ca3af;
}

/* Search Highlight */
.search-highlight {
  background: #fef08a;
  border-radius: 2px;
  padding: 0 2px;
  font-weight: 600;
}

/* No Results Message */
.no-results {
  padding: 32px;
  text-align: center;
  color: #64748b;
  font-size: 0.95rem;
}

.no-results.hidden {
  display: none;
}
