/*
 * MkDocs Material — Shades of Purple site chrome.
 * Palette from docs/themes/shades-of-purple-shiki.json (VS Code theme).
 */

/* --- Dark (Material "slate" ↔ SOP) --- */
[data-md-color-scheme="slate"] {
  /* Page is darkest; code blocks use editor.background and read as elevated panels. */
  --sop-page-bg: #1e1e3f;
  --sop-sidebar-bg: #222244;
  --sop-editor-bg: #2d2b55;
  --sop-surface-1: #28284e;
  --sop-surface-2: #222244;
  --sop-surface-3: #1e1e3f;
  --sop-surface-4: #1f1f41;
  --sop-text: #ffffff;
  --sop-text-muted: #a599e9;
  --sop-text-soft: #cec5ff;
  --sop-purple: #6943ff;
  --sop-purple-bright: #b362ff;
  --sop-gold: #fad000;
  --sop-code-bg: var(--sop-editor-bg);

  /* mkdocstrings symbol badges (enum/member use custom templates). */
  --doc-symbol-enum-fg-color: #7ee8d3;
  --doc-symbol-enum-bg-color: #7ee8d324;
  --doc-symbol-member-fg-color: #ffd866;
  --doc-symbol-member-bg-color: #ffd86624;

  --md-hue: 255deg;

  --md-default-fg-color: #ffffffde;
  --md-default-fg-color--light: #a599e9;
  --md-default-fg-color--lighter: #a599e98a;
  --md-default-fg-color--lightest: #a599e924;

  --md-default-bg-color: var(--sop-page-bg);
  --md-default-bg-color--light: #222244b3;
  --md-default-bg-color--lighter: #28284e80;
  --md-default-bg-color--lightest: #2d2b5547;

  --md-primary-fg-color: #1e1e3f;
  --md-primary-fg-color--light: #6943ff;
  --md-primary-fg-color--dark: #161633;
  --md-primary-bg-color: #ffffff;
  --md-primary-bg-color--light: #ffffffb3;

  --md-accent-fg-color: #fad000;
  --md-accent-fg-color--transparent: #fad0001a;
  --md-accent-bg-color: var(--sop-page-bg);
  --md-accent-bg-color--light: #222244b3;

  --md-code-fg-color: #e3dfff;
  --md-code-bg-color: var(--sop-code-bg);

  --md-footer-fg-color: #a599e9;
  --md-footer-bg-color: #1e1e3f;

  --md-typeset-color: var(--md-default-fg-color);
  --md-typeset-a-color: #b362ff;

  --md-typeset-table-color: #a599e93d;

  --md-admonition-bg-color: #222244;
  --md-admonition-fg-color: var(--md-default-fg-color);

  --md-typeset-kbd-color: var(--md-default-fg-color);
  --md-typeset-kbd-accent-color: var(--sop-gold);
  --md-typeset-kbd-border-color: #6943ff;
}

/* No rubber-band overscroll past the page or sidebar scroll ends. */
html,
body {
  overscroll-behavior: none;
}

.md-sidebar__scrollwrap,
.md-search__scrollwrap {
  overscroll-behavior: none;
}

[data-md-color-scheme="slate"] .md-header {
  background-color: #1e1e3f;
  color: #ffffff;
}

[data-md-color-scheme="slate"] .md-tabs {
  background-color: #1e1e3f;
  color: #a599e9;
}

[data-md-color-scheme="slate"] .md-tabs__link--active,
[data-md-color-scheme="slate"] .md-tabs__link:hover {
  color: #fad000;
}

/* Breadcrumbs (navigation.path) */
[data-md-color-scheme="slate"] .md-path__item {
  color: #a599e9;
}

[data-md-color-scheme="slate"] .md-path__item--active {
  color: #fad000;
}

/* Linked content tabs */
[data-md-color-scheme="slate"] .tabbed-labels label {
  color: #a599e9;
}

[data-md-color-scheme="slate"] .tabbed-labels label:hover,
[data-md-color-scheme="slate"] .tabbed-set > input:checked + label {
  color: #fad000;
}

[data-md-color-scheme="slate"] .tabbed-set {
  border-color: #6943ff44;
}

/* Back-to-top (navigation.top) */
[data-md-color-scheme="slate"] .md-top {
  background-color: #6943ff;
  color: #1e1e3f;
}

[data-md-color-scheme="slate"] .md-top:hover {
  background-color: #fad000;
}

/* Mermaid diagrams */
[data-md-color-scheme="slate"] .mermaid {
  --md-mermaid-edge-color: #a599e9;
  --md-mermaid-node-bg-color: #2d2b55;
  --md-mermaid-node-fg-color: #e3dfff;
  --md-mermaid-label-bg-color: #222244;
  --md-mermaid-label-fg-color: #fad000;
}

/*
 * Material pins sidebars with height:0 + position:sticky. Forcing height:auto makes
 * the sticky box as tall as the nav, so both sidebars jump upward at page bottom.
 * Keep height:0 placeholders in the flex row; pin the scroll columns to the viewport.
 */
