/* Developer documentation. Builds on homepage.css tokens and supports both colour modes. */

:root {
  --docs-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --docs-code-bg: #161619;
  --docs-code-head: #1f1f23;
  --docs-code-line: #333338;
  --docs-code-ink: #f5f5f7;
  --docs-code-muted: #a1a1a6;
  --docs-sidebar: 236px;
  --docs-toc: 196px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.wrap.docs,
.wrap.docs-header {
  width: min(1320px, calc(100% - 80px));
}

/* Header band */

[data-layout] .hero.docs-header {
  display: block;
  padding-block: clamp(36px, 5vw, 60px) clamp(28px, 3.5vw, 40px);
  text-align: left;
}

.docs-header .hero-copy {
  max-width: 780px;
}

[data-layout] .docs-header h1 {
  font-size: clamp(36px, 5vw, 52px);
  letter-spacing: -.045em;
  line-height: 1.05;
}

[data-layout] .docs-header .lede {
  max-width: 660px;
  margin: 14px 0 0;
  font-size: 18px;
}

.docs-eyebrow,
.docs-breadcrumb {
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.docs-breadcrumb {
  display: flex;
  gap: 8px;
  align-items: center;
}

.docs-breadcrumb a {
  font-size: 13px;
  color: var(--blue);
}

.docs-breadcrumb a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.docs-header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 24px;
  margin-top: 26px;
}

/* Three-column frame: guides, content, contents */

.docs {
  display: grid;
  grid-template-columns: var(--docs-sidebar) minmax(0, 1fr);
  gap: clamp(32px, 4vw, 56px);
  align-items: start;
  padding-top: 8px;
  padding-bottom: 96px;
  border-top: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}

/* The search stays fixed at the top of the sidebar so its results can overlap the content;
   only the guide list scrolls. */
.docs-sidebar {
  position: sticky;
  z-index: 4;
  top: 80px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 96px);
  padding: 24px 0;
}

nav.docs-nav {
  min-height: 0;
  overflow-y: auto;
  padding-right: 6px;
  scrollbar-width: thin;
}

.docs-main {
  min-width: 0;
  padding-top: 32px;
}

/* Search */

.docs-search {
  position: relative;
  margin-bottom: 22px;
}

.docs-search svg {
  position: absolute;
  top: 50%;
  left: 12px;
  width: 16px;
  height: 16px;
  transform: translateY(-50%);
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
  stroke-linecap: round;
  pointer-events: none;
}

.docs-search input {
  width: 100%;
  min-height: 40px;
  padding: 8px 36px 8px 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
  font-size: 14px;
}

.docs-search input::-webkit-search-cancel-button {
  display: none;
}

.docs-search input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 22%, transparent);
  background: var(--bg);
}

.docs-search kbd {
  position: absolute;
  top: 50%;
  right: 10px;
  min-width: 20px;
  padding: 1px 6px;
  transform: translateY(-50%);
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--muted);
  font: 12px/1.4 var(--docs-mono);
  text-align: center;
  pointer-events: none;
}

.docs-search input:focus ~ kbd,
.docs-search input:not(:placeholder-shown) ~ kbd {
  display: none;
}

