/* ============================================
   葬AI Web4 — Design System
   Dark editorial · Purple neon · Pixel accents
   ============================================ */

:root {
  --bg: #08060f;
  --bg-1: #0e0a1c;
  --bg-2: #14102a;
  --bg-3: #1a1438;
  --border: #2a2150;
  --border-bright: #3d3070;
  --text: #e8e2f5;
  --text-dim: #9a92b8;
  --text-faint: #5a5278;
  --primary: #7351cf;
  --primary-bright: #9166ff;
  --primary-glow: rgba(115, 81, 207, 0.35);
  --accent: #e94f8a;
  --accent-glow: rgba(233, 79, 138, 0.3);
  --cyan: #2dd4bf;
  --amber: #f5a623;
  --green: #4ade80;

  --type-product: #7c8cff;
  --type-company: #4ade80;
  --type-person: #e94f8a;
  --type-vc_firm: #f5a623;

  --nav-h: 3rem;
  --max-w: 1200px;
  --mono: "SF Mono", "Fira Code", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
}

/* ---------- Reset ---------- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: var(--primary-bright); text-decoration: none; transition: color .2s; }
a:hover { color: var(--accent); }

::selection { background: var(--primary); color: #fff; }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-1); }
::-webkit-scrollbar-thumb { background: var(--border-bright); }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ============================================
   NAVBAR
   ============================================ */
.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: rgba(8, 6, 15, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 1000;
}
.navbar-inner {
  max-width: var(--max-w);
  height: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-family: var(--mono);
  font-weight: 700;
  font-size: .8rem;
  letter-spacing: .08em;
}
.nav-brand .dot {
  width: 8px; height: 8px;
  background: var(--primary);
  border-radius: 0;
  box-shadow: 0 0 8px var(--primary-glow);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}
.nav-links { display: flex; gap: .25rem; }
.nav-link {
  font-family: var(--mono);
  font-size: .75rem;
  letter-spacing: .05em;
  color: var(--text-dim);
  padding: .35rem .75rem;
  border: 1px solid transparent;
  transition: all .2s;
  text-transform: uppercase;
}
.nav-link:hover { color: var(--text); border-color: var(--border); }
.nav-link.active { color: var(--primary-bright); border-color: var(--primary); }

/* ============================================
   LAYOUT
   ============================================ */
.page {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: calc(var(--nav-h) + 2rem) 1.5rem 4rem;
}
.page-wide {
  padding-top: var(--nav-h);
}
.section-label {
  font-family: var(--mono);
  font-size: .7rem;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: .75rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.section-label::before {
  content: '';
  width: 12px;
  height: 1px;
  background: var(--primary);
}

/* ============================================
   HOMEPAGE
   ============================================ */
.home {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  position: relative;
  overflow: hidden;
}
.home-grid-bg {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--bg-2) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-2) 1px, transparent 1px);
  background-size: 60px 60px;
  opacity: .3;
  mask-image: radial-gradient(ellipse 60% 60% at 50% 50%, #000 0%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse 60% 60% at 50% 50%, #000 0%, transparent 80%);
  pointer-events: none;
}
.home-glow {
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, var(--primary-glow) 0%, transparent 70%);
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  filter: blur(40px);
}
.home-content { position: relative; z-index: 1; text-align: center; }
.home-logo {
  font-family: var(--mono);
  font-size: .65rem;
  letter-spacing: .3em;
  color: var(--accent);
  margin-bottom: 1rem;
  text-transform: uppercase;
}
.home-title {
  font-size: clamp(2.5rem, 8vw, 5rem);
  font-weight: 900;
  letter-spacing: -.02em;
  line-height: 1;
  background: linear-gradient(135deg, var(--text) 0%, var(--primary-bright) 50%, var(--accent) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.home-subtitle {
  margin-top: 1.25rem;
  font-size: 1rem;
  color: var(--text-dim);
  max-width: 540px;
  line-height: 1.8;
}
.home-subtitle b { color: var(--text); font-weight: 600; }

.home-stats {
  margin-top: 3rem;
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
  justify-content: center;
}
.stat {
  text-align: center;
  min-width: 110px;
}
.stat-num {
  font-family: var(--mono);
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--primary-bright);
  line-height: 1;
  text-shadow: 0 0 20px var(--primary-glow);
}
.stat-label {
  font-family: var(--mono);
  font-size: .7rem;
  color: var(--text-faint);
  letter-spacing: .1em;
  text-transform: uppercase;
  margin-top: .5rem;
}

.home-nav {
  margin-top: 3rem;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}
.nav-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  padding: 1.5rem 2.5rem;
  border: 1px solid var(--border);
  background: var(--bg-1);
  transition: all .25s;
  min-width: 160px;
}
.nav-card:hover {
  border-color: var(--primary);
  background: var(--bg-2);
  transform: translateY(-2px);
  box-shadow: 0 8px 30px var(--primary-glow);
}
.nav-card-icon {
  font-size: 1.5rem;
}
.nav-card-label {
  font-family: var(--mono);
  font-size: .85rem;
  letter-spacing: .05em;
  color: var(--text);
}
.nav-card-desc {
  font-size: .7rem;
  color: var(--text-faint);
}

