/*
 * Documentation typography.
 *
 * The landing page owns the showy grammar; documents do not inherit it. Crossing
 * into /docs should feel like opening a printed specification: a comfortable
 * reading measure, a real heading hierarchy, dense but breathable text, and no
 * display type, hero, or marketing card anywhere inside a document.
 *
 * Everything here is scoped under `.docs`, so the landing and the product pages
 * are untouched by it. Static CSS only — the docs shell uses no script, and the
 * site's no-script check is binding.
 */

.docs {
  --doc-ink: #1c1b18;
  --doc-muted: #5d5a52;
  --doc-line: #ddd8cb;
  --doc-paper: #fbfaf5;
  --doc-code: #f2efe6;
  --doc-accent: #3d5a45;

  /* No radial wash: documents get a flat, calm page. */
  background: var(--doc-paper);
  color: var(--doc-ink);
  font-size: 17px;
}

/* --- shell ---------------------------------------------------------------- */

.doc-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  width: min(1400px, calc(100% - 48px));
  margin-inline: auto;
  min-height: 64px;
  border-bottom: 1px solid var(--doc-line);
}

.doc-topbar .wordmark {
  font-weight: 900;
  letter-spacing: 0.18em;
  font-size: 0.95rem;
  text-decoration: none;
}

.doc-topbar nav {
  display: flex;
  gap: 20px;
}

.doc-topbar nav a {
  color: var(--doc-muted);
  font-size: 0.85rem;
  text-decoration: none;
}

.doc-topbar nav a:hover {
  color: var(--doc-ink);
}

.doc-layout {
  display: grid;
  grid-template-columns: 16rem minmax(0, 1fr) 15rem;
  gap: 48px;
  width: min(1400px, calc(100% - 48px));
  margin-inline: auto;
  padding: 40px 0 96px;
  align-items: start;
}

/* --- sidebar and table of contents ---------------------------------------- */

.doc-sidebar,
.doc-toc {
  /*
   * Explicitly a block, because `styles.css` styles BARE `nav` as a wrapping
   * flex row for the site header — and these are `nav` elements too. With two
   * groups the headings and lists happened to wrap into something that looked
   * like a column; adding a third put "Guides" beside the first list instead of
   * above its own. Stating the display here means the sidebar's layout no longer
   * depends on how many groups happen to fit.
   */
  display: block;
  position: sticky;
  top: 24px;
  font-size: 0.86rem;
  line-height: 1.5;
}

