/* Custom styles */

:root {
  --thm-bg: #23262d;
  --thm-fg: #c5c9c7;
  --thm-selection-bg: #43464e;
  --thm-muted: #5c6066;
  --thm-subtle: #a4a7a4;

  --thm-red: #c4746e;
  --thm-green: #8a9a7b;
  --thm-yellow: #c4b28a;
  --thm-blue: #8ba4b0;
  --thm-magenta: #a292a3;
  --thm-cyan: #8ea4a2;

  --thm-bright-red: #e46876;
  --thm-bright-green: #87a987;
  --thm-bright-yellow: #e6c384;
  --thm-bright-blue: #7fb4ca;
  --thm-bright-magenta: #938aa9;
  --thm-bright-cyan: #7aa89f;

  --md-primary-fg-color: var(--thm-blue);
  --md-primary-fg-color--light: var(--thm-bright-blue);
  --md-primary-fg-color--dark: var(--thm-cyan);
  --md-accent-fg-color: var(--thm-bright-blue);

  --md-default-bg-color: var(--thm-bg);
  --md-default-fg-color: var(--thm-fg);
  --md-default-fg-color--light: var(--thm-subtle);
  --md-default-fg-color--lighter: var(--thm-muted);
  --md-default-fg-color--lightest: var(--thm-selection-bg);

  --md-typeset-color: var(--thm-fg);
  --md-typeset-a-color: var(--thm-bright-blue);

  --md-code-bg-color: #1a1c21;
  --md-code-fg-color: var(--thm-fg);

  /* Custom spacing */
  --md-typeset-spacing: 0.75rem;
}

/* Page background and foreground */
html,
body,
.terminal-mkdocs,
.terminal-mkdocs-main-grid,
.terminal-mkdocs-main-content,
.terminal-mkdocs p,
.terminal-mkdocs li,
.terminal-mkdocs td,
.terminal-mkdocs th,
.terminal-mkdocs label,
.terminal-mkdocs span,
.terminal-mkdocs div {
  background-color: var(--thm-bg) !important;
  color: var(--thm-fg) !important;
}

/* Override terminal theme's blue text */
.terminal-mkdocs-main-content,
.terminal-mkdocs-main-content p,
.terminal-mkdocs-main-content li,
.terminal-mkdocs-main-content td {
  color: var(--thm-fg) !important;
}

/* Logo adjustments */
.md-header__button.md-logo img,
.md-header__button.md-logo svg {
  height: 2rem;
  width: auto;
}

/* Code block container styling */
.highlight {
  position: relative;
  background-color: #1a1c21;
  border: none;
  border-radius: 0.4rem;
  margin: 1em 0;
  overflow: hidden;
}

.highlight pre {
  margin: 0;
  padding: 1em 1.25em;
  background: transparent !important;
  border: none;
  color: var(--thm-fg);
  overflow-x: auto;
}

.highlight code {
  font-size: 0.9em;
  line-height: 1.6;
  background: transparent !important;
}

/* Ensure no nested elements override the background */
.highlight pre code,
.highlight code span {
  background: transparent !important;
}

/* Inline code styling */
:not(pre) > code {
  background-color: #1a1c21;
  border: none;
  border-radius: 0.3rem;
  padding: 0.15em 0.4em;
  color: var(--thm-bright-cyan);
  font-size: 0.9em;
}

/* Copy button for code blocks */
.code-copy-btn {
  position: absolute;
  top: 0.5em;
  right: 0.5em;
  padding: 0.3em 0.5em;
  background-color: var(--thm-selection-bg);
  border: 1px solid var(--thm-muted);
  border-radius: 0.3rem;
  color: var(--thm-muted);
  font-size: 0.75em;
  cursor: pointer;
  opacity: 0;
  transition:
    opacity 0.2s,
    color 0.2s,
    background-color 0.2s;
  z-index: 10;
}

.highlight:hover .code-copy-btn {
  opacity: 1;
}

