/*
 * botgumi docs: the look botgumi.com's docs and every app's generated docs site share (botgumi ADR-0005).
 * Tokens (light and dark, system and forced), the docs layout (nav, article, contents column, pager) and prose.
 * botgumi.com imports it from site/src/styles.css; @botgumi/docs writes it into each site as _docs/docs.css.
 * Edit it here; then run `pnpm --filter @botgumi/docs styles` so the generator embeds the new text.
 */

:root {
  --bg: #ffffff;
  --surface: #fafafa;
  --surface-2: #f4f4f5;
  --border: #e6e6e8;
  --border-strong: #d4d4d8;
  --text: #0a0a0b;
  --text-2: #52525b;
  --text-3: #8b8b93;
  --accent: #e8502a;
  --accent-text: #c23d1b;
  --accent-soft: #fdf1ec;
  --accent-line: #f6cbbd;
  --success: #15803d;
  --warning: #a16207;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;

  --sans: "Geist", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", system-ui, -apple-system, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --wrap: 1120px;
  --gutter: 24px;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 8px 24px -12px rgb(0 0 0 / 0.08);
  color-scheme: light dark;
}

/* Light is the base. A forced choice (data-theme on <html>, set by the head script) beats the system. */
:root[data-theme="light"] {
  color-scheme: light;
}

/* Dark, twice: following a dark system unless light is forced, and forced. The two blocks must stay
   identical (CSS cannot OR a media query with a selector); test/theme.test.ts checks that they do. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0a0b;
    --surface: #111113;
    --surface-2: #18181b;
    --border: #232327;
    --border-strong: #34343a;
    --text: #ededef;
    --text-2: #a1a1aa;
    --text-3: #71717a;
    --accent-text: #f2794f;
    --accent-soft: #24130b;
    --accent-line: #5a2a14;
    --success: #4ade80;
    --warning: #facc15;
    --danger: #f87171;
    --danger-soft: #2a1213;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 24px -12px rgb(0 0 0 / 0.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a0a0b;
  --surface: #111113;
  --surface-2: #18181b;
  --border: #232327;
  --border-strong: #34343a;
  --text: #ededef;
  --text-2: #a1a1aa;
  --text-3: #71717a;
  --accent-text: #f2794f;
  --accent-soft: #24130b;
  --accent-line: #5a2a14;
  --success: #4ade80;
  --warning: #facc15;
  --danger: #f87171;
  --danger-soft: #2a1213;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 24px -12px rgb(0 0 0 / 0.5);
  color-scheme: dark;
}


/* ───────── docs ───────── */

.docs {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 200px;
  gap: 56px;
  max-width: calc(var(--wrap) + 2 * var(--gutter) + 80px);
  margin: 0 auto;
  padding: 40px var(--gutter) 96px;
}

.docs-nav nav,
.toc {
  position: sticky;
  top: 92px;
  max-height: calc(100vh - 112px);
  overflow-y: auto;
}
.docs-menu {
  display: none;
}
.docs-group {
  margin-bottom: 24px;
}
.docs-group p {
  margin: 0 0 6px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-3);
}
.docs-group ul {
  margin: 0;
  padding: 0;
  list-style: none;
}
.docs-group a {
  display: block;
  margin-left: -10px;
  padding: 5px 10px;
  border-radius: 7px;
  font-size: 0.9rem;
  color: var(--text-2);
  text-decoration: none;
}
.docs-group a:hover {
  color: var(--text);
  background: var(--surface);
}
.docs-group a[data-status="active"],
.docs-group a[aria-current="page"] {
  color: var(--text);
  font-weight: 500;
  background: var(--surface-2);
}

.doc {
  min-width: 0;
  max-width: 760px;
}
.doc > h1 {
  margin: 0 0 12px;
  font-size: clamp(1.9rem, 3.6vw, 2.5rem);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.035em;
}
.doc-lead {
  margin: 0 0 8px;
  font-size: 1.1rem;
  color: var(--text-2);
}
.doc-note {
  display: inline-block;
  margin: 12px 0 0;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 0.85rem;
  color: var(--text-2);
}

