/* nib std — the reference pages under /std/.

   Loaded after /style.css, which supplies every colour token, the type
   stacks and the code panel's highlight classes; this file only lays out a
   reference and adds nothing to the palette. It is copied to site/std/std.css
   by gen/build_docs.py — edit it here.

   The kind chips reuse colours that already mean those things on the front
   page: an effector is vermilion (the hero's "only mutation" layer, --t-shell),
   an interface cobalt (--t-core: the name a module may ask for), and data and
   functions the code panel's own type and function inks, so a chip and the
   signature under it agree. */

body.std {
  padding: 0;
}

body.std a.ref,
body.std .std-nav a,
body.std .item-head a.self,
body.std dl.mods a,
body.std .std-top a {
  border-bottom: none;
}

/* ---- top bar ---- */

.std-top {
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
  padding: 0.85rem 1.4rem 0.8rem;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
}

.std-top .mark {
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.std-top .crumb {
  color: var(--cobalt);
  font-weight: 700;
}

.std-top .crumb::before {
  content: "/";
  color: var(--ink-3);
  margin-right: 0.9rem;
  font-weight: 400;
}

.std-top .ver {
  margin-left: auto;
  font-size: 0.78rem;
  color: var(--ink-3);
}

/* the version picker: a <details>, so it needs no script */
.std-top details.ver {
  position: relative;
}

.std-top details.ver > summary {
  cursor: pointer;
  list-style: none;
  padding: 0.15rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.std-top details.ver > summary::-webkit-details-marker {
  display: none;
}

.std-top details.ver > summary::after {
  content: " ▾";
}

.std-top details.ver[open] > summary {
  color: var(--ink);
}

.std-top details.ver ul {
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  z-index: 10;
  margin: 0;
  padding: 0.35rem 0;
  list-style: none;
  min-width: 13rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
}

.std-top details.ver li a {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.35rem 0.8rem;
  color: var(--ink);
}

.std-top details.ver li a:hover {
  background: var(--line);
}

.std-top details.ver li a[aria-current="page"] {
  font-weight: 700;
}

.std-top .ver-kind {
  color: var(--ink-3);
  font-weight: 400;
}

/* every page of the pre-release reference (/std/next/): a full-width bar under
   the header, so it reads as a property of the page and not as body text */
.prerelease-banner {
  padding: 0.55rem 1.4rem;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--cobalt) 9%, transparent);
  font-size: 0.85rem;
  color: var(--ink-2);
}

.prerelease-banner p {
  margin: 0;
  max-width: none;
}

/* ---- two columns: the library, and the page ---- */

.std-layout {
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr);
  gap: 2.4rem;
  max-width: 76rem;
  margin: 0 auto;
  padding: 0 1.4rem 6rem;
}

.std-nav {
  position: sticky;
  top: 0;
  align-self: start;
  max-height: 100vh;
  overflow-y: auto;
  padding: 1.6rem 0 2rem;
  font-family: var(--mono);
  font-size: 0.84rem;
  line-height: 1.5;
}

.std-nav ul {
  list-style: none;
  margin: 0 0 1.2rem;
  padding: 0;
}

.std-nav li > a {
  display: block;
  padding: 0.12rem 0.5rem;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  font-weight: 500;
}

.std-nav li > a:hover {
  color: var(--vermilion);
}

.std-nav li.here > a {
  background: var(--panel);
  color: var(--ink);
  font-weight: 700;
}

