/* mkdocs-back-links — backlinks section + graph pane */

/* Theming hooks — override via the `graph.colors` plugin config or directly
   in your own extra.css. Defaults track the Material theme. */
:root {
  --mbl-graph-node-fill: #37474f;
  --mbl-graph-section-fill: #b0bec5;
  --mbl-graph-current-fill: var(--md-accent-fg-color);
  --mbl-graph-current-stroke: var(--md-primary-fg-color);
  --mbl-graph-link: var(--md-default-fg-color--lighter);
  --mbl-graph-highlight: var(--md-accent-fg-color);
  --mbl-graph-label: var(--md-default-fg-color--light);
  --mbl-graph-current-label: var(--md-primary-fg-color);
}

[data-md-color-scheme="slate"] {
  --mbl-graph-node-fill: #cfd8dc;
  --mbl-graph-section-fill: #78909c;
}

/* All selectors are scoped under .md-typeset to override Material's
   default typography (which would otherwise render the section as a
   full-size body heading + large list). */

.md-typeset .mbl-backlinks {
  margin-top: 3rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--md-default-fg-color--lightest);
  font-size: 0.8em;
  line-height: 1.5;
  /* Lock to the graph pane's height. Combined with JS lifting the pane to
     match this block's bottom y when in viewport, this makes the two
     border-tops land on the same y at the end of the article. Falls back
     to natural sizing when the pane isn't present. overflow-y handles the
     edge case of more inbound links than the pane is tall. */
  height: var(--mbl-pane-height, auto);
  overflow-y: auto;
  box-sizing: border-box;
}

.md-typeset .mbl-backlinks h2 {
  font-size: inherit;
  font-weight: 600;
  margin: 0 0 0.4em;
  padding: 0;
  border: 0;
  background: none;
  color: var(--md-default-fg-color--light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.md-typeset .mbl-backlinks ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.md-typeset .mbl-backlinks li {
  margin: 0.15em 0;
}

.md-typeset .mbl-backlinks a {
  color: var(--md-typeset-a-color);
  text-decoration: none;
}

.md-typeset .mbl-backlinks a:hover {
  text-decoration: underline;
}

/* --- Graph pane (sticky bottom of secondary sidebar) --- */

.mbl-graph-pane {
  position: fixed;
  bottom: 0;
  background: var(--md-default-bg-color);
  border-top: 1px solid var(--md-default-fg-color--lightest);
  display: flex;
  flex-direction: column;
  z-index: 2;
}

.mbl-graph-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.6rem;
  font-size: 0.75rem;
}

.mbl-graph-header h3 {
  margin: 0;
  font-size: inherit;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--md-default-fg-color--light);
  text-decoration: none;
  border-bottom: 0;
}

.mbl-graph-expand,
.mbl-graph-close {
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--md-default-fg-color--light);
  font-size: 1rem;
  line-height: 1;
  padding: 0.1rem;
  display: inline-flex;
  align-items: center;
}

.mbl-graph-expand:hover,
.mbl-graph-close:hover {
  color: var(--md-primary-fg-color);
}

.mbl-graph-expand svg,
.mbl-graph-close svg {
  display: block;
}

.mbl-graph-svg {
  flex: 0 0 auto;
  align-self: center;
  width: calc(100% - 0.8rem);
  aspect-ratio: 1 / 1;
  cursor: grab;
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: 0.4rem;
  margin: 0.4rem;
  background: var(--md-default-bg-color);
  box-sizing: border-box;
}

.mbl-graph-svg:active { cursor: grabbing; }

.mbl-graph-node {
  fill: var(--mbl-graph-node-fill);
  cursor: pointer;
  transition: fill 120ms ease-out, opacity 150ms ease-out;
}

.mbl-graph-node:hover {
  fill: var(--mbl-graph-highlight);
}

.mbl-graph-node--current {
  fill: var(--mbl-graph-current-fill);
  stroke: var(--mbl-graph-current-stroke);
  stroke-width: 2;
}

.mbl-graph-node--faded { opacity: 0.18; }

