/* The documentation: one page, every topic in one shape (docs/writing-docs.md). All topics on the
   left, the page in the middle, the parts of the topic being read on the right. Loaded after
   styles.css and written against its tokens; every rule is scoped to .docs-layout or .docs-head so
   the home page is untouched. Without scripts the page is whole — the list on the left is open and
   every heading has its id; docs.js adds the search, where-you-are and the phone bars. */

.docs-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 190px;
  grid-template-areas: "groups article on-page";
  gap: 48px;
  width: min(1280px, calc(100vw - 44px));
  margin: 0 auto;
  padding: 40px 0 88px;
}

/* styles.css spaces the home page's sections with padding and a rule; here the layout spaces them. */
.docs-layout section { padding: 0; border: 0; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* All topics ------------------------------------------------------------- */

.docs-groups {
  grid-area: groups;
  position: sticky;
  top: 78px;
  align-self: start;
  max-height: calc(100vh - 98px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--ink-line) transparent;
  font-family: var(--mono);
}
.docs-search { display: none; margin: 0 0 18px; }
.js .docs-search { display: block; }
.docs-search input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--ink-line);
  border-radius: 8px;
  color: var(--text-loud);
  background: var(--ink-raised);
  font-family: var(--mono);
  font-size: 12.5px;
  -webkit-appearance: none;
  appearance: none;
}
.docs-search input::placeholder { color: var(--text-quiet); }
.docs-search input:focus { outline: none; border-color: var(--coral); }
.docs-search-count { display: block; min-height: 1.4em; margin: 6px 0 0 2px; color: var(--text-quiet); font-size: 10.5px; }
.docs-search-count:empty { display: none; }

/* Search results: the topics holding every word, best first, each quoting where the words are. */
.docs-results { margin: 0 0 18px; padding: 0; list-style: none; }
.docs-results[hidden] { display: none; }
.docs-results a { display: block; padding: 8px 10px; border-radius: 8px; text-decoration: none; }
.docs-results a:hover, .docs-results a[aria-selected="true"] { background: var(--ink-raised); }
.docs-results strong { display: block; color: var(--text-loud); font-size: 12.5px; font-weight: 600; }
.docs-results span { display: block; margin-top: 3px; color: var(--text-quiet); font-family: var(--prose); font-size: 12.5px; line-height: 1.45; }
.docs-results mark { color: var(--coral-hover); background: transparent; text-decoration: underline; text-decoration-color: var(--coral); text-underline-offset: 2px; }

.docs-groups .group { margin: 0 0 20px; }
.docs-groups .group[hidden] { display: none; }
.docs-groups h2 {
  margin: 0 0 6px;
  padding: 0 10px;
  color: var(--text-quiet);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.docs-groups ul { margin: 0; padding: 0; list-style: none; }
.docs-groups li[hidden] { display: none; }
.docs-groups a {
  display: block;
  padding: 5px 10px;
  border-radius: 6px;
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.4;
  text-decoration: none;
}
.docs-groups a:hover { color: var(--coral-bright); }
.docs-groups a.here { color: var(--text-loud); background: var(--ink-raised); font-weight: 600; }

/* On this page: the parts of the topic being read, filled by docs.js. -------- */

.on-page { grid-area: on-page; position: sticky; top: 78px; align-self: start; font-family: var(--mono); font-size: 12px; }
.on-page:empty { display: none; }
.on-page h2 { margin: 0 0 10px; color: var(--text-quiet); font-size: 10px; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase; }
.on-page ol { margin: 0; padding: 0; list-style: none; }
.on-page ol a { display: block; padding: 4px 0 4px 12px; color: var(--text-quiet); text-decoration: none; box-shadow: inset 2px 0 var(--ink-line); }
.on-page ol a:hover { color: var(--coral-bright); }
.on-page ol a.here { color: var(--text-loud); box-shadow: inset 2px 0 var(--coral); }
.on-page .elsewhere { margin: 18px 0 0; padding: 14px 0 0; border-top: 1px solid var(--ink-line); }
.on-page .elsewhere a { color: var(--coral-bright); text-decoration: none; }

/* The bars that stand for the two lists on a phone; drawn only there, and only with scripts. */
.docs-bar { display: none; }

/* The page head ---------------------------------------------------------- */

.docs-layout article { grid-area: article; min-width: 0; max-width: 740px; font-size: 17px; line-height: 1.7; }
.docs-layout article p, .docs-layout article li, .docs-layout article dd { color: var(--text); }
.docs-layout article em { color: var(--text-loud); }

.docs-head { display: flex; flex-direction: column; gap: 14px; margin: 0 0 56px; }
.docs-head .eyebrow { color: var(--coral-bright); font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; }
.docs-head h1 {
  margin: 0;
  color: var(--text-loud);
  font-family: var(--mono);
  font-size: clamp(32px, 4vw, 44px);
  font-weight: 500;
  letter-spacing: -0.05em;
  line-height: 1.1;
}
.docs-head .lede { margin: 0; font-size: 20px; line-height: 1.6; }
.page-facts { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0; color: var(--text-quiet); font-family: var(--mono); font-size: 11.5px; }

.start-here { margin-top: 10px; padding: 18px 22px 14px; border: 1px solid var(--ink-line); border-radius: 12px; background: var(--ink-raised); }
.start-here p { margin: 0 0 8px; color: var(--text-quiet); font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; }
.start-here ul { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 24px; margin: 0; padding: 0; list-style: none; }
.start-here a { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--ink-line); color: var(--text); font-size: 15.5px; text-decoration: none; }
.start-here a::after { content: "→"; color: var(--text-quiet); }
.start-here a:hover { color: var(--text-loud); }

