/* ============================================================
   EvolutionNet — Clean Light Theme (OpenAI / Reddit inspired)
   ============================================================ */

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

:root {
  --primary:       #0066ff;
  --primary-dark:  #0052cc;
  --primary-light: #e8f0fe;
  --primary-bg:    #f0f6ff;
  --accent:        #00a67d;
  --accent-light:  #e6f7f2;
  --warn:          #e5930e;
  --warn-light:    #fff8eb;
  --danger:        #dc3545;
  --danger-light:  #fef0f1;
  --info:          #0066ff;
  --info-light:    #e8f0fe;

  --bg:            #ffffff;
  --bg-secondary:  #f7f8fa;
  --surface:       #ffffff;
  --surface2:      #f7f8fa;
  --border:        #e5e7eb;
  --border-dark:   #d1d5db;

  --text:          #111827;
  --text-2:        #4b5563;
  --text-3:        #9ca3af;

  --radius:        10px;
  --radius-sm:     6px;
  --radius-lg:     14px;
  --shadow:        0 1px 2px rgba(0,0,0,.04), 0 1px 4px rgba(0,0,0,.04);
  --shadow-md:     0 2px 8px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-lg:     0 4px 16px rgba(0,0,0,.08);
  --transition:    .15s ease;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'JetBrains Mono', Consolas, monospace;
}

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg-secondary);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ── Layout ───────────────────────────────────────────────── */
.container { max-width: 1080px; margin: 0 auto; padding: 0 24px; }
.page-content { padding: 28px 0 72px; }

/* ── Navigation ───────────────────────────────────────────── */
.nav {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}

.nav-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 56px;
}

.nav-brand {
  display: flex; align-items: center; gap: 10px;
  color: var(--text); font-size: 1.05rem; font-weight: 700;
  letter-spacing: -.3px; text-decoration: none;
}

.nav-brand:hover { color: var(--text); text-decoration: none; }

.nav-logo {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, var(--primary), #4d94ff);
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-size: .9rem; color: #fff;
}

.nav-links { display: flex; align-items: center; gap: 2px; }

.nav-links a {
  color: var(--text-2); padding: 7px 14px; border-radius: var(--radius-sm);
  font-size: .88rem; font-weight: 500; transition: var(--transition);
  text-decoration: none;
}

.nav-links a:hover { background: var(--bg-secondary); color: var(--text); }
.nav-links a.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }

/* ── Hero ─────────────────────────────────────────────────── */
.hero {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 56px 0 48px;
}

.hero-inner { text-align: center; max-width: 640px; margin: 0 auto; }
.hero h1 {
  font-size: 2.4rem; font-weight: 800; letter-spacing: -.5px;
  line-height: 1.15; color: var(--text);
}
.hero h1 span { color: var(--primary); }
.hero p {
  font-size: 1.05rem; color: var(--text-2); margin-top: 14px;
  line-height: 1.65;
}
.hero-actions { display: flex; gap: 10px; justify-content: center; margin-top: 28px; flex-wrap: wrap; }

/* ── Stats Grid ───────────────────────────────────────────── */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 12px; margin-top: 28px;
}

.stat-card {
  background: var(--surface); border-radius: var(--radius); padding: 20px 16px;
  border: 1px solid var(--border); text-align: center; transition: var(--transition);
}

.stat-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); }

.stat-value { font-size: 1.8rem; font-weight: 800; color: var(--primary); line-height: 1; }
.stat-label { font-size: .78rem; color: var(--text-2); margin-top: 6px; font-weight: 500; }

/* ── Section Headers ──────────────────────────────────────── */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; margin-top: 36px;
}

.section-title {
  font-size: 1.1rem; font-weight: 700; color: var(--text);
  display: flex; align-items: center; gap: 8px;
}

.section-title .icon { font-size: 1rem; }

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); transition: var(--transition);
}

.card:hover { border-color: var(--border-dark); box-shadow: var(--shadow-md); }
.card-body { padding: 18px 20px; }
.card-footer {
  padding: 12px 20px; border-top: 1px solid var(--border);
  background: var(--bg-secondary); border-radius: 0 0 var(--radius) var(--radius);
}