@media screen and (min-width: 60em) {
  .md-sidebar--secondary {
    height: 0 !important;
    max-height: none !important;
  }

  .md-sidebar--secondary .md-sidebar__scrollwrap {
    box-sizing: border-box;
    /* 4.8rem = header (2.4rem) + navigation.tabs (2.4rem); see Material .md-header--lifted */
    height: calc(100vh - 4.8rem) !important;
    max-height: calc(100vh - 4.8rem) !important;
    min-height: calc(100vh - 4.8rem) !important;
    position: fixed !important;
    top: 4.8rem !important;
    width: 12.1rem !important;
  }

  [dir="ltr"] .md-sidebar--secondary .md-sidebar__scrollwrap {
    left: max(0px, calc((100vw - 61rem) / 2 + 61rem - 12.1rem)) !important;
    right: auto !important;
  }

  [dir="rtl"] .md-sidebar--secondary .md-sidebar__scrollwrap {
    left: auto !important;
    right: max(0px, calc((100vw - 61rem) / 2)) !important;
  }
}

@media screen and (min-width: 76.25em) {
  .md-sidebar--primary {
    height: 0 !important;
    max-height: none !important;
  }

  .md-sidebar--primary .md-sidebar__scrollwrap {
    box-sizing: border-box;
    height: calc(100vh - 4.8rem) !important;
    max-height: calc(100vh - 4.8rem) !important;
    min-height: calc(100vh - 4.8rem) !important;
    position: fixed !important;
    top: 4.8rem !important;
    width: 12.1rem !important;
  }

  [dir="ltr"] .md-sidebar--primary .md-sidebar__scrollwrap {
    left: max(0px, calc((100vw - 61rem) / 2)) !important;
    right: auto !important;
  }

  [dir="rtl"] .md-sidebar--primary .md-sidebar__scrollwrap {
    left: auto !important;
    right: max(0px, calc((100vw - 61rem) / 2 + 61rem - 12.1rem)) !important;
  }
}

/* Wide layout: Material sets .md-sidebar { height: 0 }; paint the scroll column. */
[data-md-color-scheme="slate"] .md-sidebar--primary,
[data-md-color-scheme="slate"] .md-sidebar--secondary,
[data-md-color-scheme="slate"] .md-sidebar--primary .md-sidebar__scrollwrap,
[data-md-color-scheme="slate"] .md-sidebar--primary .md-sidebar__inner,
[data-md-color-scheme="slate"] .md-sidebar--secondary .md-sidebar__scrollwrap,
[data-md-color-scheme="slate"] .md-sidebar--secondary .md-sidebar__inner {
  background-color: var(--sop-sidebar-bg);
}