.home-footer {
  margin-top: 3rem;
  font-family: var(--mono);
  font-size: .65rem;
  color: var(--text-faint);
  letter-spacing: .1em;
  position: relative;
  z-index: 1;
}

/* ============================================
   PAGE HEADER
   ============================================ */
.page-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.page-title {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -.01em;
  color: var(--text);
}
.page-title .accent { color: var(--primary-bright); }
.page-desc {
  margin-top: .5rem;
  color: var(--text-dim);
  font-size: .9rem;
}

/* ============================================
   GRAPH PAGE
   ============================================ */
.graph-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}
.graph-sidebar {
  width: 380px;
  flex-shrink: 0;
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.graph-sidebar-head {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--nav-h);
}
.graph-sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.graph-tab {
  flex: 1;
  padding: .6rem;
  font-family: var(--mono);
  font-size: .7rem;
  letter-spacing: .05em;
  text-align: center;
  color: var(--text-faint);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all .2s;
  text-transform: uppercase;
}
.graph-tab:hover { color: var(--text-dim); background: var(--bg-2); }
.graph-tab.active { color: var(--primary-bright); border-bottom-color: var(--primary); }

.leaderboard-list {
  flex: 1;
  overflow-y: auto;
  padding: .5rem;
}
.lb-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem .75rem;
  margin-bottom: .25rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all .15s;
}
.lb-item:hover {
  border-color: var(--border);
  background: var(--bg-2);
}
.lb-rank {
  font-family: var(--mono);
  font-size: .75rem;
  font-weight: 700;
  color: var(--text-faint);
  width: 24px;
  text-align: right;
  flex-shrink: 0;
}
.lb-item:nth-child(1) .lb-rank { color: var(--accent); }
.lb-item:nth-child(2) .lb-rank { color: var(--primary-bright); }
.lb-item:nth-child(3) .lb-rank { color: var(--cyan); }
.lb-type-dot {
  width: 10px; height: 10px;
  flex-shrink: 0;
}
.lb-name {
  font-size: .85rem;
  color: var(--text);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lb-score {
  font-family: var(--mono);
  font-size: .7rem;
  color: var(--text-faint);
  flex-shrink: 0;
}

.graph-canvas-wrap {
  flex: 1;
  position: relative;
  background: var(--bg);
  overflow: hidden;
}
#graphCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}
#graphCanvas:active { cursor: grabbing; }

.graph-controls {
  position: absolute;
  bottom: 1rem;
  left: 1rem;
  display: flex;
  flex-direction: column;
  gap: .25rem;
}
.graph-btn {
  width: 36px; height: 36px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
}
.graph-btn:hover {
  border-color: var(--primary);
  color: var(--text);
  background: var(--bg-3);
}

.graph-legend {
  position: absolute;
  top: 1rem;
  left: 1rem;
  background: rgba(14, 10, 28, 0.9);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  padding: .75rem;
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-family: var(--mono);
  font-size: .7rem;
  color: var(--text-dim);
}
.legend-dot {
  width: 10px; height: 10px;
}

.graph-info-bar {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(14, 10, 28, 0.9);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  padding: .5rem .75rem;
  font-family: var(--mono);
  font-size: .7rem;
  color: var(--text-faint);
}

/* Node detail panel */
.node-detail {
  position: absolute;
  top: 0; right: 0;
  width: 340px;
  height: 100%;
  background: var(--bg-1);
  border-left: 1px solid var(--border);
  padding: 1.25rem;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform .3s ease;
  z-index: 10;
}
.node-detail.open { transform: translateX(0); }
.node-detail-close {
  position: absolute;
  top: .75rem; right: .75rem;
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 28px; height: 28px;
  cursor: pointer;
  font-size: .9rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.node-detail-close:hover { color: var(--text); }
.node-detail-type {
  display: inline-block;
  font-family: var(--mono);
  font-size: .65rem;
  padding: .15rem .5rem;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.node-detail-name {
  font-size: 1.4rem;
  font-weight: 800;
  margin: .5rem 0;
}
.node-detail-desc {
  font-size: .85rem;
  color: var(--text-dim);
  line-height: 1.7;
  margin-bottom: 1rem;
}
.node-detail-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .5rem;
  margin-bottom: 1rem;
}
.nd-stat {
  background: var(--bg-2);
  border: 1px solid var(--border);
  padding: .5rem .75rem;
}
.nd-stat-val {
  font-family: var(--mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary-bright);
}
.nd-stat-lbl {
  font-family: var(--mono);
  font-size: .6rem;
  color: var(--text-faint);
  text-transform: uppercase;
}
.node-detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  margin-bottom: 1rem;
}
.nd-tag {
  font-family: var(--mono);
  font-size: .65rem;
  padding: .15rem .4rem;
  background: var(--bg-3);
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.node-detail-links-section {
  margin-top: .5rem;
}
.nd-links-title {
  font-family: var(--mono);
  font-size: .7rem;
  color: var(--text-faint);
  text-transform: uppercase;
  margin-bottom: .5rem;
}
.nd-link-item {
  font-size: .8rem;
  padding: .4rem .5rem;
  margin-bottom: .2rem;
  background: var(--bg-2);
  border-left: 2px solid var(--border);
  display: flex;
  align-items: center;
  gap: .4rem;
  color: var(--text-dim);
}
.nd-link-item:hover { border-left-color: var(--primary); color: var(--text); }
.nd-link-rel {
  font-family: var(--mono);
  font-size: .6rem;
  color: var(--text-faint);
  text-transform: uppercase;
}

/* ============================================
   ARTICLES LIST
   ============================================ */
.articles-toolbar {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}
.search-box {
  flex: 1;
  min-width: 200px;
  position: relative;
}
.search-box input {
  width: 100%;
  background: var(--bg-1);
  border: 1px solid var(--border);
  color: var(--text);
  padding: .65rem 1rem .65rem 2.25rem;
  font-size: .85rem;
  font-family: var(--sans);
  outline: none;
  transition: border-color .2s;
}
.search-box input:focus { border-color: var(--primary); }
.search-box input::placeholder { color: var(--text-faint); }
.search-icon {
  position: absolute;
  left: .75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  font-size: .85rem;
}
.filter-chips {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
}
.chip {
  font-family: var(--mono);
  font-size: .7rem;
  padding: .35rem .65rem;
  background: var(--bg-1);
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  transition: all .2s;
  letter-spacing: .03em;
}
.chip:hover { border-color: var(--border-bright); color: var(--text); }
.chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.articles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1rem;
}
.article-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  padding: 1.25rem;
  transition: all .25s;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}
