/* OAR docs — layout and text of the pages under /docs/. Loaded after style.css
   and built on its tokens, top bar and colour schemes. The pages are generated
   (scripts/build-docs.mjs); three columns on a wide screen — page list, text,
   on-page contents — one column on a phone, with the page list folded. */

html { scroll-padding-top: 4.5rem; }

/* Simplified Chinese: curly quotes from a Chinese system face, as on the
   zh-cn landing page; in the Latin face “ ” come out narrow and hug the Han text. */
@font-face {
  font-family: "OAR SC Quotes";
  font-weight: 400;
  src: local("Noto Sans CJK SC"), local("NotoSansCJKsc-Regular"), local("Source Han Sans SC"), local("SourceHanSansSC-Regular"),
       local("PingFang SC Regular"), local("PingFangSC-Regular"), local("PingFang SC"), local("Microsoft YaHei"), local("MicrosoftYaHei");
  unicode-range: U+2018-2019, U+201C-201D;
}
@font-face {
  font-family: "OAR SC Quotes";
  font-weight: 700;
  src: local("Noto Sans CJK SC Bold"), local("NotoSansCJKsc-Bold"), local("Source Han Sans SC Bold"), local("SourceHanSansSC-Bold"),
       local("PingFang SC Semibold"), local("PingFangSC-Semibold"), local("Microsoft YaHei Bold"), local("MicrosoftYaHei-Bold");
  unicode-range: U+2018-2019, U+201C-201D;
}
html:lang(zh-Hans) body { font-family: "OAR SC Quotes", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
/* Japanese: no line may start with ー or a small kana. */
html:lang(ja) body { line-break: strict; }

.topbar-left { display: flex; align-items: baseline; gap: 0.9rem; }
/* Japanese and Chinese labels would otherwise break between characters. */
.topbar-left, .topbar-right, .lang-current { white-space: nowrap; }
.topbar-docs {
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.95rem;
}
.docs-release {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-dim);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
}

.docs-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0 2.5rem;
  padding-block: 0.5rem 4rem;
}

/* ── Page list ────────────────────────────────────── */

.docs-nav { font-size: 0.92rem; padding-bottom: 1rem; }
.docs-nav ul { list-style: none; margin: 0; padding: 0; }
.docs-nav ul ul { margin-left: 0.6rem; padding-left: 0.6rem; border-left: 1px solid var(--line); }
.docs-nav > ul > li { margin-top: 0.9rem; }
.docs-nav > ul > li > a { font-weight: 700; color: var(--text); }
.docs-nav a {
  display: block;
  padding: 0.22rem 0.55rem;
  border-radius: 6px;
  color: var(--text-dim);
  text-decoration: none;
  overflow-wrap: anywhere;
}
.docs-nav a:hover { color: var(--text); background: var(--bg-raise); }
.docs-nav a.on-path { color: var(--text); }
.docs-nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.docs-nav-home { font-weight: 700; }

/* ── Text ─────────────────────────────────────────── */

.docs-main { min-width: 0; }

.docs-crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  font-size: 0.82rem;
  color: var(--text-dim);
  margin: 0.4rem 0 0.2rem;
}
.docs-crumbs a { color: var(--text-dim); text-decoration: none; }
.docs-crumbs a:hover { color: var(--accent); }

/* Running text keeps a readable measure; tables, code and folded blocks may
   use the whole column. */
.docs-article > * { max-width: 78ch; }
.docs-article > h2, .docs-article > .table-wrap, .docs-article > pre, .docs-article > .fold, .docs-article > .docs-children { max-width: none; }
.docs-article h1 {
  font-size: clamp(1.8rem, 1.3rem + 1.6vw, 2.5rem);
  margin: 0.4rem 0 1rem;
  overflow-wrap: anywhere;
}
.docs-article h2 {
  font-size: 1.5rem;
  margin: 2.6rem 0 0.7rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line);
}
.docs-article h3 { font-size: 1.15rem; margin: 2rem 0 0.5rem; line-height: 1.3; }
.docs-article h4 { font-size: 1rem; margin: 1.5rem 0 0.4rem; }
.docs-article h2 code, .docs-article h3 code, .docs-article h4 code { font-size: 0.9em; }
.docs-article p, .docs-article li { overflow-wrap: break-word; }
.docs-article ul, .docs-article ol { padding-left: 1.4rem; }
.docs-article li { margin: 0.25rem 0; }
.docs-article li > ul, .docs-article li > ol { margin-top: 0.25rem; }
.docs-article > p:first-of-type { font-size: 1.08rem; }

