/* ===== MathAtlas ===== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: #f0f2f5;
  color: #111827;
  line-height: 1.6;
  font-size: 15px;
}

/* --- Nav --- */
nav {
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  padding: 0 2rem;
  height: 56px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.brand {
  color: #111827;
  font-size: 1rem;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: -0.01em;
}
.brand span { color: #6366f1; }
.nav-links { display: flex; gap: 0.25rem; }
.nav-links a {
  color: #6b7280;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  transition: background 0.1s, color 0.1s;
}
.nav-links a:hover { background: #f3f4f6; color: #111827; }

/* --- Layout --- */
.container { max-width: 860px; margin: 0 auto; padding: 2rem 1.5rem; }

h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.3rem;
}
h2 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #9ca3af;
  margin: 2rem 0 0.75rem;
}

.subtitle { color: #6b7280; font-size: 0.9rem; margin-bottom: 2rem; }
.view-all { margin-top: 1.25rem; }
.view-all a {
  font-size: 0.875rem;
  font-weight: 500;
  color: #6366f1;
  text-decoration: none;
}
.view-all a:hover { text-decoration: underline; }
a { color: #6366f1; }
a:hover { color: #4f46e5; }

/* --- Stats --- */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 2.5rem;
  max-width: 420px;
}
.stat {
  background: #fff;
  border-radius: 12px;
  padding: 1.25rem 1rem;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
}
.stat-num {
  font-size: 2rem;
  font-weight: 700;
  color: #6366f1;
  line-height: 1;
  letter-spacing: -0.03em;
}
.stat-label {
  font-size: 0.7rem;
  color: #9ca3af;
  margin-top: 0.3rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

/* --- Cards --- */
.card {
  background: #fff;
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-bottom: 0.6rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
  transition: box-shadow 0.15s, transform 0.1s;
  border-top: 3px solid transparent;
}
.card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  transform: translateY(-1px);
}
.card > a { text-decoration: none; color: inherit; display: block; }

.card-header { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.25rem; }
.type-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #fff;
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  white-space: nowrap;
}
.card-title { font-size: 0.95rem; font-weight: 600; color: #111827; }
.card-meta { font-size: 0.75rem; color: #9ca3af; margin-bottom: 0.4rem; }
.card-body { font-size: 0.83rem; color: #6b7280; line-height: 1.5; }

/* --- Filters --- */
.filters { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1.5rem; }
.filter-btn {
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.3rem 0.8rem;
  border: 1.5px solid #e5e7eb;
  border-radius: 20px;
  background: #fff;
  cursor: pointer;
  color: #6b7280;
  transition: all 0.15s;
}
.filter-btn:hover { border-color: #6366f1; color: #6366f1; }
.filter-btn.active { background: #6366f1; color: #fff; border-color: #6366f1; }

/* --- Object detail page --- */
.back {
  font-size: 0.82rem;
  font-weight: 500;
  color: #9ca3af;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-bottom: 1.75rem;
  transition: color 0.1s;
}
.back:hover { color: #111827; }

.obj-header {
  background: #fff;
  border-radius: 12px;
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
  border-top: 4px solid #6366f1;
}
.obj-type {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin-bottom: 0.4rem;
}
.obj-title { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 0.5rem; }
.obj-meta { font-size: 0.78rem; color: #9ca3af; }

.obj-body {
  background: #f9fafb;
  border-radius: 12px;
  padding: 1.5rem 1.75rem;
  font-family: ui-monospace, 'Cascadia Code', 'Fira Code', monospace;
  font-size: 0.84rem;
  line-height: 1.9;
  white-space: pre-wrap;
  overflow-x: auto;
  color: #374151;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
  border: 1px solid #e5e7eb;
}

/* --- Lists --- */
.latex-list { padding-left: 1.75rem; margin: 0.5rem 0; }
.latex-list li { margin-bottom: 0.4rem; }

/* --- Proof section --- */
.proof-section { margin-top: 1rem; }
.proof-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: #14B8A6;
  margin-bottom: 0.4rem;
}

/* --- Dependency graph --- */
.dep-graph {
  background: #fff;
  border-radius: 12px;
  padding: 1.25rem 1.75rem;
  margin-top: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
  border: 1px solid #e5e7eb;
  overflow-x: auto;
}
.dep-graph .mermaid { margin-top: 0.75rem; }

/* --- Relations (depends-on / used-in) --- */
.relation-section { margin-top: 1rem; }
.relation-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: #9ca3af;
  margin-bottom: 0.4rem;
}
.relation-list { list-style: none; padding: 0; }
.relation-list li { margin-bottom: 0.3rem; }
.relation-list a {
  font-size: 0.88rem;
  color: #6366f1;
  text-decoration: none;
}
.relation-list a:hover { text-decoration: underline; }
.relation-list li::before { content: "→ "; color: #d1d5db; }

/* --- Areas index grid --- */
.areas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
  margin-top: 0.5rem;
}
.area-card {
  display: block;
  background: #fff;
  border-radius: 12px;
  border-top: 4px solid var(--accent, #6b7280);
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.15s, transform 0.1s;
}
.area-card:hover {
  box-shadow: 0 6px 24px rgba(0,0,0,0.11);
  transform: translateY(-2px);
}
.area-card-body { padding: 1.25rem 1.5rem; }
.area-card-name {
  font-size: 1rem;
  font-weight: 700;
  color: #111827;
  margin-bottom: 0.4rem;
}
.area-card-desc {
  font-size: 0.8rem;
  color: #6b7280;
  line-height: 1.55;
  margin-bottom: 0.85rem;
}
.area-card-count {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent, #6b7280);
  font-family: ui-monospace, monospace;
}
.area-link {
  color: #9ca3af;
  text-decoration: none;
  font-size: inherit;
}
.area-link:hover { color: #374151; text-decoration: underline; }

/* --- Area detail page --- */
.area-detail-header {
  background: #fff;
  border-radius: 12px;
  border-top: 4px solid #6b7280;
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
}
.area-detail-count {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-family: ui-monospace, monospace;
  margin-top: 0.5rem;
}
.empty-state {
  text-align: center;
  color: #9ca3af;
  padding: 3rem;
  font-style: italic;
}

/* --- Area knowledge graph --- */
.area-graph-section { margin-bottom: 1.5rem; }
.area-graph-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: #9ca3af;
  margin-bottom: 0.5rem;
}
#area-graph, #global-graph {
  width: 100%;
  height: 480px;
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
  cursor: pointer;
}
#global-graph { height: 70vh; }
#graph-tooltip {
  position: fixed;
  background: #111827;
  color: #fff;
  font-size: 0.78rem;
  font-family: 'Inter', system-ui, sans-serif;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  pointer-events: none;
  display: none;
  z-index: 1000;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
}
.gtt-type {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  opacity: 0.65;
  margin-right: 0.35rem;
}
.gtt-area {
  display: block;
  font-size: 0.6rem;
  opacity: 0.5;
  margin-top: 0.1rem;
}
.graph-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.6rem;
  margin-bottom: 0.25rem;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  color: #6b7280;
  font-weight: 500;
}
.legend-item::before {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--dot, #888);
}
