/* Sphinx Unbloated Theme
 * Adapted from the jorgemartinez.space site stylesheet.
 *
 * Use vanilla CSS and semantic HTML. Keep custom classes to a minimum.
 */

/* Self-Hosted Fonts */

@font-face {
  font-family: "Source Code Pro";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../fonts/source-code-pro-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Source Code Pro";
  font-style: italic;
  font-weight: 400 700;
  font-display: swap;
  src: url("../fonts/source-code-pro-italic.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Responsive Breakpoint */

/* Use the website's mobile sizes at widths up to 500px. */

/* Design Tokens */

:root {
  font-size: 11px;

  /* Colors */
  --white: #ffffff;
  --lightgray: #ededed;
  --gray: #dddddd;
  --darkgray: #bbbbbb;
  --black: #000000;
  --blue: #007bff;

  /* Fonts */
  --font-family-regular: "Source Code Pro", monospace;
  --font-family-code: "Source Code Pro", monospace;
  font-family: "Source Code Pro", monospace;

  /* Headings */
  --h1-font-size: 2rem;
  --h2-font-size: 1.3rem;
  --h3-font-size: 1.15rem;
  --h4-font-size: 1.05rem;
  --h5-font-size: 1rem;
  --h6-font-size: 0.95rem;

  /* Borders and shadows */
  --shadow: 2px 2px var(--darkgray);
  --border: thin solid var(--black);
}

/* Responsive Design */

@media (min-width: 501px) {
  :root {
    font-size: 17px;
  }
  body {
    margin: 1rem auto;
  }
}

/* Base */

html {
  background-color: var(--gray);
}

body {
  min-height: calc(100vh - 2rem);
  max-width: 800px;
  margin: 1rem auto;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: scroll;
  background-color: var(--white);
  box-shadow: var(--shadow);
}

/* Fill the space above bottom navigation with Sphinx's content wrapper. */
body > .document {
  flex: 1;
}

/* Header */

header {
  color: var(--white);
  background-color: var(--black);
  padding: 1.5rem 0 0 1rem;

  /* Keep the site title separate from page headings. */
  & h1.title {
    font-size: 2rem;
    margin: 0;
    text-transform: uppercase;
    color: var(--white);
  }

  & p.description {
    font-size: 1.2rem;
  }

  & div.components {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  & p.social {
    font-size: 1.2rem;
  }

  & a {
    color: var(--white) !important;

    &:hover {
      color: var(--white) !important;
      cursor: pointer !important;
    }
  }
}

/* Version Switcher */

header div.version-switcher {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding-right: 1rem;

  & span.version-label {
    font-size: 0.85rem;
    color: var(--white);
  }

  & select,
  & select:focus,
  & select:active {
    font-family: var(--font-family-code);
    font-size: 0.85rem;
    color: var(--white);
    background-color: var(--black);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpolygon points='0,0 10,0 5,6' fill='white'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    border: thin solid var(--white);
    border-radius: 0;
    outline: none;
    padding: 0.2rem 1.6rem 0.2rem 0.4rem;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    text-align: right;
    direction: rtl;
    width: calc(100% - 4rem);
  }
}

/* Header Search Bar */

header #version-switcher:focus-visible,
header #header-search-input:focus-visible {
  outline: 2px solid var(--white);
  outline-offset: 3px;
}

header form.header-search {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 1;
  padding: 0 1rem;

  & label {
    color: var(--white);
    font-size: 0.85rem;
    cursor: pointer;
    flex-shrink: 0;
  }

  & input[type="search"] {
    flex: 1;
    font-family: var(--font-family-code);
    font-size: 0.85rem;
    color: var(--white);
    background-color: var(--black);
    border: thin solid var(--white);
    border-radius: 0;
    outline: none;
    padding: 0.2rem 0.4rem;
    width: 100%;

    &::placeholder {
      color: var(--darkgray);
    }

    &::-webkit-search-cancel-button {
      display: none;
    }
  }
}

/* Navigation Bar */

nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  margin-top: 1rem;
  margin-bottom: 1rem;
  padding: 0 1rem;

  /* Size each link as a flex item; its button fills the link. */
  & a {
    flex: 1 1 calc(33.3% - 1rem);
    text-decoration: none;

    & button {
      width: 100%;
      font-size: 1rem;
      font-family: var(--font-family-code);
      background-color: var(--white);
      border: thin solid var(--black);
      box-shadow: 2px 2px var(--darkgray);
      transition: background-color 0.3s ease;
      color: var(--black);

      &:hover,
      &.active {
        background-color: var(--black);
        color: var(--white);
      }
    }
  }
}

/* JavaScript in layout.html moves subnav-current after the first h1. */
nav.subnav {
  /* Use the 2.5rem horizontal padding from main. */
  padding: 0;
  margin-top: 0;
  margin-bottom: 1rem;
  border-top: none;
}

nav.subnav-current {
  margin-bottom: 2rem;
}

/* Bottom Navigation */

nav.page-navigation {
  justify-content: flex-start;
  padding: 0 2.5rem;
  margin: 1.5rem 0;

  & a.back-button {
    display: inline-flex;
    flex: 0 1 auto;
    align-items: center;
    gap: 0.5rem;
    max-width: 100%;
    font-size: 1rem;
    font-family: var(--font-family-code);
    line-height: normal;
    padding: 2px 6px;
    box-sizing: border-box;
    background-color: var(--white);
    border: thin solid var(--black);
    box-shadow: 2px 2px var(--darkgray);
    transition: background-color 0.3s ease;
    color: var(--black);

    &:visited {
      color: var(--black);
    }

    &:hover,
    &:focus-visible {
      background-color: var(--black);
      color: var(--white);
    }

    &:focus-visible {
      outline: 2px solid var(--black);
      outline-offset: 4px;
    }

    & svg {
      flex-shrink: 0;
    }
  }
}

/* Breadcrumb title */
p.nav-breadcrumb-title {
  font-size: var(--h1-font-size);
  font-weight: bold;
  text-transform: uppercase;
  margin: 2rem 0 0.67em;
  padding: 0;

  & a {
    color: var(--black);

    &:hover {
      color: var(--blue);
    }
  }
}

/* Add 2rem above the section before JavaScript moves the child links. */
main nav.subnav.subnav-current + section {
  margin-top: 2rem;
}

/* Keep 2rem above the section after JavaScript moves the child links inside it. */
main > section:only-child {
  margin-top: 2rem;
}

/* Leave 3rem between the parent section links and the child page heading. */
main nav.subnav + section > h1 {
  margin-top: 3rem;
}

/* Main Content */

main {
  flex: 1;
  padding: 0 2.5rem;
}

/* Keep heading underlines within the page content. */
main > section {
  overflow-x: clip;
  container-type: inline-size;
}

/* Typography */

/* Apply heading styles to page content. */
main {
  & h1,
  & h2,
  & h3,
  & h4,
  & h5,
  & h6 {
    text-transform: uppercase;
  }

  & h1 {
    font-size: var(--h1-font-size);
  }
  & h2 {
    font-size: var(--h2-font-size);
  }
  & h3 {
    font-size: var(--h3-font-size);
  }
  & h4 {
    font-size: var(--h4-font-size);
  }
  & h5 {
    font-size: var(--h5-font-size);
  }
  & h6 {
    font-size: var(--h6-font-size);
  }
}

main :is(h2, h3, h4, h5, h6),
main div.toctree-wrapper p.caption {
  display: inline-block;
  position: relative;
  max-width: 100%;
  box-sizing: border-box;
  background-color: var(--black);
  color: var(--white);
  padding: 0.1rem 0.5rem;
  margin-right: 0.5rem;

  & a,
  & code,
  & tt {
    color: inherit;
  }

  &::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100cqw;
    height: 2px;
    background-color: var(--black);
  }
}

