/* Website brand tokens: web-base.css defines the --mg-* palette and fonts;
   these map the theme's variables onto them. Text in the accent reads
   web-base's --mg-ochre-text, AA on every surface in both themes; the brand
   --mg-ochre is for fills, borders and rules only (Magma-Maths/web-base#80). */

:root,
html[data-theme="light"] {
  /* Fonts */
  --pst-font-family-base: var(--mg-font-sans);
  --pst-font-family-heading: var(--mg-font-sans);
  --pst-font-family-monospace: var(--mg-font-mono);

  /* Sampled from the Magma logo's triangle/chevrons (MagmaLogoOfficial.png).
     --mh- is the Handbook's own prefix; --mg- means web-base's (#2893). */
  --mh-logo-red: #A93E28;

  /* The secondary accents (--mg-purple, --mg-teal, --mg-amber and their
     -text variants) are web-base's, for its citation cards and here. */

  --pst-color-primary-bg: rgba(230, 71, 37, 0.12);
  --pst-color-secondary-bg: rgba(200, 63, 30, 0.12);

  /* Match the main Magma website's compact header. */
  --pst-header-height: 60px;
}

html[data-theme="dark"] {
  /* web-base keeps the brand --mg-ochre as the fixed brand coral in both
     themes; only --mg-ochre-text follows the dark palette. */
  --mh-logo-red: var(--mg-ochre-text);

  --pst-color-primary-bg: color-mix(in srgb, var(--mg-ochre-text) 18%, transparent);
  --pst-color-secondary-bg: color-mix(in srgb, var(--mg-ochre-text) 18%, transparent);

  /* web-base 0.6.3's dark input border (Gruvbox's bg3) is 2.0:1 on its
     input background, short of the 3:1 a field's edge needs (WCAG 1.4.11):
     the border lifted halfway to web-base's muted text, 3.6:1, resolved
     here, where the border token is still web-base's own. */
  --mh-field-edge: color-mix(in srgb, var(--mg-text-muted) 50%, var(--mg-input-border));
}

/* The handbook's search fields, the results page's (magma-search.css, a
   copy of web-base's search) and the home page's line, take that edge. */
html[data-theme="dark"] .pf-page,
html[data-theme="dark"] .pf-inline-search {
  --mg-input-border: var(--mh-field-edge);
}

:root,
html[data-theme="light"],
html[data-theme="dark"] {
  /* Backgrounds */
  --pst-color-background: var(--mg-bg);
  --pst-color-on-background: var(--mg-white);
  --pst-color-surface: var(--mg-sandstone);

  /* Text */
  --pst-color-text-base: var(--mg-text);
  --pst-color-text-muted: var(--mg-text-muted);
  --pst-color-heading: var(--mg-black);
  /* The theme's h1-h4 read this first, and fall back to the text colour
     rather than to --pst-color-heading when it is unset. */
  --pst-heading-color: var(--pst-color-heading);
  /* sphinx-book-theme colors h1-h5/captions via this variable instead of
     --pst-color-heading (see _typography.scss / _sidebar-secondary.scss) */
  --pst-color-muted: var(--mg-black);

  /* Borders */
  --pst-color-border: var(--mg-border);
  --pst-color-border-muted: var(--mg-border);

  /* Accent / links. The theme paints all of these as text (headerlinks,
     current nav items and tabs, hovered nav links). Hover keeps the colour:
     web-base's --mg-ochre-hover is short of AA as text, and the theme
     thickens a hovered link's underline, which marks it without colour. */
  --pst-color-primary: var(--mg-ochre-text);
  --pst-color-secondary: var(--mg-ochre-text);
  --pst-color-link: var(--mg-ochre-text);
  --pst-color-link-hover: var(--mg-ochre-text);
  /* Muted (not ochre) so plain inline code doesn't read as a link; theme
     default here is a leftover purple (#912583) unrelated to the brand. */
  --pst-color-inline-code: var(--pst-color-text-muted);
  /* The colour of inline code inside a link. */
  --pst-color-link-higher-contrast: var(--mg-ochre-text);

  /* Keyboard focus rings (search box, nav links, buttons, cards, copy
     button, toctree toggles): theme default here is a leftover magenta
     (#c132af) unrelated to the brand. */
  --pst-color-accent: var(--mg-ochre-text);
  --pst-color-accent-bg: var(--pst-color-primary-bg);

  /* Header chrome, kept as aliases because the header and sidebar rules
     below read them. */
  --mh-chrome-bg: var(--mg-bg);
  --mh-chrome-text: var(--mg-text);
  --mh-chrome-border: var(--mg-border);
  --mh-chrome-accent: var(--mg-ochre-text);
}

/* Website-style header: web-base's own (handbook-header.html), on the
   theme's header element. Theme-reactive background (issue #328) -- see the
   --mh-chrome-* tokens above, aliased onto this site's own theme tokens.
   The theme's !important background and shadow need the override. */
.bd-header {
  background: var(--mh-chrome-bg) !important;
  box-shadow: none;
}

/* web-base's .mg-site-header sets z-index 100 for a page with nothing else
   fixed; the theme's sidebars and dialogs are layered against its own 1030. */
.bd-header.mg-site-header {
  z-index: 1030;
}

/* --pst-header-height (60px) is the header row alone, so the theme's sticky
   sidebars sat under the header (#383): offset them by --mg-header-height,
   which web-base builds from the row, its padding and its border. Below
   960px the theme's drawer sets its own top. magma-parameter.css offsets the
   secondary sidebar itself, as its !important rules would beat this one. */
@media (min-width: 960px) {
  .bd-sidebar-primary {
    top: var(--mg-header-height);
    max-height: calc(100vh - var(--mg-header-height));
  }
}

/* For a browser without :has(), which drops web-base's scroll padding rule. */
html {
  scroll-padding-top: calc(var(--mg-header-height) + 1rem);
}

/* On a short viewport (a landscape phone, or 400% zoom) the sticky header
   takes a third of the height: let it scroll away instead. The :has() ties
   with web-base's scroll padding rule, which an html rule would not outrank. */
@media (max-height: 30em) {
  .bd-header {
    position: static;
  }

  html:has(.mg-site-header) {
    scroll-padding-top: 1rem;
  }
}

@media (min-width: 960px) and (max-height: 30em) {
  .bd-sidebar-primary {
    top: 0;
    max-height: 100vh;
  }
}

/* The loaded nav's math is typeset after the article's; hide its raw TeX
   ("\(KG\)-Modules") until then (#2949). global-sidebar-nav.js marks it
   pending until MathJax is done with it, or has not come at all. */
