/* ============================
   Wiki Memory — Global Styles
   Dark theme, minimalist knowledge base
   ============================ */

:root {
  --bg: #0d1117;
  --bg-card: #161b22;
  --bg-hover: #1c2333;
  --bg-code: #1a1f29;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --text-dim: #6e7681;
  --accent: #58a6ff;
  --accent-green: #3fb950;
  --accent-orange: #d29922;
  --accent-purple: #bc8cff;
  --accent-red: #f85149;
  --font-sans: 'Inter', -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --radius: 8px;
  --max-width: 1100px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  font-size: 16px;
}

a { color: var(--accent); text-decoration: none; transition: color 0.15s; }
a:hover { color: #79c0ff; text-decoration: underline; }

/* Header */
.wiki-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  position: sticky;
  top: 0;
  z-index: 100;
}
.wiki-header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}
.wiki-logo {
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.wiki-logo:hover { text-decoration: none; color: var(--accent); }
.wiki-logo .badge {
  font-size: 10px;
  background: var(--accent-purple);
  color: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}
.wiki-nav { display: flex; gap: 16px; flex: 1; }
.wiki-nav a {
  color: var(--text-muted);
  font-size: 14px;
  padding: 4px 8px;
  border-radius: 4px;
}
.wiki-nav a:hover { color: var(--text); background: var(--bg-hover); text-decoration: none; }
.wiki-nav a.active { color: var(--accent); }

.wiki-search { position: relative; flex-shrink: 0; }
.wiki-search input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px 6px 32px;
  color: var(--text);
  font-size: 13px;
  width: 200px;
}
.wiki-search input:focus {
  outline: none;
  border-color: var(--accent);
  width: 280px;
}
.wiki-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 13px;
}

/* Main content */
.wiki-content {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 32px 24px;
}

/* Hero */
.hero { text-align: center; padding: 48px 0 32px; }
.hero h1 {
  font-size: 2.8rem;
  font-weight: 700;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero p { color: var(--text-muted); font-size: 1.1rem; }

/* Stats */
.stats-bar {
  display: flex;
  justify-content: center;
  gap: 32px;
  padding: 24px 0 32px;
  flex-wrap: wrap;
}
.stat-item { text-align: center; }
.stat-number { font-size: 1.6rem; font-weight: 700; color: var(--text); }
.stat-label {
  font-size: 0.8rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Section titles */
.section-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 40px 0 20px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title .count {
  font-size: 0.8rem;
  color: var(--text-dim);
  font-weight: 400;
}

/* Card grid */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
  margin-bottom: 32px;
}
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  transition: all 0.15s;
}
.card:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(88,166,255,0.08);
}
.card-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.card:hover .card-title { color: var(--accent); }
.card-meta {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-bottom: 6px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.card-excerpt {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }

/* Tags */
.tag {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(88,166,255,0.1);
  color: var(--accent);
  border: 1px solid rgba(88,166,255,0.2);
  white-space: nowrap;
}
.tag.type-entity { background: rgba(188,140,255,0.1); color: var(--accent-purple); border-color: rgba(188,140,255,0.2); }
.tag.type-concept { background: rgba(63,185,80,0.1); color: var(--accent-green); border-color: rgba(63,185,80,0.2); }
.tag.type-daily { background: rgba(210,153,34,0.1); color: var(--accent-orange); border-color: rgba(210,153,34,0.2); }
.tag.type-session { background: rgba(88,166,255,0.1); color: var(--accent); border-color: rgba(88,166,255,0.2); }
.tag.type-comparison { background: rgba(248,81,73,0.1); color: var(--accent-red); border-color: rgba(248,81,73,0.2); }

/* Timeline */
.timeline { position: relative; padding-left: 24px; }
.timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}
.timeline-item {
  position: relative;
  padding: 8px 0 8px 16px;
  margin-left: -26px;
  padding-left: 42px;
}
.timeline-item::before {
  content: '';
  position: absolute;
  left: -3px;
  top: 14px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--accent);
}
.timeline-date {
  font-size: 0.8rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
}
.timeline-title { font-size: 1rem; font-weight: 500; }
.timeline-excerpt { font-size: 0.85rem; color: var(--text-muted); }