/* Groups and topics ------------------------------------------------------ */

.docs-layout .group-head { margin: 0 0 40px; padding-top: 40px; border-top: 1px solid var(--ink-line); }
.docs-layout .group-head h2 {
  margin: 0 0 6px;
  color: var(--coral-bright);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  scroll-margin-top: 84px;
}
.docs-layout .group-head p { margin: 0; color: var(--text-quiet); font-size: 16px; }

.topic { margin: 0 0 72px; }
.topic > * + * { margin-top: 28px; }
.topic h3 {
  margin: 0;
  color: var(--text-loud);
  font-family: var(--mono);
  font-size: 30px;
  font-weight: 500;
  letter-spacing: -0.05em;
  line-height: 1.15;
  scroll-margin-top: 84px;
}
.topic > .lede { margin-top: 10px; font-size: 19px; line-height: 1.6; }
.topic h4 {
  margin-top: 36px;
  margin-bottom: -14px;
  color: var(--text-loud);
  font-family: var(--mono);
  font-size: 19px;
  font-weight: 500;
  letter-spacing: -0.03em;
  scroll-margin-top: 84px;
}
.topic p { margin-bottom: 0; }
.topic ul { margin-bottom: 0; padding-left: 20px; }
.topic li + li { margin-top: 6px; }
.topic li > strong:first-child { color: var(--text-loud); }

.anchor { margin-left: 0.3em; color: var(--text-quiet); font-size: 0.7em; font-weight: 400; text-decoration: none; opacity: 0; transition: opacity 120ms; }
.topic h3:hover .anchor, .topic h4:hover .anchor, .anchor:focus-visible { opacity: 1; }
.topic h3:target, .topic h4:target { box-shadow: inset 3px 0 var(--coral); padding-left: 12px; }

/* The kit (docs/writing-docs.md) --------------------------------------------- */

.in-short { padding: 18px 22px; border: 1px solid var(--ink-line); border-radius: 12px; background: var(--ink-raised); }
.in-short > p { margin: 0 0 6px; color: var(--text-quiet); font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; }
.in-short ul { font-size: 16px; }

/* Example first: the feature in use, right after the lede (docs/writing-docs.md). */
.example { padding: 16px 22px; border: 1px solid var(--ink-line); border-left: 3px solid var(--coral); border-radius: 12px; background: var(--ink-raised); }
.example > p:first-child { margin: 0 0 6px; color: var(--text-quiet); font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; }
.example p { font-size: 16px; }
.example > pre, .example > .code { margin: 12px 0 0; }
.example .code > pre { margin: 0; }

.docs-figure { margin-left: 0; margin-right: 0; }
.docs-figure > div { display: flex; justify-content: center; padding: 22px; border: 1px solid var(--ink-line); border-radius: 12px; background: #111312; }
.docs-figure img { display: block; width: 260px; max-width: 100%; height: auto; border-radius: 6px; }
.docs-figure figcaption { margin: 10px 0 0; color: var(--text-quiet); font-family: var(--mono); font-size: 12px; text-align: center; }

.topic ol.steps { margin-bottom: 0; padding: 0; list-style: none; counter-reset: step; }
.steps > li { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 16px; counter-increment: step; }
.steps > li + li { margin-top: 16px; }
.steps > li::before {
  content: counter(step);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--coral-bright);
  border-radius: 50%;
  color: var(--coral-bright);
  font-family: var(--mono);
  font-size: 12px;
}
.steps > li > div > strong:first-child { display: block; color: var(--text-loud); font-family: var(--mono); font-size: 14px; font-weight: 600; }

