/* HyperAgents — Shared Design System */
:root {
  --color-bg: #fafbfc;
  --color-surface: #ffffff;
  --color-border: #e2e6ea;
  --color-text: #1a1d23;
  --color-text-secondary: #4a5060;
  --color-text-muted: #6b7280;
  --color-accent: #2563eb;
  --color-accent-subtle: #eff4ff;
  --color-accent-dark: #1d4ed8;
  --color-code-bg: #f3f4f6;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, monospace;
  --max-width: 780px;
  --max-width-wide: 1080px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.7;
}

/* Navigation */
nav {
  position: sticky; top: 0; z-index: 100;
  background: rgba(250, 251, 252, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
}
.nav-inner {
  max-width: var(--max-width-wide); margin: 0 auto; padding: 0 2rem;
  display: flex; align-items: center; justify-content: space-between; height: 56px;
}
.nav-logo { font-weight: 700; font-size: 1.1rem; color: var(--color-text); text-decoration: none; letter-spacing: -0.02em; }
.nav-logo span { color: var(--color-accent); }
.nav-links { display: flex; gap: 1.75rem; align-items: center; }
.nav-links a { font-size: 0.875rem; color: var(--color-text-secondary); text-decoration: none; transition: color 0.15s; }
.nav-links a:hover { color: var(--color-accent); }
.nav-links .btn-sm { background: var(--color-text); color: #fff; padding: 0.375rem 1rem; border-radius: 6px; font-weight: 500; transition: background 0.15s; }
.nav-links .btn-sm:hover { background: var(--color-accent-dark); color: #fff; }

/* Breadcrumb */
.breadcrumb {
  max-width: var(--max-width); margin: 0 auto; padding: 1rem 2rem 0;
  font-size: 0.8125rem; color: var(--color-text-muted);
}
.breadcrumb a { color: var(--color-accent); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb span { margin: 0 0.35rem; }

/* Article Header */
.article-header {
  max-width: var(--max-width); margin: 0 auto; padding: 2rem 2rem 1rem;
}
.article-header .tag-row { margin-bottom: 1rem; }
.article-tag {
  display: inline-block; font-size: 0.7rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--color-accent); background: var(--color-accent-subtle);
  padding: 0.2rem 0.65rem; border-radius: 4px;
}
.article-header h1 {
  font-size: clamp(1.75rem, 4vw, 2.5rem); font-weight: 800; letter-spacing: -0.03em;
  line-height: 1.2; margin-bottom: 0.75rem;
}
.article-meta { font-size: 0.8125rem; color: var(--color-text-muted); margin-bottom: 0.5rem; }
.article-meta time { font-weight: 500; }

/* Article Body */
article { max-width: var(--max-width); margin: 0 auto; padding: 1rem 2rem 3rem; }
article.wide { max-width: var(--max-width-wide); }

article h2 {
  font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em;
  margin: 2.5rem 0 0.75rem; line-height: 1.3; padding-top: 1rem;
  border-top: 1px solid var(--color-border);
}
article h2:first-of-type { border-top: none; padding-top: 0; margin-top: 1.5rem; }
article h3 {
  font-size: 1.125rem; font-weight: 600; margin: 1.75rem 0 0.5rem; letter-spacing: -0.01em;
}
article p { color: var(--color-text-secondary); line-height: 1.8; margin-bottom: 1rem; }
article p:last-child { margin-bottom: 0; }
article ul, article ol { margin: 0.75rem 0 1rem 1.5rem; color: var(--color-text-secondary); }
article li { margin-bottom: 0.4rem; line-height: 1.7; }
article strong { color: var(--color-text); }
article a { color: var(--color-accent); text-decoration: none; }
article a:hover { text-decoration: underline; }

/* Intro summary box */
.intro-summary {
  background: var(--color-accent-subtle); border-radius: 10px; padding: 1.25rem 1.5rem; margin-bottom: 1.5rem;
}
.intro-summary p { color: var(--color-text-secondary); font-size: 1.0625rem; margin: 0; }

/* Key points box */
.key-points {
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 10px;
  padding: 1.25rem 1.5rem; margin: 1.5rem 0;
}
.key-points-title { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--color-accent); margin-bottom: 0.5rem; }
.key-points ul { margin: 0; padding-left: 1.25rem; }
.key-points li { font-size: 0.9375rem; margin-bottom: 0.3rem; }

/* Code blocks */
.code-block {
  background: #1a1d23; border-radius: 10px; padding: 1.25rem 1.5rem; margin: 1.25rem 0; overflow-x: auto;
}
.code-block code {
  font-family: var(--font-mono); font-size: 0.8125rem; line-height: 1.65; color: #e2e6ea; white-space: pre;
}
.code-comment { color: #6b7280; }
.code-keyword { color: #93bbfb; }
.code-string { color: #a5d6a7; }
.code-decorator { color: #ce93d8; }
code:not(.code-block code) {
  font-family: var(--font-mono); font-size: 0.875em; background: var(--color-code-bg);
  padding: 0.15rem 0.4rem; border-radius: 4px;
}

/* Tables */
.table-wrap { overflow-x: auto; margin: 1.25rem 0; border: 1px solid var(--color-border); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
thead { background: var(--color-code-bg); }
th { text-align: left; padding: 0.7rem 1rem; font-weight: 600; font-size: 0.8rem; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 1px solid var(--color-border); }
td { padding: 0.7rem 1rem; border-bottom: 1px solid var(--color-border); color: var(--color-text-secondary); }
tr:last-child td { border-bottom: none; }
.tag { display: inline-block; font-size: 0.75rem; font-weight: 500; padding: 0.15rem 0.5rem; border-radius: 4px; background: var(--color-accent-subtle); color: var(--color-accent); font-family: var(--font-mono); }

/* Diagram */
.arch-diagram {
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 12px;
  padding: 1.5rem; margin: 1.25rem 0; overflow-x: auto;
}
.arch-diagram pre {
  font-family: var(--font-mono); font-size: 0.8rem; line-height: 1.7; color: var(--color-text-secondary); white-space: pre;
}

/* Feature cards grid */
.features-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; margin: 1.25rem 0; }
.feature-card {
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 10px;
  padding: 1.25rem; transition: border-color 0.15s;
}
.feature-card:hover { border-color: var(--color-accent); }
.feature-card h3 { font-size: 1rem; margin: 0 0 0.4rem; }
.feature-card p { font-size: 0.9rem; margin: 0; }

/* Callout */
.callout { background: #fef9ee; border-left: 3px solid #d97706; border-radius: 0 8px 8px 0; padding: 1.1rem 1.25rem; margin: 1.25rem 0; }
.callout-title { font-weight: 600; font-size: 0.8125rem; color: #92400e; margin-bottom: 0.25rem; }
.callout p { font-size: 0.9rem; color: #78350f; margin: 0; }
.callout-info { background: var(--color-accent-subtle); border-left-color: var(--color-accent); }
.callout-info .callout-title { color: var(--color-accent-dark); }
.callout-info p { color: var(--color-text-secondary); }

/* FAQ */
.faq-section { margin: 2rem 0; }
.faq-item { border-bottom: 1px solid var(--color-border); padding: 1rem 0; }
.faq-item:last-child { border-bottom: none; }
.faq-item h3 { font-size: 1rem; font-weight: 600; margin-bottom: 0.4rem; color: var(--color-text); }
.faq-item p { font-size: 0.9375rem; margin: 0; }

/* Related articles */
.related-articles { margin: 2.5rem 0 0; padding-top: 2rem; border-top: 1px solid var(--color-border); }
.related-articles h2 { border-top: none; padding-top: 0; margin-top: 0; font-size: 1.25rem; }
.related-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; margin-top: 1rem; }
.related-card {
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 8px;
  padding: 1rem 1.25rem; text-decoration: none; color: inherit; transition: border-color 0.15s;
  display: block;
}
.related-card:hover { border-color: var(--color-accent); text-decoration: none; }
.related-card .related-tag { font-size: 0.65rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--color-text-muted); margin-bottom: 0.35rem; }
.related-card h3 { font-size: 0.9375rem; font-weight: 600; margin: 0; line-height: 1.35; color: var(--color-text); }

/* Pillar link-back */
.pillar-link {
  display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.875rem;
  color: var(--color-accent); font-weight: 500; text-decoration: none; margin-top: 1rem;
}
.pillar-link:hover { text-decoration: underline; }

/* Footer */
footer {
  border-top: 1px solid var(--color-border); padding: 2.5rem 2rem; text-align: center;
  color: var(--color-text-muted); font-size: 0.8125rem;
}
footer a { color: var(--color-text-secondary); text-decoration: none; }
footer a:hover { color: var(--color-accent); }
.footer-links { display: flex; gap: 1.5rem; justify-content: center; margin-bottom: 1rem; flex-wrap: wrap; }

/* ===== Three-Column Layout: Left Nav + Article + Right TOC ===== */
.article-layout {
  max-width: 1280px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 200px minmax(0, var(--max-width)) 200px;
  gap: 1.5rem;
  padding: 0 2rem;
  align-items: start;
  justify-content: center;
}
.article-layout > article {
  padding: 1rem 0 3rem;
  margin: 0;
  min-width: 0;
}

/* ── Shared sidebar styles ── */
.sidebar-sticky {
  position: sticky;
  top: 72px;
  max-height: calc(100vh - 88px);
  overflow-y: auto;
  padding: 0.25rem 0 2rem;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}
.sidebar-sticky::-webkit-scrollbar { width: 3px; }
.sidebar-sticky::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 3px; }

.sidebar-title {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  margin-bottom: 0.6rem;
  padding-left: 0.75rem;
}

/* ── Right: On-page TOC ── */
.toc-list {
  list-style: none; margin: 0; padding: 0;
  border-left: 1px solid var(--color-border);
}
.toc-list li { margin: 0; }
.toc-list a {
  display: block; padding: 0.3rem 0.75rem; font-size: 0.75rem; line-height: 1.4;
  color: var(--color-text-muted); text-decoration: none;
  border-left: 2px solid transparent; margin-left: -1px;
  transition: color 0.15s, border-color 0.15s;
}
.toc-list a:hover { color: var(--color-accent); }
.toc-list a.active {
  color: var(--color-accent); border-left-color: var(--color-accent); font-weight: 500;
}

/* ── Left: Page navigation sidebar ── */
.nav-sidebar-group { margin-bottom: 1rem; }
.nav-sidebar-group-title {
  font-size: 0.625rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--color-text-muted);
  padding: 0 0.5rem; margin-bottom: 0.35rem;
}
.nav-sidebar-list { list-style: none; margin: 0; padding: 0; }
.nav-sidebar-list li { margin: 0; }
.nav-sidebar-list a {
  display: block; padding: 0.25rem 0.5rem; font-size: 0.75rem; line-height: 1.4;
  color: var(--color-text-muted); text-decoration: none; border-radius: 4px;
  transition: color 0.12s, background 0.12s;
}
.nav-sidebar-list a:hover { color: var(--color-accent); background: var(--color-accent-subtle); }
.nav-sidebar-list a.current {
  color: var(--color-accent); background: var(--color-accent-subtle); font-weight: 600;
}
.nav-sidebar-home {
  display: block; padding: 0.4rem 0.5rem; font-size: 0.8125rem; font-weight: 600;
  color: var(--color-text); text-decoration: none; margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--color-border); padding-bottom: 0.6rem;
}
.nav-sidebar-home:hover { color: var(--color-accent); }
.nav-sidebar-home span { color: var(--color-accent); }

/* ── Inline inter-page nav (bottom of article, kept for mobile) ── */
.page-nav {
  margin: 2.5rem 0 0; padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
}
.page-nav-title {
  font-size: 0.6875rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--color-text-muted); margin-bottom: 0.75rem;
}
.page-nav-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.5rem;
}
.page-nav-grid a {
  display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0.75rem;
  font-size: 0.8125rem; color: var(--color-text-secondary); text-decoration: none;
  border-radius: 6px; transition: background 0.12s, color 0.12s; line-height: 1.35;
}
.page-nav-grid a:hover { background: var(--color-accent-subtle); color: var(--color-accent); }
.page-nav-grid a.current {
  background: var(--color-accent-subtle); color: var(--color-accent);
  font-weight: 600; pointer-events: none;
}
.page-nav-dot {
  width: 5px; height: 5px; border-radius: 50%; background: var(--color-border); flex-shrink: 0;
}
.page-nav-grid a:hover .page-nav-dot,
.page-nav-grid a.current .page-nav-dot { background: var(--color-accent); }

/* ===== Responsive ===== */
@media (max-width: 1100px) {
  .article-layout {
    grid-template-columns: 180px minmax(0, 1fr);
    max-width: var(--max-width-wide);
  }
  .toc-sidebar { display: none; }
}
@media (max-width: 800px) {
  .article-layout {
    grid-template-columns: 1fr;
    padding: 0;
  }
  .article-layout > article {
    max-width: var(--max-width);
    padding: 1rem 2rem 3rem;
    margin: 0 auto;
  }
  .nav-sidebar { display: none; }
  .toc-sidebar { display: none; }
}
@media (max-width: 640px) {
  .article-header { padding: 1.5rem 1.25rem 0.75rem; }
  .article-layout > article { padding: 1rem 1.25rem 2.5rem; }
  article { padding: 1rem 1.25rem 2.5rem; }
  .breadcrumb { padding: 0.75rem 1.25rem 0; }
  .nav-inner { padding: 0 1.25rem; }
  .nav-links { gap: 1rem; }
  .features-grid { grid-template-columns: 1fr; }
}