.anchor {
  opacity: 0;
  margin-left: 0.3rem;
  font-weight: 400;
  text-decoration: none;
  color: var(--text-dim);
  transition: opacity 0.15s ease;
}
h2:hover > .anchor, h3:hover > .anchor, h4:hover > .anchor, .anchor:focus-visible { opacity: 1; }
@media (hover: none) { .anchor { opacity: 0.45; } }

.since {
  display: inline-block;
  vertical-align: middle;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 0.12rem 0.55rem;
}

/* ── Code ─────────────────────────────────────────── */

.docs-article pre {
  position: relative;
  margin: 1rem 0;
  padding: 0.9rem 1rem;
  background: var(--bg-deep);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.86rem;
  line-height: 1.55;
}
.docs-article pre code { background: none; border: none; padding: 0; font-size: inherit; white-space: pre; }
/* Plain text (messages, card texts) wraps; code keeps its lines. */
.docs-article pre[data-lang="text"] code { white-space: pre-wrap; overflow-wrap: anywhere; }
.docs-article pre .copy {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  font: inherit;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-dim);
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.15rem 0.5rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.docs-article pre:hover .copy, .docs-article pre .copy:focus-visible { opacity: 1; }
@media (hover: none) { .docs-article pre .copy { opacity: 1; } }

/* ── Tables ───────────────────────────────────────── */

/* Cells wrap, so a table fits its column; a long name breaks after an
   underscore before it pushes the table wide. Where the text column is as narrow as a phone each row becomes a block of its own with the column
   headings as labels, so nothing has to scroll sideways. */

.docs-main { container-type: inline-size; }

.table-wrap { overflow-x: auto; margin: 1rem 0; border: 1px solid var(--line); border-radius: 8px; }
.docs-article table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
.docs-article th, .docs-article td {
  text-align: left;
  vertical-align: top;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--line);
  overflow-wrap: break-word;
}
.docs-article tr:last-child td { border-bottom: none; }
.docs-article th { background: var(--bg-raise); font-size: 0.8rem; letter-spacing: 0.03em; }
/* A name breaks at its joints (the generator marks them), and inside a part
   only when even that part is wider than its column. `anywhere` would let the
   table size the column as if code were one letter wide, and break it there. */
.docs-article td code { overflow-wrap: break-word; }

@container (max-width: 32rem) {
  .table-wrap { border: none; border-radius: 0; overflow-x: visible; }
  .docs-article table, .docs-article tbody, .docs-article tr, .docs-article td { display: block; width: auto; }
  .docs-article thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .docs-article tr {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.45rem 0.8rem;
    margin-bottom: 0.6rem;
    background: color-mix(in srgb, var(--bg-raise) 55%, transparent);
  }
  .docs-article td { border: none; padding: 0.2rem 0; }
  .docs-article td:empty { display: none; }
  .docs-article td:first-child { font-weight: 600; padding-bottom: 0.3rem; }
  .docs-article td:not(:first-child)[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-dim);
  }
}

/* A table of five or more columns turns into row blocks sooner. */
@container (max-width: 46rem) {
  .table-wide { border: none; border-radius: 0; overflow-x: visible; }
  .table-wide table, .table-wide tbody, .table-wide tr, .table-wide td { display: block; width: auto; }
  .table-wide thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .table-wide tr {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.45rem 0.8rem;
    margin-bottom: 0.6rem;
    background: color-mix(in srgb, var(--bg-raise) 55%, transparent);
  }
  .table-wide td { border: none; padding: 0.2rem 0; }
  .table-wide td:empty { display: none; }
  .table-wide td:first-child { font-weight: 600; padding-bottom: 0.3rem; }
  .table-wide td:not(:first-child)[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-dim);
  }
}

