/* The documentation portal.

   Everything here layers on the tokens in style.css rather than restating
   them: one ink colour, one paper colour, the greys between, and red spent
   only on things that stop you. A second palette living in a second file is
   how a product ends up with two slightly different blacks.

   The one structural departure from the app is the layout. The wizard is a
   single column of at most 34rem because a form is read top to bottom; a
   manual is read by jumping, so it gets a persistent contents column and a
   wider measure. `main` is reset here because style.css caps it for the
   wizard and that cap is wrong for prose with a sidebar beside it. */

body.docs main {
  max-width: none;
  padding: 0;
  transition: none;
}

.doc-wrap {
  display: grid;
  grid-template-columns: 15rem minmax(0, 44rem);
  gap: 3.5rem;
  justify-content: center;
  padding: 3rem 1.5rem 7rem;
}

/* ------------------------------------------------------------- contents -- */

.toc {
  position: sticky;
  /* Below the pinned bar, not under it. */
  top: calc(var(--bar-h) + 1rem);
  align-self: start;
  max-height: calc(100vh - var(--bar-h) - 2rem);
  overflow-y: auto;
  font-size: .85rem;
  padding-right: .5rem;
}
/* The toggle belongs to the narrow layout only. Hidden by default rather
   than shown and then hidden, so a browser that never matches the media query
   does not flash an unstyled button above the contents. */
.toc-toggle { display: none; }

.toc h2 {
  font-size: .7rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .09em; color: var(--muted);
  margin: 0 0 .7rem;
}
.toc ol { list-style: none; margin: 0 0 1.6rem; padding: 0; }
.toc li { margin: 0; }
.toc a {
  display: block;
  padding: .3rem .6rem;
  color: var(--muted);
  text-decoration: none;
  border-left: 1px solid var(--line);
  line-height: 1.4;
}
.toc a:hover { color: var(--ink); border-left-color: var(--muted); }

/* The current section is marked by weight and a solid rule, not by colour.
   Colour here would have to be the one hue reserved for refusals, and
   "you are reading this" is not a refusal. */
.toc a.on {
  color: var(--ink);
  font-weight: 500;
  border-left-color: var(--ink);
}
.toc .sub a { padding-left: 1.4rem; font-size: .82rem; }

/* ------------------------------------------------------------- articles -- */

.doc h1 {
  font-size: 1.9rem; font-weight: 600; letter-spacing: -0.03em;
  margin: 0 0 .7rem;
}
.doc .lede { font-size: 1.02rem; margin-bottom: 2.4rem; }

.doc section { scroll-margin-top: 1.5rem; padding-bottom: 2.6rem; }
.doc section + section { border-top: 1px solid var(--line); padding-top: 2.6rem; }

/* h2 in style.css is the small uppercase label the wizard uses for panel
   headings. A manual's section heading is a different job, so it is restated
   in full rather than patched with overrides that leave half of the old rule
   in force. */
.doc h2 {
  font-size: 1.3rem; font-weight: 600; text-transform: none;
  letter-spacing: -0.02em; color: var(--ink);
  margin: 0 0 .9rem;
}
.doc h3 {
  font-size: 1rem; font-weight: 600; letter-spacing: -0.01em;
  margin: 2rem 0 .6rem;
}
.doc h4 {
  font-size: .88rem; font-weight: 600;
  margin: 1.4rem 0 .4rem;
}
.doc p { margin: 0 0 1rem; }
.doc ul, .doc ol { margin: 0 0 1.1rem 1.1rem; }
.doc li { margin: .3rem 0; }
.doc li > ul, .doc li > ol { margin-top: .3rem; margin-bottom: .3rem; }
.doc strong { font-weight: 600; }

.doc a { color: var(--ink); text-decoration: underline;
         text-underline-offset: 2px; text-decoration-color: var(--line); }
.doc a:hover { text-decoration-color: var(--ink); }
/* A one-click install link in the clients table: a button, not a word. */
.doc a.install {
  display: inline-block; white-space: nowrap; text-decoration: none;
  padding: .1rem .55rem; font-size: .86em; font-weight: 600;
  border: 1px solid var(--ink); border-radius: var(--radius);
}
.doc a.install:hover { background: var(--ink); color: var(--paper); }

/* A heading you can link to. Shown on hover only: a column of permanent
   hashes reads as noise in a page that is otherwise this plain. */
.anchor {
  color: var(--muted); text-decoration: none; margin-left: .4rem;
  opacity: 0; font-weight: 400;
}
h2:hover .anchor, h3:hover .anchor, .anchor:focus { opacity: 1; }

/* ---------------------------------------------------------------- code -- */

pre {
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .9rem 1rem;
  overflow-x: auto;
  margin: 0 0 1.2rem;
}
pre code {
  background: none; border: 0; padding: 0;
  font: 400 .82rem/1.65 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre;
}

/* --------------------------------------------------------------- table -- */

.doc table {
  width: 100%;
  border-collapse: collapse;
  font-size: .86rem;
  margin: 0 0 1.3rem;
}
.doc th, .doc td {
  text-align: left;
  vertical-align: top;
  padding: .55rem .7rem;
  border-bottom: 1px solid var(--line);
}
.doc th {
  font-weight: 600; font-size: .74rem; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted);
  border-bottom-color: var(--ink);
}
.doc td code { white-space: nowrap; }

/* -------------------------------------------------------------- panels -- */