.code-copy-btn:hover {
  color: var(--thm-fg);
  background-color: var(--thm-muted);
}

.code-copy-btn.copied {
  color: var(--thm-green);
  border-color: var(--thm-green);
}

.md-typeset .admonition,
.md-typeset details {
  border-left: 0.2rem solid;
  border-radius: 0.2rem;
  background-color: var(--thm-selection-bg);
}

.md-typeset .admonition.note,
.md-typeset details.note {
  border-color: var(--thm-blue);
}

.md-typeset .admonition.tip,
.md-typeset details.tip {
  border-color: var(--thm-green);
}

.md-typeset .admonition.warning,
.md-typeset details.warning {
  border-color: var(--thm-yellow);
}

.md-typeset .admonition.danger,
.md-typeset details.danger {
  border-color: var(--thm-red);
}

.md-typeset .grid.cards > ul > li {
  border: 0.05rem solid var(--thm-selection-bg);
  border-radius: 0.2rem;
  background-color: var(--thm-bg);
  transition:
    border 250ms,
    box-shadow 250ms;
}

.md-typeset .grid.cards > ul > li:hover {
  border-color: var(--thm-blue);
  box-shadow: 0 0.2rem 0.5rem rgba(0, 0, 0, 0.2);
}

/* Improve table appearance */
.md-typeset table:not([class]) {
  border: 0.05rem solid var(--thm-selection-bg);
  border-radius: 0.2rem;
  font-size: 0.875em;
}

.md-typeset table:not([class]) th {
  background-color: var(--thm-selection-bg);
  color: var(--thm-fg);
}

/* mkdocstrings parameter tables */
table,
.doc table,
.doc-contents table,
.md-typeset table {
  background-color: var(--thm-bg) !important;
  color: var(--thm-fg) !important;
  border: 1px solid var(--thm-selection-bg) !important;
  border-collapse: collapse;
}

table th,
.doc table th,
.doc-contents table th,
.md-typeset table th {
  background-color: var(--thm-selection-bg) !important;
  color: var(--thm-fg) !important;
  border: 1px solid var(--thm-selection-bg) !important;
}

table td,
.doc table td,
.doc-contents table td,
.md-typeset table td {
  background-color: var(--thm-bg) !important;
  color: var(--thm-fg) !important;
  border: 1px solid var(--thm-selection-bg) !important;
}

/* API documentation tweaks */
.doc-heading code {
  background-color: transparent;
  padding: 0;
}

/* Improve navigation */
.md-nav__item--active > .md-nav__link {
  font-weight: 600;
  color: var(--thm-bright-blue);
}

.md-nav__link:hover {
  color: var(--thm-bright-blue);
}

/* Make h1 more prominent */
.md-typeset h1 {
  font-weight: 700;
  color: var(--thm-fg);
}

.md-typeset h2,
.md-typeset h3,
.md-typeset h4 {
  color: var(--thm-subtle);
}

/* Links */
a,
.md-typeset a,
.terminal-mkdocs a,
.terminal-mkdocs-main-content a {
  color: var(--thm-bright-blue) !important;
}

a:hover,
.md-typeset a:hover,
.terminal-mkdocs a:hover,
.terminal-mkdocs-main-content a:hover {
  color: var(--thm-bright-green) !important;
  background-color: transparent !important;
}

/* Selection */
::selection {
  background-color: var(--thm-selection-bg);
  color: var(--thm-fg);
}

.video-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* Fix bibliography formatting - prevent newline after list numbers */
ol li[id^="fn:"] {
  padding-left: 0;
  margin-left: 2em;
  text-indent: -2em;
}

ol li[id^="fn:"] p {
  display: inline;
  margin: 0;
}

/* Fix mkdocstrings source code line number column width */
.highlighttable td.linenos {
  min-width: 6em;
  color: var(--thm-muted);
}

/* Custom bibliography styling for Python docstrings */
ol.bibliography {
  list-style-type: decimal;
  padding-left: 0;
}