.docs-layout .callout {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 12px;
  margin-bottom: 0;
  padding: 14px 16px;
  border: 1px solid var(--ink-line);
  border-radius: 10px;
  background: var(--ink-raised);
  color: var(--text);
  font-size: 15.5px;
  line-height: 1.6;
}
.docs-layout .callout::before { content: "i"; display: flex; align-items: center; justify-content: center; width: 18px; height: 18px; margin-top: 3px; border: 1.5px solid currentColor; border-radius: 50%; font-family: var(--mono); font-size: 11px; font-weight: 700; }
.docs-layout .callout p { margin: 0; }
.docs-layout .callout.note { border-color: #2c5a61; background: #1d2a2c; }
.docs-layout .callout.note::before { color: var(--cyan); }
.docs-layout .callout.why { border-color: #6b3a2e; background: #2a201d; }
.docs-layout .callout.why::before { content: "?"; color: var(--coral-bright); }
.docs-layout .callout.careful { border-color: #6b5c24; background: #2b2717; }
.docs-layout .callout.careful::before { content: "!"; color: #e3c35a; }

.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.choices > div { padding: 16px 18px; border: 1px solid var(--ink-line); border-radius: 10px; background: var(--ink-raised); }
.choices h5 { margin: 0; color: var(--text-loud); font-family: var(--mono); font-size: 13.5px; font-weight: 600; }
.choices p { margin: 6px 0 0; font-size: 15px; line-height: 1.6; }

.limits { margin-bottom: 0; border: 1px solid var(--ink-line); border-radius: 10px; overflow: hidden; font-size: 15.5px; }
.limits > div { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: 16px; padding: 12px 16px; }
.limits > div + div { border-top: 1px solid var(--ink-line); }
.limits dt { color: var(--text-loud); }
.limits dd { margin: 0; }

.docs-layout .code { position: relative; }
.docs-layout .code button {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 3px 9px;
  border: 1px solid var(--ink-line);
  border-radius: 6px;
  color: var(--text);
  background: var(--ink-raised);
  font-family: var(--mono);
  font-size: 11px;
  cursor: pointer;
}

/* The shortcut table, grouped. */
.shortcuts tr.group th { padding-top: 18px; color: var(--text-quiet); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; text-align: left; }
.shortcuts td { padding-top: 6px; padding-bottom: 6px; }

/* Narrower screens ------------------------------------------------------ */

@media (max-width: 1080px) {
  .docs-layout { grid-template-columns: 200px minmax(0, 1fr); grid-template-areas: "groups article"; gap: 0 40px; }
  .on-page { display: none; }
}

@media (max-width: 760px) {
  .docs-layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "bar" "groups" "on-page" "article"; padding-top: 0; }
  .docs-groups, .on-page { position: static; max-height: none; }
  /* With scripts the two lists fold behind bars under the site navigation; without them the list
     of topics is simply the first thing on the page. */
  .js .docs-bar {
    grid-area: bar;
    display: flex;
    position: sticky;
    top: 58px;
    z-index: 5;
    margin: 0 -22px 20px;
    border-bottom: 1px solid var(--ink-line);
    background: var(--ink);
  }
  .js .docs-bar button {
    flex: 1;
    min-width: 0;
    min-height: 44px;
    padding: 0 22px;
    overflow: hidden;
    border: 0;
    color: var(--text);
    background: transparent;
    font-family: var(--mono);
    font-size: 12.5px;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
  }
  .js .docs-bar button + button { border-left: 1px solid var(--ink-line); }
  .js .docs-groups:not(.open), .js .on-page:not(.open) { display: none; }
  .js .docs-groups.open, .js .on-page.open { display: block; margin: 0 0 24px; }
  .on-page .elsewhere { display: none; }
  .docs-layout article { font-size: 16.5px; }
  .docs-head .lede { font-size: 18px; }
  .topic h3 { font-size: 26px; }
  /* Below the site navigation and the bar, so a heading jumped to is not under them. */
  .topic h3, .topic h4, .docs-layout .group-head h2 { scroll-margin-top: 118px; }
  .start-here ul { grid-template-columns: minmax(0, 1fr); }
}

/* A drawing in the guides (docs/writing-docs.md, the kit): drawn in the page as SVG, never an
   image file, and every colour a token of the palette in styles.css, set here by class. ------ */

.guide-drawing { margin-left: 0; margin-right: 0; overflow-x: auto; }
.guide-drawing svg { display: block; width: 100%; height: auto; border: 1px solid var(--ink-line); border-radius: 12px; background: var(--ink); font-family: var(--mono); }
/* On a phone the drawing keeps a readable size and scrolls sideways, rather than shrinking its words. */
@media (max-width: 600px) { .guide-drawing svg { min-width: 560px; } }
.guide-drawing .frame, .guide-drawing .box { fill: var(--ink-raised); stroke: var(--ink-line); stroke-width: 1; }
.guide-drawing .you { fill: var(--ink-raised); stroke: var(--coral); stroke-width: 1; }
.guide-drawing .thread { stroke: var(--text-quiet); stroke-width: 2; }
.guide-drawing .station { fill: var(--ink); stroke: var(--coral-bright); stroke-width: 2; }
.guide-drawing .gate { fill: var(--ink); stroke: var(--cyan); stroke-width: 1.5; }
.guide-drawing .link { fill: none; stroke: var(--text-quiet); stroke-width: 1.2; stroke-dasharray: 4 3; }
.guide-drawing .arrow-head { fill: var(--text-quiet); }
.guide-drawing text { fill: var(--text); font-size: 11.5px; }
.guide-drawing text.name { fill: var(--text-loud); font-size: 13px; font-weight: 600; }
.guide-drawing figcaption { margin: 10px 0 0; color: var(--text-quiet); font-family: var(--mono); font-size: 12px; text-align: center; }

/* The site navigation names both pages; on the narrowest phones the wordmark alone goes home. */
@media (max-width: 420px) {
  .site-nav a[href="./"]:not(.wordmark) { display: none; }
}
.site-nav a[aria-current="page"]:not(.wordmark) { color: var(--text-loud); }

/* The docs home and What's new (docs/writing-docs.md, "The docs home" and "What's new") --------
   Cards: a title and one sentence, the whole card one link. Every colour a token of the palette. */

.docs-layout ul.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 0; padding: 0; list-style: none; }
.docs-layout ul.cards li + li { margin-top: 0; }
.docs-layout ul.cards a {
  display: flex;
  flex-direction: column;
  gap: 6px;
  height: 100%;
  padding: 16px 18px;
  border: 1px solid var(--ink-line);
  border-radius: 10px;
  color: var(--text);
  background: var(--ink-raised);
  text-decoration: none;
}
.docs-layout ul.cards a:hover { border-color: var(--coral); }
.docs-layout ul.cards strong { color: var(--text-loud); font-family: var(--mono); font-size: 14px; font-weight: 600; }
.docs-layout ul.cards strong::after { content: " →"; color: var(--text-quiet); }
.docs-layout ul.cards span { font-size: 15px; line-height: 1.55; }

/* The decision table: wide, so it scrolls sideways rather than squeezing its words. */
.docs-layout .which-tool table { min-width: 900px; }
.docs-layout .which-tool th, .docs-layout .which-tool td { vertical-align: top; }
.docs-layout .which-tool th[scope="row"] { color: var(--text-loud); font-size: 12.5px; font-weight: 600; letter-spacing: 0; text-transform: none; white-space: nowrap; }

/* One goal reached several ways, a card each, one under another. */
.ways { display: grid; gap: 12px; }
.ways > div { padding: 16px 18px; border: 1px solid var(--ink-line); border-radius: 10px; background: var(--ink-raised); scroll-margin-top: 84px; }
.ways h5 { margin: 0; color: var(--text-loud); font-family: var(--mono); font-size: 13.5px; font-weight: 600; }
.ways p { margin: 6px 0 0; font-size: 15.5px; line-height: 1.6; }
.ways > div > pre, .ways > div > .code { margin: 12px 0 0; }
.ways .code > pre { margin: 0; }
.ways > div:target { border-color: var(--coral); }

/* What's new: a date's lede, then one outcome to a part. */
.docs-layout .update h3 time { color: inherit; }
.docs-layout .update h4 + p { margin-top: 22px; }

@media (max-width: 760px) {
  .docs-layout ul.cards { grid-template-columns: minmax(0, 1fr); }
}

/* Six links in the site navigation: closer together on a phone, and scrolled rather than cut. */
@media (max-width: 640px) {
  .site-nav .wrap { gap: 14px; overflow-x: auto; scrollbar-width: none; }
  .site-nav .wrap a { flex: none; }
}