/* Three notes, and the difference between them is the whole point.

   A plain note is an aside. An amber one asks something of the reader before
   they proceed - the same use the consent panel makes of it in the app. A red
   one marks what stops you or what cannot be undone, and it is used sparingly
   here for the same reason it is in the app: the moment everything worth
   reading is red, red stops carrying information. */
.note {
  border: 1px solid var(--line);
  border-left-width: 2px;
  border-left-color: var(--ink);
  background: var(--raised);
  border-radius: var(--radius);
  padding: .85rem 1rem;
  margin: 0 0 1.3rem;
  font-size: .88rem;
}
.note p:last-child, .note ul:last-child { margin-bottom: 0; }
.note .note-title { display: block; font-weight: 600; margin-bottom: .3rem; }

.note.ask {
  border-color: var(--warn-line); border-left-color: var(--warn);
  background: var(--warn-bg);
}
.note.ask .note-title { color: var(--warn); }

.note.stop {
  border-color: var(--danger-line); border-left-color: var(--danger);
  background: var(--danger-bg);
}
.note.stop .note-title { color: var(--danger); }

/* ------------------------------------------------------------ sequence -- */

/* The pipeline, as a numbered list of named steps. The same names the
   progress view shows during a run, so what is read here matches what is
   watched there. */
.pipeline { list-style: none; margin: 0 0 1.4rem; padding: 0; counter-reset: p; }
.pipeline li {
  counter-increment: p;
  display: grid;
  grid-template-columns: 1.6rem 1fr;
  gap: .75rem;
  padding: .7rem 0;
  border-bottom: 1px solid var(--line);
}
.pipeline li::before {
  content: counter(p);
  font: 500 .75rem/1.45 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  width: 1.6rem; height: 1.45rem;
  display: flex; align-items: center; justify-content: center;
}
.pipeline strong { display: block; font-size: .92rem; font-weight: 600; }
.pipeline span { display: block; font-size: .85rem; color: var(--muted); }
.pipeline .only { font-style: normal; font-size: .78rem; color: var(--muted); }

/* --------------------------------------------------------------- cards -- */

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; margin-bottom: 1.4rem; }
.tile {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .9rem 1rem;
}
.tile strong { display: block; font-size: .9rem; margin-bottom: .25rem; }
.tile span { font-size: .84rem; color: var(--muted); }

/* A route on its own line: method, path, and what it is for. */
.routes { font-size: .85rem; }
.routes td:first-child { white-space: nowrap; }

/* ------------------------------------------------------------ soonness -- */

/* "Coming soon" is a claim about the future, and the page marks it as one
   rather than letting it sit in the same voice as everything that works
   today. Grey, not amber: an unfinished feature is not a warning. */
.soon {
  display: inline-block;
  font: 500 .68rem/1 inherit;
  text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .28rem .45rem;
  vertical-align: middle;
  margin-left: .5rem;
}

/* ------------------------------------------------------ troubleshooting -- */

/* Symptom first. Somebody arriving here has a message on screen and is
   scanning for it, not reading a chapter about causes. */
.trouble { margin: 0 0 1.3rem; }
.trouble > summary {
  cursor: pointer;
  padding: .7rem 0;
  border-bottom: 1px solid var(--line);
  font-weight: 500;
  font-size: .92rem;
  list-style: none;
  display: flex; gap: .6rem; align-items: baseline;
}
.trouble > summary::-webkit-details-marker { display: none; }
.trouble > summary::before { content: "+"; color: var(--muted); font-family: ui-monospace, monospace; }
.trouble[open] > summary::before { content: "\2212"; }
.trouble > summary:hover { color: var(--ink); }
.trouble .body { padding: 1rem 0 .4rem 1.2rem; font-size: .9rem; }
.trouble .body p:last-child { margin-bottom: 0; }
.trouble .body dl { grid-template-columns: max-content 1fr; margin-bottom: 1rem; }

/* ------------------------------------------------------------- compact -- */

@media (max-width: 62rem) {
  .doc-wrap { grid-template-columns: minmax(0, 44rem); gap: 0; }
  /* The contents becomes a disclosure rather than vanishing: a manual with no
     way to jump is a scroll. */
  .toc {
    position: static; max-height: none; overflow: visible;
    border-bottom: 1px solid var(--line);
    margin-bottom: 2rem; padding: 0 0 1rem;
  }
  .toc[data-collapsed="true"] ol { display: none; }
  .toc-toggle {
    display: block;
    background: none; border: 0; color: var(--ink); cursor: pointer;
    font: 600 .7rem inherit; text-transform: uppercase; letter-spacing: .09em;
    padding: .4rem 0; width: 100%; text-align: left;
  }
  .tiles { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .doc-wrap { padding: 2rem 1.2rem 4rem; }
  .doc h1 { font-size: 1.55rem; }
}

/* The note under the contents is prose, not another entry in the list, so
   its link has to opt out of the block layout every other link in here
   uses - otherwise it breaks onto its own line and leaves the comma after
   it stranded. */
.toc .fine {
  margin: 1.2rem .6rem 0;
  font-size: .78rem;
  line-height: 1.5;
  color: var(--muted);
}
.toc .fine a {
  display: inline;
  padding: 0;
  border-left: 0;
  color: var(--ink);
  text-decoration: underline;
}
.toc .fine a:hover { opacity: .7; }

/* The specification is generated, so its first heading is the document
   title and there is no separate page heading above it. */
.doc.spec > h1:first-child { margin-top: 0; }

/* The policy pages: the date a reader quotes back to us, under the title. */
.doc .updated { font-size: .85rem; color: var(--muted); margin: -1.6rem 0 2.4rem; }
