/* ============================================================
   chitta-bridge — Signal Bridge Terminal
   Avionics instrumentation meets network relay visualization
   ============================================================ */

/* --- Custom Properties --- */
:root {
  --bg: #080d15;
  --bg-deep: #04070e;
  --panel: #0d1424;
  --panel-border: #1b2d47;
  --panel-hover: #132038;
  --text: #cbd5e1;
  --text-bright: #f1f5f9;
  --muted: #64748b;
  --dim: #334155;

  --claude-coral: #f59e0b;
  --claude-amber: #fbbf24;
  --claude-glow: rgba(245,158,11,0.3);

  --open-green: #34d399;
  --open-teal: #22d3ee;
  --open-glow: rgba(34,211,238,0.3);

  --signal-cyan: #38bdf8;
  --violet: #a78bfa;

  --mono: "JetBrains Mono", "SF Mono", "IBM Plex Mono", "Fira Code", "Cascadia Code", monospace;

  --maxw: 1080px;
  --pad: clamp(16px, 4vw, 32px);
  --radius: 8px;
  --radius-sm: 5px;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 64px;
}

body {
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background:
    radial-gradient(ellipse 1200px 700px at 15% -5%, rgba(245, 158, 11, 0.03), transparent),
    radial-gradient(ellipse 1000px 600px at 85% 0%, rgba(34, 211, 238, 0.025), transparent),
    radial-gradient(ellipse 800px 800px at 50% 30%, rgba(167, 139, 250, 0.02), transparent),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* CRT scan-line overlay */
.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  background: repeating-linear-gradient(
    to bottom,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.03) 2px,
    rgba(0, 0, 0, 0.03) 4px
  );
}

::selection {
  background: rgba(102, 217, 255, 0.25);
  color: var(--text-bright);
}

a {
  color: var(--signal-cyan);
  text-decoration: none;
  transition: color 0.2s;
}
a:hover { color: var(--text-bright); }

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding-left: var(--pad);
  padding-right: var(--pad);
}

/* --- Header --- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px) saturate(1.2);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
  background: rgba(6, 9, 12, 0.8);
  border-bottom: 1px solid var(--panel-border);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  height: 52px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--signal-cyan);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.brand-icon {
  font-size: 11px;
  color: var(--muted);
}

.nav {
  display: flex;
  gap: 20px;
  margin-left: auto;
}
.nav a {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.02em;
  transition: color 0.2s;
  text-decoration: none;
}
.nav a:hover { color: var(--text); }

.nav-github {
  color: var(--muted);
  display: flex;
  margin-left: 8px;
}
.nav-github:hover { color: var(--text); }

/* --- HERO --- */
.hero {
  padding: 72px 0 32px;
  text-align: center;
  position: relative;
}

.hero-eyebrow {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.18em;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 12px;
}

.hero-title {
  font-size: clamp(28px, 5vw, 44px);
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--text-bright);
  line-height: 1.1;
  margin-bottom: 8px;
}

.hero-subtitle {
  font-size: clamp(14px, 2vw, 17px);
  font-weight: 300;
  color: var(--muted);
  margin-bottom: 4px;
}

.hero-micro {
  font-size: 12px;
  font-style: italic;
  color: var(--dim);
  margin-bottom: 24px;
}

.hero-install {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 48px;
}
.hero-install code {
  color: var(--claude-amber);
  font-size: 13px;
}

.copy-btn {
  background: none;
  border: 1px solid var(--dim);
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
  padding: 3px 5px;
  display: flex;
  align-items: center;
  transition: all 0.2s;
}
.copy-btn:hover { border-color: var(--signal-cyan); color: var(--signal-cyan); }
.copy-btn.copied { border-color: var(--open-green); color: var(--open-green); }

/* --- Topology Animation --- */
.topology {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 20px 16px 8px;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}
.topology::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--panel-border) 1px, transparent 1px),
    linear-gradient(90deg, var(--panel-border) 1px, transparent 1px);
  background-size: 48px 48px;
  opacity: 0.12;
  pointer-events: none;
}
.topo-svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}


