/* Docs page. The contents is drawn as a signal wire: one node per chapter,
   and the stretch of wire up to the chapter you are reading is lit, like a
   route in the mixer's Signal flow. Everything else stays quiet. */

.docs {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  gap: 56px;
  align-items: start;
  margin-top: 8px;
  padding-bottom: 72px;
}

/* Contents ------------------------------------------------------------ */

.toc {
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 8px 4px 16px 0;
  scrollbar-width: thin;
}

.toc-toggle { display: none; }

.toc-title {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 14px;
}

.wire {
  position: relative;
  list-style: none;
  margin: 0;
  padding: 0 0 0 24px;
  --level: 0px;
}

/* The wire itself, then the lit part of it. */
.wire::before,
.wire::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 12px;
  width: 2px;
  border-radius: 1px;
}

.wire::before {
  bottom: 12px;
  background: var(--divider);
}

.wire::after {
  height: var(--level);
  background: var(--accent);
  box-shadow: 0 0 10px color-mix(in srgb, var(--accent) 55%, transparent);
  transition: height 0.28s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.wire li { position: relative; }

.wire a {
  position: relative;
  display: block;
  padding: 4px 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.4;
  text-decoration: none;
}

.wire a::before {
  content: "";
  position: absolute;
  left: -23px;
  top: 9px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--bg);
  box-shadow: inset 0 0 0 2px var(--divider);
  z-index: 1;
  transition: background-color 0.2s, box-shadow 0.2s;
}

.wire .sub a {
  padding: 2px 0 2px 2px;
  font-size: 13.5px;
}

.wire .sub a::before {
  left: -21px;
  top: 8px;
  width: 6px;
  height: 6px;
}

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

.wire .passed > a::before { background: var(--accent); box-shadow: none; }

.wire a[aria-current="location"] { color: var(--text); }

.wire a[aria-current="location"]::before {
  background: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent);
}

/* Article ------------------------------------------------------------- */

.doc-main { min-width: 0; }

.doc {
  max-width: 72ch;
  font-size: 17px;
  line-height: 1.68;
  color: var(--soft);
}

.doc:focus { outline: none; }

.doc h1,
.doc h2,
.doc h3 {
  color: var(--text);
  font-weight: 500;
  line-height: 1.25;
  scroll-margin-top: 24px;
}

.doc h1 {
  margin: 12px 0 0;
  font-size: clamp(32px, 4.6vw, 46px);
  letter-spacing: -0.015em;
}

.doc h2 {
  margin: 76px 0 14px;
  font-size: 28px;
  letter-spacing: -0.01em;
}

.doc h3 {
  margin: 40px 0 8px;
  font-size: 19px;
}

.doc p { margin: 0 0 16px; }

.doc ul,
.doc ol { margin: 0 0 18px; padding-left: 22px; }

.doc li { margin: 6px 0; }
.doc li::marker { color: var(--muted); }

.doc strong { color: var(--text); font-weight: 500; }

.doc code {
  font-family: var(--mono);
  font-size: 0.86em;
  color: var(--text);
  background: var(--inset);
  border-radius: 6px;
  padding: 1px 6px;
  overflow-wrap: anywhere;
}

.doc a code { color: inherit; }

.doc-lead {
  margin: 18px 0 0;
  font-size: 19px;
  line-height: 1.6;
  color: var(--soft);
}

.lang-note {
  max-width: 72ch;
  margin: 8px 0 0;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--card);
  color: var(--soft);
  font-size: 15px;
}

/* A control as the panel draws it: a pill for buttons, a small square tab
   for route buttons. Text in these is what you press. */
.ui {
  display: inline-block;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--control);
  color: var(--text);
  font-size: 0.86em;
  line-height: 1.65;
  white-space: nowrap;
}

.route {
  display: inline-block;
  min-width: 2.5em;
  padding: 0 6px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--accent) 18%, var(--inset));
  color: var(--accent);
  font-size: 0.8em;
  font-weight: 600;
  line-height: 1.75;
  text-align: center;
  white-space: nowrap;
  vertical-align: 0.06em;
}

/* Signal chain in the hero ------------------------------------------- */

.doc-hero { padding-top: 8px; }

.chain {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  margin: 40px 0 8px;
  padding: 0;
}

.stage {
  position: relative;
  padding: 26px 16px 0 0;
}

/* Node on the wire, and the wire to the next stage. */
.stage::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 18%, transparent);
  z-index: 1;
}

.stage:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 6px;
  right: -6px;
  top: 5px;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 45%, var(--divider)));
}

.doc .stage-name {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0;
  scroll-margin-top: 0;
}

.stage ul {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  font-size: 14px;
  line-height: 1.45;
  color: var(--muted);
}

.stage li { margin: 4px 0; }

/* Steps: a real sequence, so numbered, on the same kind of wire. --------- */

.doc ol.steps {
  list-style: none;
  counter-reset: step;
  padding: 0;
  margin: 18px 0 24px;
}

.steps li {
  counter-increment: step;
  position: relative;
  margin: 0;
  padding: 2px 0 20px 46px;
}

.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--inset);
  box-shadow: inset 0 0 0 2px var(--accent);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
}

.steps li:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 14px;
  top: 34px;
  bottom: 4px;
  width: 2px;
  background: var(--divider);
}