.magma-global-sidebar-nav[data-math-pending] .math {
  visibility: hidden;
}

/* The theme's on-this-page toggle in web-base's icon button: the theme draws
   its icons 1.25em wide (Font Awesome 7) and larger than web-base's 15px ones,
   and gives this toggle a 1rem margin meant for its own header, where the
   bar's gap spaces web-base's controls. */
.bd-header button.secondary-toggle {
  --fa-width: auto;
  font-size: 15px;
  margin-left: 0;
}

/* Keep the link's native underline continuous through MathJax glyphs. */
.bd-article a.reference:has(.math),
.bd-article a.reference:has(.math) .math {
  text-decoration-skip-ink: none;
}

/* The search button (search-button.html) and the on-this-page toggle are
   pydata's, with web-base's .mg-navbar-icon-btn added, but pydata's "html
   .pst-navbar-icon" outranks that class on these and bootstrap's
   .btn:focus-visible recolours it, so restate the class's values. Its hover
   underline is suppressed too: the bordered box is the hover, as on the
   theme toggle (#389). */
html .mg-navbar-icon-btn.pst-navbar-icon {
  border: 1px solid var(--mg-border);
  border-radius: 10px;
  color: var(--mg-text-muted);
  height: 32px;
  padding: 0;
}

html .mg-navbar-icon-btn.pst-navbar-icon:hover {
  border-color: var(--mg-charcoal);
  color: var(--mg-charcoal);
}

html .mg-navbar-icon-btn.pst-navbar-icon:hover::before {
  border-bottom: none;
}

/* "Hide Search Matches" toggle (issue #389). pydata-sphinx-theme renders
   it into #searchbox -- which sits *before* the <article>, above the H1 --
   and styles it as a full-size coral button with a Font Awesome icon. It
   only appears when a page is opened with a ?highlight= query (the rebuilt
   handbook search no longer emits those, but bookmarked/external links
   still can). Demote it to a quiet inline text link so it never upstages
   the page title. Selectors match the theme's own
   `div#searchbox p.highlight-link a` specificity. */
div#searchbox p.highlight-link {
  box-shadow: none !important;
  width: auto;
  margin: 0 0 1rem !important;
}
div#searchbox p.highlight-link a {
  background: none;
  color: var(--pst-color-primary);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0;
  border-radius: 0;
  box-shadow: none !important;
  text-decoration: underline;
}
div#searchbox p.highlight-link a:hover {
  box-shadow: none !important;
  text-decoration: none;
}
div#searchbox p.highlight-link a:before {
  content: "";
  margin: 0;
}

/* Matches the page tree's drawer (below): under the bar, with its scrim and
   2px edge, and no sideways pan. The padding keeps the active bar and focus
   ring the theme draws 1rem left of a link's text inside the clip, and puts
   the text 1.25rem in, level with the left drawer's header links. */
@media (max-width: 1199.98px) {
  #pst-secondary-sidebar-modal {
    border-left: 2px solid var(--mg-text-muted);
    bottom: 0;
    height: auto;
    margin-block: 0;
    max-height: none;
    overflow-x: hidden;
    overscroll-behavior: contain;
    padding-left: 0.75rem;
    top: var(--mg-header-height);
  }

  /* The ::backdrop inherits --mg-header-height from the dialog, so the scrim
     starts under the bar. A click on the bar lands on it and closes the drawer. */
  #pst-secondary-sidebar-modal::backdrop {
    background: linear-gradient(
      to bottom,
      transparent var(--mg-header-height),
      rgba(0, 0, 0, 0.45) var(--mg-header-height)
    );
  }
}

/* Forced colours drop a gradient, and with it the scrim. Keep it, in the
   colour they give the page tree's scrim: Canvas at the same 0.45. */
@media (max-width: 1199.98px) and (forced-colors: active) {
  #pst-secondary-sidebar-modal::backdrop {
    background: linear-gradient(
      to bottom,
      transparent var(--mg-header-height),
      color-mix(in srgb, Canvas 45%, transparent) var(--mg-header-height)
    );
    forced-color-adjust: none;
  }
}

/* The page tree's drawer is 20rem (85vw at most). Match it where the screen
   is narrow, past the theme's 350px cap, which a large text size reaches.
   Where there is room keep the theme's 350px, unless a large text size makes
   20rem wider, so the drawer is never narrower than the page tree's. */
@media (max-width: 1199.98px) {
  #pst-secondary-sidebar-modal {
    max-width: max(350px, 20rem);
  }
}

@media (width < 56.25em) {
  #pst-secondary-sidebar-modal {
    width: min(20rem, 85vw);
  }
}

/* The close button sidebar-dialog-close.js adds for the keyboard and screen
   readers, shown only while it has focus: web-base's icon button, in the
   panel's top padding. The button and its focus ring do not scale with the
   text, so the theme's 2rem padding grows where it is too short for them. */
#pst-secondary-sidebar-modal {
  padding-top: max(2rem, calc(0.5rem + 32px + 6px));
}

#pst-secondary-sidebar-modal > .handbook-dialog-close {
  position: absolute;
  right: 0.5rem;
  top: 0.5rem;
}

/* The bar's toggle turns into a cross while the drawer is open, as the
   hamburger does for the page tree's. Font Awesome's script has replaced the
   icon's span with an SVG, so hide that and draw the cross. */
.bd-header button.secondary-toggle[aria-expanded="true"] > :is(svg, .fa-outdent) {
  display: none;
}

.bd-header button.secondary-toggle[aria-expanded="true"]::after {
  background: currentColor;
  content: "";
  height: 1em;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M18 6 6 18M6 6l12 12'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M18 6 6 18M6 6l12 12'/%3E%3C/svg%3E") center / contain no-repeat;
  width: 1em;
}

/* Forced colours replace the background the mask shows with the page's. */
@media (forced-colors: active) {
  .bd-header button.secondary-toggle[aria-expanded="true"]::after {
    background: ButtonText;
    forced-color-adjust: none;
  }
}

/* -- The header's drawer, with the page tree in it --------------------------
   On a page with a tree (.handbook-tree) it serves to 1200px, where the tree
   becomes a column (handbook-drawer.js moves it). Without JavaScript the tree
   is out of reach below 1200px, its column hidden, as with the theme's drawer. */
@media (width < 1200px), (width < 56.25em) {
  body:not(.mg-no-js) .mg-site-header.handbook-tree .mg-navbar-center {
    align-items: stretch;
    flex-direction: column;
  }

  body:not(.mg-no-js) .handbook-drawer-tree {
    border-top: 2px solid var(--mg-ochre);
    margin-top: 0.5rem;
    padding: 0.75rem 1.25rem 0;
  }
}