/* Flow trace */
.flow-trace {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--panel);
  border: 1px dashed var(--panel-border);
  border-radius: var(--radius-sm);
  font-size: 11px;
}

.ft-node {
  padding: 2px 8px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  white-space: nowrap;
}
.ft-claude { color: var(--claude-coral); border-color: rgba(255, 122, 107, 0.2); }
.ft-mcp { color: var(--signal-cyan); border-color: rgba(102, 217, 255, 0.2); }
.ft-hub { color: var(--open-green); border-color: rgba(94, 227, 139, 0.2); }
.ft-model { color: var(--violet); border-color: rgba(155, 123, 255, 0.2); }
.ft-arrow { color: var(--dim); }

/* --- Sections --- */
.section {
  padding: 56px 0 32px;
  border-top: 1px solid var(--panel-border);
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.section.in-view {
  opacity: 1;
  transform: translateY(0);
}

.section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.15em;
  color: var(--dim);
  margin-bottom: 6px;
}

.section h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-bright);
  margin-bottom: 20px;
  letter-spacing: -0.02em;
}

.section-desc {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 20px;
  max-width: 600px;
}

.section-note {
  font-size: 11px;
  color: var(--dim);
  margin-top: 12px;
}

/* --- Code Block --- */
.code-block {
  background: var(--bg-deep);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  overflow: hidden;
  max-width: 500px;
}

.code-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--panel-border);
}
.code-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.code-dot.red { background: #ff5f57; }
.code-dot.yellow { background: #febc2e; }
.code-dot.green { background: #28c840; }
.code-title {
  font-size: 10px;
  color: var(--dim);
  margin-left: 8px;
}

.code-block pre {
  padding: 14px 16px;
  overflow-x: auto;
}
.code-block code {
  font-size: 13px;
  color: var(--text);
}
.prompt {
  color: var(--open-green);
  margin-right: 8px;
  user-select: none;
}

/* --- Spec Grid (Capabilities) --- */
.spec-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}

.spec-card {
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  transition: border-color 0.3s, transform 0.3s;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.4s ease, transform 0.4s ease, border-color 0.3s;
}
.spec-card.in-view {
  opacity: 1;
  transform: translateY(0);
}
.spec-card:hover {
  border-color: rgba(102, 217, 255, 0.2);
}

.spec-key {
  font-size: 12px;
  font-weight: 600;
  color: var(--signal-cyan);
  margin-bottom: 4px;
}
.spec-val {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

/* Stagger spec cards */
.spec-card:nth-child(1) { transition-delay: 0.05s; }
.spec-card:nth-child(2) { transition-delay: 0.1s; }
.spec-card:nth-child(3) { transition-delay: 0.15s; }
.spec-card:nth-child(4) { transition-delay: 0.2s; }
.spec-card:nth-child(5) { transition-delay: 0.25s; }
.spec-card:nth-child(6) { transition-delay: 0.3s; }
.spec-card:nth-child(7) { transition-delay: 0.35s; }

/* --- Flow Diagram --- */
.flow-diagram {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-width: 580px;
}

.flow-step {
  display: flex;
  align-items: center;
  gap: 12px;
  opacity: 0;
  transform: translateX(-12px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.flow-step.in-view {
  opacity: 1;
  transform: translateX(0);
}
.flow-step:nth-child(1) .flow-box { transition-delay: 0s; }
.flow-step:nth-child(3) .flow-box { transition-delay: 0.08s; }
.flow-step:nth-child(5) .flow-box { transition-delay: 0.16s; }
.flow-step:nth-child(7) .flow-box { transition-delay: 0.24s; }
.flow-step:nth-child(9) .flow-box { transition-delay: 0.32s; }

.flow-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--dim);
  flex-shrink: 0;
}

.flow-box {
  flex: 1;
  padding: 10px 14px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--panel-border);
  background: var(--panel);
}

.fb-claude { border-left: 2px solid var(--claude-coral); color: var(--text); }
.fb-bridge { border-left: 2px solid var(--signal-cyan); color: var(--text); }
.fb-opencode { border-left: 2px solid var(--open-green); color: var(--text); }

.flow-connector {
  display: flex;
  align-items: center;
  padding-left: 36px;
  height: 20px;
}
.fc-line {
  width: 1px;
  height: 100%;
  background: var(--panel-border);
}
.fc-arrow { display: none; }

/* --- Tool Cards --- */
.tool-group {
  margin-bottom: 28px;
}

.tool-group-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--panel-border);
}

