/* syntropd - Native AI Subsystem for systemd
 * Engineering Design System (Dark Mode, High Contrast, Zero CDN)
 */

:root {
  --bg-primary: #0a0e17;
  --bg-surface: #111827;
  --bg-card: #162032;
  --bg-card-hover: #1c2a42;
  --bg-code: #070a0f;
  --bg-subtle: #1e293b;

  --border: #223249;
  --border-focus: #00d2b4;
  --border-light: #2d4263;

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --text-link: #38bdf8;
  --text-link-hover: #00d2b4;

  --teal: #00d2b4;
  --teal-dim: rgba(0, 210, 180, 0.12);
  --cyan: #38bdf8;
  --cyan-dim: rgba(56, 189, 248, 0.12);
  --green: #10b981;
  --green-dim: rgba(16, 185, 129, 0.15);
  --amber: #f59e0b;
  --amber-dim: rgba(245, 158, 11, 0.15);
  --rose: #f43f5e;
  --rose-dim: rgba(244, 63, 94, 0.15);
  --purple: #a855f7;
  --purple-dim: rgba(168, 85, 247, 0.15);

  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --max-width: 1200px;
}

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

html {
  font-size: 16px;
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.6;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--text-link);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--text-link-hover);
}

/* ---------------- Top Banner ---------------- */
.top-banner {
  background: linear-gradient(90deg, #0e1e2d 0%, #0d2836 100%);
  border-bottom: 1px solid var(--border);
  padding: 0.45rem 1rem;
  font-size: 0.8rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  text-align: center;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1.25rem;
}

.top-banner .badge {
  background: var(--teal-dim);
  color: var(--teal);
  border: 1px solid rgba(0, 210, 180, 0.3);
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

/* ---------------- Navigation ---------------- */
.site-header {
  background: rgba(10, 14, 23, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.nav-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-main);
  font-weight: 700;
  font-size: 1.25rem;
  font-family: var(--font-mono);
  letter-spacing: -0.02em;
}

.brand:hover {
  color: var(--text-main);
}

.brand svg {
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  list-style: none;
}

.nav-links a {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text-main);
  background: var(--bg-card);
}

.nav-links a.active {
  border: 1px solid var(--border-light);
  color: var(--teal);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.github-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  font-family: var(--font-mono);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.github-btn:hover {
  background: var(--bg-card);
  border-color: var(--border-light);
  color: var(--teal);
}

/* Mobile Nav Toggle */
.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 0.4rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

/* ---------------- Hero Section ---------------- */
.hero {
  padding: 4.5rem 1.5rem 3.5rem;
  border-bottom: 1px solid var(--border);
  background: radial-gradient(circle at 50% 20%, rgba(0, 210, 180, 0.05) 0%, rgba(10, 14, 23, 0) 70%);
}

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

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--teal);
  background: var(--teal-dim);
  border: 1px solid rgba(0, 210, 180, 0.25);
  padding: 0.25rem 0.8rem;
  border-radius: 9999px;
  margin-bottom: 1.5rem;
}

.hero h1 {
  font-size: clamp(2.4rem, 5vw, 3.8rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.03em;
  margin-bottom: 1.25rem;
}

.hero h1 .highlight {
  background: linear-gradient(135deg, #00d2b4 0%, #38bdf8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-lead {
  font-size: 1.2rem;
  color: var(--text-muted);
  max-width: 800px;
  margin: 0 auto 2.25rem;
}

.hero-lead strong {
  color: var(--text-main);
}

.hero-ctas {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 3rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.75rem 1.4rem;
  border-radius: var(--radius-md);
  transition: all 0.15s ease;
  cursor: pointer;
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--teal);
  color: #070a0f;
  box-shadow: 0 4px 14px rgba(0, 210, 180, 0.25);
}

.btn-primary:hover {
  background: #00ebb4;
  color: #070a0f;
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-surface);
  border-color: var(--border);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: var(--bg-card);
  border-color: var(--border-light);
  color: var(--teal);
}

