/* AI Semis Atlas — Editorial Design System */

:root {
  --bg: #fafaf7;
  --bg-paper: #ffffff;
  --ink: #1a1a1a;
  --ink-soft: #4a4a4a;
  --ink-faint: #888;
  --rule: #e5e5e0;
  --accent: #1e3a8a;
  --accent-soft: #3b82f6;
  --inner: #1e3a8a;
  --outer: #6b7280;
  --bridge: #c2410c;
  --warn: #b91c1c;
  --ok: #15803d;
  --code-bg: #f5f5f0;
  --max: 720px;
  --max-wide: 1100px;
  --font-serif: "Source Han Serif SC", "Songti SC", "Noto Serif CJK SC", Georgia, serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.7;
  font-size: 17px;
  margin: 0;
  padding: 0;
}

.container {
  max-width: var(--max);
  margin: 0 auto;
  padding: 4rem 2rem 6rem;
}

.container-wide {
  max-width: var(--max-wide);
  margin: 0 auto;
  padding: 4rem 2rem 6rem;
}

/* Top navigation */
nav.topnav {
  position: sticky;
  top: 0;
  background: rgba(250, 250, 247, 0.92);
  backdrop-filter: saturate(180%) blur(8px);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--rule);
  z-index: 100;
  padding: 0.9rem 2rem;
}
.topnav-inner {
  max-width: var(--max-wide);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
}
.topnav .brand {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: 0.01em;
}
.topnav .brand-sub {
  color: var(--ink-faint);
  font-size: 0.85rem;
  font-weight: 400;
  margin-left: 0.5rem;
}
.topnav .links {
  display: flex;
  gap: 1.6rem;
}
.topnav a.link {
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  transition: color 0.15s;
}
.topnav a.link:hover { color: var(--accent); }
.topnav a.link.active { color: var(--accent); border-bottom: 2px solid var(--accent); padding-bottom: 0.3rem; }

/* Typography */
h1, h2, h3, h4, h5 {
  font-family: var(--font-serif);
  color: var(--ink);
  letter-spacing: -0.01em;
  line-height: 1.25;
  margin-top: 2.6rem;
  margin-bottom: 1rem;
  font-weight: 600;
}
h1 { font-size: 2.6rem; margin-top: 0; letter-spacing: -0.02em; }
h2 { font-size: 1.8rem; padding-top: 1rem; border-top: 1px solid var(--rule); }
h3 { font-size: 1.35rem; }
h4 { font-size: 1.1rem; color: var(--ink-soft); }
h5 { font-size: 1rem; font-weight: 700; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.05em; }

p { margin: 1rem 0; }

strong { font-weight: 600; color: var(--ink); }
em { font-style: italic; }

a { color: var(--accent); text-decoration: none; border-bottom: 1px solid transparent; transition: border-color 0.15s; }
a:hover { border-bottom-color: var(--accent); }

blockquote {
  border-left: 3px solid var(--accent);
  margin: 1.6rem 0;
  padding: 0.3rem 1.2rem;
  color: var(--ink-soft);
  font-style: italic;
  background: rgba(30, 58, 138, 0.03);
}

ul, ol { padding-left: 1.6rem; }
li { margin: 0.4rem 0; }

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

code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 0.1em 0.35em;
  border-radius: 3px;
  color: var(--ink);
}

pre {
  background: var(--code-bg);
  padding: 1rem 1.2rem;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 0.88rem;
  line-height: 1.55;
  border: 1px solid var(--rule);
}
pre code { background: transparent; padding: 0; }

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.4rem 0;
  font-size: 0.92rem;
}
th, td {
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
th {
  font-weight: 600;
  font-family: var(--font-sans);
  background: var(--bg-paper);
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
tbody tr:hover { background: rgba(0,0,0,0.015); }

/* Ring badges */
.ring-inner, .ring-outer, .ring-bridge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.55rem;
  border-radius: 99px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-right: 0.5rem;
  vertical-align: middle;
}
.ring-inner { background: var(--inner); color: white; }
.ring-outer { background: var(--outer); color: white; }
.ring-bridge { background: var(--bridge); color: white; }

/* Landing page */
.hero {
  padding: 5rem 0 3rem;
  border-bottom: 1px solid var(--rule);
}
.hero-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--ink-faint);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 1rem;
}
.hero h1 {
  font-size: 3.4rem;
  margin: 0 0 1.5rem;
  letter-spacing: -0.025em;
}
.hero-tagline {
  font-size: 1.25rem;
  color: var(--ink-soft);
  max-width: 640px;
  margin-bottom: 2.5rem;
  line-height: 1.55;
}
.hero-meta {
  display: flex;
  gap: 3rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--ink-faint);
  margin-top: 2rem;
}
.hero-meta .stat {
  display: flex;
  flex-direction: column;
}
.hero-meta .stat-value {
  font-family: var(--font-serif);
  font-size: 2rem;
  color: var(--ink);
  font-weight: 600;
  line-height: 1;
  margin-bottom: 0.35rem;
}
.hero-meta .stat-label {
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Card grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin: 3rem 0;
}
.card {
  background: var(--bg-paper);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 1.8rem;
  transition: all 0.2s;
  text-decoration: none;
  color: var(--ink);
  display: block;
  position: relative;
  overflow: hidden;
}
.card:hover {
  border-color: var(--accent-soft);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(30, 58, 138, 0.08);
}
.card h3 { margin: 0 0 0.5rem; font-size: 1.25rem; }
.card p { margin: 0; color: var(--ink-soft); font-size: 0.95rem; line-height: 1.55; }
.card-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-faint);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.6rem;
}

