/* Copyright (c) 2026 ttldtor.
 * SPDX-License-Identifier: BSL-1.0
 */

.mermaidgraph {
  margin: 1.5em 0;
}

/* Theme-specific illustrations preserve the standard Markdown image. */
.turbo-diagram { display: none; }

.mermaidgraph img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  background: white;
  border-radius: 6px;
}

/* SVG illustrations have their own light palette; adapt it with the page. */
html.dark-mode .mermaidgraph img,
html.dark-mode .contents :is(img[src$="components.svg"], object[data$="components.svg"]),
html.dark-mode .contents :is(img[src$="event-flow.svg"], object[data$="event-flow.svg"]),
html.dark-mode .contents :is(img[src$="ownership.svg"], object[data$="ownership.svg"]) {
  filter: invert(0.88) hue-rotate(180deg);
  background: transparent;
}

@media (prefers-color-scheme: dark) {
  html:not(.light-mode) { --primary-color: #58a6ff; }
  html:not(.light-mode) .mermaidgraph img,
  html:not(.light-mode) .contents :is(img[src$="components.svg"], object[data$="components.svg"]),
  html:not(.light-mode) .contents :is(img[src$="event-flow.svg"], object[data$="event-flow.svg"]),
  html:not(.light-mode) .contents :is(img[src$="ownership.svg"], object[data$="ownership.svg"]) {
    filter: invert(0.88) hue-rotate(180deg);
    background: transparent;
  }
}

html.dark-mode { --primary-color: #58a6ff; }

.contents .image object[type="image/svg+xml"] {
  max-width: 100%;
  height: auto;
}
/* Page-level language navigation remains usable without JavaScript. */
.portals-languages {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: center;
  gap: 0.25rem;
  padding: 0;
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
}
.portals-languages [aria-current="page"] { font-weight: bold; }
.portals-languages a:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }

/* Put compact utilities beside the project name, leaving search its own row. */
html {
  --top-height: 112px;
  --side-nav-arrow-opacity: 0.7;
  --side-nav-arrow-hover-opacity: 1;
}

#titlearea { position: relative; }
#projectname { padding-right: 7rem; }
.portals-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
#titlearea .portals-languages {
  position: absolute;
  top: 0.75rem;
  right: 1rem;
  flex-wrap: nowrap;
  margin: 0;
}

.portals-languages > :is(a, span) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  min-height: 1.75rem;
  border-radius: var(--border-radius-small);
}

.portals-languages [aria-current="page"] {
  background: var(--code-background);
}

.portals-appearance {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  margin-left: auto;
  padding: 0;
  color: var(--page-foreground-color);
  background: transparent;
  border: 1px solid var(--separator-color);
  border-radius: var(--border-radius-small);
  cursor: pointer;
}

.portals-appearance[hidden] { display: none; }
.portals-appearance svg { width: 1rem; height: 1rem; }
.portals-appearance:hover { background: var(--code-background); }
.portals-appearance:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Reserve space for the fixed synchronization control below the tree. */
#nav-tree-contents { padding-bottom: 3rem; }

/* Keep the native link target over the complete row, including its indent. */
#nav-tree .item { position: relative; }
#nav-tree .item > .label > a::after {
  content: "";
  position: absolute;
  inset: 0;
}
/* Disclosure buttons retain their own hit area above the row's link. */
#nav-tree .item > a[role="button"] { position: relative; z-index: 1; }
#nav-tree .selected::after { pointer-events: none; }

/* Give the rotating chevron a stable box independent of the text baseline. */
#nav-tree .arrow {
  display: inline-flex;
  align-items: center;
  height: var(--tree-item-height);
  padding-right: 0.4rem;
  vertical-align: top;
}

#nav-tree .item > a[role="button"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
}

#nav-tree .item > a:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: -2px;
  border-radius: 3px;
}

/* Replace the border-square rotation with two static disclosure shapes. */
span.arrowhead,
span.arrowhead.opened,
.selected span.arrowhead {
  width: 12px;
  height: 12px;
  margin: 0;
  border: 0;
  transform: none;
  transition: none;
  vertical-align: middle;
}

#nav-tree span.arrowhead { margin: 0; }
span.arrowhead::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--primary-color);
  clip-path: polygon(35% 20%, 75% 50%, 35% 80%);
}

span.arrowhead.opened::before {
  clip-path: polygon(20% 35%, 80% 35%, 50% 75%);
}

@media screen and (min-width: 768px) {
  #doc-content { padding-top: 0; }
  #nav-sync { left: calc(var(--side-nav-fixed-width) - 40px); }
  /* Doxygen 1.18's ID selector otherwise restores the fixed sidebar's handle. */
  #splitbar { display: none; }
}