.article-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 3px; height: 100%;
  background: var(--primary);
  transform: scaleY(0);
  transform-origin: top;
  transition: transform .25s;
}
.article-card:hover {
  border-color: var(--border-bright);
  background: var(--bg-2);
}
.article-card:hover::before { transform: scaleY(1); }
.article-card-id {
  font-family: var(--mono);
  font-size: .65rem;
  color: var(--text-faint);
  letter-spacing: .1em;
}
.article-card-title {
  font-size: 1rem;
  font-weight: 700;
  margin: .5rem 0;
  line-height: 1.5;
  color: var(--text);
}
.article-card:hover .article-card-title { color: var(--primary-bright); }
.article-card-excerpt {
  font-size: .8rem;
  color: var(--text-dim);
  line-height: 1.6;
  flex: 1;
  margin-bottom: .75rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.article-card-meta {
  display: flex;
  align-items: center;
  gap: .75rem;
  font-family: var(--mono);
  font-size: .7rem;
  color: var(--text-faint);
}
.article-card-author {
  padding: .1rem .4rem;
  border: 1px solid var(--border);
}
.article-card-author.葬爱咸鱼 { color: var(--accent); border-color: var(--accent); }
.article-card-author.沐秋 { color: var(--cyan); border-color: var(--cyan); }
.article-card-author.骡子马 { color: var(--amber); border-color: var(--amber); }
.article-card-author.罗子马 { color: var(--amber); border-color: var(--amber); }

.no-results {
  text-align: center;
  padding: 3rem;
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: .85rem;
}

/* ============================================
   ARTICLE DETAIL
   ============================================ */
.article-detail {
  max-width: 780px;
  margin: 0 auto;
  padding: calc(var(--nav-h) + 2rem) 1.5rem 4rem;
}
.article-back {
  font-family: var(--mono);
  font-size: .75rem;
  color: var(--text-dim);
  margin-bottom: 2rem;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  transition: color .2s;
}
.article-back:hover { color: var(--primary-bright); }
.article-detail-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.article-detail-id {
  font-family: var(--mono);
  font-size: .7rem;
  color: var(--accent);
  letter-spacing: .15em;
}
.article-detail-title {
  font-size: clamp(1.5rem, 4vw, 2.25rem);
  font-weight: 800;
  line-height: 1.3;
  margin: .75rem 0;
  color: var(--text);
}
.article-detail-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-family: var(--mono);
  font-size: .75rem;
  color: var(--text-dim);
}
.article-detail-author {
  padding: .15rem .5rem;
  border: 1px solid var(--border);
}