.hero-specs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.25rem;
  max-width: 980px;
  margin: 0 auto;
  text-align: left;
}

.spec-pill {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem;
  transition: border-color 0.15s ease;
}

.spec-pill:hover {
  border-color: var(--border-light);
}

.spec-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--teal);
  margin-bottom: 0.25rem;
}

.spec-value {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  font-family: var(--font-mono);
}

.spec-desc {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 0.2rem;
}

/* ---------------- Main Content Layout ---------------- */
.main-wrap {
  flex: 1;
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: 3rem 1.5rem;
}

.page-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 2rem;
  margin-bottom: 3rem;
}

.page-header .category {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--teal);
  letter-spacing: 0.1em;
  margin-bottom: 0.5rem;
}

.page-header h1 {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
}

.page-header p {
  font-size: 1.1rem;
  color: var(--text-muted);
  max-width: 760px;
}

/* ---------------- Architecture & Diagrams ---------------- */
.diagram-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  margin-bottom: 2.5rem;
}

.diagram-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.diagram-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
}

.diagram-header p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

.diagram-viewport {
  background: #070a0f;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  overflow-x: auto;
  position: relative;
}

/* Interactive SVG Styling */
svg.interactive-arch {
  width: 100%;
  height: auto;
  min-width: 700px;
  display: block;
}

.arch-node {
  cursor: pointer;
  transition: all 0.2s ease;
}

.arch-node:hover rect,
.arch-node.active rect {
  stroke: var(--teal);
  stroke-width: 2.5px;
  filter: drop-shadow(0 0 8px rgba(0, 210, 180, 0.4));
}

.arch-node text {
  pointer-events: none;
  user-select: none;
}

/* Inspector Drawer for Nodes */
.inspector-panel {
  margin-top: 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: none;
}

.inspector-panel.visible {
  display: block;
  animation: fadeIn 0.2s ease;
}

.inspector-title {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  color: var(--teal);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.inspector-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
  font-size: 0.85rem;
  font-family: var(--font-mono);
}

.meta-item {
  background: var(--bg-surface);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.meta-item span {
  color: var(--text-dim);
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
}

/* ---------------- Triage Stepper Flow ---------------- */
.stepper-container {
  display: flex;
  gap: 1.5rem;
  margin-top: 1.5rem;
  flex-direction: column;
}

.step-tracker {
  display: flex;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  gap: 0.5rem;
}

.step-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.step-btn .step-num {
  background: var(--bg-card);
  color: var(--text-dim);
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  font-weight: 700;
}

.step-btn:hover {
  background: var(--bg-card);
  color: var(--text-main);
}

.step-btn.active {
  background: var(--teal-dim);
  border-color: var(--teal);
  color: var(--teal);
}

.step-btn.active .step-num {
  background: var(--teal);
  color: #070a0f;
}

.step-content-card {
  background: #070a0f;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
}

.step-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.step-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.step-latency {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--green);
  background: var(--green-dim);
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* ---------------- Subsystem Daemon Grid ---------------- */
.subsystem-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 1.5rem;
  margin-bottom: 3rem;
}

.daemon-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.daemon-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-light);
}

.daemon-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.daemon-name {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
}

.daemon-socket {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--teal);
  background: var(--teal-dim);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(0, 210, 180, 0.25);
  margin-top: 0.25rem;
  word-break: break-all;
}

.daemon-desc {
  font-size: 0.92rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  flex: 1;
}

.daemon-features {
  list-style: none;
  margin-bottom: 1.5rem;
  font-size: 0.85rem;
}

.daemon-features li {
  position: relative;
  padding-left: 1.25rem;
  margin-bottom: 0.4rem;
  color: var(--text-muted);
}

.daemon-features li::before {
  content: "›";
  position: absolute;
  left: 0;
  color: var(--teal);
  font-weight: bold;
}

.daemon-footer {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  font-family: var(--font-mono);
}

