/* ---------- Docs ----------
   The landing page is a column you fall down. This is a room you walk around
   in: a way of finding things on the left, and one page at a time on the right.
   Everything below is layout and hierarchy. The ink, the ground and the
   typeface are /styles.css's, because a docs page that invents its own is a
   second website.

   Written by scripts/docs.py, which owns the markup these class names land on. */

.docs {
  width: 100%;
  max-width: 1180px;
  flex: 1;
  margin: 0 auto;
  padding: 88px 40px 0;
  display: grid;
  grid-template-columns: 214px minmax(0, 1fr);
  gap: 72px;
  align-items: start;
  text-align: left;
}

/* Sticky rather than fixed, so it stays inside the 1180px the rest of the site
   is measured in and never drifts out to the window's edge on a wide screen. */
.docs-side {
  position: sticky;
  top: 88px;
  max-height: calc(100vh - 128px);
  display: flex;
  flex-direction: column;
  padding-bottom: 24px;
}

/* ---------- Finding something ---------- */

/* A well rather than a box.
   A hairline rectangle is the one shape on this page that has to be drawn to
   exist, and it sits at the top of a column of plain words where nothing else
   is outlined. Sunk into the page instead, it reads as somewhere to put
   something without a line saying so. The ground has to come down a shade off
   the page for the shadow to have anything to fall on: an inset shadow on
   white is invisible. */