ol.bibliography li {
  padding-left: 0;
  margin-left: 2em;
  text-indent: -2em;
  margin-bottom: 1em;
}

ol.bibliography li p {
  display: inline;
  margin: 0;
}

/* Citation links styling */
a.citation {
  text-decoration: none;
  color: var(--thm-bright-blue);
}

a.citation:hover {
  text-decoration: underline;
  color: var(--thm-bright-cyan);
}

/* Citation backlink styling */
a.citation-backlink {
  text-decoration: none;
  color: var(--thm-blue);
  font-size: 0.9em;
}

a.citation-backlink:hover {
  text-decoration: underline;
}

/* Lower the breakpoint for side-by-side layout (default is 70em) */
@media only screen and (min-width: 50em) {
  .terminal-mkdocs-main-grid {
    grid-template-columns: 3fr 10fr;
  }
}

/* Pygments syntax highlight */

.highlight {
  color: var(--thm-fg);
}

/* Comments */
.highlight .c,
.highlight .ch,
.highlight .cm,
.highlight .cpf,
.highlight .c1,
.highlight .cs {
  color: var(--thm-muted);
  font-style: italic;
}

/* Preprocessor */
.highlight .cp {
  color: var(--thm-yellow);
}

/* Errors */
.highlight .err {
  color: var(--thm-bright-red);
}

/* Generic */
.highlight .gd {
  color: var(--thm-red);
}
.highlight .gi {
  color: var(--thm-green);
}
.highlight .ge {
  font-style: italic;
}
.highlight .gs {
  font-weight: bold;
}
.highlight .gh,
.highlight .gu {
  color: var(--thm-bright-blue);
  font-weight: bold;
}

/* Keywords */
.highlight .k,
.highlight .kc,
.highlight .kd,
.highlight .kn,
.highlight .kp,
.highlight .kr {
  color: var(--thm-magenta);
}
.highlight .kt {
  color: var(--thm-yellow);
}

/* Literals */
.highlight .l,
.highlight .ld {
  color: var(--thm-green);
}

/* Numbers */
.highlight .m,
.highlight .mb,
.highlight .mf,
.highlight .mh,
.highlight .mi,
.highlight .mo,
.highlight .il {
  color: var(--thm-bright-magenta);
}

/* Strings */
.highlight .s,
.highlight .sa,
.highlight .sb,
.highlight .sc,
.highlight .dl,
.highlight .sd,
.highlight .s2,
.highlight .se,
.highlight .sh,
.highlight .si,
.highlight .sx,
.highlight .sr,
.highlight .s1,
.highlight .ss {
  color: var(--thm-green);
}

/* Names */
.highlight .n {
  color: var(--thm-fg);
}
.highlight .na {
  color: var(--thm-cyan);
}
.highlight .nb {
  color: var(--thm-bright-blue);
}
.highlight .nc {
  color: var(--thm-bright-yellow);
}
.highlight .nd {
  color: var(--thm-bright-cyan);
}
.highlight .ne {
  color: var(--thm-bright-red);
}
.highlight .nf,
.highlight .fm {
  color: var(--thm-bright-blue);
}
.highlight .ni {
  color: var(--thm-bright-yellow);
}
.highlight .nn {
  color: var(--thm-fg);
}
.highlight .nt {
  color: var(--thm-blue);
}
.highlight .nv,
.highlight .vc,
.highlight .vg,
.highlight .vi,
.highlight .vm {
  color: var(--thm-fg);
}

/* Operators */
.highlight .o,
.highlight .ow {
  color: var(--thm-cyan);
}

/* Punctuation */
.highlight .p {
  color: var(--thm-fg);
}

/* Special */
.highlight .w {
  color: var(--thm-fg);
}

/* Line numbers */
.highlight .linenos {
  color: var(--thm-muted);
  background-color: transparent;
  padding-right: 1em;
  user-select: none;
}