/* ---------------- Varlink Specifications Browser ---------------- */
.spec-browser-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 2rem;
  align-items: start;
}

.spec-sidebar {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  position: sticky;
  top: 5rem;
}

.spec-nav-group {
  margin-bottom: 1.5rem;
}

.spec-nav-title {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
  letter-spacing: 0.08em;
}

.spec-nav-list {
  list-style: none;
}

.spec-nav-link {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 0.4rem 0.6rem;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
  cursor: pointer;
}

.spec-nav-link:hover {
  background: var(--bg-card);
  color: var(--text-main);
}

.spec-nav-link.active {
  background: var(--teal-dim);
  color: var(--teal);
  font-weight: 600;
}

.spec-view {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
}

/* ---------------- Code Blocks ---------------- */
pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.5;
  color: #e2e8f0;
  position: relative;
  margin: 1rem 0;
}

code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--bg-subtle);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  color: var(--cyan);
}

pre code {
  background: transparent;
  padding: 0;
  color: inherit;
}

.code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-bottom: none;
  border-top-left-radius: var(--radius-md);
  border-top-right-radius: var(--radius-md);
  padding: 0.45rem 1rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
}

.code-header + pre {
  margin-top: 0;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.copy-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.copy-btn:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
  border-color: var(--border-light);
}

/* Varlink syntax highlight simulation */
.hl-keyword { color: #f43f5e; font-weight: 600; }
.hl-type { color: #38bdf8; }
.hl-method { color: #00d2b4; }
.hl-string { color: #a3e635; }
.hl-comment { color: #64748b; font-style: italic; }
.hl-number { color: #f59e0b; }

/* ---------------- Tables ---------------- */
.table-wrap {
  overflow-x: auto;
  margin: 1.5rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  text-align: left;
}

th {
  background: var(--bg-card);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* ---------------- Callouts / Notes ---------------- */
.callout {
  border-left: 3px solid var(--teal);
  background: var(--bg-surface);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: 1.25rem 1.5rem;
  margin: 1.5rem 0;
}

.callout-title {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--teal);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.callout p {
  font-size: 0.92rem;
  color: var(--text-muted);
}

.callout.callout-warn {
  border-left-color: var(--amber);
}
.callout.callout-warn .callout-title {
  color: var(--amber);
}

/* ---------------- Footer ---------------- */
.site-footer {
  border-top: 1px solid var(--border);
  background: #070a0f;
  padding: 3.5rem 1.5rem 2rem;
  margin-top: auto;
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 2.5rem;
  margin-bottom: 2.5rem;
}

.footer-brand .brand {
  margin-bottom: 0.75rem;
}

.footer-brand p {
  color: var(--text-dim);
  font-size: 0.88rem;
  max-width: 320px;
  line-height: 1.5;
}

.footer-col h4 {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-main);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 1rem;
}

.footer-col ul {
  list-style: none;
}

.footer-col li {
  margin-bottom: 0.5rem;
}

.footer-col a {
  color: var(--text-dim);
  font-size: 0.85rem;
  transition: color 0.15s ease;
}

.footer-col a:hover {
  color: var(--teal);
}

.footer-bottom {
  max-width: var(--max-width);
  margin: 0 auto;
  border-top: 1px solid var(--border);
  padding-top: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
  flex-wrap: wrap;
  gap: 1rem;
}

/* ---------------- Responsive Styles ---------------- */
@media (max-width: 900px) {
  .spec-browser-layout {
    grid-template-columns: 1fr;
  }
  .spec-sidebar {
    position: static;
  }
  .footer-inner {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 768px) {
  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 1rem;
    gap: 0.5rem;
  }

  .nav-links.open {
    display: flex;
  }

  .nav-toggle {
    display: block;
  }

  .hero h1 {
    font-size: 2.2rem;
  }

  .footer-inner {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .top-banner {
    font-size: 0.72rem;
    flex-direction: column;
    gap: 0.25rem;
  }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