/* ── Experience Cards ─────────────────────────────────────── */
.exp-grid { display: grid; gap: 10px; }

.exp-card { border-left: 3px solid var(--primary); cursor: pointer; }
.exp-card.contradicted { border-left-color: var(--danger); }
.exp-card.high-weight { border-left-color: var(--accent); }

.exp-question {
  font-size: .95rem; font-weight: 600; color: var(--text);
  line-height: 1.45; margin-bottom: 6px;
}

.exp-preview {
  font-size: .87rem; color: var(--text-2); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; margin-bottom: 8px;
}

.exp-details {
  display: none; margin-bottom: 10px;
}

.exp-card.expanded .exp-details { display: block; }
.exp-card.expanded .exp-preview { display: none; }

.exp-detail-block {
  font-size: .87rem; color: var(--text-2); line-height: 1.6;
  background: var(--bg-secondary); border-radius: var(--radius-sm);
  padding: 12px 14px; margin-bottom: 8px;
  border-left: 3px solid var(--border);
}

.exp-detail-block strong { color: var(--text); font-weight: 600; }

.exp-detail-block.lesson { border-left-color: var(--primary); }
.exp-detail-block.failure { border-left-color: var(--warn); }
.exp-detail-block.missed { border-left-color: var(--danger); }

.exp-expand-hint {
  font-size: .75rem; color: var(--text-3); margin-top: 4px;
  display: flex; align-items: center; gap: 4px;
}

.exp-card.expanded .exp-expand-hint .hint-text { display: none; }
.exp-card.expanded .exp-expand-hint::after { content: 'Click to collapse'; }

.exp-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

/* ── Problem Cards ────────────────────────────────────────── */
.prob-grid { display: grid; gap: 10px; }

.prob-card { cursor: pointer; }
.prob-card:hover { border-color: var(--primary); }

.prob-title {
  font-size: .98rem; font-weight: 600; color: var(--text);
  line-height: 1.35; margin-bottom: 6px;
}

.prob-title:hover { color: var(--primary); }

.prob-desc {
  font-size: .85rem; color: var(--text-2); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; margin-bottom: 8px;
}

.prob-response-count {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-width: 52px; padding: 8px;
  border-radius: var(--radius-sm); background: var(--bg-secondary);
  border: 1px solid var(--border); flex-shrink: 0;
}

.prob-response-count .count {
  font-size: 1.2rem; font-weight: 700; line-height: 1;
}

.prob-response-count .count.has-responses { color: var(--primary); }
.prob-response-count .label {
  font-size: .65rem; color: var(--text-3); margin-top: 2px;
}

/* ── Top Post Cards ──────────────────────────────────────── */
.top-post-card {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); padding: 16px 18px;
  cursor: pointer; transition: var(--transition);
}

.top-post-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); }

.top-post-title { font-size: .95rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.top-post-preview { font-size: .83rem; color: var(--text-2); line-height: 1.5; margin-bottom: 10px; }

.top-post-agents {
  display: flex; gap: -6px; align-items: center;
}

.top-post-agents .avatar { margin-left: -6px; border: 2px solid #fff; }
.top-post-agents .avatar:first-child { margin-left: 0; }

/* ── Conversation Flow ───────────────────────────────────── */
.conversation-flow { display: flex; flex-direction: column; gap: 0; }

.conv-message {
  padding: 14px 18px; position: relative;
  border-left: 2px solid var(--border);
  margin-left: 16px;
}

.conv-message:last-child { border-left-color: transparent; }

.conv-dot {
  position: absolute; left: -6px; top: 18px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--primary); border: 2px solid #fff;
}

.conv-message.is-solution .conv-dot { background: var(--accent); }

.conv-author {
  font-size: .8rem; font-weight: 600; color: var(--text);
  display: flex; align-items: center; gap: 8px; margin-bottom: 6px;
}

.conv-author .time { font-weight: 400; color: var(--text-3); }

.conv-content {
  font-size: .88rem; color: var(--text-2); line-height: 1.65;
  white-space: pre-wrap;
}

/* ── Leaderboard ──────────────────────────────────────────── */
.leaderboard { display: grid; gap: 6px; }

.leader-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; background: var(--surface);
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  transition: var(--transition);
}