/* Anchor Links */

/* Hide heading link symbols. Section IDs still serve as link targets. */
a.headerlink {
  display: none;
}

/* Links */

a {
  text-decoration: none;
  color: var(--blue);

  &:hover {
    color: var(--black);
  }
  &:visited {
    color: var(--blue);
  }
}

/* Lists */

ul {
  list-style-type: "- ";
  margin-left: 0;
  padding-left: 2rem;
}

/* Remove paragraph margins from list items wrapped in <li><p> by Sphinx. */
li {
  margin-bottom: 1rem;

  & > p {
    margin: 0;
  }
}

/* Inline and Block Code */

code,
tt {
  font-family: var(--font-family-code);
  color: var(--black);
  padding: 0 0.2rem;
  border: thin solid var(--black);
}

/* Code blocks with Pygments syntax highlighting */
div.highlight {
  border: thin solid var(--black);
  background: var(--lightgray);
  margin-bottom: 1rem;
  overflow-x: auto;

  & pre {
    font-size: 0.8rem;
    font-family: var(--font-family-code);
    padding: 0.5rem 1rem;
    overflow-x: auto;
    margin: 0;
    border: none;
    background: transparent;
  }
}

/* Plain <pre> blocks without a highlight wrapper */
pre {
  font-size: 1rem;
  font-family: var(--font-family-code);
  padding: 0.5rem 1rem;
  overflow-x: auto;
  border: thin solid var(--black);
  margin-bottom: 1rem;
}

