/* ==========================================================================
   custom.css — Theme overrides for the "furo" Sphinx theme.
   Furo is styled via CSS custom properties, so we override those instead
   of targeting layout classes (which don't exist in furo). See:
   https://pradyunsg.me/furo/customisation/
   ========================================================================== */

/* ---- Light mode palette --------------------------------------------------- */
:root {
  --color-brand-primary: #3457d5;
  --color-brand-content: #3457d5;

  --color-background-primary: #ffffff;
  --color-background-secondary: #f7f8fc;
  --color-background-hover: #eef1fd;
  --color-background-border: #e3e6ec;

  --color-foreground-primary: #1f2430;
  --color-foreground-secondary: #5a6472;
  --color-foreground-muted: #7a8290;
  --color-foreground-border: #e3e6ec;

  --color-code-background: #f4f6fb;
  --color-code-foreground: #b8452e;

  --color-admonition-background: #eef1fd;

  --font-stack: "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-stack--monospace: "JetBrains Mono", "Fira Code", SFMono-Regular, Consolas, monospace;

  --sidebar-background: #171b26;
  --sidebar-background-border: #171b26;
  --sidebar-item-background--hover: #3457d5;
  --sidebar-item-expander-background--hover: transparent;
  --color-sidebar-link-text: #c7cbe0;
  --color-sidebar-link-text--top-level: #ffffff;
  --color-sidebar-caption-text: #7a86b8;
}

/* ---- Dark mode palette (furo toggles [data-theme="dark"]) ----------------- */
@media (prefers-color-scheme: dark) {
  body:not([data-theme="light"]) {
    --color-brand-primary: #7c93ff;
    --color-brand-content: #7c93ff;
    --color-background-primary: #14161f;
    --color-background-secondary: #1b1e2a;
    --color-background-hover: #232739;
    --color-code-background: #1e2230;
    --color-code-foreground: #ff8a65;
    --color-admonition-background: #1b1e2a;
  }
}
body[data-theme="dark"] {
  --color-brand-primary: #7c93ff;
  --color-brand-content: #7c93ff;
  --color-background-primary: #14161f;
  --color-background-secondary: #1b1e2a;
  --color-background-hover: #232739;
  --color-code-background: #1e2230;
  --color-code-foreground: #ff8a65;
  --color-admonition-background: #1b1e2a;
}

/* ---- Keep <html> in sync with <body>'s theme --------------------------
   Furo toggles `data-theme` on <body>, but CSS variables only cascade to
   descendants, not up to <html>. Without this, <html>'s background stays
   on the light value, which flashes through during overscroll/rubber-band
   scrolling in dark mode. Mirror the same rules on <html> via :has(). */
@media (prefers-color-scheme: dark) {
  html:has(body:not([data-theme="light"])) {
    background: #14161f;
  }
}
html:has(body[data-theme="dark"]) {
  background: #14161f;
}

/* ---- Base typography -------------------------------------------------- */

html {
  background: var(--color-background-primary);
  min-height: 100%;
}

body {
  background: var(--color-background-primary);
  min-height: 100vh;
  font-size: 16.5px;
  line-height: 1.7;
}

article {
  max-width: 860px;
}

/* ---- Headings ------------------------------------------------------------ */

h1 {
  font-weight: 800;
  letter-spacing: -0.02em;
  border-bottom: 3px solid var(--color-brand-primary);
  padding-bottom: 0.5rem;
}

h2 {
  font-weight: 700;
  margin-top: 3rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--color-background-border);
  letter-spacing: -0.01em;
}

h2::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  background: var(--color-brand-primary);
  border-radius: 2px;
  margin-right: 8px;
  vertical-align: middle;
}

h3 {
  font-weight: 700;
  margin-top: 1.75rem;
  font-size: 1.12em;
}

hr {
  border: none;
  border-top: 2px dashed var(--color-background-border);
  margin: 3rem 0;
}

/* ---- Lists ----------------------------------------------------------------- */

li {
  margin-bottom: 0.5rem;
}

li strong {
  color: var(--color-brand-content);
  font-weight: 700;
}

/* ---- Inline code & code blocks --------------------------------------------- */

code.literal, .rst-content code {
  border-radius: 5px;
  font-size: 0.88em;
}

pre {
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

/* ---- Tables ------------------------------------------------------------------ */

table.docutils {
  border-collapse: collapse;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

table.docutils th {
  background: var(--color-brand-primary);
  color: #fff;
}

table.docutils tr:nth-child(even) {
  background: var(--color-background-hover);
}

/* ---- Admonitions --------------------------------------------------------------- */

.admonition {
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

/* ---- Sidebar polish -------------------------------------------------------------- */

.sidebar-brand, .sidebar-search-container input {
  border-radius: 6px;
}

.sidebar-tree .current > .reference {
  font-weight: 700;
}

/* ---- Links --------------------------------------------------------------------- */

a {
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s ease, color 0.15s ease;
}

a:hover {
  border-bottom-color: currentColor;
}