.tool-count {
  display: inline-block;
  font-size: 11px;
  font-weight: 400;
  color: var(--dim);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  padding: 1px 8px;
  margin-left: 8px;
  vertical-align: middle;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 8px;
}

.tool-card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  transition: border-color 0.3s, opacity 0.4s, transform 0.4s;
  opacity: 0;
  transform: translateY(8px);
}
.tool-card.in-view {
  opacity: 1;
  transform: translateY(0);
}
.tool-card:hover {
  border-color: rgba(102, 217, 255, 0.15);
}

.tool-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--signal-cyan);
}
.tool-desc {
  font-size: 11px;
  color: var(--muted);
}

/* --- Domain Chips (Auto-Framing) --- */
.domain-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  font-size: 11px;
  font-weight: 400;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  transition: transform 0.2s, border-color 0.3s, box-shadow 0.3s;
  cursor: default;
}
.chip:hover {
  transform: translateY(-2px);
}

.chip-hot {
  color: var(--claude-coral);
  border-color: rgba(255, 122, 107, 0.2);
}
.chip-hot:hover { box-shadow: 0 0 12px rgba(255, 122, 107, 0.15); border-color: rgba(255, 122, 107, 0.4); }

.chip-warm {
  color: var(--claude-amber);
  border-color: rgba(255, 180, 84, 0.2);
}
.chip-warm:hover { box-shadow: 0 0 12px rgba(255, 180, 84, 0.15); border-color: rgba(255, 180, 84, 0.4); }

.chip-cool {
  color: var(--open-teal);
  border-color: rgba(51, 195, 185, 0.2);
}
.chip-cool:hover { box-shadow: 0 0 12px rgba(51, 195, 185, 0.15); border-color: rgba(51, 195, 185, 0.4); }

.chip-muted {
  color: var(--muted);
  border-color: rgba(87, 103, 114, 0.3);
}

/* --- Chunk Specs --- */
.chunk-specs {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 600px;
  margin-bottom: 28px;
}

.chunk-row {
  display: flex;
  gap: 12px;
  padding: 8px 14px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  align-items: baseline;
  opacity: 0;
  transform: translateX(-10px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.chunk-row.in-view {
  opacity: 1;
  transform: translateX(0);
}
.chunk-row:nth-child(1) { transition-delay: 0s; }
.chunk-row:nth-child(2) { transition-delay: 0.08s; }
.chunk-row:nth-child(3) { transition-delay: 0.16s; }
.chunk-row:nth-child(4) { transition-delay: 0.24s; }

.chunk-key {
  font-size: 11px;
  font-weight: 600;
  color: var(--open-green);
  min-width: 72px;
}
.chunk-val {
  font-size: 12px;
  color: var(--muted);
}

/* --- Chunk Pipeline Visualization --- */
.chunk-viz {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  max-width: 600px;
  overflow-x: auto;
}

.cv-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 6px;
}

.cv-bar {
  height: 10px;
  border-radius: 3px;
}
.cv-full {
  width: 80px;
  background: linear-gradient(90deg, var(--claude-coral), var(--claude-amber));
  opacity: 0.7;
}
.cv-result {
  width: 80px;
  background: linear-gradient(90deg, var(--open-teal), var(--open-green));
  opacity: 0.7;
}

.cv-size {
  font-size: 9px;
  color: var(--dim);
  margin-top: 4px;
}

.cv-arrow {
  color: var(--dim);
  font-size: 16px;
  flex-shrink: 0;
}

.cv-chunk-row {
  display: flex;
  gap: 3px;
}
.cv-chunk {
  width: 14px;
  height: 10px;
  border-radius: 2px;
  background: var(--signal-cyan);
  animation: chunkProcess 3s ease-in-out infinite;
}
.cv-chunk.c1 { animation-delay: 0s; }
.cv-chunk.c2 { animation-delay: 0.3s; }
.cv-chunk.c3 { animation-delay: 0.6s; }
.cv-chunk.c4 { animation-delay: 0.9s; }
.cv-chunk.c5 { animation-delay: 1.2s; }
.cv-chunk.c6 { animation-delay: 1.5s; }

@keyframes chunkProcess {
  0%, 100% { opacity: 0.3; transform: scaleY(0.8); }
  50% { opacity: 1; transform: scaleY(1.2); }
}

/* --- Links --- */
.link-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 500px;
}