.prose {
  margin-top: 32px;
  color: color-mix(in srgb, var(--text) 88%, var(--text-2));
}
.prose h2,
.prose h3,
.prose h4 {
  position: relative;
  color: var(--text);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
  scroll-margin-top: 84px;
}
.prose h2 {
  margin: 2.4em 0 0.7em;
  padding-top: 1.4em;
  border-top: 1px solid var(--border);
  font-size: 1.45rem;
}
.prose h3 {
  margin: 1.8em 0 0.5em;
  font-size: 1.12rem;
}
.prose > h2:first-child,
.prose > h3:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}
.prose .anchor {
  position: absolute;
  left: -1em;
  padding-right: 0.3em;
  color: var(--text-3);
  font-weight: 400;
  text-decoration: none;
  opacity: 0;
}
.prose h2 .anchor {
  top: 1.4em;
}
.prose > h2:first-child .anchor {
  top: 0;
}
.prose h2:hover .anchor,
.prose h3:hover .anchor {
  opacity: 1;
}
.prose p,
.prose ul,
.prose ol {
  margin: 0 0 1.15em;
}
.prose li + li {
  margin-top: 0.35em;
}
.prose a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.prose a:hover {
  color: var(--accent-text);
}
.prose strong {
  color: var(--text);
  font-weight: 600;
}
.prose code {
  padding: 0.15em 0.4em;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  font: 0.84em var(--mono);
}
.prose pre {
  margin: 0 0 1.4em;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.65;
}
.prose pre code {
  padding: 0;
  border: 0;
  background: none;
  font-size: inherit;
}
.prose blockquote {
  margin: 0 0 1.3em;
  padding: 12px 16px;
  border: 1px solid var(--accent-line);
  border-radius: 10px;
  background: var(--accent-soft);
}
.prose blockquote p:last-child {
  margin-bottom: 0;
}
.prose table {
  display: block;
  width: 100%;
  margin: 0 0 1.5em;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: 0.9rem;
  /* A soft shadow at an edge while there is more table to scroll to (it stays put as the table scrolls). */
  background:
    linear-gradient(to right, var(--bg) 30%, transparent) left / 32px 100% no-repeat local,
    linear-gradient(to left, var(--bg) 30%, transparent) right / 32px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, var(--border-strong), transparent) left / 10px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, var(--border-strong), transparent) right / 10px 100% no-repeat scroll;
}
.prose th,
.prose td {
  padding: 9px 12px 9px 0;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
.prose th {
  color: var(--text);
  font-weight: 600;
  border-bottom-color: var(--border-strong);
}
.prose hr {
  margin: 2em 0;
  border: 0;
  border-top: 1px solid var(--border);
}
.prose img {
  max-width: 100%;
}
.dead-link {
  text-decoration: underline dotted var(--text-3);
  text-underline-offset: 3px;
}
.callout {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 1.4em;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}
.callout p {
  margin: 0;
}
html:not([lang="zh-Hans"]) .callout [lang="zh-Hans"],
html[lang="zh-Hans"] .callout [lang="en"] {
  display: none;
}
.prose .callout a {
  font-weight: 500;
}

.doc-pager {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 56px;
}
.pager {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-weight: 500;
  text-decoration: none;
  transition: border-color 0.15s ease;
}
.pager:hover {
  border-color: var(--border-strong);
}
.pager span {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--text-3);
}
.pager--next {
  margin-left: auto;
  text-align: right;
}

