/* Sysand documentation theme.
 *
 * The docs keep the pydata-sphinx-theme layout (sidebar TOC, on-page nav,
 * search) but adopt the Sysand Index web app's visual identity so the two
 * sites feel like one product. We only re-point pydata's own CSS variables;
 * we do not restyle the app chrome.
 *
 * Design tokens mirror requirements-specification/design.md in the app repo.
 * The font files are the same self-hosted woff2 the app ships
 * (sysandindex/static/vendor/fonts/, fetched by scripts/fetch-vendor-assets.sh);
 * keep them in sync if the app's fonts change.
 */

/* === Self-hosted fonts (copied from the app's vendor bundle) === */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('../fonts/inter/inter-latin-variable.woff2') format('woff2');
}

@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('../fonts/jetbrains-mono/jetbrains-mono-latin-variable.woff2') format('woff2');
}

/* === Shared tokens === */
:root {
  --si-accent: #c2410c;
  --si-accent-hover: #9a3412;
  --si-accent-subtle: rgba(237, 137, 54, 0.12);

  --pst-font-family-base: 'Inter', var(--pst-font-family-base-system);
  --pst-font-family-heading: 'JetBrains Mono', var(--pst-font-family-base-system);
  --pst-font-family-monospace: 'JetBrains Mono', var(--pst-font-family-monospace-system);
}

/* === Light theme (pydata default mode) === */
html[data-theme="light"] {
  --pst-color-primary: var(--si-accent);
  --pst-color-primary-bg: var(--si-accent-subtle);
  /* pydata's secondary accent defaults to purple; map it onto the Sysand
     accent too so the back-to-top button (#pst-back-to-top) and any other
     secondary-colored controls stay on-theme. */
  --pst-color-secondary: var(--si-accent);
  --pst-color-secondary-bg: var(--si-accent-subtle);
  --pst-color-secondary-highlight: var(--si-accent-hover);
  /* pydata's accent (focus rings on the search field, tab labels, and other
     Bootstrap focus states) also defaults to purple/magenta. */
  --pst-color-accent: var(--si-accent);
  --pst-color-accent-bg: var(--si-accent-subtle);
  --pst-color-link: var(--si-accent);
  --pst-color-link-hover: var(--si-accent-hover);
  --pst-color-inline-code: var(--si-accent);
  --pst-color-inline-code-links: var(--si-accent);

  --pst-color-background: #ffffff;
  --pst-color-on-background: #f6f8fa;
  --pst-color-surface: #f6f8fa;
  --pst-color-border: #d1d9e0;
  --pst-color-text-base: #1f2328;
  --pst-color-text-muted: #57606a;
}

/* === Dark theme === */
html[data-theme="dark"] {
  --si-accent: #ed8936;
  --si-accent-hover: #dd6b20;
  --si-accent-subtle: rgba(237, 137, 54, 0.15);

  --pst-color-primary: var(--si-accent);
  --pst-color-primary-bg: var(--si-accent-subtle);
  /* pydata's secondary accent defaults to purple; map it onto the Sysand
     accent too so the back-to-top button (#pst-back-to-top) and any other
     secondary-colored controls stay on-theme. */
  --pst-color-secondary: var(--si-accent);
  --pst-color-secondary-bg: var(--si-accent-subtle);
  --pst-color-secondary-highlight: var(--si-accent-hover);
  /* pydata's accent (focus rings on the search field, tab labels, and other
     Bootstrap focus states) also defaults to purple/magenta. */
  --pst-color-accent: var(--si-accent);
  --pst-color-accent-bg: var(--si-accent-subtle);
  --pst-color-link: var(--si-accent);
  --pst-color-link-hover: var(--si-accent-hover);
  --pst-color-inline-code: var(--si-accent);
  --pst-color-inline-code-links: var(--si-accent);

  --pst-color-background: #0d1117;
  --pst-color-on-background: #161b22;
  --pst-color-surface: #161b22;
  --pst-color-border: #30363d;
  --pst-color-text-base: #e6edf3;
  --pst-color-text-muted: #8b949e;
}