.doc-sidebar-title {
  margin: 0 0 8px;
  color: var(--doc-muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.doc-sidebar ul,
.doc-toc ul {
  list-style: none;
  margin: 0 0 28px;
  padding: 0;
  border-left: 1px solid var(--doc-line);
}

.doc-sidebar li,
.doc-toc li {
  margin: 0;
}

.doc-sidebar a,
.doc-toc a {
  display: block;
  padding: 5px 0 5px 14px;
  margin-left: -1px;
  border-left: 2px solid transparent;
  color: var(--doc-muted);
  text-decoration: none;
}

.doc-sidebar a:hover,
.doc-toc a:hover {
  color: var(--doc-ink);
  background: rgb(0 0 0 / 2.5%);
}

.doc-sidebar a[aria-current="page"] {
  color: var(--doc-ink);
  font-weight: 700;
  border-left-color: var(--doc-accent);
}

/* --- document body -------------------------------------------------------- */
/*
 * `.doc-authored` is the same reading experience as `.doc-body` and deliberately
 * NOT the same container name: the pinned collections use `.doc-body`, and the
 * site's vocabulary lints are scoped by that name. Authored prose must stay
 * inside the lints, so it gets its own class and shares only the typography.
 */

.doc-main {
  min-width: 0;
  /* A reading measure, not a full-bleed column. */
  max-width: 46rem;
}

.doc-breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
  color: var(--doc-muted);
  font-size: 0.8rem;
}

.doc-breadcrumbs a {
  color: var(--doc-muted);
  text-decoration: none;
}

.doc-breadcrumbs a:hover {
  color: var(--doc-ink);
}

/* Deliberately not display type: a document title, not a headline. */
.docs h1 {
  max-width: none;
  margin: 0 0 20px;
  font-size: 2rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.doc-provenance {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 4px 16px;
  margin: 0 0 14px;
  padding: 14px 16px;
  border: 1px solid var(--doc-line);
  border-radius: 4px;
  background: rgb(255 255 255 / 55%);
  font-size: 0.8rem;
}

.doc-provenance dt {
  color: var(--doc-muted);
}

.doc-provenance dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.doc-note {
  margin: 0 0 10px;
  color: var(--doc-muted);
  font-size: 0.82rem;
  line-height: 1.6;
}

.doc-body,
.doc-authored {
  margin-top: 28px;
}

.docs :is(.doc-body, .doc-authored) h2,
.docs :is(.doc-body, .doc-authored) h3,
.docs :is(.doc-body, .doc-authored) h4,
.docs :is(.doc-body, .doc-authored) h5,
.docs :is(.doc-body, .doc-authored) h6 {
  max-width: none;
  margin: 2em 0 0.6em;
  line-height: 1.25;
  letter-spacing: -0.01em;
  scroll-margin-top: 24px;
}

.docs :is(.doc-body, .doc-authored) h2 {
  font-size: 1.4rem;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--doc-line);
}

.docs :is(.doc-body, .doc-authored) h3 { font-size: 1.12rem; }
.docs :is(.doc-body, .doc-authored) h4 { font-size: 1rem; }
.docs :is(.doc-body, .doc-authored) h5,
.docs :is(.doc-body, .doc-authored) h6 { font-size: 0.94rem; }

.docs :is(.doc-body, .doc-authored) p,
.docs :is(.doc-body, .doc-authored) li {
  color: var(--doc-ink);
  font-size: 1rem;
  line-height: 1.72;
}

.docs :is(.doc-body, .doc-authored) p {
  margin: 0 0 1.1em;
}

.docs :is(.doc-body, .doc-authored) ul,
.docs :is(.doc-body, .doc-authored) ol {
  margin: 0 0 1.1em;
  padding-left: 1.4em;
}

.docs :is(.doc-body, .doc-authored) li {
  margin-bottom: 0.4em;
}

.docs :is(.doc-body, .doc-authored) code {
  padding: 0.1em 0.35em;
  border-radius: 3px;
  background: var(--doc-code);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
}

.docs :is(.doc-body, .doc-authored) pre {
  margin: 0 0 1.3em;
  padding: 14px 16px;
  overflow-x: auto;
  border: 1px solid var(--doc-line);
  border-radius: 4px;
  background: var(--doc-code);
}

.docs :is(.doc-body, .doc-authored) pre code {
  padding: 0;
  background: none;
  font-size: 0.84rem;
  line-height: 1.6;
}

.docs :is(.doc-body, .doc-authored) table {
  width: 100%;
  margin: 0 0 1.4em;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.docs :is(.doc-body, .doc-authored) th,
.docs :is(.doc-body, .doc-authored) td {
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--doc-line);
}

.docs :is(.doc-body, .doc-authored) thead th {
  color: var(--doc-muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom-color: var(--doc-ink);
}

.docs :is(.doc-body, .doc-authored) a {
  color: var(--doc-accent);
}

/* --- pager ---------------------------------------------------------------- */

.doc-pager {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 56px;
  padding-top: 20px;
  border-top: 1px solid var(--doc-line);
}

.doc-pager a {
  max-width: 48%;
  color: var(--doc-ink);
  font-size: 0.92rem;
  text-decoration: none;
}

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

.doc-pager span {
  display: block;
  color: var(--doc-muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.doc-pager a:hover {
  color: var(--doc-accent);
}

/* --- command reference ---------------------------------------------------- */

.doc-command {
  margin: 0 0 2.4em;
  scroll-margin-top: 24px;
}

.doc-synopsis {
  margin: 0 0 1em;
}

.doc-status {
  display: inline-block;
  margin-left: 8px;
  padding: 0.1em 0.5em;
  border: 1px solid currentColor;
  border-radius: 99px;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  vertical-align: middle;
}

.doc-status-shipped { color: var(--doc-accent); }
.doc-status-designed { color: #8a5a00; }

/* --- narrow screens ------------------------------------------------------- */

@media (max-width: 1100px) {
  .doc-layout {
    grid-template-columns: 14rem minmax(0, 1fr);
  }
  .doc-toc {
    display: none;
  }
}

@media (max-width: 820px) {
  .doc-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 28px;
  }
  .doc-sidebar {
    position: static;
  }
  .doc-main {
    max-width: none;
  }
}

/* --- diagrams ------------------------------------------------------------- */
/*
 * Mermaid sources are laid out and drawn as inline SVG at build time.
 *
 * Not a runtime: the site ships no client script and its CSP is
 * `default-src 'none'`, so a diagramming library could not load even if one were
 * wanted. Inline also means the diagram inherits these colours and the reader's
 * zoom, instead of being a flat image that goes blurry.
 *
 * The steps list under each figure is not a fallback nobody reads. It is the
 * same flow in words, and it is what a screen reader, a printed page, and a
 * phone-width column are actually good at.
 */

.doc-diagram {
  margin: 0 0 1.6em;
  padding: 18px 16px 4px;
  border: 1px solid var(--doc-line);
  border-radius: 4px;
  background: rgb(255 255 255 / 55%);
}

.doc-diagram-svg {
  display: block;
  width: 100%;
  /* Never scaled up past its drawn size: the labels are set at a real reading
     size, and stretching them to fill a wide column only makes them coarse. */
  max-width: 440px;
  height: auto;
  margin: 0 auto 14px;
}

.doc-diagram-node {
  fill: var(--doc-paper);
  stroke: var(--doc-ink);
  stroke-width: 1.2;
}

.doc-diagram-store {
  fill: var(--doc-code);
}

.doc-diagram-label {
  fill: var(--doc-ink);
  font-family: inherit;
  font-size: 13px;
}

.doc-diagram-edge {
  fill: none;
  stroke: var(--doc-accent);
  stroke-width: 1.4;
}

.doc-diagram-arrow {
  fill: var(--doc-accent);
}

.doc-diagram figcaption {
  border-top: 1px solid var(--doc-line);
  padding-top: 12px;
}

.docs .doc-diagram-caption,
.docs .doc-diagram-steps-title {
  margin: 0 0 6px;
  color: var(--doc-muted);
  font-size: 0.82rem;
}

.docs .doc-diagram-steps {
  margin: 0 0 1em;
  padding-left: 1.3em;
}

.docs .doc-diagram-steps li {
  margin-bottom: 0.2em;
  color: var(--doc-muted);
  font-size: 0.84rem;
  line-height: 1.55;
}

/* --- translated bodies and publication notes ------------------------------ */
/*
 * A translated guide body reads exactly like the English one. The marker is
 * structural, for the provenance checks; it is not a visual warning strip,
 * because a Korean reader is reading their own page, not a caveat.
 */

.doc-publication-note {
  margin: 0 0 1.6em;
  padding: 14px 16px;
  border: 1px solid var(--doc-line);
  border-left: 3px solid var(--doc-accent);
  border-radius: 4px;
  background: rgb(255 255 255 / 55%);
}

.docs .doc-publication-note p {
  margin: 0 0 0.6em;
  font-size: 0.9rem;
  line-height: 1.65;
}

.docs .doc-publication-note p:last-child {
  margin-bottom: 0;
}

.doc-publication-note-title {
  margin: 0 0 6px;
  color: var(--doc-muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* --- wide content on a narrow screen -------------------------------------- */
/*
 * A table of five prose columns, or a command synopsis, has a minimum width
 * that no phone has. Left alone it widens the DOCUMENT, and then everything
 * else — the provenance box, the paragraphs, the language switch in the header
 * — runs off the right edge with it. The page is not overflowing because the
 * prose is too wide; it is overflowing because one element inside it is.
 *
 * So the wide element scrolls, and nothing else has to.
 */

.doc-table {
  max-width: 100%;
  overflow-x: auto;
  margin: 0 0 1.4em;
  /* Keep the scrolled edge visible rather than letting a row look truncated. */
  border-bottom: 1px solid var(--doc-line);
}

.docs .doc-table table {
  /* Fills the column when it fits, scrolls inside the wrapper when it does not. */
  width: auto;
  min-width: 100%;
  margin-bottom: 0;
}

.doc-table:focus-visible {
  outline: 2px solid var(--doc-accent);
  outline-offset: 2px;
}

/* Every preformatted block in the docs area, not only the ones inside a
   document body — the command reference's synopses live in `.doc-reference`
   and were forcing the widest overflow on the whole site. */
.docs pre {
  max-width: 100%;
  overflow-x: auto;
}

/* The header's own navigation wraps instead of pushing the language switch off
   the side of the screen. */
.doc-topbar {
  flex-wrap: wrap;
  padding-block: 8px;
}

.doc-topbar nav {
  flex-wrap: wrap;
  row-gap: 4px;
}

/*
 * Inline code may break mid-token; a preformatted block may not.
 *
 * A 40-character commit hash in a sentence has no break opportunity in it, so
 * on a phone that one `<code>` is wider than the screen and takes the page with
 * it. Breaking it is the right answer: the hash stays complete and readable
 * across two lines, which is what "keep the full hash available" means on a
 * narrow screen.
 *
 * `<pre>` is excluded deliberately. A command line broken mid-flag is a command
 * that does not run, so those scroll instead — the rule above.
 */
.docs :not(pre) > code {
  overflow-wrap: anywhere;
}