.toc p {
  margin: 0 0 8px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-3);
}
.toc ul {
  margin: 0 0 24px;
  padding: 0;
  list-style: none;
}
.toc li a {
  display: block;
  padding: 4px 0;
  font-size: 0.84rem;
  line-height: 1.4;
  color: var(--text-2);
  text-decoration: none;
}
.toc li a:hover {
  color: var(--text);
}
.toc .toc-3 a {
  padding-left: 12px;
  font-size: 0.8rem;
}
.toc .toc-source {
  font-weight: 400;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.toc-source code {
  font: 0.76rem var(--mono);
}

/* ───────── docs on narrow screens ───────── */

@media (max-width: 1100px) {
  .docs {
    grid-template-columns: 200px minmax(0, 1fr);
    gap: 40px;
  }
  .toc {
    display: none;
  }
}

@media (max-width: 800px) {
  .docs {
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
    padding-top: 16px;
  }
  .docs-menu {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    height: 42px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
    font-size: 0.9rem;
    font-weight: 500;
  }
  .docs-nav nav {
    position: static;
    max-height: none;
    margin-top: 8px;
    padding: 16px 16px 0;
    border: 1px solid var(--border);
    border-radius: 10px;
  }
  .docs-nav[data-open="false"] nav {
    display: none;
  }
}

/*
 * The generated docs site's own rules: what botgumi.com's page chrome provides there and an app's docs site needs
 * here. The look itself (tokens, layout, prose) is docs.css, shared with botgumi.com. @botgumi/docs writes both
 * into each site as _docs/docs.css. Edit here; then run `pnpm --filter @botgumi/docs styles`.
 */

/* ───────── page ───────── */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font: 16px/1.6 var(--sans);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

[id] {
  scroll-margin-top: 76px;
}

a {
  color: inherit;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* The site's labels are written in both locales; show the one for the page's UI locale (English by default). */
[data-l="zh-Hans"] {
  display: none;
}
:root[data-ui="zh-Hans"] [data-l="zh-Hans"] {
  display: inline;
}
:root[data-ui="zh-Hans"] [data-l="en"] {
  display: none;
}

/* ───────── header ───────── */

.site-header {
  position: sticky;
  top: 0;
  z-index: 5;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
}
.site-header-inner {
  display: flex;
  align-items: center;
  gap: 20px;
  max-width: calc(var(--wrap) + 2 * var(--gutter) + 80px);
  height: 56px;
  margin: 0 auto;
  padding: 0 var(--gutter);
}
.brand {
  margin-right: auto;
  font-weight: 600;
  text-decoration: none;
}
.nav-link {
  font-size: 0.9rem;
  color: var(--text-2);
  text-decoration: none;
}
.nav-link:hover {
  color: var(--text);
}
.theme {
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.8rem;
  color: var(--text-2);
}
.theme:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

/* ───────── docs extras ───────── */

.eyebrow {
  margin: 0 0 12px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--accent-text);
}
.eyebrow a {
  text-decoration: none;
}
.eyebrow a:hover {
  text-decoration: underline;
}

/* A long nav section folds; it opens on its own pages. */
.docs-group details {
  margin: 0 0 4px;
}
.docs-group summary {
  margin-left: -10px;
  padding: 5px 10px;
  border-radius: 7px;
  font-size: 0.9rem;
  color: var(--text-2);
  cursor: pointer;
  list-style: none;
}
.docs-group summary::-webkit-details-marker {
  display: none;
}
.docs-group summary::before {
  content: "▸";
  display: inline-block;
  width: 14px;
  color: var(--text-3);
  transition: transform 0.15s ease;
}
.docs-group details[open] summary::before {
  transform: rotate(90deg);
}
.docs-group summary span {
  color: var(--text-3);
}
.docs-group details ul {
  margin-left: 14px;
}
.docs-group .docs-sub {
  margin: 12px 0 4px;
}

/* Prose stays at reading width; boards, tables and code may use the whole column. */
.docs .doc {
  max-width: none;
}
.doc > :not(.prose),
.prose > * {
  max-width: 760px;
}
.prose > table,
.prose > pre,
.prose > p:has(> iframe.embed) {
  max-width: none;
}
.prose > p:has(> iframe.embed) {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-start;
}

/* The home page has no contents column; its article takes the rest of the row. */
.doc--wide {
  grid-column: 2 / -1;
}

/* What a page or module shows: the gallery, the API reference, a live app. It spans the content columns. */
.doc-view {
  grid-column: 2 / -1;
  min-width: 0;
}
.doc-view iframe {
  display: block;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
}
.doc-view p {
  margin: 8px 0 0;
  font-size: 0.85rem;
  color: var(--text-3);
}

/* A view shown as a link: a card that opens the app or site in a new tab. */
.view-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 760px;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none;
  transition: border-color 0.15s ease;
}
.view-card:hover {
  border-color: var(--border-strong);
}
.view-card-title {
  font-size: 1.05rem;
  font-weight: 600;
}
.view-card-url {
  font: 0.85rem var(--mono);
  color: var(--text-2);
}
.view-card-note {
  font-size: 0.8rem;
  color: var(--text-3);
}

iframe.embed {
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
  vertical-align: top;
}
pre.mermaid {
  border: 0;
  background: none;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-3);
}
pre.mermaid svg {
  max-width: 100%;
  height: auto;
}

/* ───────── home ───────── */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  margin-top: 32px;
}
.card {
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.card h2 {
  margin: 0 0 6px;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.card h2 a {
  text-decoration: none;
}
.card h2 a:hover {
  color: var(--accent-text);
}
.card p {
  margin: 0 0 8px;
  font-size: 0.92rem;
  color: var(--text-2);
}
.card .card-meta {
  font-size: 0.8rem;
  color: var(--text-3);
}
.card ul {
  margin: 0;
  padding-left: 18px;
  font-size: 0.88rem;
}


/*
 * With a view in the first row: the nav runs down both rows so it stays sticky, and the article and the contents
 * column are pinned to their columns, or auto-placement would drop the article into the nav's column below it.
 */
.docs:has(> .doc-view) > .docs-nav {
  grid-row: 1 / span 2;
}
.docs:has(> .doc-view) > .doc {
  grid-column: 2;
}
.docs:has(> .doc-view) > .toc {
  grid-column: 3;
}

/* ───────── phones: one column ───────── */

@media (max-width: 800px) {
  .docs > .doc-view,
  .docs > .doc,
  .docs > .doc--wide,
  .docs:has(> .doc-view) > .docs-nav,
  .docs:has(> .doc-view) > .doc {
    grid-column: auto;
    grid-row: auto;
  }
}