/* The rule over the tree: Magma's ochre in light mode, Gruvbox's orange in
   dark (web-base keeps the brand ochre fixed there, and its --mg-ochre-text
   is the Gruvbox orange). */
html[data-theme="dark"] .handbook-drawer-tree {
  border-top-color: var(--mg-ochre-text);
}

/* At a large text size from 1200px up, web-base's drawer shows the slot while
   the tree is in the page column, so the empty seat would show its ochre rule
   and padding. */
.handbook-drawer-tree:empty {
  display: none;
}

/* The version switcher's copy in the drawer (handbook-header.html): the bar
   has no room for its own below 56.25em. Without JavaScript there is no
   drawer, and the switcher's form changes page by script anyway. */
.handbook-drawer-version {
  display: none;
}

@media (width < 56.25em) {
  body:not(.mg-no-js) .mg-site-header .mg-navbar-center {
    align-items: stretch;
    flex-direction: column;
  }

  body:not(.mg-no-js) .handbook-drawer-version {
    border-top: 1px solid var(--mg-border);
    display: block;
    margin-top: 0.5rem;
    padding: 0.75rem 1.25rem 0;
  }
}

/* web-base's drawer rules, restated for 900px up to the tree's column over
   its own row layout for that range (the same values, at the higher
   specificity the .handbook-tree class gives), with the row its flex bar
   below 56.25em, not its grid, so the hamburger stays beside the brand. */
@media (56.25em <= width < 1200px) {
  body:not(.mg-no-js) .mg-site-header.handbook-tree button.mg-navbar-hamburger {
    display: flex;
  }

  body:not(.mg-no-js) .mg-site-header.handbook-tree .mg-navbar-row {
    align-items: center;
    column-gap: 0;
    display: flex;
    height: 60px;
    min-height: 0;
    padding: 0;
  }

  body:not(.mg-no-js) .mg-site-header.handbook-tree .mg-navbar-brand,
  body:not(.mg-no-js) .mg-site-header.handbook-tree .mg-navbar-right {
    margin-top: 0;
  }

  body:not(.mg-no-js) .mg-site-header.handbook-tree .mg-navbar-menu {
    align-items: stretch;
    background: var(--mg-bg);
    border-right: 2px solid var(--mg-text-muted);
    bottom: 0;
    box-sizing: border-box;
    display: none;
    flex: none;
    flex-direction: column;
    height: auto;
    left: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0.5rem 0 1rem;
    position: fixed;
    top: var(--mg-header-height);
    width: min(20rem, 85vw);
    z-index: 2;
  }

  body:not(.mg-no-js) .mg-site-header.handbook-tree .mg-navbar-menu.mg-is-open {
    display: flex;
  }

  body:not(.mg-no-js) .mg-site-header.handbook-tree.mg-menu-open .mg-navbar-scrim {
    background: rgba(0, 0, 0, 0.45);
    display: block;
    inset: var(--mg-header-height) 0 0;
    position: fixed;
    z-index: 1;
  }

  body:not(.mg-no-js) .mg-site-header.handbook-tree .mg-navbar-drawer:not(:empty) {
    display: block;
    width: 100%;
  }

  body:not(.mg-no-js) .mg-site-header.handbook-tree .mg-navbar-center {
    flex: none;
    flex-wrap: nowrap;
    justify-content: flex-start;
    min-width: auto;
    width: 100%;
  }

  body:not(.mg-no-js) .mg-site-header.handbook-tree .mg-navbar-links-primary,
  body:not(.mg-no-js) .mg-site-header.handbook-tree .mg-navbar-links-primary .mg-navbar-links-row1 {
    align-items: stretch;
    display: flex;
    flex-direction: column;
    gap: 0;
    width: 100%;
  }

  body:not(.mg-no-js) .mg-site-header.handbook-tree .mg-navbar-links-primary a:not(.mg-navbar-dropdown-item) {
    font-size: 0.95rem;
    padding: 0.6rem 1.25rem;
    white-space: normal;
  }

  body:not(.mg-no-js) .mg-site-header.handbook-tree .mg-navbar-right {
    flex-shrink: 1;
    min-width: 0;
  }
}

/* The page tree in the drawer. The theme styles a tree's branches and
   toggles under .bd-sidebar-primary, which the drawer is not (the scripts
   that take the first one on the page must not find it here): restated
   from the theme's rules for it. */
.handbook-drawer-tree {
  font-size: var(--pst-sidebar-font-size-mobile);
}

.handbook-drawer-tree .list-caption {
  list-style: none;
  padding-left: 0;
}

.handbook-drawer-tree li.has-children {
  position: relative;
}

.handbook-drawer-tree li.has-children .caption,
.handbook-drawer-tree li.has-children > .reference {
  margin-right: calc(30px + 0.1875rem);
  padding-top: 0.25rem;
}

.handbook-drawer-tree li.has-children > details > summary {
  list-style: none;
}

.handbook-drawer-tree li.has-children > details > summary::-webkit-details-marker {
  display: none;
}

.handbook-drawer-tree li.has-children > details > summary:focus-visible {
  outline: none;
}

.handbook-drawer-tree li.has-children > details > summary:focus-visible > .toctree-toggle {
  outline: var(--pst-color-accent) solid 0.1875rem;
  outline-offset: -0.1875rem;
}

.handbook-drawer-tree li.has-children > details > summary .toctree-toggle {
  align-items: center;
  cursor: pointer;
  display: inline-flex;
  height: 30px;
  justify-content: center;
  position: absolute;
  right: 0;
  top: 0;
  width: 30px;
}

.handbook-drawer-tree li.has-children > details > summary .toctree-toggle .fa-chevron-down {
  font-size: 0.75rem;
}

.handbook-drawer-tree li.has-children > details[open] > summary .fa-chevron-down {
  transform: rotate(180deg);
}

/* Anchor the handbook navigation to the browser's left edge on wide screens. */
@media (min-width: 960px) {
  .bd-container {
    justify-content: flex-start;
    /* Containing block for the two .magma-sidebar-rail elements
       (left-sidebar-collapse.js / collapsible-right-toc.js) -- the edge
       tabs are absolutely positioned against it so they span the full
       article height and stay clear of any sidebar's own overflow clip. */
    position: relative;
  }

  .bd-sidebar-primary {
    padding-top: 0.75rem;
  }

  .bd-sidebar-primary .sidebar-primary-items__start .sidebar-primary-item:first-of-type {
    padding-top: 0;
  }
}