/* Wiki page */
.wiki-page { max-width: 800px; }
.wiki-page-header {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.wiki-page-header h1 { font-size: 2rem; font-weight: 700; margin-bottom: 8px; }
.wiki-page-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--text-dim);
}

/* Wiki page body */
.wiki-page-body { line-height: 1.8; font-size: 1rem; }
.wiki-page-body h2 { font-size: 1.4rem; font-weight: 600; margin: 32px 0 12px; padding-bottom: 4px; border-bottom: 1px solid var(--border); }
.wiki-page-body h3 { font-size: 1.15rem; font-weight: 600; margin: 24px 0 8px; }
.wiki-page-body p { margin-bottom: 16px; color: var(--text-muted); }
.wiki-page-body ul, .wiki-page-body ol { margin-bottom: 16px; padding-left: 24px; color: var(--text-muted); }
.wiki-page-body li { margin-bottom: 4px; }
.wiki-page-body code {
  background: var(--bg-code);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.85em;
}
.wiki-page-body pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  overflow-x: auto;
  margin-bottom: 16px;
}
.wiki-page-body pre code { background: none; padding: 0; }
.wiki-page-body blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 16px;
  margin: 16px 0;
  color: var(--text-muted);
  font-style: italic;
}
.wiki-page-body table { width: 100%; border-collapse: collapse; margin: 16px 0; }
.wiki-page-body th, .wiki-page-body td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.wiki-page-body th { background: var(--bg-card); font-weight: 600; }
.wiki-page-body img { max-width: 100%; border-radius: var(--radius); }

/* Breadcrumbs */
.breadcrumbs {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 16px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.breadcrumbs a { color: var(--text-dim); }
.breadcrumbs a:hover { color: var(--accent); text-decoration: none; }
.breadcrumbs .sep { color: var(--border); }

/* Backlinks */
.backlinks-section { margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--border); }
.backlinks-section h3 { font-size: 1rem; font-weight: 600; margin-bottom: 12px; color: var(--text-muted); }
.backlinks-list { display: flex; flex-direction: column; gap: 8px; }
.backlink-item {
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.backlink-item a { font-weight: 500; }
.backlink-excerpt { font-size: 0.85rem; color: var(--text-muted); margin-top: 2px; }

/* Search */
.search-page { max-width: 800px; margin: 0 auto; }
.search-page input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1.1rem;
  margin-bottom: 24px;
}
.search-page input:focus { outline: none; border-color: var(--accent); }
.search-results { display: flex; flex-direction: column; gap: 8px; }

/* Footer */
.wiki-footer {
  border-top: 1px solid var(--border);
  text-align: center;
  padding: 24px;
  color: var(--text-dim);
  font-size: 0.8rem;
  margin-top: 64px;
}

/* Wikilinks */
.wikilink { color: var(--accent-green); border-bottom: 1px dashed rgba(63,185,80,0.3); }
.wikilink:hover { border-bottom-style: solid; }
.wikilink.missing { color: var(--text-dim); border-bottom-color: rgba(110,118,129,0.3); cursor: not-allowed; }

/* Loading / empty state */
.loading, .empty-state { text-align: center; padding: 48px; color: var(--text-dim); }

/* Responsive */
@media (max-width: 768px) {
  .hero h1 { font-size: 2rem; }
  .wiki-nav { order: 3; width: 100%; }
  .wiki-search input { width: 160px; }
  .wiki-search input:focus { width: 200px; }
  .card-grid { grid-template-columns: 1fr; }
  .stats-bar { gap: 16px; }
}

/* Marks for search */
mark { background: rgba(88,166,255,0.2); color: var(--accent); padding: 0 2px; border-radius: 2px; }