/**
 * research.css · rag.engineering Research Atom
 * Ultra-minimalist, distraction-free typographic system for technical dispatches & interactive visualizers.
 */

:root {
  --bg: #0c0d10;
  --bg-deep: #07080a;
  --surface: #121419;
  --surface-hover: #171a21;
  --surface-active: #1d212a;
  
  --border: #222631;
  --border-light: #2c3240;
  --border-focus: #41495a;
  
  --text: #b6bcc9;
  --text-dim: #5a6170;
  --text-light: #818898;
  --white: #d6dae4;
  --accent: #d6dae4;
  
  --brand-blue: #5c8fc7;
  --brand-blue-dim: rgba(92, 143, 199, 0.08);
  --ok: #38a169;
  --err: #d9534f;
  
  --mono: ui-monospace, 'JetBrains Mono', 'SFMono-Regular', Menlo, Monaco, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', system-ui, sans-serif;
  
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-full: 9999px;
  
  --transition-fast: 0.12s ease;
  --transition-normal: 0.2s ease;
}

/* ── Reset & Antialiasing ────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  color-scheme: dark;
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* ── Typography ──────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  color: var(--white);
  font-weight: 550;
  letter-spacing: -0.015em;
  line-height: 1.3;
}

h1 { font-size: 24px; }
h2 { font-size: 18px; margin: 36px 0 14px; letter-spacing: -0.01em; }
h3 { font-size: 15px; margin: 24px 0 10px; }

p {
  color: var(--text);
  margin-bottom: 18px;
}

a {
  color: var(--brand-blue);
  text-decoration: none;
  transition: opacity var(--transition-fast);
}
a:hover { opacity: 0.8; }

code, pre, .font-mono {
  font-family: var(--mono);
}

.subtle {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.6px;
  text-transform: lowercase;
  color: var(--text-dim);
}

/* ── Layout & Containers ─────────────────────────── */
.wrap {
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px 40px 80px;
}

@media (max-width: 768px) {
  .wrap { padding: 18px 14px 60px; }
}

.header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  gap: 16px;
}

/* ── Minimalist Site Navbar ──────────────────────── */
.site-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 6px 0 10px 0;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
  background: transparent;
}
.site-nav a {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 0;
  position: relative;
  transition: color var(--transition-fast);
  white-space: nowrap;
}
.site-nav a:hover {
  color: var(--white);
}
.site-nav a.active {
  color: var(--white);
  font-weight: 600;
}
.site-nav a.active::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -11px;
  height: 1px;
  background: var(--text);
}

/* ── Two-Column Research Layout ──────────────────── */
.research-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 36px;
  align-items: start;
}

@media (max-width: 960px) {
  .research-layout { grid-template-columns: 1fr; }
}

/* ── Sidebar (Catalog) ───────────────────────────── */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 24px;
}

.search-input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--white);
  outline: none;
  width: 100%;
  box-sizing: border-box;
  transition: border-color var(--transition-fast);
}
.search-input:focus {
  border-color: var(--border-focus);
}

.cat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.cat-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 2px;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 9px;
  text-transform: uppercase;
  padding: 3px 7px;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.cat-btn:hover {
  color: var(--white);
  border-color: var(--border-light);
}
.cat-btn.active {
  background: var(--surface-active);
  color: var(--white);
  border-color: var(--border-focus);
  font-weight: 600;
}

.dispatches-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: calc(100vh - 220px);
  overflow-y: auto;
  padding-right: 4px;
}

.dispatch-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.dispatch-card:hover {
  border-color: var(--border-light);
  background: var(--surface-hover);
}
.dispatch-card.active {
  border-color: var(--border-focus);
  background: var(--surface-active);
}

.dispatch-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text-dim);
}
.dispatch-title {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 550;
  color: var(--white);
  line-height: 1.35;
}
.dispatch-deck {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.dispatch-tag {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--brand-blue);
  margin-top: 4px;
}

/* ── Reading Article View ────────────────────────── */
.article-view {
  max-width: 860px;
  width: 100%;
}

.article-tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--brand-blue);
  margin-bottom: 12px;
}
.article-title {
  font-size: 26px;
  font-weight: 550;
  line-height: 1.3;
  color: var(--white);
  letter-spacing: -0.35px;
  margin-bottom: 14px;
}
.article-deck {
  font-size: 15px;
  color: var(--text-light);
  line-height: 1.65;
  margin-bottom: 24px;
}
.article-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-bottom: 32px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
}
.article-meta strong {
  color: var(--text);
}

.article-body {
  font-size: 15px;
  line-height: 1.75;
  color: var(--text);
}
.article-body ul, .article-body ol {
  margin: 16px 0 20px 24px;
}
.article-body li {
  margin-bottom: 8px;
}

.manifest-box {
  border-left: 2px solid var(--brand-blue);
  padding: 14px 18px;
  background: var(--surface);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 24px 0;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
  line-height: 1.6;
}
.manifest-box strong {
  color: var(--white);
}

.terminal-box {
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin: 20px 0;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  color: #93c5fd;
}

.quote-box {
  margin: 28px 0;
  padding: 16px 20px;
  border-left: 2px solid var(--border-light);
  background: var(--surface);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 15px;
  font-style: italic;
  color: var(--text-light);
  line-height: 1.65;
}

/* ── Interactive Simulation Embed ────────────────── */
.embed-container {
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin: 32px 0;
  overflow: hidden;
}
.embed-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 11px;
}
.embed-title {
  color: var(--white);
  display: flex;
  align-items: center;
  gap: 8px;
}
.embed-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
}
.embed-actions {
  display: flex;
  gap: 8px;
}
.embed-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 2px;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition-fast);
}
.embed-btn:hover {
  color: var(--white);
  border-color: var(--border-focus);
}

iframe.embed-frame {
  width: 100%;
  height: 720px;
  border: none;
  display: block;
  background: var(--bg-deep);
}

.embed-footer {
  padding: 8px 14px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.5;
}

/* ── Citation Card ───────────────────────────────── */
.citation-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-top: 36px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
}
.citation-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.citation-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 2px;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.citation-btn:hover {
  color: var(--white);
  border-color: var(--border-focus);
}

/* ── Footer ──────────────────────────────────────── */
.footer {
  margin-top: 48px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
}