.std-nav .nav-head {
  margin: 0 0 0.35rem;
  padding-left: 0.5rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.std-nav ul.items {
  margin: 0.2rem 0 0.6rem 0.7rem;
  padding-left: 0.6rem;
  border-left: 2px solid var(--line);
  font-size: 0.78rem;
}

.std-nav ul.items ul {
  margin: 0 0 0.4rem;
}

.std-nav li.sub > span {
  display: block;
  padding: 0.3rem 0.5rem 0.05rem;
  color: var(--ink-3);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.std-main {
  min-width: 0;
  padding-top: 1.6rem;
}

/* ---- a page ---- */

.std-page h1 {
  font-family: var(--mono);
  font-size: clamp(1.7rem, 5vw, 2.3rem);
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin: 0.3rem 0 0.6rem;
}

.std-page p.summary {
  font-size: 1.08rem;
  color: var(--ink-2);
  margin-bottom: 1.4rem;
}

.std-page p,
.std-page ul {
  max-width: 44rem;
}

.std-page ul {
  padding-left: 1.2rem;
  margin: 0 0 1.05rem;
}

.std-page li {
  margin-bottom: 0.3rem;
}

.std-page li code {
  white-space: normal;
}

.std-page h4 {
  font-family: var(--mono);
  font-size: 0.95rem;
  margin: 1.8rem 0 0.5rem;
}

.chip-line {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}

.chip-line .use,
dl.mods .use {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--ink-3);
  background: none;
  box-shadow: none;
  padding: 0;
}

/* ---- kind chips ---- */

.chip {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1;
  padding: 0.3rem 0.45rem 0.28rem;
  border-radius: 4px;
  border: 1.5px solid currentColor;
  white-space: nowrap;
}

.chip.type { color: var(--c-type); }
.chip.data { color: var(--c-type); }
.chip.module { color: var(--t-core); }
.chip.interface { color: var(--t-core); }
.chip.effector { color: var(--t-shell); }
.chip.func { color: var(--c-function); }

/* ---- groups and items ---- */

section.group {
  padding-top: 2.2rem;
}

section.group::before {
  display: none;
}

section.group > h2 {
  font-size: 1.25rem;
  padding-bottom: 0.45rem;
  border-bottom: 2px solid var(--line);
  margin-bottom: 0.4rem;
}

.item {
  padding: 1.3rem 0 0.4rem;
  border-bottom: 1px solid var(--line);
  scroll-margin-top: 1rem;
}

.item:last-child {
  border-bottom: none;
}

.item-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.55rem;
}

.item-head a.self {
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
}

.item-head a.self:hover {
  color: var(--vermilion);
}

.item-head .native {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-3);
}

.item:target .item-head a.self {
  background: var(--pen-wash);
  box-shadow: inset 0 -0.2em 0 0 var(--pen-line);
}

/* A signature is read, not run: flat, a thin rail, one size down. */
pre.code.sig {
  box-shadow: none;
  border-left-width: 3px;
  padding: 0.7rem 1rem 0.7rem 0.9rem;
  font-size: 13px;
  margin-bottom: 0.9rem;
}

.doc {
  padding-left: 0.1rem;
}

/* ---- examples: the code, then what nibc printed for it ---- */

.example {
  margin: 0.4rem 0 1.4rem;
  max-width: 50rem;
}

.example pre.code {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  box-shadow: none;
}

.example pre.output {
  margin: 0;
  padding: 0.55rem 1.1rem 0.6rem 0.9rem;
  background: var(--run-bg);
  color: var(--run-ink);
  border-left: 4px solid var(--mustard);
  border-radius: 0 0 var(--r-md) var(--r-md);
  font-family: var(--mono);
  font-size: 12.6px;
  line-height: 1.55;
  overflow-x: auto;
  white-space: pre;
}

.example pre.output::before {
  content: "⇒ ";
  color: var(--mustard);
}

.example pre.output code {
  color: inherit;
  font-size: inherit;
}

pre.code.plain {
  box-shadow: none;
  margin: 0.4rem 0 1.4rem;
}

/* ---- the index ---- */

dl.mods {
  margin: 0.6rem 0 0;
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  column-gap: 1.6rem;
}

dl.mods dt {
  font-family: var(--mono);
  font-weight: 700;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
}

dl.mods dd {
  margin: 0;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink-2);
}

dl.mods dt .use {
  display: block;
  font-weight: 400;
}

section.internal details summary {
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--ink-2);
  margin-bottom: 0.8rem;
}

/* ---- narrow screens: the nav folds above the page ---- */

@media (max-width: 52rem) {
  .std-layout {
    display: block;
    padding: 0 1rem 4rem;
  }
  .std-top {
    padding: 0.8rem 1rem;
  }
  .std-nav {
    position: static;
    max-height: none;
    padding: 0.8rem 0 0;
    border-bottom: 1px solid var(--line);
  }
  .std-nav > ul:not(:has(li.here)) {
    display: flex;
    flex-wrap: wrap;
    gap: 0.1rem 0.2rem;
  }
  .std-nav ul {
    display: flex;
    flex-wrap: wrap;
    gap: 0.1rem 0.2rem;
    margin-bottom: 0.8rem;
  }
  .std-nav ul.items {
    display: none;
  }
  dl.mods {
    display: block;
  }
  dl.mods dt {
    border-bottom: none;
    padding-bottom: 0;
  }
  pre.code.sig,
  .example pre.code {
    margin-left: 0;
    margin-right: 0;
  }
}

/* Inline code in reference prose may wrap at its spaces: the front page's
   nowrap is for a primer's short tokens, and a reference quotes whole
   expressions (`{ acc, x -> acc + x }`), which at 390 px would push the page
   sideways. */
.std-page p code,
.std-page li code,
dl.mods dd code {
  white-space: normal;
}