/* === Brand wordmark in the navbar uses the heading (mono) font === */
.navbar-brand .title,
.sidebar-primary-item .navbar-brand .title {
  font-family: var(--pst-font-family-heading);
}

/* Keep the compact logo mark proportionate next to the wordmark. */
.navbar-brand img.logo__image {
  height: 1.75rem;
  width: auto;
}

/* Header brand and nav links are navigation chrome, not body links: keep
   hover/focus states to one accent indicator instead of pydata's link purple. */
.bd-header ul.navbar-nav.nav-underline > li.nav-item > .nav-link {
  border-bottom-color: transparent;
  box-shadow: none;
  text-decoration: none;
}

.bd-header ul.navbar-nav.nav-underline > li.nav-item > .nav-link::before {
  border-bottom-color: transparent;
}

.navbar-brand:is(:hover, :focus),
.bd-header ul.navbar-nav > li.nav-item > .nav-link:is(:hover, :focus, .active) {
  border-bottom-color: transparent;
  box-shadow: none;
  color: var(--pst-color-primary);
  text-decoration: none;
}

.bd-header ul.navbar-nav.nav-underline > li.nav-item > .nav-link:is(:hover, :focus, .active)::before {
  border-bottom-color: var(--pst-color-primary);
}

.bd-header .pst-navbar-icon {
  color: var(--pst-color-text-base);
}

.bd-header .pst-navbar-icon:is(:hover, :focus) {
  color: var(--pst-color-primary);
}

.bd-header .pst-navbar-icon::before,
.bd-header .pst-navbar-icon:is(:hover, :focus)::before {
  border-bottom-color: transparent;
}

/* === Keep the color mode toggle in the header on mobile === */
/* Below pydata's 960px breakpoint the navbar end folds into the hamburger
   sidebar, leaving only the persistent search icon in the header. Keep the
   end controls (the theme toggle) in the header next to that icon, and
   drop the sidebar's copy; the doc links keep living in the sidebar. The
   sidebar rule needs three classes because the theme shows the copy with a
   three-class selector. */
@media (max-width: 959.98px) {
  .bd-header .navbar-header-items {
    display: flex;
    flex-grow: 0;
    flex-shrink: 0;
    margin-left: auto;
  }

  .bd-header .navbar-header-items__center {
    display: none;
  }

  .bd-sidebar-primary .sidebar-header-items .sidebar-header-items__end {
    display: none;
  }

  /* On narrow phones the wordmark would push the icons off screen: let it
     shrink and ellipsize instead. Every flex level between the header row
     and the text needs min-width: 0, or its min-content size wins. */
  .bd-header .navbar-header-items__start,
  .bd-header .navbar-brand {
    flex-shrink: 1;
  }

  .bd-header .navbar-header-items__start,
  .bd-header .navbar-header-items__start .navbar-item,
  .bd-header .navbar-brand {
    min-width: 0;
  }

  .bd-header .navbar-brand .title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* The end controls above already include the persistent search button,
     so the theme's extra mobile copy would show search twice. */
  .bd-header .navbar-persistent--mobile {
    display: none;
  }
}

/* Heading permalinks should use the Sysand accent, not pydata's purple
   secondary link color. */
a.headerlink,
a.headerlink:hover,
a.headerlink:focus {
  color: var(--pst-color-primary);
  text-decoration: none;
}

/* === Inline code: subtle accent background like the app === */
code.literal,
.rst-content code:not(.xref) {
  background-color: var(--si-accent-subtle);
}

/* Console prompts ($, PS>) are visual cues, not part of the command: keep
   them out of text selection, matching the copybutton_exclude in conf.py. */
.highlight span.gp {
  user-select: none;
}