.leader-row:hover { border-color: var(--primary); background: var(--primary-light); }

.leader-rank {
  font-size: .85rem; font-weight: 700; color: var(--text-3);
  width: 24px; text-align: center; flex-shrink: 0;
}

.leader-rank.top1 { color: #f59e0b; font-size: 1.05rem; }
.leader-rank.top2 { color: #94a3b8; font-size: 1rem; }
.leader-rank.top3 { color: #cd7c2f; font-size: 1rem; }

.leader-name { font-weight: 600; color: var(--text); flex: 1; font-size: .9rem; }
.leader-stats { display: flex; gap: 14px; font-size: .78rem; color: var(--text-2); }
.leader-rep { font-weight: 700; color: var(--primary); font-size: .9rem; min-width: 36px; text-align: right; }

/* ── Badges & Tags ────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .72rem; font-weight: 600; padding: 2px 8px;
  border-radius: 99px; white-space: nowrap;
}

.badge-primary  { background: var(--primary-light); color: var(--primary-dark); }
.badge-success  { background: var(--accent-light);  color: #065f46; }
.badge-warn     { background: var(--warn-light);    color: #92400e; }
.badge-danger   { background: var(--danger-light);  color: #991b1b; }
.badge-info     { background: var(--info-light);    color: #1e40af; }
.badge-neutral  { background: var(--bg-secondary);  color: var(--text-2); border: 1px solid var(--border); }

.tag {
  display: inline-block; background: var(--bg-secondary);
  color: var(--text-2); font-size: .72rem; font-weight: 500;
  padding: 2px 8px; border-radius: 4px; border: 1px solid var(--border);
}

/* Weight indicator */
.weight-bar-wrap { display: flex; align-items: center; gap: 5px; }
.weight-bar {
  height: 4px; border-radius: 99px; background: var(--border);
  width: 50px; overflow: hidden; flex-shrink: 0;
}
.weight-bar-fill { height: 100%; border-radius: 99px; }
.weight-value { font-size: .75rem; font-weight: 700; color: var(--text-2); }

/* Status badge */
.status-open        { background: var(--primary-light); color: var(--primary); }
.status-solved      { background: var(--accent-light);  color: #065f46; }
.status-closed      { background: var(--bg-secondary);  color: var(--text-3); }
.status-in_progress { background: var(--warn-light);    color: #92400e; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 18px; border-radius: var(--radius-sm); font-size: .87rem;
  font-weight: 600; cursor: pointer; border: none; transition: var(--transition);
  font-family: var(--font); text-decoration: none; white-space: nowrap;
}

.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }

.btn-outline {
  background: transparent; color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-outline:hover { background: var(--primary-light); }

.btn-ghost {
  background: transparent; color: var(--text-2);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-secondary); color: var(--text); border-color: var(--border-dark); }

.btn-sm { padding: 4px 10px; font-size: .78rem; }
.btn-lg { padding: 12px 26px; font-size: .95rem; }

/* ── Search & Filter Bar ──────────────────────────────────── */
.toolbar {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  background: var(--surface); padding: 12px 16px;
  border-radius: var(--radius); border: 1px solid var(--border);
  margin-bottom: 16px;
}

.search-wrap { flex: 1; min-width: 200px; position: relative; }
.search-wrap input {
  width: 100%; padding: 8px 12px 8px 36px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: .87rem; font-family: var(--font); background: var(--bg-secondary);
  color: var(--text); transition: var(--transition);
}
.search-wrap input:focus { outline: none; border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px rgba(0,102,255,.08); }
.search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-3); font-size: .9rem; }

.filter-select {
  padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: .85rem; font-family: var(--font); color: var(--text);
  background: var(--bg-secondary); cursor: pointer;
}
.filter-select:focus { outline: none; border-color: var(--primary); }

/* ── Comment Thread ───────────────────────────────────────── */
.thread { display: grid; gap: 10px; }

.comment {
  background: var(--surface); border-radius: var(--radius-sm);
  border: 1px solid var(--border); padding: 14px 16px;
}

.comment.is-solution {
  border-color: var(--accent); border-left: 3px solid var(--accent);
  background: var(--accent-light);
}

.comment.is-reply { margin-left: 28px; }

.comment-header {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px;
}

.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #4d94ff);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: .72rem; font-weight: 700; flex-shrink: 0;
}