.docs-search-results {
  position: absolute;
  z-index: 5;
  top: calc(100% + 6px);
  left: 0;
  width: max(100%, 320px);
  max-height: min(420px, 60vh);
  margin: 0;
  padding: 6px;
  overflow-y: auto;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.docs-search-results a {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.35;
}

.docs-search-results a span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.docs-search-results [aria-selected="true"] a,
.docs-search-results a:hover {
  background: var(--panel);
}

.docs-search-results mark {
  background: none;
  color: var(--blue);
  font-weight: 600;
}

.docs-search-empty {
  padding: 10px;
  color: var(--muted);
  font-size: 14px;
}

/* Guide navigation */

.docs-nav-toggle {
  display: none;
}

nav.docs-nav {
  display: block;
}

.docs-nav > p:first-of-type {
  margin-top: 18px;
}

.docs-nav p {
  margin: 22px 0 6px;
  padding-left: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.docs-nav ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.docs-nav a {
  display: block;
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.35;
  transition: color .15s ease, background-color .15s ease;
}

.docs-nav a:hover {
  color: var(--ink);
  background: color-mix(in srgb, var(--panel) 70%, transparent);
}

.docs-nav a[aria-current="page"] {
  background: var(--panel);
  color: var(--ink);
  font-weight: 600;
  box-shadow: inset 2px 0 0 var(--blue);
}

.docs-nav-external span {
  color: var(--muted);
  font-size: 12px;
}

.docs-block-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 20px;
  margin-bottom: 12px;
}

.docs-block-head h2 {
  margin-bottom: 0;
}

.docs-block-head .text-link {
  font-size: 15px;
}

.docs-nav-home {
  font-weight: 500;
}

/* Guide page with an "On this page" column */

.docs-page.has-toc {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--docs-toc);
  gap: clamp(32px, 4vw, 56px);
  align-items: start;
}

nav.docs-toc {
  display: block;
  position: sticky;
  top: 104px;
  max-height: calc(100vh - 128px);
  overflow-y: auto;
}

.docs-toc > p {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.docs-toc ol {
  margin: 0;
  padding: 0;
  list-style: none;
  border-left: 1px solid var(--line);
}

.docs-toc a {
  display: block;
  margin-left: -1px;
  padding: 4px 0 4px 14px;
  border-left: 1px solid transparent;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.4;
  transition: color .15s ease, border-color .15s ease;
}

.docs-toc .sub a {
  padding-left: 26px;
  font-size: 13px;
}

.docs-toc a:hover {
  color: var(--ink);
}

.docs-toc a[aria-current="location"] {
  border-left-color: var(--blue);
  color: var(--ink);
  font-weight: 600;
}

/* Article typography */

.docs-body {
  max-width: 760px;
  font-size: 16px;
  line-height: 1.7;
}

.docs-body > :first-child {
  margin-top: 0;
}

.docs-body h2 {
  margin: 52px 0 14px;
  font-size: clamp(23px, 2.4vw, 27px);
  letter-spacing: -.03em;
  line-height: 1.2;
}

.docs-body h3 {
  margin: 32px 0 10px;
  font-size: 18px;
  letter-spacing: -.015em;
  line-height: 1.3;
}

.docs-body h2,
.docs-body h3 {
  position: relative;
  scroll-margin-top: 96px;
}

.docs-anchor {
  margin-left: 8px;
  color: var(--muted);
  font-weight: 400;
  opacity: 0;
  transition: opacity .15s ease;
}

.docs-body h2:hover .docs-anchor,
.docs-body h3:hover .docs-anchor,
.docs-anchor:focus-visible {
  opacity: 1;
}

.docs-body p,
.docs-body ul,
.docs-body ol {
  margin: 0 0 16px;
}

.docs-body ul,
.docs-body ol {
  padding-left: 1.3em;
}

.docs-body li + li {
  margin-top: 6px;
}

.docs-body li > p {
  margin-bottom: 6px;
}

.docs-body a,
.docs-overview a,
.docs-help a {
  color: var(--blue);
}

.docs-body a:hover,
.docs-overview a:hover,
.docs-help a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.docs-body strong {
  font-weight: 600;
}

.docs-body :not(pre) > code,
.docs-overview :not(pre) > code,
.docs-endpoints code {
  padding: .12em .4em;
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  border-radius: 6px;
  background: var(--panel);
  font-family: var(--docs-mono);
  font-size: .86em;
  overflow-wrap: anywhere;
}

/* Inline HTTP endpoints, e.g. `POST /v1/moderations` */

.docs-route {
  white-space: nowrap;
}

.http-method {
  display: inline-block;
  margin-right: .35em;
  padding: 0 .4em;
  border-radius: 4px;
  font-size: .82em;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--blue);
  background: color-mix(in srgb, var(--blue) 12%, transparent);
}

.http-method.post {
  color: var(--green);
  background: color-mix(in srgb, var(--green) 12%, transparent);
}

/* Tables */

