/* JSDoc viewer (/jsdocs), also inlined into the standalone pages it downloads */
.jd {
  /* Room for the site's sticky header when scrolling to things */
  --jd-offset: 80px;
}

/* /jsdocs?embed=1, shown in a frame by the library's View JSDocs dialogs:
   just the docs. Choosing files and the downloads are hidden (the frame is
   sandboxed, so the downloads couldn't fetch what they need anyway). */
.jd.is-embedded {
  /* No sticky site header above it */
  --jd-offset: 1rem;
  padding-top: 1.25rem;
}

.jd.is-embedded .section-head,
.jd.is-embedded .jd-drop:not(:has(.jd-status.is-error)),
.jd.is-embedded .jd-sources,
.jd.is-embedded .jd-url-form,
.jd.is-embedded .jd-paste,
.jd.is-embedded .jd-download {
  display: none !important;
}

.jd.is-standalone {
  --jd-offset: 1rem;
}

.jd h1 {
  overflow-wrap: anywhere;
}
.jd .section-head {
  margin-bottom: 1.5rem;
}

.jd .lead {
  max-width: 760px;
}

/* Choosing files, pasting code or loading a URL */
.jd-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  padding: 2rem 1.5rem;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}

.jd-drop.is-dragging {
  border-color: var(--accent-text);
  background: rgb(247 223 30 / 0.06);
}

.jd-drop.has-docs {
  align-items: stretch;
  padding: 0.75rem 1rem;
  border-width: 1px;
  text-align: left;
}

.jd-sources {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem 0.75rem;
}

.has-docs .jd-sources {
  justify-content: flex-start;
}

.jd-paste-toggle {
  font-family: inherit;
  cursor: pointer;
}

.jd-paste-toggle[aria-expanded="true"] {
  border-color: var(--accent-text);
}

.jd-url-form {
  display: flex;
  gap: 0.5rem;
  width: min(640px, 100%);
}

.has-docs .jd-url-form {
  width: 100%;
}

.jd-url-form button {
  font-family: inherit;
  cursor: pointer;
}

.jd-url,
.jd-paste-text,
.jd-kind-filter {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-sunken);
  color: var(--text);
  font: inherit;
}

.jd-url {
  flex: 1;
  min-width: 0;
  padding: 0.45rem 0.85rem;
  font-size: 0.9rem;
}

.jd-paste {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
  width: 100%;
}

.jd-paste-text {
  width: 100%;
  min-height: 10rem;
  padding: 0.75rem 0.9rem;
  font: 0.85rem/1.6 var(--mono);
  resize: vertical;
}

.jd-paste-show {
  font-family: inherit;
  cursor: pointer;
}

.jd-url:focus,
.jd-paste-text:focus,
.jd-kind-filter:focus {
  border-color: var(--accent-text);
  outline: none;
}

.jd-drop-text {
  margin: 0;
}

.jd-choose {
  cursor: pointer;
}

/* Download split button: the main part downloads HTML, the arrow opens a menu */
.jd-download {
  position: relative;
  display: inline-flex;
}

.jd-download button {
  font-family: inherit;
  cursor: pointer;
}

.jd-download button:disabled {
  opacity: 0.6;
  cursor: progress;
}

.jd-download-main {
  border-radius: 999px 0 0 999px;
}

.jd-download-toggle {
  margin-left: -1px;
  padding-inline: 0.6rem 0.75rem;
  border-radius: 0 999px 999px 0;
}

.jd-download-toggle svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

.jd-download-menu {
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 0;
  z-index: 20;
  min-width: 17rem;
  padding: 0.35rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-raised);
  box-shadow: 0 12px 32px var(--shadow);
}

.jd-download-menu button {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  text-align: left;
}

.jd-download-menu button:hover,
.jd-download-menu button:focus-visible {
  outline: none;
  background: var(--bg-sunken);
}

.jd-download-menu small {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 400;
}

.jd-choose:focus-within {
  outline: 2px solid var(--accent-text);
  outline-offset: 3px;
}

.jd-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.jd-status.is-error {
  color: var(--danger-text);
}

.jd-messages {
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}

