/* ========================================
   Feature Circuits in LLMs — Shared Styles
   ======================================== */

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

:root {
  --bg:           #FAFAF9;
  --bg-dark:      #1C1917;
  --text:         #292524;
  --text-muted:   #78716C;
  --heading:      #0C0A09;
  --link:         #1D4ED8;
  --cite:         #6D28D9;
  --accent:       #C2410C;
  --border:       #E7E5E4;
  --code-bg:      #F5F5F4;
  --nav-bg:       #1C1917;
  --nav-text:     #F5F5F4;
  --max-width:    760px;
  --nav-h:        56px;
  --font-body:    Georgia, 'Times New Roman', serif;
  --font-sans:    -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', 'Fira Code', Consolas, monospace;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.78;
  font-size: 1.0625rem;
  padding-top: var(--nav-h);
}

/* ── Navigation ──────────────────────────── */

.site-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--nav-bg);
  z-index: 100;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.nav-inner {
  height: var(--nav-h);
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
}

.nav-brand {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 0.85rem;
  color: #F5F5F4 !important;
  text-decoration: none !important;
  white-space: nowrap;
  flex-shrink: 0;
  margin-right: 1.25rem;
}
.nav-brand:hover { color: #FCA5A5 !important; }

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

.nav-link {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  color: #A8A29E;
  text-decoration: none !important;
  padding: 6px 10px;
  border-radius: 4px;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover,
.nav-link.active {
  background: rgba(255,255,255,0.1);
  color: #F5F5F4;
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  margin-left: auto;
  flex-direction: column;
  gap: 5px;
}
.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: #A8A29E;
  border-radius: 2px;
}

@media (max-width: 900px) {
  .nav-toggle { display: flex; }
  .nav-links {
    display: none;
    position: absolute;
    top: var(--nav-h);
    left: 0;
    right: 0;
    background: var(--nav-bg);
    flex-direction: column;
    align-items: stretch;
    padding: 0.5rem 1rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    gap: 0;
  }
  .nav-links.open { display: flex; }
  .nav-link { padding: 10px 8px; }
}

/* ── Page layout ─────────────────────────── */

main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 3rem 1.5rem 6rem;
}

/* Hero / Index only */
.hero {
  background: var(--bg-dark);
  color: #F5F5F4;
  padding: 4rem 1.5rem 3.5rem;
  text-align: center;
}

.hero-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}

.hero-tag {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #FCA5A5;
  margin-bottom: 1.25rem;
}

.hero h1 {
  font-family: var(--font-sans);
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  line-height: 1.15;
  color: #FAFAF9;
  letter-spacing: -0.03em;
  margin-bottom: 1rem;
}