/* TOC */
aside.toc {
  position: sticky;
  top: 5rem;
  width: 240px;
  max-height: calc(100vh - 7rem);
  overflow-y: auto;
  padding: 1.4rem 1rem 1.4rem 1.4rem;
  border-left: 1px solid var(--rule);
  font-size: 0.88rem;
}
aside.toc h5 {
  margin: 0 0 0.8rem;
  font-size: 0.75rem;
}
aside.toc ul { list-style: none; padding: 0; margin: 0; }
aside.toc li { margin: 0.45rem 0; line-height: 1.4; }
aside.toc li.depth-3 { padding-left: 1rem; font-size: 0.85rem; }
aside.toc li.depth-4 { padding-left: 2rem; font-size: 0.82rem; }
aside.toc a {
  color: var(--ink-soft);
  text-decoration: none;
  border: none;
  transition: color 0.15s;
}
aside.toc a:hover { color: var(--accent); }
aside.toc a.active { color: var(--accent); font-weight: 600; }

.layout-with-toc {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 3rem;
  max-width: var(--max-wide);
  margin: 0 auto;
  padding: 2rem 2rem 6rem;
}
.layout-with-toc .content { max-width: var(--max); }

@media (max-width: 900px) {
  .layout-with-toc { grid-template-columns: 1fr; }
  aside.toc { display: none; }
  .hero h1 { font-size: 2.4rem; }
  .hero-meta { gap: 1.5rem; flex-wrap: wrap; }
  body { font-size: 16px; }
}

/* Graph page */
#graph-canvas {
  width: 100%;
  height: 75vh;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--bg-paper);
}

.graph-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  margin: 1.5rem 0;
  padding: 1rem 1.2rem;
  background: var(--bg-paper);
  border: 1px solid var(--rule);
  border-radius: 6px;
}
.graph-controls label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  color: var(--ink-soft);
  cursor: pointer;
}
.graph-controls .legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
}
.graph-controls .legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}
.graph-controls .legend-line {
  width: 24px;
  height: 2px;
  display: inline-block;
}

.side-panel {
  position: fixed;
  top: 60px;
  right: 0;
  width: 380px;
  max-width: 90vw;
  height: calc(100vh - 60px);
  background: var(--bg-paper);
  border-left: 1px solid var(--rule);
  box-shadow: -4px 0 24px rgba(0,0,0,0.08);
  padding: 2rem 1.8rem;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  z-index: 50;
}
.side-panel.open { transform: translateX(0); }
.side-panel .close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--ink-faint);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.side-panel .close:hover { background: var(--code-bg); color: var(--ink); }
.side-panel h2 { margin-top: 0; font-size: 1.5rem; border: none; padding: 0; }
.side-panel .org { color: var(--ink-faint); font-size: 0.9rem; margin-bottom: 1rem; }
.side-panel .tagline { font-style: italic; color: var(--ink-soft); margin: 1rem 0 1.5rem; }
.side-panel .field { margin: 0.7rem 0; font-size: 0.92rem; }
.side-panel .field-label { font-family: var(--font-mono); font-size: 0.75rem; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.05em; }
.side-panel .field-value { color: var(--ink); }

.footer {
  text-align: center;
  margin-top: 5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--rule);
  color: var(--ink-faint);
  font-size: 0.85rem;
  font-family: var(--font-mono);
}

/* Atlas-specific h-anchors */
h1[id], h2[id], h3[id], h4[id] {
  scroll-margin-top: 5rem;
}
