/* Routling wiki - static stylesheet.
   Palette and fonts mirror src/index.css so the wiki reads as one site with the
   landing page. Plain CSS on purpose: these pages are pre-rendered and must not
   depend on the SPA bundle. */

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #111118;
  --bg-card: #16161f;
  --accent: #1fc0a5;
  --accent-dim: #18a08a;
  --accent-glow: rgba(31, 192, 165, 0.15);
  --text-primary: #e8e8f0;
  --text-secondary: #8888a0;
  --border: #2a2a3a;
  --warning: #f0a742;
  --font-heading: "Space Grotesk", system-ui, sans-serif;
  --font-body: "Manrope", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --sidebar-w: 270px;
  --toc-w: 210px;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.7;
  /* Nothing in the wiki is allowed to scroll the page sideways; wide content
     (tables, diagrams, code) scrolls inside its own container instead. */
  overflow-x: hidden;
}

::selection { background: var(--accent); color: var(--bg-primary); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Skip link ───────────────────────────────────────────────────────────── */

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--accent);
  color: var(--bg-primary);
  padding: 0.6rem 1rem;
  border-radius: 0 0 8px 0;
  font-weight: 600;
}
.skip-link:focus { left: 0; }

/* ── Top bar ─────────────────────────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 60px;
  padding: 0 1.25rem;
  background: rgba(10, 10, 15, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text-primary);
}
.topbar-brand:hover { text-decoration: none; }
.topbar-brand img { width: 26px; height: 26px; border-radius: 6px; }

.topbar-tag {
  font-family: var(--font-heading);
  font-size: 0.72rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
}

.topbar-spacer { flex: 1; }

.topbar-link {
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 500;
}
.topbar-link:hover { color: var(--accent); text-decoration: none; }

.topbar-cta {
  background: var(--accent);
  color: var(--bg-primary);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.45rem 0.95rem;
  border-radius: 8px;
}
.topbar-cta:hover { background: var(--accent-dim); text-decoration: none; }

/* Mobile nav toggle - checkbox hack, no JS required for core navigation. */
.nav-toggle { display: none; }
.nav-toggle-label {
  display: none;
  cursor: pointer;
  padding: 0.35rem;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 7px;
  line-height: 0;
}

/* ── Layout ──────────────────────────────────────────────────────────────── */

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  gap: 2.5rem;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 1.5rem;
  align-items: start;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */

.sidebar {
  position: sticky;
  top: 60px;
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  padding: 2rem 0.5rem 3rem 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.sidebar-section { margin-bottom: 1.6rem; }

.sidebar-title {
  font-family: var(--font-heading);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin: 0 0 0.55rem 0.75rem;
}
.sidebar-title a { color: inherit; }
.sidebar-title a:hover { color: var(--accent); text-decoration: none; }

.sidebar-list { list-style: none; margin: 0; padding: 0; }

.sidebar-list a {
  display: block;
  padding: 0.34rem 0.75rem;
  font-size: 0.885rem;
  color: var(--text-secondary);
  border-left: 2px solid transparent;
  border-radius: 0 6px 6px 0;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.sidebar-list a:hover {
  color: var(--text-primary);
  background: var(--bg-secondary);
  text-decoration: none;
}
.sidebar-list a[aria-current="page"] {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--accent-glow);
  font-weight: 600;
}

/* ── Main column ─────────────────────────────────────────────────────────── */

.content {
  min-width: 0;
  padding: 2rem 0 5rem;
}

.breadcrumbs {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 1.1rem;
}
.breadcrumbs ol {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
}
.breadcrumbs li::after {
  content: "/";
  margin-left: 0.4rem;
  color: var(--border);
}
.breadcrumbs li:last-child::after { content: ""; }
.breadcrumbs a { color: var(--text-secondary); }
.breadcrumbs a:hover { color: var(--accent); text-decoration: none; }

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

.page-header h1 {
  font-family: var(--font-heading);
  font-size: clamp(1.9rem, 4vw, 2.6rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 0.7rem;
}

.page-summary {
  font-size: 1.06rem;
  color: var(--text-secondary);
  margin: 0;
  max-width: 62ch;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 1rem;
}

.badge {
  font-family: var(--font-heading);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.24rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.badge-pro { color: var(--accent); border-color: var(--accent); background: var(--accent-glow); }
.badge-free { color: var(--text-secondary); }

/* ── Prose ───────────────────────────────────────────────────────────────── */

.prose { max-width: 76ch; }

/* Long unbroken tokens - file paths, device names - wrap instead of widening
   the column. */
.prose p, .prose li, .prose h2, .prose h3, .prose h4, td, th {
  overflow-wrap: break-word;
}

.prose h2 {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 2.6rem 0 0.9rem;
  padding-top: 0.4rem;
}

.prose h3 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 600;
  margin: 2rem 0 0.7rem;
}

.prose h4 {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  margin: 1.6rem 0 0.6rem;
}

.prose p { margin: 0 0 1.05rem; }

.prose ul, .prose ol { margin: 0 0 1.15rem; padding-left: 1.35rem; }
.prose li { margin-bottom: 0.42rem; }
.prose li::marker { color: var(--accent); }

.prose strong { color: #fff; font-weight: 600; }
.prose em { color: var(--text-primary); }

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

.prose code {
  font-family: var(--font-mono);
  font-size: 0.855em;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.12em 0.4em;
  color: var(--accent);
  word-break: break-word;
}

.anchor {
  margin-left: 0.5rem;
  color: var(--border);
  font-weight: 400;
  opacity: 0;
  transition: opacity 0.15s;
}
h2:hover .anchor, h3:hover .anchor { opacity: 1; }
.anchor:hover { color: var(--accent); text-decoration: none; }

/* ── Code blocks ─────────────────────────────────────────────────────────── */

.code-block {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  margin: 0 0 1.3rem;
  font-size: 0.85rem;
  line-height: 1.65;
}
.code-block code {
  font-family: var(--font-mono);
  background: none;
  border: 0;
  padding: 0;
  color: var(--text-primary);
  font-size: inherit;
}
.code-block.is-diagram code { color: var(--text-secondary); white-space: pre; }

/* ── Tables ──────────────────────────────────────────────────────────────── */

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

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

thead { background: var(--bg-secondary); }

th {
  text-align: left;
  font-family: var(--font-heading);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-secondary);
  padding: 0.7rem 0.95rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 0.7rem 0.95rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255, 255, 255, 0.017); }

/* ── Callouts ────────────────────────────────────────────────────────────── */

.callout {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  border: 1px solid var(--border);
  border-left: 3px solid var(--text-secondary);
  border-radius: 8px;
  background: var(--bg-secondary);
  padding: 0.9rem 1.1rem;
  margin: 0 0 1.4rem;
}
.callout p { margin: 0 0 0.5rem; }
.callout p:last-child { margin-bottom: 0; }
.callout-body { font-size: 0.94rem; }

.callout-label {
  font-family: var(--font-heading);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.callout-note { border-left-color: var(--accent); }
.callout-note .callout-label { color: var(--accent); }

.callout-warning { border-left-color: var(--warning); }
.callout-warning .callout-label { color: var(--warning); }

.callout-pro {
  border-left-color: var(--accent);
  background: var(--accent-glow);
}
.callout-pro .callout-label { color: var(--accent); }

.callout-meta {
  border-left-color: var(--border);
  background: var(--bg-card);
}

/* ── Placeholders: screenshots and pending content ───────────────────────── */

.placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 190px;
  padding: 1.75rem 1.25rem;
  margin: 0 0 1.5rem;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background:
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 11px,
      rgba(42, 42, 58, 0.16) 11px,
      rgba(42, 42, 58, 0.16) 22px
    ),
    var(--bg-secondary);
}

.placeholder-icon { color: var(--border); line-height: 0; }

.placeholder-title {
  font-family: var(--font-heading);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.placeholder-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  max-width: 46ch;
  margin: 0;
}

.placeholder-id {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--border);
}

.pending {
  border-left: 3px solid var(--border);
  background: var(--bg-card);
}
.pending .callout-label { color: var(--text-secondary); }

/* ── Diagrams ────────────────────────────────────────────────────────────── */

.diagram {
  margin: 0 0 1.6rem;
  padding: 1.1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow-x: auto;
}

.diagram svg {
  display: block;
  width: 100%;
  height: auto;
  min-width: 460px;
  font-family: var(--font-body);
}

.d-box { fill: var(--bg-card); stroke: var(--border); stroke-width: 1; }
.d-rail { fill: var(--accent); opacity: 0.85; }
.d-label {
  fill: var(--text-secondary);
  font-size: 11.5px;
  text-anchor: middle;
  dominant-baseline: middle;
}
.d-label-strong { fill: var(--text-primary); font-weight: 600; }
/* External things - a DAW, Discord, the call app - are outlined, not filled. */
.d-box-ghost { fill: transparent; stroke-dasharray: 4 3; }
.d-wire { fill: none; stroke: var(--accent); stroke-width: 1.7; opacity: 0.9; }
/* Sidechain / key routes: carried but not mixed into the output. */
.d-wire-dashed { stroke-dasharray: 5 4; opacity: 0.75; }
.d-arrowhead { fill: var(--accent); }
.d-edge-label {
  fill: var(--text-secondary);
  font-size: 10.5px;
  font-family: var(--font-mono);
  text-anchor: middle;
}