.docs-find {
  position: relative;
  flex: none;
  display: flex;
  align-items: center;
  height: 32px;
  padding: 0 10px;
  border: 0;
  background: #f1f2f3;
  box-shadow: inset 0 1px 2.5px rgba(20, 22, 24, 0.07),
              inset 0 0 0 1px rgba(20, 22, 24, 0.035);
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

/* Deeper rather than outlined, so focus is the same gesture as the resting
   state and not a second treatment laid over it. */
.docs-find:focus-within {
  background: #edeef0;
  box-shadow: inset 0 1px 3px rgba(20, 22, 24, 0.1),
              inset 0 0 0 1px rgba(20, 22, 24, 0.06);
}

/* Both of these used to sit on white. On the well's ground they need a step
   down to hold the same separation from it. */
.df-glass {
  flex: none;
  margin-right: 7px;
  color: #8d9298;
}

.df-input {
  flex: 1;
  min-width: 0;
  border: 0;
  padding: 0;
  background: none;
  color: var(--ink);
  font-family: inherit;
  font-size: 0.8125rem;
  line-height: 1.4;
}

.df-input::placeholder { color: #8d9298; }
.df-input:focus { outline: 0; }

/* The native clear button is a second, differently-shaped affordance sitting
   inside a field that is already one control. Escape empties it. */
.df-input::-webkit-search-cancel-button { display: none; }

/* Not a label of what the field is, which the placeholder already says. It is
   the shortcut, shown until you no longer need telling. */
.df-hint {
  flex: none;
  margin-left: 6px;
  opacity: 1;
  transition: opacity 0.12s ease;
}

.docs-find:focus-within .df-hint,
.docs-find.has .df-hint { opacity: 0; }

/* ---------- What it found ----------
   Over the page rather than pushing it down: a list that reflows the sidebar
   on every keystroke moves the thing you are reading while you type. */
.df-out {
  position: absolute;
  z-index: 30;
  top: calc(100% + 6px);
  left: 0;
  width: min(420px, calc(100vw - 48px));
  max-height: min(420px, calc(100vh - 200px));
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid #e4e6e9;
  background: #fff;
  box-shadow: 0 8px 28px rgba(20, 22, 24, 0.08);
}

.df-hit {
  display: block;
  padding: 11px 13px;
  border-top: 1px solid #f2f3f4;
  text-decoration: none;
}

.df-hit:first-child { border-top: 0; }

.df-hit:hover,
.df-hit.on { background: #f7f8f8; }

.df-hit b {
  display: block;
  color: var(--ink);
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.45;
}

.df-hit i {
  float: right;
  margin-left: 12px;
  color: #a9aeb3;
  font-size: 0.6875rem;
  font-style: normal;
  line-height: 1.9;
}

.df-hit span {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: #74797e;
  font-size: 0.75rem;
  line-height: 1.55;
  /* two lines of the paragraph the hit is in, which is enough to know whether
     it is the one you meant */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.df-hit em {
  color: var(--ink);
  font-style: normal;
  font-weight: 500;
}

.df-none {
  padding: 13px;
  color: #a9aeb3;
  font-size: 0.8125rem;
  line-height: 1.5;
}

/* ---------- The list on the left ---------- */

.docs-nav {
  flex: 1;
  min-height: 0;
  margin-top: 26px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
}

.docs-nav::-webkit-scrollbar { display: none; }

/* A group heading is a word, set in the sentence case the rest of the site is
   written in. It carries weight instead of capitals: small uppercase grey is
   the standard-issue docs label, and it says "this is a docs template" before
   it says what the group is. Bold ink is louder than the page links under it
   without shouting the letters. */
.docs-nav h2 {
  margin: 28px 0 0;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: -0.005em;
  color: var(--ink);
}

.docs-nav h2:first-child { margin-top: 0; }

.dn-page {
  display: block;
  margin-top: 2px;
  padding: 5px 0;
  color: #6b7075;
  font-size: 0.875rem;
  line-height: 1.45;
  text-decoration: none;
  transition: color 0.15s ease;
}

.docs-nav h2 + .dn-page { margin-top: 8px; }

.dn-page:hover { color: var(--ink); }

/* Where you are. Weight rather than a rule or a tint: the heaviest word in a
   list of words is the one you are on, and nothing else has to be drawn. */
.dn-page.on {
  color: var(--ink);
  font-weight: 500;
}

/* The sections of the page you are on, and only that page. Indented off a
   hairline so the list reads as belonging to the link above it. */
.dn-subs {
  margin: 4px 0 6px;
  padding-left: 11px;
  border-left: 1px solid #ececec;
}

.dn-sub {
  display: block;
  padding: 4px 0;
  color: #85898e;
  font-size: 0.8125rem;
  line-height: 1.45;
  text-decoration: none;
  transition: color 0.15s ease;
}

.dn-sub:hover { color: var(--ink); }
.dn-sub.on { color: var(--ink); }

.docs-nav a:focus-visible,
.df-hit:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

/* ---------- The page you are reading ---------- */

.docs-body {
  max-width: 700px;
  padding-bottom: 120px;
}

.docs-body .eyebrow {
  display: inline-block;
  margin-top: 0;
}

.docs-title {
  margin: 16px 0 0;
  font-weight: 400;
  font-size: min(2.125rem, 7.4vw);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.docs-lede {
  margin: 14px 0 0;
  font-size: 1.0625rem;
  line-height: 1.65;
  color: #45494d;
}

/* A section starts on a hairline, the only rule on the page. It says the
   subject changed without a heading having to shout it. */
.docs-body section {
  margin-top: 56px;
  padding-top: 32px;
  border-top: 1px solid #ececec;
}

.docs-body h2 {
  margin: 0;
  font-size: 1.375rem;
  font-weight: 400;
  line-height: 1.3;
  letter-spacing: -0.015em;
  color: var(--ink);
}

.docs-body h3 {
  margin: 34px 0 0;
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.5;
  letter-spacing: -0.005em;
  color: var(--ink);
}

.docs-body p,
.docs-body li {
  font-size: 0.9375rem;
  line-height: 1.75;
  color: #45494d;
}

.docs-body p { margin: 14px 0 0; }

.docs-body ul {
  margin: 14px 0 0;
  padding-left: 20px;
}

.docs-body li { margin-top: 8px; }
.docs-body li::marker { color: #c2c8cd; }

.docs-body b,
.docs-body strong {
  font-weight: 500;
  color: var(--ink);
}

.docs-body a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: #c9ced3;
  text-underline-offset: 3px;
  transition: text-decoration-color 0.15s ease;
}

.docs-body a:hover { text-decoration-color: var(--ink); }

.docs-body a:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

/* ---------- A keystroke ----------
   Drawn the way the app draws its own, in the "/" menu and the zoom menu, so
   the page and the product teach one notation rather than two. */
.key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 21px;
  height: 21px;
  padding: 0 5px;
  border: 1px solid #e2e5e8;
  background: #fff;
  color: #45494d;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1;
  vertical-align: 1px;
}

.key + .key { margin-left: 3px; }

.df-hint .key {
  min-width: 18px;
  height: 18px;
  font-size: 0.6875rem;
}

/* what you type, inside a sentence */
.docs-body code {
  padding: 1px 5px;
  background: #f1f2f3;
  color: #2b2e31;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 0.8125rem;
}

/* ---------- A block of it ----------
   Labelled, because somebody who has scrolled to a rectangle of monospace
   deserves to be told where they are meant to type it. */
.snip {
  margin-top: 16px;
  border: 1px solid #ececec;
  background: #fff;
}

.snip-tag {
  padding: 9px 14px;
  border-bottom: 1px solid #ececec;
  background: #fafafa;
  color: #8a8f94;
  font-size: 0.75rem;
  line-height: 1.4;
  letter-spacing: 0.02em;
}

.snip pre {
  margin: 0;
  padding: 14px;
  overflow-x: auto;
}

.snip code {
  padding: 0;
  background: none;
  color: #2b2e31;
  font-size: 0.8125rem;
  line-height: 1.7;
  white-space: pre;
}

/* ---------- The command list ----------
   Three columns: what you type, the key it also answers to, what it does. A
   definition list rather than a table, because a table draws a grid and there
   is nothing to compare down a column here. */
.cmds {
  margin: 22px 0 0;
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  gap: 0;
  align-items: baseline;
}

/* The shortcut list is not a list of commands, so its left column is words
   rather than something you type, and should not wear a typewriter. */
.cmds.plain dt {
  font-family: inherit;
  font-size: 0.9375rem;
  color: #45494d;
}

.cmds dt {
  padding: 11px 0;
  border-top: 1px solid #f0f0f0;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 0.8125rem;
  color: var(--ink);
  white-space: nowrap;
}

.cmds .k {
  padding: 11px 20px 11px 18px;
  border-top: 1px solid #f0f0f0;
  white-space: nowrap;
}

.cmds dd {
  margin: 0;
  padding: 11px 0;
  border-top: 1px solid #f0f0f0;
  font-size: 0.9375rem;
  line-height: 1.6;
  color: #45494d;
}

.cmds dt:first-child,
.cmds dt:first-child + .k,
.cmds dt:first-child + .k + dd { border-top: 0; }

/* ---------- Steps ----------
   Numbered because the order is load-bearing, which is not true of the
   bulleted lists elsewhere. */
.steps {
  margin: 20px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.steps > li {
  position: relative;
  margin-top: 20px;
  padding-left: 34px;
  counter-increment: step;
}

.steps > li:first-child { margin-top: 0; }

.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 2px;
  width: 21px;
  height: 21px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f1f2f3;
  color: #6b7075;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1;
}

.steps > li > p:first-child { margin-top: 0; }

/* ---------- An aside ----------
   For the sentence that is true, useful, and not what the paragraph is about. */
.note {
  margin-top: 20px;
  padding: 2px 0 2px 16px;
  border-left: 2px solid #e5e7e9;
}

.note p {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.7;
  color: #6b7075;
}

.note p + p { margin-top: 10px; }

/* ---------- The way on ----------
   Eight pages read in an order, so the bottom of one says what the next is
   rather than sending people back to the sidebar to work it out. */
.docs-pn {
  margin-top: 64px;
  padding-top: 24px;
  border-top: 1px solid #ececec;
  display: flex;
  gap: 16px;
}

.pn {
  flex: 1;
  min-width: 0;
  padding: 13px 15px;
  border: 1px solid #ececec;
  background: #fff;
  color: var(--ink);
  font-size: 0.9375rem;
  line-height: 1.45;
  text-decoration: none;
  transition: border-color 0.15s ease;
}

.pn:hover { border-color: #d6d9dc; }

.pn span {
  display: block;
  margin-bottom: 3px;
  color: #9a9fa4;
  font-size: 0.75rem;
  line-height: 1.4;
}

.pn.next {
  text-align: right;
  margin-left: auto;
}

.pn:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* ---------- The fold, on a screen too narrow for a column beside the text ----
   The list becomes a disclosure above the page rather than a drawer over it.
   There is nothing to hide behind on a page that is only words, and a panel
   sliding in from the edge is a mechanism to learn for eight links. */

.docs-toggle {
  display: none;
  width: 100%;
  margin: 20px 0 0;
  padding: 11px 0;
  border: 0;
  border-bottom: 1px solid #ececec;
  background: none;
  color: var(--ink);
  font-family: inherit;
  font-size: 0.875rem;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
}

.docs-toggle svg {
  float: right;
  margin-top: 4px;
  transition: transform 0.2s ease;
}

.docs-toggle[aria-expanded="true"] svg { transform: rotate(45deg); }

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

  .docs-side {
    position: static;
    max-height: none;
    display: block;
    padding-bottom: 0;
  }

  .docs-toggle { display: block; }

  .docs-nav {
    margin-top: 0;
    padding: 22px 0 26px;
    border-bottom: 1px solid #ececec;
    overflow: visible;
  }

  .docs-nav[hidden] { display: none; }

  .docs-nav h2 { margin-top: 26px; }

  .docs-body { padding-bottom: 88px; }
  .docs-body .eyebrow { margin-top: 40px; }

  .docs-body section {
    margin-top: 44px;
    padding-top: 28px;
  }

  /* Three columns do not fit on a phone, and folding one under another inside
     a grid means hand-placing every cell. So the grid is given up rather than
     fought: each entry becomes three stacked lines under one rule, which is
     the same reading order at a quarter of the machinery. */
  .cmds { display: block; }

  .cmds dt {
    display: block;
    padding: 15px 0 0;
    border-top: 1px solid #f0f0f0;
  }

  .cmds .k {
    display: block;
    padding: 7px 0 0;
    border-top: 0;
  }

  .cmds dd {
    display: block;
    padding: 3px 0 15px;
  }

  .cmds dt:first-child {
    padding-top: 0;
    border-top: 0;
  }

  .docs-pn { flex-direction: column; }
  .pn.next { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  .docs-toggle svg { transition: none; }
}