.hero-meta {
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  color: #A8A29E;
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.social-icon {
  color: #78716C;
  text-decoration: none !important;
  display: flex;
  align-items: center;
  transition: color 0.15s;
}
.social-icon:hover { color: #F5F5F4; }
.hero-meta .sep { margin: 0 0.5rem; }

.hero-abstract {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 1.5rem 2rem;
  text-align: left;
  font-size: 1rem;
  line-height: 1.75;
  color: #D6D3D1;
  margin-bottom: 2.5rem;
}

.hero-abstract strong {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #FCA5A5;
  margin-bottom: 0.75rem;
}

/* ── Typography ──────────────────────────── */

h1, h2, h3, h4, h5 {
  font-family: var(--font-sans);
  color: var(--heading);
  font-weight: 700;
  letter-spacing: -0.02em;
}

h1 { font-size: 2.25rem; line-height: 1.2; margin-bottom: 0.75rem; }

h2 {
  font-size: 1.625rem;
  margin-top: 3.5rem;
  margin-bottom: 0.75rem;
  padding-top: 2rem;
  border-top: 2px solid var(--border);
  color: var(--heading);
}

h2:first-child { margin-top: 0; }

h3 {
  font-size: 1.25rem;
  margin-top: 2.25rem;
  margin-bottom: 0.5rem;
  color: #1C1917;
}

h4 {
  font-size: 1.0625rem;
  margin-top: 1.75rem;
  margin-bottom: 0.25rem;
  color: var(--accent);
}

p { margin-top: 1.125rem; }
p:first-child { margin-top: 0; }

strong { font-weight: 700; color: var(--heading); }
em { font-style: italic; }

/* ── Links & Citations ───────────────────── */

a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.15s;
}
a:hover { color: #1E40AF; }

.citation {
  color: var(--cite);
  font-size: 0.8125em;
  vertical-align: super;
  line-height: 1;
  font-family: var(--font-sans);
  text-decoration: none;
  font-weight: 600;
  padding: 0 1px;
  transition: color 0.15s;
}
.citation:hover { color: #4C1D95; }

/* ── Math / Equations ────────────────────── */

.eq-block {
  overflow-x: auto;
  margin: 1.75rem 0;
  padding: 1.25rem 1.5rem;
  background: var(--code-bg);
  border-left: 3px solid var(--border);
  border-radius: 0 6px 6px 0;
  text-align: center;
}

/* MathJax inline fix */
mjx-container { font-size: 1em !important; }

/* ── Figures ─────────────────────────────── */

figure {
  margin: 2.5rem 0;
  text-align: center;
}

figure img {
  max-width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: 0 2px 12px rgba(0,0,0,0.07);
}

figcaption {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
  line-height: 1.5;
  font-style: italic;
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
}

/* ── Lists ───────────────────────────────── */

ol, ul {
  margin-top: 1.125rem;
  padding-left: 1.75rem;
}
li { margin-top: 0.5rem; }
li:first-child { margin-top: 0; }

/* ── Table of Contents (index) ───────────── */

.toc {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.toc-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.toc-item:hover {
  border-color: #A78BFA;
  box-shadow: 0 2px 12px rgba(109,40,217,0.1);
  transform: translateY(-1px);
  color: var(--text);
  text-decoration: none;
}

.toc-num {
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 0.8125rem;
  color: var(--text-muted);
  padding-top: 1px;
  flex-shrink: 0;
}

.toc-info { flex: 1; }
.toc-info strong {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--heading);
}
.toc-info span {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--text-muted);
}

@media (max-width: 560px) {
  .toc { grid-template-columns: 1fr; }
}

/* ── Section navigation (prev/next) ─────── */

.section-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  gap: 1rem;
}

.section-nav a {
  display: flex;
  flex-direction: column;
  font-family: var(--font-sans);
  text-decoration: none;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  flex: 1;
  max-width: 280px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.section-nav a:hover {
  border-color: #A78BFA;
  box-shadow: 0 2px 8px rgba(109,40,217,0.1);
  text-decoration: none;
}
.section-nav a.next { text-align: right; margin-left: auto; }
.section-nav .nav-dir {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.section-nav .nav-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--heading);
  margin-top: 0.25rem;
}

/* ── References ──────────────────────────── */

.reference-list {
  list-style: none;
  padding: 0;
  margin-top: 1.5rem;
}

.reference-list li {
  margin-top: 0;
  padding: 1rem 0 1rem 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 1rem;
  align-items: baseline;
}

.reference-list li:last-child { border-bottom: none; }

.ref-num {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
  padding-top: 1px;
  min-width: 1.75rem;
}

.ref-body {
  font-size: 0.9375rem;
  line-height: 1.6;
  flex: 1;
}

.ref-title {
  font-weight: 700;
  color: var(--heading);
  font-style: italic;
}
.ref-title a {
  font-style: italic;
  font-weight: 700;
  text-decoration: none;
  color: var(--link);
}
.ref-title a:hover { text-decoration: underline; }

.ref-venue {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.ref-link {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  margin-top: 0.25rem;
}

/* ── Callout box ─────────────────────────── */

.callout {
  background: #FFF7ED;
  border: 1px solid #FED7AA;
  border-left: 4px solid var(--accent);
  border-radius: 0 8px 8px 0;
  padding: 1rem 1.25rem;
  margin: 1.75rem 0;
  font-size: 0.9375rem;
}

.callout-label {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 0.4rem;
}

/* ── Utility ─────────────────────────────── */

.page-header {
  margin-bottom: 2rem;
}

.page-header .section-label {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.page-header h1 {
  font-size: 2rem;
  margin-bottom: 0;
}

.lead {
  font-size: 1.125rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
  line-height: 1.65;
}

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--code-bg);
  padding: 0.15em 0.35em;
  border-radius: 3px;
  border: 1px solid var(--border);
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}