/* Remove borders and shadows from elements inside code blocks. */
pre > *,
div.highlight pre > * {
  border: none !important;
  box-shadow: none !important;
}

/* API Reference */

main section[id^="module-"] > h1,
main .autoapi-page > h1 {
  overflow-wrap: anywhere;
}

.autoapi-summary {
  margin: 1rem 0 2rem;

  & > .autoapi-summary-panel > p.rubric {
    font-weight: bold;
    margin: 1rem 0 0.5rem;
  }
}

.autoapi-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  border-bottom: 2px solid var(--black);
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;

  & button {
    font: inherit;
    padding: 0.2rem 0.5rem;
    border: var(--border);
    box-shadow: var(--shadow);
    background-color: var(--white);
    color: var(--black);
    cursor: pointer;

    &[aria-selected="true"],
    &:hover {
      background-color: var(--black);
      color: var(--white);
    }

    &:focus-visible {
      outline: 2px solid var(--black);
      outline-offset: 3px;
    }
  }
}

table.autoapi-summary-table {
  width: 100%;
  table-layout: fixed;
  text-align: left;

  & td {
    vertical-align: top;
    overflow-wrap: anywhere;

    & > :first-child {
      margin-top: 0;
    }
    & > :last-child {
      margin-bottom: 0;
    }
  }

  & .pre {
    white-space: normal;
  }
}

main dl:has(> dt.sig-object) {
  margin: 2rem 0;
  border: var(--border);
  box-shadow: var(--shadow);

  & > dd {
    margin: 0;
    padding: 1rem;
    overflow-wrap: anywhere;

    & > :first-child {
      margin-top: 0;
    }
    & > :last-child {
      margin-bottom: 0;
    }
  }
}

main dt.sig-object {
  display: flow-root;
  padding: 0.75rem 1rem;
  border-bottom: var(--border);
  background-color: var(--lightgray);
  font-family: var(--font-family-code);
  font-size: 0.95rem;
  line-height: 1.6;
  overflow-wrap: anywhere;

  & .sig-name {
    font-weight: bold;
  }
  & .sig-param {
    font-style: normal;
  }
  & .pre {
    white-space: normal;
  }

  & code,
  & tt {
    padding: 0;
    border: none;
    font-size: inherit;
    color: inherit;
  }

  & a:has(.viewcode-link) {
    float: right;
    margin-left: 1rem;
    font-size: 0.8em;
    white-space: nowrap;
  }

  & a:focus-visible {
    outline: 2px solid var(--black);
    outline-offset: 2px;
  }
}

main dl:has(> dt.sig-object) > dd > p.rubric {
  margin: 1.5rem 0 0.5rem;
  font-weight: bold;
}