.mbl-graph-link {
  stroke: var(--mbl-graph-link);
  stroke-opacity: 0.9;
  transition: stroke 150ms ease-out, stroke-opacity 150ms ease-out, stroke-width 150ms ease-out;
}

.mbl-graph-link--active {
  stroke: var(--mbl-graph-highlight);
  stroke-opacity: 1;
  stroke-width: 2;
}

.mbl-graph-link--faded {
  stroke-opacity: 0.12;
}

.mbl-graph-label {
  font-size: 0.7rem;
  font-family: var(--md-text-font-family, system-ui), sans-serif;
  fill: var(--mbl-graph-label);
  pointer-events: none;
  user-select: none;
  transition: opacity 150ms ease-out, font-size 150ms ease-out, fill 150ms ease-out;
  transform-box: fill-box;
  transform-origin: left center;
}

.mbl-graph-label--current {
  fill: var(--mbl-graph-current-label);
  font-weight: 600;
}

.mbl-graph-label--faded { opacity: 0.25; }

.mbl-graph-label--hover {
  font-weight: 600;
  font-size: 1.05rem;
}

/* Modal overlay for expanded view */
.mbl-graph-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 200ms ease-out;
}

.mbl-graph-modal--open {
  opacity: 1;
}

.mbl-graph-modal--closing {
  opacity: 0;
}

.mbl-graph-modal__inner {
  background: var(--md-default-bg-color);
  width: min(90vw, 1100px);
  height: min(85vh, 800px);
  display: flex;
  flex-direction: column;
  border-radius: 0.6rem;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  transform: scale(0.92);
  opacity: 0;
  transition: transform 250ms cubic-bezier(0.2, 0.8, 0.2, 1), opacity 200ms ease-out;
}

.mbl-graph-modal--open .mbl-graph-modal__inner {
  transform: scale(1);
  opacity: 1;
}

.mbl-graph-modal--closing .mbl-graph-modal__inner {
  transform: scale(0.92);
  opacity: 0;
}

/* --- Section nodes & contains edges --- */
.mbl-graph-node--section {
  fill: var(--mbl-graph-section-fill);
  r: 5;
}

.mbl-graph-link--contains {
  stroke-dasharray: 3 3;
  stroke-opacity: 0.75;
}

/* --- Scrolled-into-view indicator (distinct from hover) --- */
.mbl-graph-node--scrolled {
  stroke: var(--mbl-graph-current-stroke);
  stroke-width: 2;
  stroke-opacity: 0.9;
}

.mbl-graph-label--scrolled {
  font-weight: 600;
}

/* --- Clustered sections: hidden by default, revealed when scrolled into view --- */
.mbl-graph-node--clustered,
.mbl-graph-label--clustered,
.mbl-graph-link--clustered {
  display: none;
}

.mbl-graph-node--clustered.mbl-graph-node--scrolled,
.mbl-graph-label--clustered.mbl-graph-label--scrolled,
.mbl-graph-link--clustered.mbl-graph-link--scrolled {
  display: unset;
}

/* --- Per-section backlinks aside --- */
.md-typeset .mbl-section-backlinks {
  margin: 1.5em 0 1em;
  padding-top: 0.4em;
  border-top: 1px solid var(--md-default-fg-color--lightest);
  font-size: 0.8em;
  line-height: 1.5;
}

.md-typeset .mbl-section-backlinks h3 {
  font-size: inherit;
  font-weight: 600;
  margin: 0 0 0.3em;
  padding: 0;
  border: 0;
  color: var(--md-default-fg-color--light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.md-typeset .mbl-section-backlinks ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.md-typeset .mbl-section-backlinks li {
  margin: 0.15em 0;
}

.md-typeset .mbl-section-backlinks a {
  color: var(--md-typeset-a-color);
  text-decoration: none;
}

.md-typeset .mbl-section-backlinks a:hover {
  text-decoration: underline;
}

.md-typeset .mbl-section-backlinks summary {
  cursor: pointer;
  color: var(--md-default-fg-color--light);
}