.docs-table {
  margin: 0 0 20px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.docs-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
  line-height: 1.55;
}

.docs-table th,
.docs-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.docs-table tbody tr:last-child td {
  border-bottom: 0;
}

.docs-table th {
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.docs-table td:first-child code {
  white-space: nowrap;
}

/* Callouts: ::: note / ::: warning */

.docs-body .note,
.docs-body .warning {
  margin: 0 0 20px;
  padding: 14px 18px;
  border: 1px solid color-mix(in srgb, var(--blue) 30%, var(--line));
  border-left: 3px solid var(--blue);
  border-radius: 12px;
  background: color-mix(in srgb, var(--blue) 6%, var(--bg));
}

.docs-body .warning {
  border-color: color-mix(in srgb, var(--review) 35%, var(--line));
  border-left-color: var(--review);
  background: color-mix(in srgb, var(--review) 7%, var(--bg));
}

.docs-body .note::before,
.docs-body .warning::before {
  display: block;
  margin-bottom: 4px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  content: "Note";
}

.docs-body .warning::before {
  color: var(--review);
  content: "Important";
}

.docs-body .note > :last-child,
.docs-body .warning > :last-child {
  margin-bottom: 0;
}

/* Code blocks. Rendered without JavaScript as plain dark panels; docs.js adds the toolbar and tabs. */

.docs-body pre,
.docs-overview pre {
  margin: 0 0 20px;
  padding: 16px 20px;
  overflow-x: auto;
  border: 1px solid var(--docs-code-line);
  border-radius: 14px;
  background: var(--docs-code-bg);
  color: var(--docs-code-ink);
  font: 13px/1.65 var(--docs-mono);
  tab-size: 2;
}

.docs-body pre code,
.docs-overview pre code {
  font: inherit;
}

.docs-code {
  margin: 0 0 22px;
  overflow: hidden;
  border: 1px solid var(--docs-code-line);
  border-radius: 14px;
  background: var(--docs-code-bg);
  color: var(--docs-code-ink);
}

.docs-code pre,
.docs-overview .docs-code pre {
  margin: 0;
  border: 0;
  border-radius: 0;
}

.docs-code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  padding: 0 8px 0 14px;
  border-bottom: 1px solid var(--docs-code-line);
  background: var(--docs-code-head);
}