/* Below 1200px the page tree is in the header's drawer (handbook-drawer.js),
   and the theme's static sidebar column, which it otherwise keeps showing
   through 959.98px, is empty (issue #120). From 960px to 1199px the column
   has no grid track (#2664). */
@media (max-width: 1199.98px) {
  #pst-primary-sidebar {
    display: none;
  }
}

/* ── Sidebar hide/reveal (issue #409) ────────────────────────────────────
   The desktop hide/reveal for both sidebars: the grid tracks in
   magma-parameter.css read --magma-*-sidebar-w, and the two scripts tween
   that length between its open value and 0. Transitioning the registered
   custom property (rather than grid-template-columns directly) is what
   makes the columns animate smoothly -- the tracks just re-resolve the
   var() each frame. .magma-sidebar-anim gates it on so setting the initial
   width at load doesn't itself animate. */
html.magma-sidebar-anim {
  transition:
    --magma-primary-sidebar-w 0.18s ease,
    --magma-secondary-sidebar-w 0.18s ease;
}

/* A grid track at 0 still can't squeeze out the sidebar's own 16px edge
   padding (or the right panel's 1px border), so the collapsed column keeps
   a ~33px stub with a sliver of clipped nav text showing. Drop the padding
   and edge border with the same 0.18s timing as the width so the column
   truly closes to nothing. */
html.magma-sidebar-anim #pst-primary-sidebar,
html.magma-sidebar-anim #pst-secondary-sidebar {
  transition: padding 0.18s ease, border-width 0.18s ease;
}

html.left-sidebar-collapsed #pst-primary-sidebar,
html.right-toc-collapsed #pst-secondary-sidebar {
  border-left-width: 0 !important;
  border-right-width: 0 !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}

/* Fade the nav contents slightly ahead of the track closing, so the eye
   reads a panel sliding away rather than a list re-wrapping as it's
   squeezed. */
html.magma-sidebar-anim #pst-primary-sidebar > *,
html.magma-sidebar-anim #pst-secondary-sidebar > * {
  transition: opacity 0.12s ease;
}

html.left-sidebar-collapsed #pst-primary-sidebar > *,
html.right-toc-collapsed #pst-secondary-sidebar > * {
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  html.magma-sidebar-anim #pst-primary-sidebar,
  html.magma-sidebar-anim #pst-secondary-sidebar,
  html.magma-sidebar-anim #pst-primary-sidebar > *,
  html.magma-sidebar-anim #pst-secondary-sidebar > * {
    transition: none;
  }
}

/* The reopen/close control: a slim tab permanently docked to the sidebar's
   own inner (content-facing) edge, protruding out past it into the
   article/gutter space. As --magma-*-sidebar-w tweens, the rail's
   left/right position reads that same live (already-animating, see above)
   value each frame, exactly like the grid track does -- so the tab rides
   along with the sidebar's edge as it slides, rather than sitting fixed
   while the sidebar moves under it. Collapsed (width 0) that edge is the
   window edge, so the tab ends up flush there; open, it sits right where
   the sidebar's own edge stops. Shared by left-sidebar-collapse.js and
   collapsible-right-toc.js; the rail is an absolutely-positioned,
   full-height strip so the tab clears the sidebar's overflow clip and a
   sticky offset keeps it near the middle of the viewport without drifting
   past the footer. */
.magma-sidebar-rail {
  position: absolute;
  top: 0;
  bottom: 0;
  /* WCAG 2.5.8's 24px minimum target width. */
  width: 24px;
  z-index: 30;
  pointer-events: none;
}

.magma-sidebar-rail--left {
  left: var(--magma-primary-sidebar-w);
}

.magma-sidebar-rail--right {
  right: var(--magma-secondary-sidebar-w);
}

.magma-sidebar-tab {
  align-items: center;
  background: var(--pst-color-on-background);
  border: 1px solid var(--pst-color-border);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  color: var(--pst-color-text-muted);
  cursor: pointer;
  display: flex;
  height: 54px;
  justify-content: center;
  margin: 0;
  padding: 0;
  pointer-events: auto;
  position: sticky;
  /* Tracks the viewport middle while scrolling through the article, then
     rides up with the rail near the footer (the rail ends where the
     article does) -- not position: fixed, which would keep it pinned over
     the footer after the sidebars themselves have scrolled away. */
  top: calc(50vh - 27px);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  width: 100%;
}

/* No border/shadow on the side touching the sidebar's own edge, so the tab
   reads as growing directly out of it rather than floating just beside it. */
.magma-sidebar-rail--left .magma-sidebar-tab {
  border-left: 0;
  border-radius: 0 7px 7px 0;
}

.magma-sidebar-rail--right .magma-sidebar-tab {
  border-right: 0;
  border-radius: 7px 0 0 7px;
}

.magma-sidebar-tab:hover {
  background: var(--pst-color-surface);
  border-color: var(--mg-ochre);
  color: var(--mg-ochre-text);
}

.magma-sidebar-tab span {
  font-size: 11px;
  line-height: 1;
  pointer-events: none;
}

/* The tab sits at the middle of the viewport, but the right panel's edge
   is only as tall as its own list, so on a page with a heading or two the
   edge stopped above the tab and the tab floated (#2710). Keep the panel
   at least tall enough for its edge to pass under the tab's lower corner:
   the tab's bottom is 50vh + 27px down the viewport, and the panel starts
   at the header offset magma-parameter.css gives it (top: 0 on a short
   viewport). The max-height there still caps a long list. */
@media (min-width: 1200px) {
  #pst-secondary-sidebar {
    min-height: calc(50vh + 27px - var(--mg-header-height));
  }
}

@media (min-width: 1200px) and (max-height: 30em) {
  #pst-secondary-sidebar {
    min-height: calc(50vh + 27px);
  }
}

/* Below 1200px viewport both sidebars are the theme's off-canvas drawers,
   not in-flow columns (they have their own toggles), so there is nothing
   for these tabs to collapse -- hide the rails entirely. */