main dl:has(> dt.sig-object) dl.field-list {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 0.75rem 1.25rem;
  margin: 1rem 0;

  & > dt {
    font-weight: bold;
  }

  & > dd {
    min-width: 0;
    margin: 0;
    padding: 0;

    & > :first-child {
      margin-top: 0;
    }
    & > :last-child {
      margin-bottom: 0;
    }
  }

  & > dd > dl {
    margin: 0;

    & > dt {
      font-weight: normal;
    }

    & > dd {
      margin: 0.25rem 0 0.75rem;

      & > :first-child {
        margin-top: 0;
      }
      & > :last-child {
        margin-bottom: 0;
      }
      &:last-child {
        margin-bottom: 0;
      }
    }
  }

  & ul {
    list-style: none;
    padding-left: 0;
    margin: 0;
  }

  & li {
    margin-bottom: 0.5rem;

    &:last-child {
      margin-bottom: 0;
    }
  }

  & .pre {
    white-space: normal;
  }

  & .classifier::before {
    content: " : ";
    white-space: pre-wrap;
  }
}

@media (max-width: 500px) {
  main dl:has(> dt.sig-object) dl.field-list {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.25rem;

    & > dd {
      margin-bottom: 0.75rem;
    }
    & > dd:last-child {
      margin-bottom: 0;
    }
  }
}

/* Blockquotes and Admonitions */

blockquote {
  border: thin solid var(--black);
  background: var(--lightgray);
  border-left: 5px solid var(--black);
  padding: 0.05rem 1rem;
  margin-bottom: 1rem;
}

div.admonition,
div.note,
div.warning,
div.tip,
div.important {
  border: thin solid var(--black);
  background: var(--lightgray);
  border-left: 5px solid var(--black);
  padding: 0.05rem 1rem;
  margin-bottom: 1rem;

  & p.admonition-title {
    font-weight: bold;
    text-transform: uppercase;
  }
}

/* Tables */

table {
  margin-left: auto;
  margin-right: auto;
  max-width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--black);
  text-align: center;
  margin-bottom: 1rem;

  & th,
  & td {
    border: 1px solid var(--black);
    padding: 0.3rem 0.6rem;
  }
}

/* Images and Figures */

img {
  display: block;
  margin: 2em auto;
  max-width: 100%;
}

figcaption,
div.figure p.caption {
  font-size: 0.95em;
  text-align: center;
  font-style: italic;
  margin-bottom: 3em;
}

/* Topic and Contents Boxes */

div.topic {
  border: thin solid var(--black);
  background: var(--lightgray);
  padding: 0.5rem 1rem;
  margin-bottom: 1rem;
}

/* Sphinx Elements to Hide */

div.sphinxsidebar,
div.related {
  display: none;
}

/* Footer */

footer {
  color: var(--white);
  background-color: var(--black);
  margin-top: auto;
  padding: 0.5rem 0;
  text-align: center;
  box-shadow: var(--shadow);
  font-size: 1rem;

  & a {
    color: var(--white) !important;
  }
}

/* Download Buttons (nbsphinx Prolog) */

div.download-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;

  & a {
    flex: 1 1 calc(33.3% - 1rem);
    text-decoration: none;

    & button {
      width: 100%;
      font-size: 1rem;
      font-family: var(--font-family-code);
      background-color: var(--white);
      border: thin solid var(--black);
      box-shadow: 2px 2px var(--darkgray);
      transition: background-color 0.3s ease;
      color: var(--black);
      padding: 0.4rem 0.6rem;
      cursor: pointer;

      &:hover {
        background-color: var(--black);
        color: var(--white);
      }
    }
  }
}

/* Jupyter Notebook */

/* Use h3 styles for toctree and notebook gallery captions. */
div.toctree-wrapper p.caption {
  font-size: var(--h3-font-size);
  font-weight: bold;
  text-transform: uppercase;
  margin-bottom: 0;
}

.nbinput,
.nboutput {
  & .prompt {
    display: none;
  }
}

/* Center images inside output cells */
.nboutput {
  & img {
    display: block !important;
    margin: 0 auto !important;

    /* Hide the next element after an output image, including snapshot labels. */
    & + * {
      display: none;
    }
  }
}

/* 404 Page */

section.not-found {
  flex: 1;
}

/* Search Page */

#search-results > h2 {
  display: none;
}
