/* ---------- Fonts ---------- */

:root {
  --font-family: "Lexend", system-ui, sans-serif;
  --font-family-mono: "Atkinson Hyperlegible Mono", ui-monospace, "Cascadia Code",
    Consolas, monospace;
}

/* ---------- Colors ---------- */

:root {
  --codapi-bg: #f6f8fa;
  --codapi-border: #d0d7de;
  --codapi-text: #24292f;
  --codapi-muted: #57606a;
  --code-border: #8c959f;
}

/* Off-white page background in light mode (easier on the eyes than #fff) */
:root[data-theme="light"] {
  --color-bg: #faf8f3;
}

/* Light code theme (GitHub Light colors) */
:root[data-theme="light"] {
  --codeblock-bg: #f6f8fa;
  --codeblock-color: #000;
  --codeblock-comment: #59636e;
  --codeblock-function: #6639ba;
  --codeblock-important: #cf222e;
  --codeblock-keyword: #cf222e;
  --codeblock-operator: #0550ae;
  --codeblock-property: #0550ae;
  --codeblock-punctuation: #1f2328;
  --codeblock-selector: #0a3069;
  --codeblock-tag: #0550ae;
  --codeblock-variable: #953800;
}

:root[data-theme="dark"] {
  --codapi-bg: #161b22;
  --codapi-border: #30363d;
  --codapi-text: #c9d1d9;
  --codapi-muted: #8b949e;
  --code-border: #6e7681;
  --codeblock-color: #fff;
}

/* ---------- Theme toggle button ---------- */

#theme-toggle {
  position: fixed;
  top: 12px;
  right: 16px;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--code-border);
  border-radius: 50%;
  background: var(--codapi-bg);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

#theme-toggle:hover {
  filter: brightness(1.15);
}

/* ---------- Font settings (added by font-settings.js) ---------- */

#settings-toggle {
  position: fixed;
  bottom: 16px;
  left: 16px;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--code-border);
  border-radius: 50%;
  background: var(--codapi-bg);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

#settings-toggle:hover {
  filter: brightness(1.15);
}

#settings-panel {
  position: fixed;
  bottom: 64px;
  left: 16px;
  z-index: 100;
  display: grid;
  gap: 0.35em;
  width: min(260px, calc(100vw - 32px));
  padding: 1em;
  border: 1px solid var(--code-border);
  border-radius: 8px;
  background: var(--codapi-bg);
  color: var(--codapi-text);
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.2);
}

#settings-panel[hidden] {
  display: none;
}

#settings-panel label {
  font-size: 0.9em;
  font-weight: 600;
}

#settings-panel select {
  margin-bottom: 0.6em;
  padding: 0.35em 0.5em;
  border: 1px solid var(--code-border);
  border-radius: 6px;
  background: var(--codeblock-bg, var(--codapi-bg));
  color: inherit;
  font: inherit;
}

#settings-panel select:last-child {
  margin-bottom: 0;
}

/* Keep the last sidebar links clear of the gear */
.sidebar-nav {
  padding-bottom: 72px;
}

/* ---------- Code blocks ---------- */

.markdown-section pre[data-lang] {
  border: 1px solid var(--code-border);
}

/* Line-number gutter (added by line-numbers.js) */
.markdown-section pre.has-line-numbers {
  display: flex;
}

.markdown-section pre.has-line-numbers > code {
  flex: 1;
  min-width: 0;
  padding-inline-start: 1rem !important;
}

.markdown-section pre .line-numbers {
  flex: none;
  padding-block: 1.5rem;
  padding-inline: 1rem 0.75rem;
  border-right: 1px solid var(--code-border);
  color: var(--codeblock-comment);
  text-align: right;
  user-select: none;
}

.markdown-section pre .line-numbers > span {
  display: block;
}

/* ---------- Codapi toolbar ---------- */

/* .markdown-section prefix is needed to beat docsify's button styles */
.markdown-section codapi-toolbar button {
  padding: 0.35em 1em;
  border: none;
  border-radius: 6px;
  background: var(--theme-color, #0b85ff);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.markdown-section codapi-toolbar button:hover {
  filter: brightness(1.1);
}

.markdown-section codapi-toolbar button:disabled {
  opacity: 0.6;
  cursor: wait;
}

codapi-toolbar a {
  color: var(--theme-color, #0b85ff);
}

codapi-status {
  color: var(--codapi-muted);
  font-size: 0.9em;
}

/* ---------- Codapi output panel ---------- */

codapi-output {
  margin-top: 0.5em;
  border: 1px solid var(--codapi-border);
  border-radius: 6px;
  background: var(--codapi-bg);
}

.markdown-section codapi-output pre {
  margin: 0;
  padding: 1em;
  background: transparent;
  color: var(--codapi-text);
}

/* Undo docsify's inline-code chip styling inside output */
.markdown-section codapi-output pre code {
  margin: 0;
  padding: 0;
  background: transparent;
  color: inherit;
}

codapi-output a[href="#close"] {
  color: var(--codapi-muted);
  text-decoration: none;
}

/* Wrap content in <div class="center"> to center it (tables shrink to fit
   their content and still scroll sideways on narrow screens) */
.markdown-section .center {
  text-align: center;
}

.markdown-section table {
  display: block;
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
  margin-inline: auto;
}