@media (max-width: 1199.98px) {
  .magma-sidebar-rail {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html.magma-sidebar-anim {
    transition: none;
  }

  .magma-sidebar-tab {
    transition: none;
  }
}

/* Headings: match the website's weight + tracking on h1-h3 */
h1, h2, h3 {
  font-family: var(--pst-font-family-heading);
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* Reduced text spacing (issue #38): theme defaults are loose
   (line-height: 1.65, p margin-bottom: 1.15rem), leaving large gaps within
   and between paragraphs/text blocks. Tighten to a more compact reading
   density, scoped to the article body so sidebar/nav chrome is untouched. */
.bd-article-container {
  line-height: 1.35;
}

/* Paragraph gap (issue #53): 0.6rem still read as a much bigger jump than
   the tightened in-paragraph line gap above. Bring it down further so
   consecutive paragraphs feel like one reading rhythm. Not in web-base's
   citation and 404 cards or its notes pages, whose paragraphs set their
   own gaps (web-base#62, web-base#61, web-base#92). */
.bd-article-container p:not(.mg-citation p, .mg-not-found p, .notes-page p) {
  margin-bottom: 0.5rem;
}

/* The theme's 0.1rem vertical padding makes inline code 23.2px tall in a
   21.6px line, so literals on consecutive lines overlap (#2949). Dropping it
   fits the box to the line without changing the line spacing; a wrapped
   literal keeps its border and padding on both pieces. */
.bd-article-container code.literal {
  padding-block: 0;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

/* MathJax scales inline math to about 1.2 times the text, so the container's
   inherited 1.35 line-height is a 25.8px box in a 21.6px line and pushes the
   lines apart (#2949). Without it only the formula's own height counts, so a
   tall one (a fraction, a sum) still opens its line. */
.bd-article-container mjx-container[jax="CHTML"]:not([display="true"]) {
  line-height: 0;
}

/* Cap prose line length on large screens (issue #121): magma-parameter.css
   deliberately gives .bd-article-container itself no max-width (removing
   the theme's old 88rem page cap avoided a growing empty gutter outside
   the sidebars on wide displays), so its width is purely proportional
   (76% of the page) with nothing stopping it growing arbitrarily wide on
   large monitors, and lines got uncomfortably long to read.
   Capping the paragraph/list text itself, not the container, keeps that
   fix: tables and signature blocks still use the full column width
   (display math and code blocks get the same cap in their own rules
   below), and any leftover space next to short-measure text is just
   ordinary trailing whitespace, not a layout gutter.
   web-base's notes pages set their own measure (web-base#92); :where()
   keeps this rule's specificity below the admonition rule's. */
.bd-article-container p:not(:where(.notes-page p)),
.bd-article-container li:not(:where(.notes-page li)) {
  max-width: 112ch; /* 1.5x a plain-prose 75ch measure */
}

/* ...except inside an admonition (issue #152): the box itself (e.g. the
   homepage's "Preview version" banner) is a plain block that already
   spans the full column width, with no matching cap of its own -- capping
   just the text inside left an awkward empty gap next to it instead of
   the banner reading as intentionally full width. An admonition's border
   already bounds the text, so the long-line-length concern the 112ch cap
   exists for doesn't apply inside one regardless. */
.bd-article-container .admonition p,
.bd-article-container .admonition li {
  max-width: none;
}

/* Display math (issue #230): div.math -- MathJax's display-equation wrapper
   -- sits alongside p/li in the article body rather than being one itself,
   so the 112ch cap two rules up never applied to it. MathJax
   centers it within whatever width it's given; with no cap that's the
   full uncapped container, not the capped text column the surrounding
   prose actually reads at, so the equation visibly sits to the right of
   the text (and shifts further whenever a sidebar's open/closed state
   changes the container's own width) instead of tracking the column the
   prose around it is capped to. Same 112ch value as the prose cap, kept
   in sync by hand -- centering (margin: auto) is MathJax's own default
   behavior on the block once it fits within a max-width, not something
   this rule needs to set itself. */
.bd-article-container div.math {
  max-width: 112ch;
}

/* A code block (issue #3041) is not a p or li, so the prose cap misses it.
   Hold it to the same 112ch text column, kept in sync by hand; a longer
   line scrolls or wraps inside the block. */
.bd-article-container div.highlight {
  max-width: 112ch;
}

/* Card-like surfaces: bump toward the website's rounder card radius */
div.admonition {
  border-radius: 10px;
}

/* Flatten sphinx-design's cards site-wide (issue #90): drop the drop-shadow
   it applies by default (.sd-shadow-sm, on every grid-item-card) and use a
   plain border plus a subtle ochre hover accent instead of a shadow/lift.
   Scoped to .sd-card generally, so the homepage's compact topic cards
   (index-cards.css) and the single-column category lists below both pick
   up the same flat look automatically.
   The theme's own stylesheet sets both of these with selectors specific
   enough (and, for the shadow, !important) to otherwise win regardless of
   load order -- html[data-theme=...] .sd-shadow-sm for the shadow,
   .bd-content .sd-card.sd-card-hover:hover for the hover border -- so these
   overrides match that specificity (rather than just adding !important,
   which the shadow rule would still tie on) to reliably beat them. */
.sd-card {
  border-radius: 4px;
  transition: border-color 0.15s ease;
}

html .sd-card.sd-shadow-sm {
  box-shadow: none !important;
}

.sd-card:hover,
.bd-content .sd-card.sd-card-hover:hover {
  border-color: var(--mg-ochre);
}

/* sphinx-design's own .sd-card-hover:hover rule also sets
   `transform: scale(1.01)` -- a whole-card (and thus title) grow-on-hover
   effect (issue #189) separate from the border/shadow this block already
   flattens above. That rule shares this same selector, so it isn't a
   specificity gap: cascade doesn't borrow one rule's specificity for a
   property the overriding rule never declares, so `transform` still fell
   through to the theme's declaration until named explicitly here. Cancel
   just the scale, keep the border-color hover accent above. */
.sd-card-hover:hover {
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  .sd-card {
    transition: none;
  }
}

/* Rows with a single grid-item-card (intro text, Preface): the grid still
   reserves a topic-card-width column, so center that lone card instead of
   leaving it pinned to the left. */
.index-solo-row .sd-row {
  justify-content: center;
}

/* ── Depth-2 category pages: single-column list of cards (issue #90) ──────
   One level below the homepage, a category's subsections render as a
   single-column list (the .rst grid directive is forced to 1 column)
   instead of the homepage's compact multi-column grid. Title-only, same as
   the homepage -- the description stays in a hover/focus tooltip rather
   than a permanent second line (index-cards.js), just left-aligned and
   full width instead of centred. Still carries index-topic-grid too (see
   the .rst sources), so it keeps the same flat .sd-card look above and
   llms_txt.py's card scraper keeps working unchanged; these rules just
   override index-cards.css's centred layout for this container. */
.index-list {
  max-width: 760px;
  margin-left: 0;
  margin-right: 0;
}

.index-list .sd-card-body {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  text-align: left;
  padding: 0.85rem 1.2rem;
  min-height: 0;
}

.index-list .sd-card-title {
  text-align: left;
  font-size: 0.95rem;
  margin: 0;
}

/* Buttons / inputs: match the website's 8px control radius */
.btn,
.bd-search-button__click-hint,
input[type="search"],
.search-button-field {
  border-radius: 8px;
}

/* Doc-version switcher (alpha / beta / release), navbar, next to search */
.version-switcher-navbar {
  display: flex;
  align-items: center;
}

/* Below 56.25em the bar has no room for it beside the controls: the drawer
   holds a copy, after the header's links (.handbook-drawer-version). */
@media (width < 56.25em) {
  .mg-navbar-right .version-switcher-navbar {
    display: none;
  }
}

/* Plain text in --mh-chrome-text, as the header's links are, with no
   permanent border/box and --mh-chrome-accent only on hover/focus -- not its
   own separately-styled bordered pill. It keeps a visible border on
   hover/focus, since the browser's own dropdown panel that pops up from a
   native <select> can't be restyled at all -- that's OS-native chrome, no
   amount of CSS reaches inside it. */
.version-switcher-select {
  padding: 0.3rem 0.5rem;
  font-size: 0.8rem;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--mh-chrome-text);
  cursor: pointer;
  appearance: auto;
  transition: color 0.15s ease, border-color 0.15s ease;
  /* The dropdown *panel* a native <select> opens is OS/browser chrome:
     nothing here reaches inside it. Left alone, most
     browsers render its <option> list following the OS's own light/dark
     preference rather than this page's [data-theme] -- a page in one
     theme with the OS set to the other would get an unreadable panel
     (e.g. light text on a light background). color-scheme tells the
     browser which of its two built-in native palettes to use for that
     unstyled panel, matching the page's own theme -- explicit <option>
     color/background below (Chromium honours these on individual
     options; browsers that don't just fall back to color-scheme's native
     palette) then makes it match --pst-color-on-background/-text-base
     exactly, the page's own tokens, rather than merely "readable". */
  color-scheme: light dark;
}

/* The select only picks; the Go button navigates, since arrow keys on a
   closed select fire change and a change must not leave the page (3.2.2). */
.version-switcher-form {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin: 0;
}

.version-switcher-go {
  min-height: 24px;
  padding: 0.3rem 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid var(--mh-chrome-border);
  border-radius: 8px;
  background: transparent;
  color: var(--mh-chrome-text);
  cursor: pointer;
  transition: color 0.15s ease;
}

.version-switcher-go:hover {
  color: var(--mh-chrome-accent);
}

.version-switcher-go:focus-visible {
  outline: 2px solid var(--mh-chrome-accent);
  outline-offset: 1px;
}

.version-switcher-select option {
  background: var(--pst-color-on-background);
  color: var(--pst-color-text-base);
}

.version-switcher-select:hover {
  color: var(--mh-chrome-accent);
}

.version-switcher-select:hover,
.version-switcher-select:focus {
  border-color: var(--mh-chrome-border);
}

.version-switcher-select:focus {
  outline: 2px solid var(--mh-chrome-accent);
  outline-offset: 1px;
}

/* web-base links (#2649): the theme's a:visited colour outranks web-base's
   single-class link rules, so visited footer links stayed accent coloured.
   web-base leaves visited links alone. */
.mg-footer-links a:visited {
  color: var(--mg-text-muted);
}

.mg-footer-links a:visited:hover,
.mg-footer-usyd:visited {
  color: var(--mg-ochre-text);
}

/* The 404 page's buttons (web-base#61): visited, the homepage button's
   label took the link colour, ochre on its ochre fill. */
.mg-button-primary:visited {
  color: var(--mg-button-text);
}

.mg-button-secondary:visited {
  color: var(--mg-text);
}

/* Hovered, the secondary button's label took the theme's link-hover ochre:
   web-base's hover only changes its background (#2958). */
.mg-button-secondary:hover,
.mg-button-secondary:visited:hover {
  color: var(--mg-text);
}

/* The References page's DOI, arXiv and MR links (web-base#62), which
   turned the link colour too. */
.mg-citation-link:visited {
  color: var(--mg-citation-muted, var(--mg-text-muted));
}

.mg-citation-link--arxiv:visited {
  color: var(--mg-navy);
}

.mg-citation-link--mr:visited {
  color: var(--mg-teal-text);
}

.mg-citation-link:visited:hover {
  color: var(--mg-ochre-text);
}

/* A part page's downloads, web-base's arrow link (web-base#63), which
   turned the link colour from their quiet text colour. */
.mg-link-arrow:visited {
  color: var(--mg-link-arrow-color, var(--mg-ochre-text));
}

.mg-link-arrow:visited:hover {
  color: var(--mg-ochre-text);
}

/* The notes pages' own links (web-base#92): back, previous and next
   muted, card and attachment links in the accent. */
.mg-notes-back:visited,
.mg-notes-pager-btn:visited {
  color: var(--mg-notes-muted, var(--mg-text-muted));
}

.mg-notes-back:visited:hover,
.mg-notes-pager-btn:visited:hover,
.mg-notes-card-link:visited,
.mg-notes-attachment:visited {
  color: var(--mg-notes-accent, var(--mg-ochre-text));
}

/* Footer (#2649): web-static's Pico base supplied the top padding and the
   logo's height:auto (else the 776x848 logo squeezes into 48x48), and the
   theme's h2 rule sets the headings' line-height to 1.15, not 1.2. */
.mg-site-footer {
  padding-top: 1rem;
}

.mg-footer-logo-img {
  height: auto;
}

.mg-footer-col-heading {
  line-height: 1.2;
}

/* ── Cleaner nav/sidebar scrollbars (issue #102) ───────────────────────────
   The left nav and right on-this-page panes scroll their own overflow
   (theme default) and are tall enough that a scrollbar is visible on
   most pages, permanently, in the browser/OS's default thick, high-
   contrast style -- clashing with the site's flat, muted chrome. Thin it
   down, colour it from the same border token the rest of the chrome uses
   (already theme-reactive light/dark), and keep the thumb transparent
   until the pane is hovered so it doesn't read as "always on". Firefox
   uses the standard scrollbar-color/-width properties; other browsers
   use the older -webkit-scrollbar-* pseudo-elements -- both are declared
   since neither engine reads the other's syntax. The header's drawer has
   neither theme class, and below 1200px it holds the left nav (#3154). */
.bd-sidebar-primary,
.bd-sidebar-secondary,
.mg-site-header .mg-navbar-menu {
  scrollbar-color: transparent transparent;
  scrollbar-width: thin;
}

/* Move the right sidebar's own scrollbar to its inner-left edge (issue
   #109): .bd-sidebar-secondary sits flush against the browser's right
   viewport edge, so its scrollbar lands under the browser's own edge
   scrollbar/overlay and can't be reliably grabbed. Flipping direction puts
   the scrollbar on the left of the sidebar instead; the immediate content
   wrapper flips back to ltr so text, links and layout inside read normally
   -- only the scrollbar's side is affected.
   The sidebar shares the page's own background with no border, so a
   scrollbar sitting at its bare left edge reads as floating in the gap
   before the sidebar rather than inside it -- add a hairline border (the
   same muted token already used for the scrollbar thumb) so there's a
   visible edge for the scrollbar to sit against. */
.bd-sidebar-secondary {
  border-left: 1px solid var(--pst-color-border);
  direction: rtl;
  /* The theme's own unconditional 1rem left/right padding (same on both
     sides, meant for a plain undecorated edge) now sits between the
     flipped scrollbar/border and the sidebar's real content -- shrink
     just this side so the now-decorated (bordered) edge reads as closer
     to what it's decorating, matching how little space the theme leaves
     around a plain content edge elsewhere. */
  padding-left: 0.375rem;
}

.bd-sidebar-secondary > .sidebar-secondary-items {
  direction: ltr;
}

/* issue #188: at >=1200px the theme's own .sidebar-secondary-item (the
   "On this page" wrapper, one level inside .sidebar-secondary-items) gets
   its own separate border-left + padding-left: 1rem -- meant, in the
   theme's original left-to-right layout, to read as a matched pair with
   .bd-sidebar-secondary's own right-side border as a single visual
   separator between article and sidebar. The RTL flip above only moved
   .bd-sidebar-secondary's own border/scrollbar to the left; it left this
   inner element's identical border+1rem padding stacked on the SAME side,
   so the flipped scrollbar (backed by .bd-sidebar-secondary's border,
   right at the sidebar's true edge) ends up ~40px+ before any real
   content -- reading as "floating" well to the left of the sidebar
   instead of part of it. That inner border is now redundant (the outer
   one already gives the scrollbar its edge); drop it and its matching
   padding back to the theme's own narrower-breakpoint value. */
.bd-sidebar-secondary .sidebar-secondary-item {
  border-left: none;
  padding-left: 0.5rem;
}

.bd-sidebar-primary:hover,
.bd-sidebar-secondary:hover,
.mg-site-header .mg-navbar-menu:hover {
  scrollbar-color: var(--pst-color-border) transparent;
}

.bd-sidebar-primary::-webkit-scrollbar,
.bd-sidebar-secondary::-webkit-scrollbar,
.mg-site-header .mg-navbar-menu::-webkit-scrollbar {
  width: 8px;
}

.bd-sidebar-primary::-webkit-scrollbar-track,
.bd-sidebar-secondary::-webkit-scrollbar-track,
.mg-site-header .mg-navbar-menu::-webkit-scrollbar-track {
  background: transparent;
}

.bd-sidebar-primary::-webkit-scrollbar-thumb,
.bd-sidebar-secondary::-webkit-scrollbar-thumb,
.mg-site-header .mg-navbar-menu::-webkit-scrollbar-thumb {
  background-color: transparent;
  border-radius: 8px;
}

.bd-sidebar-primary:hover::-webkit-scrollbar-thumb,
.bd-sidebar-secondary:hover::-webkit-scrollbar-thumb,
.mg-site-header .mg-navbar-menu:hover::-webkit-scrollbar-thumb {
  background-color: var(--pst-color-border);
}

/* ── Preview-tier navbar badge (source/_templates/tier-badge.html) ───────
   Only present in the DOM on a `-t alpha`/`-t beta` build (see conf.py's
   html_context["build_tag"]), so this never shows on the real site. Text
   content is the lowercase tag name ("alpha"/"beta"); uppercase is
   presentation-only so the template has one plain value to emit. */
.tier-site-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 0.5rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-family: var(--pst-font-family-base);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #fff;
  vertical-align: middle;
}

/* Amber for the earliest tier, purple for the one after it (alpha -> beta
   -> release) -- colour follows the maturity stage, not the tag name, so
   swapped along with the order correction. */
.tier-site-badge.tier-alpha {
  background-color: var(--mg-amber);
}

.tier-site-badge.tier-beta {
  background-color: var(--mg-purple);
}

/* The bar carries the theme toggle and Login as well as the badge, so a
   narrow phone has no room for it; the drawer's version switcher still
   names the build. */
@media (width < 30em) {
  .bd-header .tier-site-badge {
    display: none;
  }
}

/* Dark text wherever white misses 4.5:1: on both tiers' pale dark-mode
   fills (~1.3 and ~1.9:1) and on light-mode amber (3.2:1). White stays on
   light-mode purple (5.7:1). */
html[data-theme="dark"] .tier-site-badge,
.tier-site-badge.tier-alpha {
  color: #1a1225;
}

/* "Disguised list" description lists (issue #273): the converter falls
   back to a description list for bulleted/lettered/numbered runs whose
   marker has no macro signal to structure into a real list -- CommonMark
   simply has no native syntax for lettered/roman/fully-parenthesised
   markers. The theme's default <dl>/<dt>/<dd> renders term and definition
   as separate block siblings, so the definition starts on its own line
   below the marker instead of hanging beside it -- correct for a genuine
   description list, wrong for a list in disguise. marker_list_style.py
   tags only the latter (every term marker-shaped) with this class; a
   description list with any real term text is untouched.
   Grid (not float) so a marker-shaped term still lines up correctly even
   when a definition wraps onto several lines. */
dl.marker-list {
  display: grid;
  /* minmax(0, ...): a bare 1fr track is never narrower than its widest
     content, so a wide display formula would widen the list past the
     article and pan it on a phone rather than scroll in its own box (#2949). */
  grid-template-columns: max-content minmax(0, 1fr);
  column-gap: 0.5em;
  row-gap: 0.25rem;
  /* Align by the first line's text baseline, not the grid row's box edge --
     the marker and definition can differ in font metrics (e.g. a definition
     starting with MathJax-rendered math, whose line box isn't plain text
     height), and top/stretch alignment then leaves the marker looking
     slightly higher than the text it's paired with. */
  align-items: baseline;
}

dl.marker-list > dt {
  grid-column: 1;
  font-weight: 400;
  /* Manrope (the theme's heading/body font) has a built-in "(c)" -> "©"
     ligature -- confirmed via a direct font-variant-ligatures probe, not a
     Sphinx/converter artifact. Harmless in prose, but "(c)" is a completely
     ordinary third marker after "(a)", "(b)" in this corpus's lettered
     lists, where silently turning into a copyright symbol is genuinely
     wrong. Scoped to just the marker cell, not the whole page, since other
     ligatures (fi/fl etc.) are fine to keep in running prose. */
  font-variant-ligatures: none;
}

dl.marker-list > dd {
  grid-column: 2;
  margin: 0;
}

/* ── Permanent example labels (issue #237) ─────────────────────────────── */

/* The bracketed permanent id next to a magma:example's title (see
   source/_ext/magma_domain.py's MagmaExample.handle_signature) -- muted
   and monospace, same visual weight as the holdback "(preview)" inline
   remark (.handbook-holdback-inline-notice in holdback.css): a citable
   identifier a reader can see and copy, but not something meant to
   compete with the title itself for attention. */
.magma-example-tag {
  color: var(--pst-color-text-muted);
  font-family: var(--pst-font-family-monospace, monospace);
  font-size: 0.8em;
}

/* ── Accessibility corrections (#2546) ─────────────────────────────────── */

/* A wide display formula scrolls in its div.math, not in itself: focus on
   a formula goes to MathJax's explorer, which takes the arrow keys
   (math-overflow-focus.js). Across only, as the theme's overflow: hidden
   already has it down; tall glyphs' boxes overflow into the margin. */
div.math {
  overflow-x: auto;
}

div.math mjx-container {
  overflow: visible;
}

/* The theme's row-reverse would open a wide formula scrolled to its right
   end; row opens it at its start, and an equation number stays right. */
div.math {
  flex-direction: row;
}

div.math > .eqno {
  order: 1;
}

/* A div.math that scrolls is a Tab stop (math-overflow-focus.js); it gets
   the site's ring, inside because the box clips its overflow. */
div.math:focus-visible {
  outline: 3px solid var(--pst-color-accent);
  outline-offset: -3px;
}

/* The theme's breadcrumb separator is an icon-font character, which screen
   readers announce; the empty alternative text keeps it visual only. A
   browser without that syntax would drop the separator, so it keeps the
   theme's. */
@supports (content: "x" / "") {
  ul.bd-breadcrumbs li.breadcrumb-item:not(.breadcrumb-home)::before {
    content: var(--pst-breadcrumb-divider) / "";
  }
}

/* The theme keeps each breadcrumb on one line and cuts a long one off with
   an ellipsis, which at 320px hid most of a part or chapter title (#2719).
   A long one wraps instead. */
ul.bd-breadcrumbs li.breadcrumb-item {
  white-space: normal;
}

/* sphinx-copybutton shows its button only while the pointer is over the
   code, or while the button has focus, but link hinting (Vimium) still
   hinted it while it was invisible (#2719). It stays shown, in the theme's
   muted colour. */
div.highlight button.copybtn {
  opacity: 1;
}

/* Reflow at 320px: Sphinx keeps each span.pre on one line, so a long
   intrinsic name widened the whole article past the viewport. A signature
   breaks inside a word only when it cannot fit on its own line. */
.bd-article-container dt.sig span.pre {
  white-space: normal;
}

/* Wrapping text may break after a hyphen, which split a signature's "->".
   Punctuation tokens are short, so they stay whole. */
.bd-article-container dt.sig .p span.pre {
  white-space: nowrap;
}

.bd-article-container dt.sig {
  overflow-wrap: anywhere;
}

/* A literal in prose is one span.pre per word, not tokenised, so letting
   it wrap split "x -> y" or "--check-map" after the hyphen wherever a
   line happened to end there. It keeps Sphinx's nowrap and wraps only on
   a phone, where a long name would otherwise scroll the article. */
@media (max-width: 40em) {
  .bd-article-container code.literal span.pre {
    white-space: normal;
  }

  .bd-article-container code.literal {
    overflow-wrap: anywhere;
  }

  /* A heading's last word and its permalink "#" are one unbreakable run: it
     scrolled the article sideways, or broke to leave the "#", hidden until
     hover, on a blank line of its own (#2960). A phone has no hover to show
     it, so it takes no space; a word longer than the column still breaks. */
  .bd-article-container :is(h1, h2, h3, h4, h5, h6) {
    overflow-wrap: break-word;
  }

  .bd-article-container :is(h1, h2, h3, h4, h5, h6) > a.headerlink {
    display: none;
  }

  /* A word in prose wider than the column, such as an intrinsic's name in
     plain text, scrolled the article sideways (#2993). As in a heading, only
     a word that cannot fit on a line breaks. The breadcrumbs are list items
     here too, and already wrap (#2719). */
  .bd-article-container :is(p, li) {
    overflow-wrap: break-word;
  }
}

/* A long previous/next title kept its min-content width, so the theme's
   overflow clip cut off the title and the chevron beside it. */
.prev-next-area a .prev-next-info {
  min-width: 0;
  overflow-wrap: anywhere;
}

.prev-next-area a > :is(i, svg) {
  flex-shrink: 0;
}

/* Side by side at 45% each, a narrow screen left a title some 80px, and
   ordinary words broke mid-word: stack the two links instead. */
@media (max-width: 40em) {
  .prev-next-area a {
    float: none;
    max-width: none;
  }

  .prev-next-area a.right-next {
    justify-content: flex-end;
  }
}

/* The general index sets its entries out in a three-column table, 756px
   wide at a 320px viewport: one column on a narrow screen. !important
   beats the cell's inline width. */
@media (max-width: 40em) {
  table.genindextable,
  table.genindextable tbody,
  table.genindextable tr,
  table.genindextable td {
    display: block;
    width: auto !important;
  }
}

/* Index links were 22px tall rows of adjacent targets and the [1], [2]
   aliases narrower still; WCAG 2.5.8 asks for 24px. */
table.indextable li {
  overflow-wrap: break-word;
}

table.indextable li > a {
  display: inline-block;
  line-height: 24px;
  max-width: 100%;
  min-height: 24px;
}

table.indextable li > a ~ a {
  min-width: 24px;
  text-align: center;
}

/* Reduced motion: web-base's own rule for its header and footer loses to
   their transition rules on specificity, and some transitions (the example
   toggle, the copy tooltip) have none. 0.01ms rather than none, so
   transitionend handlers still run. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-delay: 0s !important;
    transition-duration: 0.01ms !important;
  }
}