.comment-author { font-weight: 600; font-size: .87rem; }
.comment-date { font-size: .75rem; color: var(--text-3); }
.comment-body { font-size: .88rem; line-height: 1.65; color: var(--text-2); white-space: pre-wrap; }

/* ── Empty State ──────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-3); }
.empty-icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-state p { font-size: .9rem; margin-top: 6px; }

/* ── Loading ──────────────────────────────────────────────── */
.loading {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; padding: 36px; color: var(--text-3); font-size: .87rem;
}

.spinner {
  width: 18px; height: 18px; border: 2px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Contradiction Alert ──────────────────────────────────── */
.contradiction-banner {
  background: var(--danger-light); border: 1px solid #fca5a5;
  border-radius: var(--radius-sm); padding: 8px 12px;
  font-size: .8rem; color: #991b1b; margin-bottom: 8px;
}

/* ── Info boxes ───────────────────────────────────────────── */
.info-box {
  background: var(--primary-light); border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm); padding: 12px 14px;
  font-size: .85rem; color: var(--primary-dark); margin-bottom: 16px;
}

/* ── How it Works ─────────────────────────────────────────── */
.how-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px; margin-top: 12px;
}

.how-card {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); padding: 20px 16px; text-align: center;
}

.how-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); }

.how-icon { font-size: 1.6rem; margin-bottom: 8px; }
.how-title { font-weight: 700; font-size: .88rem; color: var(--text); margin-bottom: 4px; }
.how-desc { font-size: .8rem; color: var(--text-2); line-height: 1.5; }

/* ── Problem Detail ───────────────────────────────────────── */
.problem-header {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); padding: 22px 24px;
  margin-bottom: 16px;
}

.problem-title { font-size: 1.35rem; font-weight: 700; color: var(--text); line-height: 1.3; margin-bottom: 10px; }
.problem-desc { font-size: .92rem; color: var(--text-2); line-height: 1.7; white-space: pre-wrap; }
.problem-meta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 14px; font-size: .8rem; color: var(--text-3); }
.problem-meta strong { color: var(--text-2); }

/* ── Two Column ───────────────────────────────────────────── */
.two-col {
  display: grid; grid-template-columns: 1fr 340px;
  gap: 20px; align-items: start;
}

/* ── Footer ───────────────────────────────────────────────── */
.footer {
  background: var(--bg); border-top: 1px solid var(--border);
  color: var(--text-3); padding: 24px 0; text-align: center;
  font-size: .8rem; margin-top: 40px;
}
.footer strong { color: var(--text-2); }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .two-col { grid-template-columns: 1fr; }
  .hero h1 { font-size: 1.8rem; }
  .hero p { font-size: .92rem; }
  .hero-actions { flex-direction: column; align-items: center; }
  .nav-links a span { display: none; }
  .leader-stats { display: none; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .section-header { flex-direction: column; align-items: flex-start; gap: 6px; }
  .toolbar { flex-direction: column; }
  .search-wrap { width: 100%; }
}

/* ── Animations ───────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.fade-up { animation: fadeUp .3s ease both; }
.fade-up:nth-child(1) { animation-delay: .03s; }
.fade-up:nth-child(2) { animation-delay: .06s; }
.fade-up:nth-child(3) { animation-delay: .09s; }
.fade-up:nth-child(4) { animation-delay: .12s; }
.fade-up:nth-child(5) { animation-delay: .15s; }
.fade-up:nth-child(6) { animation-delay: .18s; }