/* ── Table of contents ───────────────────────────────────────────────────── */

.toc {
  position: sticky;
  top: 60px;
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  padding: 2.4rem 0 3rem;
  font-size: 0.83rem;
  scrollbar-width: thin;
}

.toc-title {
  font-family: var(--font-heading);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin: 0 0 0.7rem;
}

.toc ul { list-style: none; margin: 0; padding: 0; }

.toc a {
  display: block;
  padding: 0.24rem 0 0.24rem 0.7rem;
  color: var(--text-secondary);
  border-left: 1px solid var(--border);
  line-height: 1.45;
}
.toc a:hover { color: var(--accent); border-left-color: var(--accent); text-decoration: none; }
.toc .toc-h3 a { padding-left: 1.4rem; font-size: 0.79rem; }

/* ── Prev / next ─────────────────────────────────────────────────────────── */

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 3.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.pager-link {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.9rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.pager-link:hover {
  border-color: var(--accent);
  box-shadow: 0 0 18px var(--accent-glow);
  text-decoration: none;
}
.pager-next { text-align: right; }
.pager-dir {
  font-size: 0.7rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.pager-name { font-family: var(--font-heading); font-weight: 600; color: var(--text-primary); }

/* ── Cards (index + hub pages) ───────────────────────────────────────────── */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  margin: 0 0 2.5rem;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 1.15rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}
.card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 22px var(--accent-glow);
  text-decoration: none;
  transform: translateY(-2px);
}

.card-title {
  font-family: var(--font-heading);
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--text-primary);
}
.card-desc { font-size: 0.875rem; color: var(--text-secondary); line-height: 1.55; }
.card-meta {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

.section-lead {
  font-size: 1.06rem;
  color: var(--text-secondary);
  max-width: 62ch;
  margin: 0 0 2rem;
}

/* ── Footer ──────────────────────────────────────────────────────────────── */

.wiki-footer {
  border-top: 1px solid var(--border);
  padding: 2rem 1.5rem 3rem;
  margin-top: 2rem;
}

.wiki-footer-inner {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.trademark {
  max-width: 1440px;
  margin: 0 auto 1rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  opacity: 0.65;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 1180px) {
  .layout { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .toc { display: none; }
}

@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 0; padding: 0 1.1rem; }

  .nav-toggle-label { display: inline-flex; }

  .sidebar {
    display: none;
    position: static;
    max-height: none;
    padding: 1rem 0 1.5rem;
    border-bottom: 1px solid var(--border);
  }
  .nav-toggle:checked ~ .layout .sidebar { display: block; }

  .content { padding: 1.5rem 0 3.5rem; }
  .prose { max-width: none; }
  .pager { grid-template-columns: 1fr; }
  .diagram { padding: 0.75rem; }

  /* Keep the bar inside the viewport: the brand truncates before the CTA is
     pushed off-screen. */
  .topbar { gap: 0.6rem; padding: 0 0.85rem; }
  .topbar-brand { min-width: 0; overflow: hidden; }
  .topbar-brand span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .topbar-cta { flex: none; padding: 0.4rem 0.7rem; font-size: 0.8rem; }
  .topbar-tag { flex: none; }

  /* Tables reflow to stacked key/value rows rather than scrolling sideways. */
  .table-wrap { border: 0; border-radius: 0; }
  table, thead, tbody, tr, td { display: block; width: 100%; }
  thead { display: none; }
  tr {
    border: 1px solid var(--border);
    border-radius: 9px;
    margin-bottom: 0.7rem;
    padding: 0.3rem 0;
    background: var(--bg-card);
  }
  td { border: 0; padding: 0.42rem 0.9rem; }
  td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-family: var(--font-heading);
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 0.12rem;
  }
  .topbar-link { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* ── Print ───────────────────────────────────────────────────────────────── */

@media print {
  .topbar, .sidebar, .toc, .pager, .wiki-footer, .anchor { display: none; }
  body { background: #fff; color: #000; }
  .layout { display: block; padding: 0; }
  .prose { max-width: none; }
  a { color: #000; }
}