/* ── Callouts and folded blocks ───────────────────── */

.callout {
  margin: 1.2rem 0;
  padding: 0.7rem 1rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--text-dim);
  border-radius: 6px;
  background: var(--bg-raise);
}
.callout > :first-child { margin-top: 0; }
.callout > :last-child { margin-bottom: 0; }
.callout-title { font-weight: 700; }
.callout-tip { border-left-color: #3fa796; }
.callout-warning { border-left-color: var(--accent); }

.fold { margin: 1.2rem 0; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-raise); }
.fold > summary { cursor: pointer; padding: 0.6rem 1rem; font-weight: 600; }
.fold-body { padding: 0 1rem 0.6rem; border-top: 1px solid var(--line); }
.fold-body .table-wrap { background: var(--bg); }

/* ── Child pages, previous / next ─────────────────── */

.docs-children {
  list-style: none;
  padding: 0 !important;
  margin: 1.5rem 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 0.8rem;
}
.docs-children li { margin: 0; }
.docs-children a {
  display: block;
  height: 100%;
  padding: 0.8rem 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-raise);
  text-decoration: none;
  color: var(--text-dim);
  font-size: 0.9rem;
  transition: border-color 0.15s ease;
}
.docs-children a:hover { border-color: var(--accent); }
.docs-children strong { display: block; color: var(--accent); font-size: 1rem; margin-bottom: 0.2rem; }

.docs-pager {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--line);
}
.docs-pager a { text-decoration: none; font-weight: 600; }
.docs-pager a span { display: block; font-size: 0.75rem; font-weight: 400; color: var(--text-dim); }
.docs-pager .next { text-align: right; margin-left: auto; }

.docs-footer {
  border-top: 1px solid var(--line);
  padding: 1.5rem 0 2.5rem;
  font-size: 0.85rem;
  color: var(--text-dim);
}

/* ── Page list and "On this page": where they sit ───
   Phone: two buttons in a bar that stays under the top bar; each opens its
   list as a panel over the text. Tablet: the page list is a column, "On this
   page" stays a button above the text. Desktop: both are columns.
   Both are <details>, open in the HTML: without docs.js they are plain lists
   in the page, with it they open and close to fit the screen. */

.docs-bar > details > summary {
  list-style: none;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.86rem;
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-raise);
  user-select: none;
}
.docs-bar > details > summary::-webkit-details-marker { display: none; }
.docs-bar > details[open] > summary { margin-bottom: 0.6rem; }
.docs-toc-wrap > summary::after { content: " ▾"; opacity: 0.6; }

.docs-toc { font-size: 0.86rem; }
.docs-toc-title { display: none; }
.docs-toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.docs-toc a {
  display: block;
  padding: 0.22rem 0.7rem;
  margin-left: -1px;
  border-left: 2px solid transparent;
  color: var(--text-dim);
  text-decoration: none;
  overflow-wrap: anywhere;
}
.docs-toc .toc-h3 a { padding-left: 1.5rem; }
.docs-toc .toc-h4 a { padding-left: 2.3rem; font-size: 0.95em; }
.docs-toc a:hover { color: var(--text); }
.docs-toc a.reading { color: var(--accent); border-left-color: var(--accent); }
.docs-toc code { font-size: 0.9em; background: none; border: none; padding: 0; }

