/* ===== VARIABLES & RESET ===== */
:root {
  --bg: #111827;
  --bg-2: #1f2937;
  --bg-3: #374151;
  --text: #f9fafb;
  --text-2: #d1d5db;
  --text-muted: #9ca3af;
  --accent: #818cf8;
  --accent-hover: #a5b4fc;
  --accent-dim: rgba(129, 140, 248, 0.12);
  --border: #374151;
  --radius: 8px;
  --radius-lg: 12px;
  --max-w: 900px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 1rem;
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== TYPOGRAPHY ===== */
h1, h2, h3, h4 { color: var(--text); line-height: 1.3; font-weight: 700; }
h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); }
h2 { font-size: clamp(1.3rem, 3vw, 1.75rem); margin-top: 2.5rem; margin-bottom: 0.75rem; }
h3 { font-size: 1.2rem; margin-top: 2rem; margin-bottom: 0.5rem; }
p { margin-bottom: 1.2rem; color: var(--text-2); }
p:last-child { margin-bottom: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
ul, ol { padding-left: 1.5rem; margin-bottom: 1.2rem; }
li { margin-bottom: 0.4rem; color: var(--text-2); }
strong { color: var(--text); }
hr { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }

/* ===== LAYOUT ===== */
.container { width: 100%; max-width: var(--max-w); margin: 0 auto; padding: 0 1.5rem; }
main { flex: 1; padding-bottom: 5rem; }

/* ===== NAVIGATION ===== */
.site-nav {
  background: rgba(17, 24, 39, 0.96);
  backdrop-filter: blur(8px);
  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: 64px;
}

.nav-logo {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}
.nav-logo:hover { color: var(--accent); text-decoration: none; }
.nav-logo .accent { color: var(--accent); }

.nav-links {
  display: flex;
  list-style: none;
  padding: 0;
  margin: 0;
  gap: 0.25rem;
}
.nav-links a {
  display: block;
  padding: 0.45rem 0.75rem;
  color: var(--text-muted);
  border-radius: var(--radius);
  font-size: 0.9375rem;
  transition: color 0.15s, background 0.15s;
}
.nav-links a:hover,
.nav-links a.active {
  color: var(--text);
  background: var(--bg-2);
  text-decoration: none;
}

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 0.4rem 0.65rem;
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
}

@media (max-width: 600px) {
  .nav-toggle { display: block; }
  .nav-links {
    display: none;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--bg-2);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 0.75rem 1.5rem 1rem;
    gap: 0.15rem;
  }
  .nav-links.open { display: flex; }
  .site-nav { position: relative; }
}

/* ===== HERO ===== */
.hero {
  padding: 5rem 0 4rem;
  text-align: center;
}
.hero h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  margin-bottom: 1rem;
  letter-spacing: -0.025em;
}
.hero .tagline {
  font-size: 1.125rem;
  color: var(--text-muted);
  max-width: 560px;
  margin: 0 auto 2.25rem;
}
.hero-actions { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-block;
  padding: 0.6rem 1.5rem;
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: #0f172a; }
.btn-primary:hover { background: var(--accent-hover); color: #0f172a; }
.btn-secondary { background: var(--bg-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg-3); color: var(--text); }

/* ===== FEATURE CARDS (homepage) ===== */
.features { padding: 3.5rem 0; border-top: 1px solid var(--border); }
.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}
.feature-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  transition: border-color 0.2s;
}
.feature-card:hover { border-color: var(--accent); }
.feature-icon { margin-bottom: 0.75rem; line-height: 0; }
.feature-card h3 { margin-top: 0; font-size: 1.05rem; margin-bottom: 0.4rem; }
.feature-card p { font-size: 0.9rem; margin: 0; color: var(--text-muted); }

/* ===== SECTION HEADERS ===== */
.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
}
.section-header h2 { margin: 0; }

/* ===== BLOG CARDS ===== */
.blog-section { padding: 3.5rem 0; }
.blog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 1.5rem;
}
.blog-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color 0.2s, transform 0.2s;
  display: flex;
  flex-direction: column;
}
.blog-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.blog-card > a {
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  height: 100%;
}
.blog-card > a:hover { text-decoration: none; }

.card-body { padding: 1.25rem; flex: 1; display: flex; flex-direction: column; }
.card-meta { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.5rem; }
.card-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.5rem;
  line-height: 1.4;
}
.card-excerpt { font-size: 0.875rem; color: var(--text-muted); flex: 1; margin: 0; }

/* ===== PAGE HEADER ===== */
.page-header {
  padding: 3rem 0 2.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2.5rem;
}
.page-header h1 { margin-bottom: 0.5rem; }
.page-header .subtitle { color: var(--text-muted); font-size: 1.0625rem; }

/* ===== ARTICLE ===== */
.article-header { padding: 3rem 0 2rem; }
.article-header h1 { margin-bottom: 0.75rem; }
.article-meta {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  flex-wrap: wrap;
}
.article-meta .sep { color: var(--border); }

.article-body { max-width: 720px; padding-bottom: 2rem; }
.article-body h2 {
  margin-top: 2.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}
.article-body h3 { margin-top: 2rem; }
.article-body img { max-width: 100%; border-radius: var(--radius); margin: 1.5rem 0; }
.article-body ul li, .article-body ol li { margin-bottom: 0.5rem; }

.article-back { margin-bottom: 2rem; font-size: 0.9rem; }
.article-back a { color: var(--text-muted); }
.article-back a:hover { color: var(--accent); }

/* ===== AI RESPONSE BLOCKS ===== */
.ai-response {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin: 1.5rem 0;
  font-size: 0.9375rem;
}
.ai-response p, .ai-response li { color: var(--text-2); }
.ai-response ul { margin-bottom: 0.75rem; }
.ai-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 0.75rem;
}

/* ===== TWO COLUMN ===== */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2.5rem;
  margin: 2rem 0;
}
@media (max-width: 640px) { .two-col { grid-template-columns: 1fr; } }

/* ===== TIMELINE ===== */
.timeline { list-style: none; padding: 0; margin: 1rem 0; }
.timeline li {
  position: relative;
  padding-left: 1.5rem;
  padding-bottom: 1rem;
  border-left: 2px solid var(--border);
  margin-left: 0.25rem;
}
.timeline li:last-child { border-left-color: transparent; }
.timeline li::before {
  content: '';
  position: absolute;
  left: -5px;
  top: 0.5rem;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
.timeline .year {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 0.15rem;
}
.timeline li p { font-size: 0.9rem; margin: 0; color: var(--text-2); }

/* ===== RESOURCES ===== */
.resource-group { margin-bottom: 3rem; }
.resource-group h2 {
  font-size: 1.2rem;
  margin-top: 0;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}
.resource-list { list-style: none; padding: 0; }
.resource-list li {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}
.resource-list li:last-child { border-bottom: none; }
.resource-list a { font-weight: 500; }
.resource-desc { display: block; font-size: 0.875rem; color: var(--text-muted); margin-top: 0.2rem; }

/* ===== D3 CHART ===== */
.chart-container { margin: 2rem 0; }
#chart svg text { fill: var(--text-2); font-size: 12px; }

/* ===== FOOTER ===== */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  text-align: center;
}
.site-footer p { color: var(--text-muted); font-size: 0.875rem; }

/* ===== BACK TO TOP ===== */
.back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  font-size: 1.1rem;
  z-index: 50;
  text-decoration: none;
}
.back-to-top.visible { opacity: 1; pointer-events: auto; }
.back-to-top:hover { background: var(--bg-3); color: var(--text); text-decoration: none; }