/* Markdown screenshots and animations fit the reading column. */
#doc-content img.inline,
#doc-content .image img {
  max-width: 100%;
  height: auto;
}

/* Inline commands are prose; wide code blocks retain their own scrolling. */
.contents :is(p, li) :is(code, .tt) {
  white-space: normal;
  overflow-wrap: anywhere;
}

/* Keep guide and reference gutters stable beside either navigation panel. */
html:not(.turbo-mode) {
  --content-maxwidth: 100%;
  --portals-content-gutter: 16px;
}

html:not(.turbo-mode) div.contents {
  margin-inline: var(--portals-content-gutter);
  padding-inline: 0;
}

html:not(.turbo-mode) div.header .title {
  margin-inline: 0;
  padding-inline: var(--portals-content-gutter);
}

/* A wide child must not force the reading column beyond its flex container. */
html:not(.turbo-mode) div.contents .textblock { min-width: 0; }

/* Vendor full-bleed code margins assume padding on the reading column. */
html:not(.turbo-mode) .contents :is(div.fragment, pre.fragment) {
  margin-inline: 0;
}

html:not(.turbo-mode) .contents :is(center, .center) {
  width: auto;
  max-width: 100%;
  margin-inline: 0;
}

/* Wrap the displayed source without changing the text copied from it. */
html:not(.turbo-mode) .contents div.fragment div.line {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: normal;
}

/* API signatures reflow inside the panel instead of a table's intrinsic width. */
html:not(.turbo-mode) .memproto table.memname,
html:not(.turbo-mode) .memproto table.memname > tbody,
html:not(.turbo-mode) .memproto table.memname > tbody > tr {
  display: block;
  width: auto;
  max-width: 100%;
  margin: 0;
}
html:not(.turbo-mode) .memproto table.memname td {
  display: inline;
  padding: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}
html:not(.turbo-mode) .memproto table.memname td.paramtype { padding-right: 0.5ch; }
html:not(.turbo-mode) .memproto :is(.memtemplate, .paramname, .paramdefval) {
  white-space: normal;
  overflow-wrap: anywhere;
}
html:not(.turbo-mode) table.memberdecls { width: 100%; }
html:not(.turbo-mode) table.memberdecls :is(.memItemLeft, .memTemplItemLeft, .mdescLeft) {
  width: 32%;
}
html:not(.turbo-mode) table.memberdecls td { overflow-wrap: anywhere; white-space: normal; }

@media screen and (max-width: 767px) {
  html:not(.turbo-mode) .contents table.memberdecls,
  html:not(.turbo-mode) .contents table.memberdecls > tbody,
  html:not(.turbo-mode) .contents table.memberdecls > tbody > tr,
  html:not(.turbo-mode) .contents table.memberdecls > tbody > tr > td {
    display: block;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    margin-inline: 0;
  }
}

/* Keep full overload signatures readable outside the scrollable navigation. */
#nav-tree .item:has([data-overload-signature]) {
  display: flex;
  align-items: flex-start;
  height: auto;
  min-height: var(--tree-item-height);
  overflow: visible;
  white-space: normal;
}
#nav-tree .item:has([data-overload-signature]) > .arrow { flex: 0 0 auto; }
#nav-tree .label:has([data-overload-signature]) { min-width: 0; flex: 1; }
#nav-tree .label:has([data-overload-signature]) a {
  display: block;
  padding-block: 4px;
  line-height: 1.5;
  white-space: normal;
  overflow-wrap: anywhere;
}

.portals-overload-tooltip {
  position: fixed;
  z-index: 10000;
  box-sizing: border-box;
  max-width: min(42rem, calc(100vw - 16px));
  max-height: calc(100vh - 16px);
  overflow: auto;
  padding: 8px 12px;
  border: 1px solid var(--separator-color);
  background: var(--page-background-color);
  color: var(--page-foreground-color);
  font-family: var(--font-family-monospace);
  white-space: normal;
  overflow-wrap: anywhere;
  pointer-events: none;
}

/* Static previews share the documentation palette and retain terminal colors. */
.widget-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
  gap: 2rem 1.5rem;
  margin: 1.25rem 0 2.5rem;
}
.widget-gallery-card { min-width: 0; }
.contents .widget-gallery-card h3 {
  margin: 0 0 .5rem;
  padding: 0;
  border: 0;
}
.widget-gallery-card p { margin: .5rem 0; }
.widget-gallery-card a:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 4px;
}
.widget-gallery-card img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  box-sizing: border-box;
  border: 1px solid var(--separator-color);
  border-radius: var(--border-radius-small);
}