/* Markdown body */
.article-body {
  font-size: 16px;
  line-height: 1.85;
  color: var(--text);
}
.article-body h1 {
  font-size: 1.5rem;
  font-weight: 800;
  margin: 1.5rem 0 1rem;
}
.article-body h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 1.5rem 0 .75rem;
  color: var(--primary-bright);
}
.article-body h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 1.25rem 0 .5rem;
}
.article-body p {
  margin-bottom: 1rem;
}
.article-body strong {
  color: var(--text);
  font-weight: 700;
}
.article-body em {
  color: var(--accent);
  font-style: italic;
}
.article-body del {
  color: var(--text-faint);
}
.article-body a {
  color: var(--primary-bright);
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-underline-offset: 2px;
}
.article-body a:hover { text-decoration-color: var(--primary); }
.article-body blockquote {
  border-left: 3px solid var(--primary);
  padding: .5rem 0 .5rem 1rem;
  margin: 1rem 0;
  color: var(--text-dim);
  font-style: italic;
}
.article-body ul, .article-body ol {
  margin: 1rem 0;
  padding-left: 1.5rem;
}
.article-body li {
  margin-bottom: .4rem;
}
.article-body code {
  font-family: var(--mono);
  font-size: .85em;
  background: var(--bg-3);
  padding: .1rem .35rem;
  color: var(--accent);
}
.article-body pre {
  background: var(--bg-1);
  border: 1px solid var(--border);
  padding: 1rem;
  overflow-x: auto;
  margin: 1rem 0;
}
.article-body pre code {
  background: none;
  padding: 0;
  color: var(--text);
  font-size: .85rem;
}
.article-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}
.article-body img {
  max-width: 100%;
  margin: 1rem 0;
}
.article-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: .85rem;
}
.article-body th, .article-body td {
  border: 1px solid var(--border);
  padding: .5rem .75rem;
  text-align: left;
}
.article-body th {
  background: var(--bg-2);
  font-weight: 700;
}

/* Article footer nav */
.article-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  gap: 1rem;
}
.article-nav-link {
  flex: 1;
  padding: 1rem;
  border: 1px solid var(--border);
  background: var(--bg-1);
  transition: all .2s;
  display: flex;
  flex-direction: column;
  gap: .25rem;
}
.article-nav-link:hover {
  border-color: var(--primary);
  background: var(--bg-2);
}
.article-nav-link.next { text-align: right; }
.article-nav-dir {
  font-family: var(--mono);
  font-size: .65rem;
  color: var(--text-faint);
  text-transform: uppercase;
}
.article-nav-title {
  font-size: .85rem;
  color: var(--text);
  font-weight: 600;
}

/* ============================================
   TYPE COLORS
   ============================================ */
.type-product { background: var(--type-product); }
.type-company { background: var(--type-company); }
.type-person { background: var(--type-person); }
.type-vc_firm { background: var(--type-vc_firm); }

.type-badge-product { color: var(--type-product); border: 1px solid var(--type-product); }
.type-badge-company { color: var(--type-company); border: 1px solid var(--type-company); }
.type-badge-person { color: var(--type-person); border: 1px solid var(--type-person); }
.type-badge-vc_firm { color: var(--type-vc_firm); border: 1px solid var(--type-vc_firm); }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .graph-layout { flex-direction: column; }
  .graph-sidebar { width: 100%; height: 40vh; border-right: none; border-bottom: 1px solid var(--border); }
  .graph-canvas-wrap { height: 60vh; }
  .node-detail { width: 100%; }
  .articles-grid { grid-template-columns: 1fr; }
  .home-stats { gap: 1.5rem; }
  .stat-num { font-size: 2rem; }
}

/* ============================================
   UTILITIES
   ============================================ */
.mono { font-family: var(--mono); }
.faint { color: var(--text-faint); }
.dim { color: var(--text-dim); }
.center { text-align: center; }
