/* API ドキュメント（/docs/api/）。notes.css の上に重ねる。
   ページ本体は docs/api/tools/build-api-docs.mjs が docs/api/quickstart.md から生成する（直接編集しない）。
   既定はダーク。ライトはアプリの確定配色（塗りはフルシアン・文字のアクセントは #0b7f9a）に合わせる。 */
html[data-theme="light"] {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --border: #d9e0ea;
  --text: #0f172a;
  --body: #334155;
  --muted: #64748b;
  --accent: #0b7f9a;
  color-scheme: light;
}
html[data-theme="dark"] {
  color-scheme: dark;
}
/* ロゴは白文字なので、ライトでもヘッダーだけは暗いまま */
html[data-theme="light"] header {
  background: #0f1220;
  border-bottom-color: #1c2240;
}
html[data-theme="light"] .header-cta {
  background: #1ec8e8;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.theme-toggle,
.copy-btn {
  font: 600 12px/1 "Noto Sans JP", sans-serif;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
  cursor: pointer;
}
header .theme-toggle {
  color: #c9cfdb;
  border-color: #2a3256;
}
.theme-toggle:hover,
.copy-btn:hover {
  color: var(--text);
}
header .theme-toggle:hover {
  color: #ffffff;
}
.theme-toggle:focus-visible,
.copy-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---- 目次と本文の 2 段組み（狭い画面では目次を本文の上に畳んで置く） ---- */
.docs-layout {
  max-width: 1120px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 24px;
  padding: 0 24px;
}
.docs-layout main {
  max-width: 800px;
  margin: 0;
  padding: 40px 0 96px;
  min-width: 0;
}
.docs-toc {
  position: sticky;
  top: 80px;
  align-self: start;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  padding: 40px 0 24px;
  font-size: 13px;
  line-height: 1.6;
}
.docs-toc summary {
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  margin-bottom: 8px;
}
.docs-toc ul {
  list-style: none;
  display: grid;
  gap: 4px;
}
.docs-toc ul ul {
  margin: 4px 0 4px 12px;
}
.docs-toc a {
  color: var(--muted);
  text-decoration: none;
}
.docs-toc a:hover {
  color: var(--text);
}
.docs-toc code {
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 0.92em;
}
@media (max-width: 900px) {
  .docs-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    padding: 0 16px;
  }
  .docs-toc {
    position: static;
    max-height: none;
    padding: 20px 0 0;
  }
  .docs-toc details {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    background: var(--surface);
  }
  .docs-toc summary {
    margin-bottom: 0;
  }
  .docs-toc details[open] summary {
    margin-bottom: 8px;
  }
  .docs-layout main {
    padding-top: 24px;
  }
}
@media (max-width: 600px) {
  header {
    padding: 10px 16px;
  }
  .header-logo {
    height: 32px;
  }
  .note.docs h1 {
    font-size: 26px;
  }
}

/* ---- 本文 ---- */
.note.docs h2,
.note.docs h3 {
  scroll-margin-top: 80px;
}
.docs-intro {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 20px 0 12px;
}
.docs-intro p {
  margin: 0;
}
.docs-intro p + p {
  margin-top: 0.6em;
}
.docs-links {
  list-style: none;
  padding-left: 0;
  margin: 0 0 32px;
  font-size: 14px;
  color: var(--muted);
}
.note.docs hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 32px 0;
}

/* notes.css の箇条書きは grid なので、項目の既定の min-width:auto だと中の <pre>（折り返さない）の
   幅まで項目が広がり、スマホでページごと横にはみ出す（§12 の JSON）。項目を親の幅に収める */
.note.docs li {
  min-width: 0;
}
/* 文中の長い code（`GET /debates?status=&created_after=…` など）は区切りが無いので、どこでも折り返す */
.note.docs :not(pre) > code,
.docs-intro code {
  overflow-wrap: anywhere;
}

/* コード（curl・JSON）は折り返さず横にスクロールする（コピーした文面を崩さない） */
.code-block {
  position: relative;
  margin: 1em 0 1.4em;
  max-width: 100%;
}
.code-block pre {
  margin: 0;
  padding-top: 40px;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
  line-height: 1.6;
}
.code-block pre code {
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 13px;
  color: var(--body);
}
.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--surface-2);
}
.copy-btn[data-copied] {
  color: var(--accent);
  border-color: var(--accent);
}