/* The panel a button opens (only with docs.js: it also closes it again). */
.js .docs-bar,
.js .docs-toc-wrap {
  position: sticky;
  top: var(--topbar-h, 2.95rem);
  z-index: 9;
  background: var(--bg);
}
.js .docs-bar {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem 0;
}
/* The bar's background and rule reach the edges of the screen, the bar does not. */
.js .docs-bar::before {
  content: "";
  position: absolute;
  inset: 0 calc((100% - 100vw) / 2);
  z-index: -1;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.js .docs-bar .docs-toc-wrap { position: static; margin-left: auto; }
.js .docs-bar > details[open] > summary { margin-bottom: 0; color: var(--accent); border-color: var(--accent); }
.js .docs-bar > details[open] > nav {
  position: absolute;
  top: calc(100% + 0.3rem);
  left: 0;
  right: 0;
  max-height: calc(100vh - var(--topbar-h, 2.95rem) - 5rem);
  max-height: calc(100dvh - var(--topbar-h, 2.95rem) - 5rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0.7rem;
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
@media (max-width: 79.99rem) { html { scroll-padding-top: 7.5rem; } }

@media (min-width: 60rem) {
  .docs-layout { grid-template-columns: 15rem minmax(0, 1fr); }
  .docs-bar, .js .docs-bar { display: contents; }
  .js .docs-bar::before { content: none; }
  .docs-nav-wrap > summary { display: none !important; }
  .docs-nav-wrap {
    grid-column: 1;
    grid-row: 1 / span 2;
    position: sticky;
    top: 4rem;
    align-self: start;
    max-height: calc(100vh - 5rem);
    overflow-y: auto;
  }
  .js .docs-bar > .docs-nav-wrap[open] > nav {
    position: static;
    max-height: none;
    overflow: visible;
    padding: 0 0 1rem;
    background: none;
    border: none;
    box-shadow: none;
  }
  .docs-toc-wrap, .js .docs-bar .docs-toc-wrap {
    grid-column: 2;
    grid-row: 1;
    position: sticky;
    top: var(--topbar-h, 2.95rem);
    z-index: 9;
    margin: 0;
    padding: 0.5rem 0;
    background: var(--bg);
  }
  .docs-toc-wrap > summary { display: inline-block; }
  .docs-main { grid-column: 2; grid-row: 2; }
}

@media (min-width: 80rem) {
  .docs-layout { grid-template-columns: 15rem minmax(0, 1fr) 14rem; }
  .docs-main { grid-row: 1 / span 2; }
  .docs-toc-wrap > summary { display: none !important; }
  .docs-toc-wrap, .js .docs-bar .docs-toc-wrap {
    grid-column: 3;
    grid-row: 1 / span 2;
    top: 4rem;
    z-index: auto;
    align-self: start;
    max-height: calc(100vh - 5rem);
    overflow-y: auto;
    padding: 0;
    background: none;
  }
  .js .docs-bar > .docs-toc-wrap[open] > nav {
    position: static;
    max-height: none;
    overflow: visible;
    padding: 0;
    background: none;
    border: none;
    box-shadow: none;
  }
  .docs-toc-title {
    display: block;
    margin: 0.4rem 0 0.5rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-dim);
  }
}

@media (prefers-reduced-motion: reduce) {
  .anchor, .docs-article pre .copy, .docs-children a { transition: none; }
}

/* Phones: with the language menu, the top bar has no room for the release pill. */
@media (max-width: 24.99rem) {
  .docs-release { display: none; }
}

/* ── Search: a box above the page list; its results replace the list ── */

.docs-search { display: none; margin: 0 0 0.9rem; }
.js .docs-search { display: block; }
.docs-search input {
  width: 100%;
  font: inherit;
  font-size: 0.9rem;
  padding: 0.45rem 0.7rem;
  color: var(--text);
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.docs-search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.docs-search-results { list-style: none; margin: 0.6rem 0 0; padding: 0; }
.docs-nav .docs-search-results a { padding: 0.45rem 0.55rem; }
.docs-search-results a:focus { background: var(--bg-raise); color: var(--text); outline: none; }
.docs-search-results .crumbs { display: block; font-size: 0.72rem; }
.docs-search-results strong { display: block; color: var(--text); font-weight: 600; font-size: 0.88rem; line-height: 1.35; }
.docs-search-results .snippet { display: block; margin-top: 0.15rem; font-size: 0.8rem; line-height: 1.45; }
.docs-search-results mark { color: var(--accent); background: var(--accent-soft); border-radius: 2px; }
.docs-search-results .none { padding: 0.45rem 0.55rem; font-size: 0.85rem; color: var(--text-dim); }
.docs-nav.searching > :not(.docs-search) { display: none; }