.link-item {
  display: flex;
  gap: 12px;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: border-color 0.3s;
  align-items: baseline;
}
.link-item:hover {
  border-color: rgba(102, 217, 255, 0.2);
}

.link-key {
  font-size: 11px;
  font-weight: 600;
  color: var(--signal-cyan);
  min-width: 56px;
}
.link-val {
  font-size: 12px;
  color: var(--muted);
}

/* --- Footer --- */
.site-footer {
  padding: 28px 0 48px;
  border-top: 1px solid var(--panel-border);
  margin-top: 32px;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 11px;
  color: var(--dim);
}
.footer-sep { color: var(--panel-border); }

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
  .cv-chunk {
    animation: none !important;
  }

  .topo-svg circle[r="3"],
  .topo-svg circle[r="2"] {
    animation: none !important;
    opacity: 0 !important;
  }

  .section,
  .spec-card,
  .flow-step,
  .tool-card,
  .chunk-row {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
}

/* --- Hamburger Nav Toggle --- */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  margin-left: auto;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.2s;
}
.nav-toggle:hover,
.nav-toggle:focus-visible {
  border-color: var(--panel-border);
}
.nav-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--muted);
  border-radius: 1px;
  transition: transform 0.25s ease, opacity 0.2s ease;
}
/* Animate to X when open */
.nav-toggle.open span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.nav-toggle.open span:nth-child(2) {
  opacity: 0;
}
.nav-toggle.open span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .nav-toggle {
    display: flex;
  }

  .nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0;
    margin: 0;
    background: rgba(6, 9, 12, 0.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--panel-border);
    padding: 8px 0;
    z-index: 99;
  }
  .nav.nav-open {
    display: flex;
  }
  .nav a {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 0 var(--pad);
    font-size: 13px;
    color: var(--text);
    border-bottom: 1px solid rgba(20, 30, 39, 0.4);
  }
  .nav a:last-child {
    border-bottom: none;
  }
  .nav a:hover,
  .nav a:active {
    background: rgba(102, 217, 255, 0.05);
    color: var(--text-bright);
  }

  .nav-github {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .site-header {
    position: relative;
  }

  .hero { padding: 48px 0 24px; }
  .hero-title { font-size: 26px; }

  .flow-trace {
    font-size: 10px;
    gap: 4px;
  }

  .spec-grid {
    grid-template-columns: 1fr;
  }

  .tool-grid {
    grid-template-columns: 1fr;
  }

  .chunk-viz {
    flex-direction: column;
    align-items: flex-start;
  }
  .cv-arrow { transform: rotate(90deg); }

  .footer-inner {
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 10px;
  }

  .link-item {
    flex-direction: column;
    gap: 4px;
  }
}

@media (max-width: 480px) {
  :root {
    --pad: 14px;
  }
  .hero-install {
    flex-direction: column;
    gap: 6px;
  }
  .hero-install code {
    font-size: 11px;
  }

  .flow-trace {
    font-size: 9px;
    padding: 8px 10px;
  }
  .ft-node {
    padding: 2px 5px;
  }
}

@media (max-width: 360px) {
  :root {
    --pad: 10px;
  }
  body {
    font-size: 13px;
  }
  .hero-title { font-size: 22px; }
  .hero-subtitle { font-size: 13px; }
  .hero-install code { font-size: 10px; }

  .brand {
    font-size: 12px;
  }

  .section h2 {
    font-size: 16px;
  }
  .spec-key {
    font-size: 11px;
  }
  .spec-val {
    font-size: 11px;
  }
}