.docs-code-label {
  color: var(--docs-code-muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .02em;
}

.docs-code-tabs {
  display: flex;
  gap: 2px;
  margin-left: -6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.docs-code-tabs button {
  min-height: 42px;
  padding: 0 10px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--docs-code-muted);
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
}

.docs-code-tabs button:hover {
  color: var(--docs-code-ink);
}

.docs-code-tabs button[aria-selected="true"] {
  border-bottom-color: #70b4ff;
  color: var(--docs-code-ink);
}

.docs-copy {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  color: var(--docs-code-muted);
  font-size: 12px;
}

.docs-copy:hover {
  border-color: var(--docs-code-line);
  color: var(--docs-code-ink);
}

.docs-copy svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.docs-copy.copied {
  color: #80cba4;
}

.docs-code button:focus-visible,
.docs-code pre:focus-visible {
  outline: 2px solid #70b4ff;
  outline-offset: -2px;
}

/* Syntax colours, shared by every language */
.tok-comment { color: #8e8e93; font-style: italic; }
.tok-string { color: #80cba4; }
.tok-number { color: #edc078; }
.tok-keyword { color: #c9a7ff; }
.tok-key { color: #70b4ff; }
.tok-literal { color: #ff9fb2; }
.tok-variable { color: #ffd479; }

/* Previous / next and help */

nav.docs-pager {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 56px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}

.docs-pager-link {
  display: block;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  transition: border-color .15s ease, transform .15s ease;
}

.docs-body .docs-pager-link {
  color: var(--ink);
}

.docs-body .docs-pager-link:hover {
  border-color: var(--blue);
  text-decoration: none;
  transform: translateY(-1px);
}

.docs-pager-link span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.docs-pager-link strong {
  color: var(--blue);
  font-size: 16px;
}

.docs-pager-link.next {
  grid-column: 2;
  text-align: right;
}

.docs-help {
  margin-top: 28px;
  color: var(--muted);
  font-size: 14px;
}

/* Overview page */

.docs-overview {
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
  gap: clamp(28px, 4vw, 48px);
  align-items: start;
  margin-bottom: 64px;
}

.docs-overview h2,
.docs-block h2 {
  margin-bottom: 12px;
  font-size: clamp(23px, 2.4vw, 27px);
  letter-spacing: -.03em;
  line-height: 1.2;
}

.docs-overview-copy > p {
  color: var(--muted);
  font-size: 16px;
  line-height: 1.65;
}

.docs-steps {
  display: grid;
  gap: 16px;
  margin: 24px 0 0;
  padding: 0;
  list-style: none;
}

.docs-steps li {
  display: flex;
  gap: 14px;
}

.docs-steps li > span {
  display: grid;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--blue);
  font-size: 13px;
  font-weight: 600;
}

.docs-steps strong {
  font-size: 15px;
  font-weight: 600;
}

.docs-steps p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.5;
}

.docs-block {
  margin-bottom: 56px;
}

.docs-endpoints {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.docs-endpoints a {
  display: grid;
  grid-template-columns: minmax(0, 300px) minmax(0, 1fr);
  gap: 20px;
  align-items: center;
  padding: 13px 18px;
  font-size: 14.5px;
  transition: background-color .15s ease;
}

.docs-endpoints a + a {
  border-top: 1px solid var(--line);
}

.docs-endpoints a:hover {
  background: var(--panel);
}

.docs-endpoints code {
  justify-self: start;
  border: 0;
  background: none;
  padding: 0;
  font-size: 13.5px;
}

.docs-endpoints span {
  color: var(--muted);
}

.docs-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.docs-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.docs-card:hover {
  border-color: color-mix(in srgb, var(--blue) 55%, var(--line));
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.docs-card strong {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -.01em;
}

.docs-card strong::after {
  margin-left: 6px;
  color: var(--blue);
  content: "→";
  transition: margin-left .15s ease;
}

.docs-card:hover strong::after {
  margin-left: 10px;
}

.docs-card span {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

/* Responsive */

@media (max-width: 1200px) {
  .docs-page.has-toc {
    display: block;
  }

  nav.docs-toc {
    display: none;
  }

  .docs-overview {
    grid-template-columns: minmax(0, 1fr);
  }

  .docs-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .wrap.docs,
  .wrap.docs-header {
    width: calc(100% - 48px);
  }

  .docs {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    padding-top: 0;
  }

  .docs-sidebar {
    position: static;
    max-height: none;
    padding: 20px 0 0;
  }

  nav.docs-nav {
    overflow: visible;
  }

  .docs-search {
    margin-bottom: 10px;
  }

  .docs-search kbd {
    display: none;
  }

  .docs-sidebar.collapsible .docs-nav-toggle {
    display: flex;
    width: 100%;
    min-height: 44px;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: none;
    font-size: 15px;
    font-weight: 500;
  }

  .docs-nav-toggle svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform .2s ease;
  }

  .docs-nav-toggle[aria-expanded="true"] svg {
    transform: rotate(180deg);
  }

  .docs-sidebar.collapsible .docs-nav:not(.open) {
    display: none;
  }

  .docs-nav {
    padding: 6px 4px 8px;
  }

  .docs-main {
    padding-top: 28px;
  }
}

@media (max-width: 600px) {
  .wrap.docs,
  .wrap.docs-header {
    width: calc(100% - 32px);
  }

  .docs-cards,
  nav.docs-pager {
    grid-template-columns: minmax(0, 1fr);
  }

  .docs-pager-link.next {
    grid-column: 1;
  }

  .docs-endpoints a {
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
  }

  .docs-body pre,
  .docs-overview pre {
    padding: 14px 16px;
    font-size: 12.5px;
  }

  .docs-search-results {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .docs-card,
  .docs-pager-link,
  .docs-nav-toggle svg {
    transition: none;
  }
}