/* Commands ----------------------------------------------------------- */

.doc .command {
  margin: 14px 0 18px;
  max-width: none;
}

/* Commands wrap instead of scrolling, so the end of a line (the part that
   differs between install, autostart and uninstall) is always in view. */
.doc .command code {
  background: transparent;
  padding: 6px 0;
  color: var(--soft);
  font-size: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Notes -------------------------------------------------------------- */

.aside-note {
  margin: 22px 0;
  padding: 14px 18px;
  border-left: 3px solid var(--accent);
  border-radius: 0 12px 12px 0;
  background: var(--card);
  font-size: 15.5px;
  line-height: 1.6;
}

.doc .aside-note { margin: 22px 0; }

.aside-note.warn { border-left-color: #f2b13a; }

/* Figures ------------------------------------------------------------ */

.shot { margin: 28px 0; }

.shot img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 14px;
  background: var(--inset);
}

.shot.narrow { max-width: 640px; }

.shot figcaption {
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 28px;
  align-items: center;
}

.split .shot { margin: 0; }

/* Definition rows ---------------------------------------------------- */

.parts {
  display: grid;
  grid-template-columns: 11rem minmax(0, 1fr);
  margin: 16px 0 20px;
}

.parts dt,
.parts dd {
  padding: 12px 0;
  border-top: 1px solid var(--divider);
}

.parts dt {
  padding-right: 16px;
  color: var(--text);
  font-weight: 500;
}

.parts dd { margin: 0; }

/* Tables ------------------------------------------------------------- */

.table-scroll {
  margin: 16px 0 22px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.doc table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15.5px;
  line-height: 1.5;
}

.doc th,
.doc td {
  padding: 11px 12px 11px 0;
  border-top: 1px solid var(--divider);
  text-align: left;
  vertical-align: top;
}

.doc thead th {
  border-top: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 400;
}

.doc tbody th {
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
}

/* Troubleshooting ---------------------------------------------------- */

.faq { border-bottom: 1px solid var(--divider); }

.faq details { border-top: 1px solid var(--divider); }

.faq summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 0;
  color: var(--text);
  font-weight: 500;
  cursor: pointer;
  list-style: none;
}

.faq summary::-webkit-details-marker { display: none; }

.faq summary::after {
  content: "";
  flex: none;
  width: 9px;
  height: 9px;
  margin-right: 4px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: translateY(-3px) rotate(45deg);
  transition: transform 0.2s;
}

.faq details[open] summary::after { transform: translateY(2px) rotate(-135deg); }

.faq summary:hover { color: var(--accent); }

.faq details p { margin: 0 0 18px; }

/* Phones and narrow windows ----------------------------------------- */

@media (max-width: 960px) {
  .docs {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }

  /* The contents becomes a bar that stays at the top and opens on demand. */
  .toc {
    position: sticky;
    top: 0;
    z-index: 5;
    max-height: none;
    overflow: visible;
    margin: 0 -16px;
    padding: 8px 16px;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--divider);
  }

  .toc-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    height: 44px;
    padding: 0 16px;
    background: var(--card);
    text-align: left;
  }

  .toc-now {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .toc-toggle svg { flex: none; transition: transform 0.2s; }
  .toc-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }

  .toc-panel {
    display: none;
    position: absolute;
    left: 16px;
    right: 16px;
    top: calc(100% + 6px);
    max-height: min(70vh, 560px);
    overflow-y: auto;
    padding: 16px 16px 12px;
    border-radius: 14px;
    background: var(--card);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  }

  .toc-toggle[aria-expanded="true"] + .toc-panel { display: block; }

  .doc h1,
  .doc h2,
  .doc h3 { scroll-margin-top: 80px; }
}

@media (max-width: 720px) {
  .docs { padding-bottom: 48px; }
  .doc { font-size: 16px; line-height: 1.65; }
  .doc-lead { font-size: 17px; }
  .doc h2 { margin-top: 56px; font-size: 24px; }
  .doc h3 { margin-top: 32px; font-size: 18px; }

  /* The chain runs down the page instead of across it. */
  .chain {
    grid-template-columns: minmax(0, 1fr);
    margin-top: 28px;
  }

  .stage { padding: 0 0 20px 30px; }
  .stage::before { top: 5px; }
  .stage:not(:last-child)::after {
    left: 5px;
    right: auto;
    top: 10px;
    bottom: -6px;
    width: 2px;
    height: auto;
    background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent) 45%, var(--divider)));
  }
  .stage ul { display: flex; flex-wrap: wrap; gap: 0 14px; margin-top: 2px; }
  .stage li { margin: 2px 0; }

  .split { grid-template-columns: minmax(0, 1fr); }

  .parts { grid-template-columns: minmax(0, 1fr); }
  .parts dt { padding-bottom: 0; }
  .parts dd { padding-top: 4px; border-top: 0; }

  .doc .command { flex-direction: row; align-items: flex-start; padding: 8px 8px 8px 14px; }
  .doc .command button { height: 40px; }
  .doc .command code { font-size: 13px; }
  .doc tbody th { white-space: normal; }
}

@media (prefers-reduced-motion: reduce) {
  .wire::after,
  .wire a::before,
  .faq summary::after,
  .toc-toggle svg { transition: none; }
}
