/* 节点共和国 — Shared Design System */

:root {
  --bg:          #070b14;
  --bg-panel:    #0d1626;
  --bg-card:     #111d33;
  --border:      #1a2d4a;
  --border-dim:  #0f1e35;
  --text:        #c8d8f0;
  --text-dim:    #5a7a9e;
  --text-muted:  #2d4a6a;

  --builder:     #3b82f6;
  --builder-dim: #1d3a6e;
  --scout:       #f59e0b;
  --scout-dim:   #7c4f0a;
  --trader:      #10b981;
  --trader-dim:  #064e35;
  --researcher:  #8b5cf6;
  --researcher-dim: #3b1f7a;

  --accent:      #38bdf8;
  --danger:      #ef4444;
  --success:     #22c55e;

  --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  --font-sans: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;

  --radius: 6px;
  --radius-lg: 10px;
}

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

html, body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── INDEX PAGE ─── */

.index-page {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
}

#bg-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

.hero {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 60px 24px;
  text-align: center;
}

.hero-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 4px 14px;
  margin-bottom: 32px;
}

.hero-title {
  font-size: clamp(52px, 10vw, 96px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  margin-bottom: 12px;
  background: linear-gradient(135deg, #e2eeff 30%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle {
  font-family: var(--font-mono);
  font-size: 14px;
  letter-spacing: 0.2em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 24px;
}

.hero-desc {
  max-width: 560px;
  color: var(--text-dim);
  font-size: 15px;
  line-height: 1.7;
  margin-bottom: 48px;
}

.hero-actions {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 64px;
}

.btn-enter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: var(--bg);
  font-weight: 600;
  font-size: 14px;
  padding: 12px 28px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
  text-decoration: none;
}
.btn-enter:hover { opacity: 0.9; transform: translateY(-1px); text-decoration: none; color: var(--bg); }

.btn-secondary-link {
  color: var(--text-dim);
  font-size: 14px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1px;
}
.btn-secondary-link:hover { color: var(--text); text-decoration: none; }

.node-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  max-width: 780px;
  width: 100%;
}

.node-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 16px;
  text-align: left;
  transition: border-color 0.2s;
}
.node-card:hover { border-color: var(--accent); }

.node-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-bottom: 10px;
  box-shadow: 0 0 8px currentColor;
}
.builder-dot  { background: var(--builder);  color: var(--builder); }
.scout-dot    { background: var(--scout);    color: var(--scout); }
.trader-dot   { background: var(--trader);   color: var(--trader); }
.researcher-dot { background: var(--researcher); color: var(--researcher); }

.node-card-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.node-card-desc {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.5;
}

/* ─── SIMULATION PAGE ─── */

.sim-page {
  height: 100vh;
  overflow: hidden;
}

.sim-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  height: 100vh;
}

.canvas-wrapper {
  position: relative;
  background: #060a12;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#world {
  display: block;
  border-radius: 4px;
}

.event-log {
  position: absolute;
  bottom: 24px;
  left: 24px;
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}

.event-item {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 6px 12px;
  border-radius: var(--radius);
  border-left: 3px solid;
  backdrop-filter: blur(8px);
  transition: opacity 1s;
}
.event-item.fading { opacity: 0; }

.event-boom       { background: rgba(30,64,175,0.5); border-color: var(--builder); color: #93c5fd; }
.event-shock      { background: rgba(127,29,29,0.5); border-color: var(--danger); color: #fca5a5; }
.event-knowledge  { background: rgba(91,33,182,0.5); border-color: var(--researcher); color: #c4b5fd; }
.event-entrants   { background: rgba(6,78,59,0.5); border-color: var(--trader); color: #6ee7b7; }
.event-freeze     { background: rgba(15,23,42,0.7); border-color: var(--text-dim); color: var(--text-dim); }

/* ─── SIDEBAR ─── */

.sidebar {
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.sidebar-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-dim);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: var(--bg-panel);
  z-index: 10;
}

.back-link {
  font-size: 12px;
  color: var(--text-dim);
}
.back-link:hover { color: var(--text); }

.tick-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.panel {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-dim);
}

.panel-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-link {
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--accent);
}

.controls {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.btn-primary {
  flex: 1;
  padding: 7px 12px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-primary:hover { opacity: 0.85; }

.btn-secondary {
  flex: 1;
  padding: 7px 12px;
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.speed-control {
  display: flex;
  align-items: center;
  gap: 10px;
}
.speed-control label {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  min-width: 60px;
}
.speed-control label span {
  font-family: var(--font-mono);
  color: var(--accent);
}
.speed-control input[type=range] {
  flex: 1;
  accent-color: var(--accent);
  cursor: pointer;
}

.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.metric {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius);
  padding: 8px 10px;
  text-align: center;
}

.metric-value {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
  margin-bottom: 2px;
}

.metric-label {
  font-size: 9px;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.agent-bars {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.agent-bar {
  display: grid;
  grid-template-columns: 10px 52px 1fr 20px;
  gap: 6px;
  align-items: center;
}

.agent-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: block;
  box-shadow: 0 0 5px currentColor;
}

.agent-label {
  font-size: 11px;
  color: var(--text-dim);
}

.bar-track {
  height: 4px;
  background: var(--bg-card);
  border-radius: 99px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.4s ease;
}

.builder-fill    { background: var(--builder); }
.scout-fill      { background: var(--scout); }
.trader-fill     { background: var(--trader); }
.researcher-fill { background: var(--researcher); }

.agent-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  text-align: right;
}

#gini-chart {
  display: block;
  width: 100%;
  border-radius: var(--radius);
}

.legend-panel { padding: 12px 16px; }

.legend-items {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-dim);
}

.legend-hex {
  display: inline-block;
  width: 10px;
  height: 10px;
  background: transparent;
  border: 1.5px solid #1e40af;
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
}

/* ─── ANALYTICS PAGE ─── */

.analytics-page {
  min-height: 100vh;
  padding: 0;
}

.analytics-header {
  padding: 20px 32px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-panel);
}

.analytics-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.analytics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto;
  gap: 1px;
  background: var(--border);
  min-height: calc(100vh - 65px);
}

.analytics-cell {
  background: var(--bg);
  padding: 24px;
}

.analytics-cell h2 {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.analytics-cell canvas {
  display: block;
  width: 100%;
}

/* ─── SCROLLBAR (global) ─── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