[data-md-color-scheme="slate"] .md-sidebar--primary .md-sidebar__scrollwrap,
[data-md-color-scheme="slate"] .md-sidebar--secondary .md-sidebar__scrollwrap {
  /* Material's 0.2rem side margins + stable scrollbar gutter make sticky
     title bands look wider than the links below. */
  margin-left: 0;
  margin-right: 0;
  overflow-x: clip;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

/* Drawer markup: list still uses page bg unless overridden. */
[data-md-color-scheme="slate"] .md-sidebar--primary .md-nav--primary .md-nav__title ~ .md-nav__list {
  background-color: var(--sop-sidebar-bg);
  box-shadow: none;
}

/* TOC: scroll-padding keeps toc.follow from hiding items under the sticky title. */
@media screen and (min-width: 60em) {
  [data-md-color-scheme="slate"] .md-sidebar--secondary .md-sidebar__scrollwrap {
    scroll-padding-top: 2.75rem;
  }
}

/* Sticky sidebar headers (site title + TOC) use page bg + spread shadow by default. */
[data-md-color-scheme="slate"] .md-sidebar--primary .md-nav--primary > .md-nav__title,
[data-md-color-scheme="slate"] .md-sidebar--secondary .md-nav--secondary > .md-nav__title {
  background-color: var(--sop-sidebar-bg) !important;
  box-shadow: none !important;
  box-sizing: border-box;
  margin: 0;
  padding-left: 0.6rem;
  padding-right: 0.6rem;
  width: 100%;
}

[data-md-color-scheme="slate"] .md-sidebar--primary .md-nav--primary > .md-nav__title::after,
[data-md-color-scheme="slate"] .md-sidebar--secondary .md-nav--secondary > .md-nav__title::after {
  display: none;
}

[data-md-color-scheme="slate"] .md-sidebar--primary .md-nav--primary > .md-nav__list,
[data-md-color-scheme="slate"] .md-sidebar--secondary .md-nav--secondary > .md-nav__list {
  padding-left: 0.6rem;
  padding-right: 0.6rem;
}

/* Primary nav only — do not style the TOC sidebar like the section nav. */
[data-md-color-scheme="slate"] .md-sidebar--primary .md-nav__link:focus,
[data-md-color-scheme="slate"] .md-sidebar--primary .md-nav__link:hover,
[data-md-color-scheme="slate"] .md-sidebar--primary .md-nav__link--active {
  color: #fad000;
}

[data-md-color-scheme="slate"] .md-sidebar--primary .md-nav__item > .md-nav__link--active {
  background-color: #2d2b5580;
  padding: 0.2rem;
  border-radius: 0.3rem;
}

/* Table of contents (right sidebar) */
[data-md-color-scheme="slate"] .md-sidebar--secondary .md-nav--secondary > .md-nav__title {
  color: #a599e9;
  position: sticky;
  top: 0;
  z-index: 2;
}

[data-md-color-scheme="slate"] .md-sidebar--secondary .md-nav--secondary .md-nav__link {
  color: #a599e9;
  position: relative;
  padding-left: 0.5rem;
  margin-right: 0;
}

[data-md-color-scheme="slate"] .md-sidebar--secondary .md-nav--secondary .md-nav__link:focus,
[data-md-color-scheme="slate"] .md-sidebar--secondary .md-nav--secondary .md-nav__link:hover {
  color: #cec5ff;
}

/* TOC scroll-spy uses data-urdf-toc-active (see toc-scrollspy.js). */
[data-md-color-scheme="slate"]
  .md-sidebar--secondary
  .md-nav--secondary
  .md-nav__link[data-urdf-toc-active="true"] {
  color: #fad000;
  background-color: transparent;
  box-shadow: none;
}

[data-md-color-scheme="slate"]
  .md-sidebar--secondary
  .md-nav--secondary
  .md-nav__link[data-urdf-toc-active="true"]::before {
  background-color: #fad000;
  border-radius: 1px;
  bottom: 0.2em;
  content: "";
  left: 0;
  position: absolute;
  top: 0.2em;
  width: 0.15rem;
}

/* Material may still toggle md-nav__link--active when toc.follow was enabled; never show two indicators. */
[data-md-color-scheme="slate"]
  .md-sidebar--secondary
  .md-nav--secondary
  .md-nav__link--active:not([data-urdf-toc-active="true"]) {
  color: #a599e9;
}

[data-md-color-scheme="slate"]
  .md-sidebar--secondary
  .md-nav--secondary
  .md-nav__link--active:not([data-urdf-toc-active="true"])::before {
  content: none;
}

/* TOC duplicated inside the mobile drawer */
[data-md-color-scheme="slate"] .md-nav--primary .md-nav--secondary > .md-nav__title {
  background-color: var(--sop-sidebar-bg) !important;
  box-shadow: none !important;
}

[data-md-color-scheme="slate"] .md-search__input {
  background-color: #28284e;
  color: #fad000;
}

[data-md-color-scheme="slate"] .md-search__input::placeholder {
  color: #a599e9;
}

[data-md-color-scheme="slate"] .md-main,
[data-md-color-scheme="slate"] .md-content,
[data-md-color-scheme="slate"] .md-content__inner {
  background-color: var(--sop-page-bg);
}

[data-md-color-scheme="slate"] .md-typeset hr {
  border-bottom-color: #6943ff55;
}

[data-md-color-scheme="slate"] .md-typeset blockquote {
  border-left-color: #6943ff;
  background-color: #1e1e3f;
  color: #cec5ff;
}

[data-md-color-scheme="slate"] .md-typeset :not(pre) > code {
  background-color: #1e1e3f;
  color: #fad000;
  border: 1px solid #6943ff44;
}

[data-md-color-scheme="slate"] .md-typeset table:not([class]) {
  background-color: #222244;
  border: 1px solid #6943ff33;
}

[data-md-color-scheme="slate"] .md-typeset table:not([class]) th {
  background-color: #1e1e3f;
  color: #fad000;
}

[data-md-color-scheme="slate"] .md-typeset table:not([class]) tr:hover {
  background-color: #2d2b5580;
}

[data-md-color-scheme="slate"] .md-typeset .admonition {
  border-color: #6943ff66;
  background-color: #222244;
}

[data-md-color-scheme="slate"] .md-typeset details {
  border-color: #6943ff44;
  background-color: #222244;
}

[data-md-color-scheme="slate"] .md-typeset .tabbed-labels {
  border-color: #6943ff44;
  background-color: #1e1e3f;
}

[data-md-color-scheme="slate"] .md-typeset .tabbed-labels > label:hover {
  color: #fad000;
}

[data-md-color-scheme="slate"] .md-typeset .tabbed-set {
  border-color: #6943ff33;
}

[data-md-color-scheme="slate"] .md-typeset .doc,
[data-md-color-scheme="slate"] .md-typeset .doc-contents {
  color: var(--md-default-fg-color);
}

[data-md-color-scheme="slate"] .md-typeset .doc-summary {
  border-color: #6943ff44;
}

/* Signature / param code in headings — not symbol badges or decorator labels */
[data-md-color-scheme="slate"] .md-typeset .doc-heading code:not(.doc-symbol):not(.doc-labels code) {
  background-color: #1e1e3f;
  color: #fad000;
}