.jd-message {
  margin-bottom: 0.5rem;
  padding: 0.6rem 0.9rem;
  border: 1px solid rgb(247 223 30 / 0.35);
  border-radius: 8px;
  background: rgb(247 223 30 / 0.06);
  font: 0.85rem/1.5 var(--mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.jd-message.is-error,
.jd-message.is-fatal {
  border-color: rgb(255 107 107 / 0.4);
  background: rgb(255 107 107 / 0.08);
}

/* Sidebar + docs */
.jd-docs {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 2.5rem;
  margin-top: 2rem;
}

.jd-sidebar {
  position: sticky;
  top: var(--jd-offset);
  align-self: start;
  max-height: calc(100vh - var(--jd-offset) - 1rem);
  overflow-y: auto;
  padding-right: 0.25rem;
}

.jd-search {
  width: 100%;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-raised);
  color: var(--text);
  font: inherit;
}

.jd-search:focus {
  border-color: var(--accent-text);
  outline: none;
}

.jd-count {
  margin: 0.5rem 0 1rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.jd-nav-group h2 {
  margin: 1.25rem 0 0.35rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

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

.jd-nav ul ul {
  margin: 0.1rem 0 0.4rem 0.75rem;
  padding-left: 0.6rem;
  border-left: 1px solid var(--border);
}

.jd-nav a {
  display: block;
  overflow: hidden;
  padding: 0.12rem 0;
  color: var(--text);
  font: 0.85rem/1.5 var(--mono);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.jd-nav ul ul a {
  color: var(--muted);
}

.jd-nav a:hover {
  color: var(--accent-text);
  text-decoration: none;
}

/* Sections and entries */
.jd-main {
  min-width: 0;
}

.jd-section {
  margin-bottom: 3.5rem;
  scroll-margin-top: var(--jd-offset);
}

/* While searching, a section shown only for some of its entries */
.jd-section.is-collapsed > :not(.jd-section-head, .jd-group) {
  display: none;
}

.jd-section-head {
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.jd-section-head h2 {
  margin: 0;
  font: 700 1.75rem/1.2 var(--mono);
  overflow-wrap: anywhere;
}

.jd-kind {
  margin: 0 0 0.2rem;
  color: var(--accent-text);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.jd-longname {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.jd-group-title {
  margin: 2rem 0 0.75rem;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.jd-children {
  padding-left: 1.25rem;
}

.jd-summary {
  color: var(--muted);
}

.jd-entry,
.jd-constructor {
  margin-bottom: 1rem;
  padding: 1.1rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
  scroll-margin-top: var(--jd-offset);
}

.jd-entry:target,
.jd-section:target > .jd-section-head {
  border-color: var(--accent-text);
}

.jd-signature {
  margin: 0 0 0.5rem;
  font: 600 1.05rem/1.5 var(--mono);
  overflow-wrap: anywhere;
}

.jd-params,
.jd-colon,
.jd-arrow {
  color: var(--muted);
  font-weight: 400;
}

.jd-optional {
  opacity: 0.75;
}

.jd-type {
  color: var(--info-text);
  font-family: var(--mono);
  font-weight: 400;
}

.jd-type a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: rgb(130 170 255 / 0.4);
}

.jd-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0 0 0.6rem;
}

.jd-section-head .jd-badges {
  margin: 0.5rem 0 0;
}

.jd-badge {
  padding: 0.05rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.72rem;
}

.jd-badge.is-deprecated,
.jd-badge.is-private {
  border-color: rgb(255 107 107 / 0.4);
  color: var(--danger-text);
}

.jd-badge.is-async,
.jd-badge.is-static {
  border-color: rgb(130 170 255 / 0.4);
  color: var(--info-text);
}

.jd-deprecated {
  margin: 0 0 0.75rem;
  padding: 0.5rem 0.85rem;
  border-left: 3px solid #ff6b6b;
  border-radius: 4px;
  background: rgb(255 107 107 / 0.08);
}

.jd-deprecated .jd-text > :last-child {
  margin-bottom: 0;
}

/* Markdown descriptions */
.jd-text > :first-child {
  margin-top: 0;
}

.jd-text :is(p, ul, ol, blockquote) {
  margin: 0 0 0.75rem;
}

.jd-text > :last-child {
  margin-bottom: 0;
}

.jd-main h5 {
  margin: 1.1rem 0 0.4rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.jd-main code {
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: var(--bg);
  font-family: var(--mono);
  font-size: 0.88em;
}

.jd-main pre {
  margin: 0 0 0.75rem;
  padding: 0.85rem 1rem;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-sunken);
  font: 0.85rem/1.6 var(--mono);
}

.jd-main pre code {
  padding: 0;
  background: none;
  font-size: inherit;
}

.jd-caption {
  margin: 0 0 0.4rem;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Parameter tables and facts */
.jd-params-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.jd-params-table :is(th, td) {
  padding: 0.45rem 0.75rem 0.45rem 0;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.jd-params-table th {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.jd-params-table tr:last-child td {
  border-bottom: 0;
}

.jd-param-name {
  white-space: nowrap;
}

.jd-notes {
  margin: 0 0 0.2rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.jd-type-line {
  margin: 0 0 0.25rem;
}

.jd-return + .jd-return {
  margin-top: 0.5rem;
}

.jd-facts {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 0.25rem 1rem;
  margin: 1rem 0 0;
  font-size: 0.88rem;
}

.jd-facts dt {
  color: var(--muted);
}

.jd-facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}

/* Search filters and the result picked with the arrow keys */
.jd-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.85rem;
  margin-top: 0.6rem;
  font-size: 0.85rem;
}

.jd-kind-filter {
  flex: 1 1 100%;
  padding: 0.35rem 0.6rem;
  font-size: 0.85rem;
}

.jd-check {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--muted);
  cursor: pointer;
}

.jd-nav a.is-active {
  margin-inline: -0.4rem;
  padding-inline: 0.4rem;
  border-radius: 4px;
  background: var(--bg-sunken);
  color: var(--accent-text);
}

/* Copy-link buttons, for docs loaded from a URL */
.jd-link {
  display: inline-grid;
  place-items: center;
  width: 1.6em;
  height: 1.6em;
  margin-left: 0.25rem;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--muted);
  font-size: 0.8em;
  vertical-align: middle;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}

:is(.jd-entry, .jd-section-head):hover .jd-link,
.jd-link:focus-visible,
.jd-link.is-copied {
  opacity: 1;
}

.jd-link:hover {
  background: var(--bg-sunken);
  color: var(--text);
}

.jd-link svg {
  width: 1em;
  height: 1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
}

.jd-link.is-copied svg {
  display: none;
}

.jd-link.is-copied::after {
  content: "✓";
  color: var(--success-text);
}

/* Source buttons and the code they show */
.jd-source {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-text);
  font: inherit;
  cursor: pointer;
}

.jd-source code {
  color: inherit;
}

.jd-source:hover code {
  text-decoration: underline;
}

.jd-source[aria-expanded="true"] code::after {
  content: " ▴";
}

.jd-source-view {
  margin-top: 0.75rem;
}

.jd-source-more {
  margin: -0.4rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.jd-show-in-file,
.jd-view-source {
  font-family: inherit;
  cursor: pointer;
}

.jd-sidebar .jd-view-source {
  justify-content: center;
  width: 100%;
  margin: -0.4rem 0 0.75rem;
}

.jd-show-in-file {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-text);
  font-size: inherit;
}

.jd-show-in-file:hover {
  text-decoration: underline;
}

/* The source window: a whole file, with an item's lines marked */
.jd-source-dialog {
  width: min(1100px, 100vw - 2rem);
  height: min(900px, 100vh - 2rem);
  max-width: none;
  max-height: none;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
  color: var(--text);
  box-shadow: 0 24px 64px var(--shadow);
}

.jd-source-dialog[open] {
  display: flex;
  flex-direction: column;
}

.jd-source-dialog::backdrop {
  background: rgb(0 0 0 / 0.55);
}

.jd-source-dialog-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.85rem;
  padding: 0.65rem 0.75rem 0.65rem 1.1rem;
  border-bottom: 1px solid var(--border);
}

.jd-source-title {
  margin: 0;
  font: 600 1rem var(--mono);
  overflow-wrap: anywhere;
}

.jd-source-file {
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-sunken);
  color: var(--text);
  font: 600 0.9rem var(--mono);
}

.jd-source-original {
  font-size: 0.9rem;
}

.jd-source-download,
.jd-source-copy {
  font-family: inherit;
  cursor: pointer;
}

.jd-source-download {
  margin-left: auto;
}

.jd-source-close {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  cursor: pointer;
}

.jd-source-close:hover {
  background: var(--bg-sunken);
  color: var(--text);
}

.jd-source-close svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
}

.jd-source-scroll {
  flex: 1;
  overflow: auto;
  background: var(--bg-sunken);
}

.jd-source-file-view {
  position: relative;
  min-width: max-content;
}

.jd-source-file-view pre {
  display: flex;
  margin: 0;
  padding: 0.85rem 1.25rem 2rem 0;
  font: 0.85rem/1.6 var(--mono);
}

/* Line numbers stay put when scrolling sideways */
.jd-source-file-view .jd-gutter {
  position: sticky;
  left: 0;
  z-index: 1;
  padding-left: 1rem;
  background: var(--bg-sunken);
}

.jd-source-mark {
  position: absolute;
  right: 0;
  left: 0;
  z-index: 2;
  border-left: 3px solid var(--accent-text);
  background: rgb(247 223 30 / 0.12);
  pointer-events: none;
}

/* Code blocks: examples and source, with a Copy button */
.jd-code {
  position: relative;
}

.jd-copy {
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
  padding: 0.15rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-raised);
  color: var(--muted);
  font: 600 0.75rem var(--font);
  cursor: pointer;
  opacity: 0.85;
}

.jd-copy:hover,
.jd-copy:focus-visible {
  color: var(--text);
  opacity: 1;
}

.jd-code pre {
  display: flex;
  padding-right: 4.5rem;
}

.jd-gutter {
  flex: none;
  margin-right: 1rem;
  padding-right: 0.75rem;
  border-right: 1px solid var(--border);
  color: var(--muted);
  text-align: right;
  user-select: none;
}

/* Syntax highlighting (highlight.js classes) */
.jd {
  --hl-keyword: #c792ea;
  --hl-string: #c3e88d;
  --hl-number: #f78c6c;
  --hl-title: #82aaff;
  --hl-comment: #7f879a;
  --hl-built-in: #ffcb6b;
  --hl-regexp: #89ddff;
}

@media (prefers-color-scheme: light) {
  .jd {
    --hl-keyword: #a626a4;
    --hl-string: #2f6b22;
    --hl-number: #8a5300;
    --hl-title: #2f5bd3;
    --hl-comment: #5d626c;
    --hl-built-in: #8a5300;
    --hl-regexp: #b3261e;
  }
}

.jd :is(.hljs-keyword, .hljs-literal, .hljs-variable.language_) { color: var(--hl-keyword); }
.jd :is(.hljs-string, .hljs-template-tag, .hljs-template-variable) { color: var(--hl-string); }
.jd :is(.hljs-number, .hljs-attr, .hljs-property) { color: var(--hl-number); }
.jd :is(.hljs-title, .hljs-title.function_, .hljs-title.class_) { color: var(--hl-title); }
.jd :is(.hljs-comment, .hljs-meta) { color: var(--hl-comment); font-style: italic; }
.jd :is(.hljs-built_in, .hljs-type) { color: var(--hl-built-in); }
.jd :is(.hljs-regexp, .hljs-subst) { color: var(--hl-regexp); }
.jd .hljs-doctag { color: var(--hl-keyword); font-style: normal; }

/* Coverage report */
.jd-coverage {
  margin-bottom: 2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
}

.jd-coverage summary {
  padding: 0.75rem 1.1rem;
  cursor: pointer;
}

.jd-coverage-body {
  padding: 0 1.1rem 1rem;
  border-top: 1px solid var(--border);
}

.jd-coverage-body > p {
  margin: 0.85rem 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.jd-issues {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.9rem;
}

.jd-issues li {
  margin-bottom: 0.4rem;
}

.jd-issue-where {
  color: var(--muted);
  font-size: 0.85em;
}

.jd-issues .jd-source-view {
  margin-bottom: 0.75rem;
}

@media (max-width: 860px) {
  .jd-docs {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .jd-sidebar {
    position: static;
    max-height: 45vh;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
  }

  .jd-params-table,
  .jd-params-table tbody,
  .jd-params-table tr,
  .jd-params-table td {
    display: block;
  }

  .jd-params-table thead {
    display: none;
  }

  .jd-params-table tr {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
  }

  .jd-params-table td {
    padding: 0.1rem 0;
    border: 0;
  }
}
