/* ── Holdback highlight (source/_ext/holdback.py) ────────────────────────── */

/* Visual marker for content still gated by a `.. holdback::`/`:holdback:`
   wrapper for the *current* preview version. Paired with an explicit
   "Preview only" notice (the .mg-holdback-notice admonition for a block, or
   .mg-holdback-inline-notice text for a role) -- see holdback.py -- so the
   highlight itself only needs to mark the extent of the held-back content,
   not carry the explanation on its own. Never present in the DOM on a
   release build, and never once a wrapper's condition has fully expired
   (see holdback.py's is_highlighted): at that point content renders as
   plain, unstyled prose, same as if the wrapper had already been
   stripped.

   Colour: --mg-purple, the same token the preview-tier navbar badge uses
   for the beta tag (custom.css's .tier-site-badge.tier-beta) -- one
   colour reused for every holdback surface (in-page highlight, notice,
   link/card highlighting below), rather than each piece picking its own
   accent. color-mix() (not a hardcoded rgba literal) so the tint still
   follows --mg-purple's light/dark swap. */
.mg-holdback {
  background-color: color-mix(in srgb, var(--mg-purple) 20%, transparent);
  border-radius: 3px;
}

/* Inline (the :holdback: role, a <span>): a small highlight around the
   held-back clause, sitting inline with the surrounding sentence. */
span.mg-holdback {
  padding: 0.05em 0.35em;
}

/* Block (the .. holdback:: directive, a <div>): a left accent bar only,
   no fill (issue #229) -- the inline .span rule's small filled highlight
   reads fine for a clause inside a sentence, but stretched across a whole
   block (often several paragraphs, or a nested directive like a rendered
   magma:function signature) the same filled/rounded treatment read as a
   heavy, boxed-in slab that didn't match the page-level marker's own
   much lighter touch (a notice with no surrounding band at all -- see
   the module docstring). A plain left bar is common practice for
   "this ran differently"-style margin notes (blockquotes, diff/changed-
   line gutters) and stays legible for content of any length without
   drawing a border around it on every side. Overrides -- doesn't just
   add to -- the shared .mg-holdback rule's background-color/border-radius
   above, which still apply as-is to the inline (span) variant. */
div.mg-holdback {
  display: block;
  background-color: transparent;
  border-radius: 0;
  padding: 0.1em 0 0.1em 0.9em;
  margin: 0.75em 0;
  border-left: 3px solid var(--mg-purple);
}

/* The "Preview only" admonition _notice_node() builds ahead of a
   highlighted block's real content (as a sibling, never nested inside the
   .mg-holdback band above -- see that function's docstring for why) -- an
   ordinary Sphinx admonition (themed generically by the site already),
   purple-accented here to read as part of the same holdback family rather
   than a generic note/warning.

   pydata-sphinx-theme's own `.admonition,div.admonition` rule sets
   background-color at 0,1,1 specificity (the actual element is
   `<div class="mg-holdback-notice admonition">`, so that rule matches
   too, and would otherwise win by specificity regardless of stylesheet
   load order) -- `.mg-holdback-notice.admonition` at 0,2,0 is needed to
   reliably beat it, plain `.mg-holdback-notice` is not enough.

   The body (this rule) is deliberately mixed against a fixed `white`,
   not the theme's --pst-color-on-background like the title bar below --
   in LIGHT mode that token is already close to white anyway, so mixing
   against it or against literal white reads the same there; the
   difference only matters in dark mode, where --pst-color-on-background
   is itself dark (a fixed-white mix would stay a light lavender
   regardless of theme -- deliberately, at first, to fix a "too dim"
   complaint, but that then reads as barely-tinted-white sitting oddly
   bright against a dark page, not a good look either). The dark-mode
   block further down instead mixes against the theme's own dark
   background at a much higher percentage, restoring a proper saturated
   purple there, with white body text for contrast against it -- light
   mode keeps this rule's dark body text, correct against its
   close-to-white background.

   pydata-sphinx-theme also puts a `box-shadow` (with `!important`) on
   every admonition -- a drop shadow reads as "floating card", at odds
   with the flat, bordered-box look the rest of the site (custom.css's
   .sd-card flattening, `div.admonition{border-radius:10px}`) already
   goes for elsewhere, so it's turned off here too, matching `!important`
   for `!important` since a plain override can't otherwise win. */
.mg-holdback-notice.admonition {
  background-color: color-mix(in srgb, var(--mg-purple) 10%, white);
  border-left-color: var(--mg-purple);
  color: #2b2233;
  box-shadow: none !important;
}

/* The title bar's own background is a fixed purple hex, not --mg-purple
   (which deliberately *lightens* in dark mode, right for text/borders
   sitting on a dark page, wrong here: a filled block meant to hold light
   text needs to get MORE saturated in dark mode, not less, or that text
   stops contrasting -- mixing more of an already-light token in only
   makes the result lighter still). Percentage instead of a flat colour
   so it still adapts a little to the page's own background per theme.

   Text colour IS given explicitly here, though, unlike background --
   white in both modes, deliberately not inherited from the parent
   .mg-holdback-notice.admonition's own `color` the way it used to be:
   that gave dark text in light mode (correct for the near-white body
   there, wrong for this title bar's own more-saturated purple
   background). Dark mode already got white here via that same
   inheritance, so this is a no-op change there -- only light mode's
   title text (and, via currentColor below, the bell icon) actually
   changes, to white either way. */
.mg-holdback-notice.admonition > .admonition-title {
  background-color: color-mix(in srgb, #7c3aed 55%, var(--pst-color-on-background));
  color: #fff;
}

/* Dark mode: both the body and title bar need their own override --
   see this rule's and the title rule's comments above for why each
   can't just be the light-mode value with --mg-purple's dark-mode swap
   layered on top. Title goes MORE saturated than its light-mode value
   (70% vs 55%), clearly more so than the body below it, so the two
   still read as a distinct header + body pairing rather than blurring
   into one flat block -- title and body are close in tone at equal
   percentages since both start from the same fixed purple. */
html[data-theme="dark"] .mg-holdback-notice.admonition {
  background-color: color-mix(in srgb, var(--mg-purple) 45%, var(--pst-color-on-background));
  color: #fff;
}
html[data-theme="dark"] .mg-holdback-notice.admonition > .admonition-title {
  background-color: color-mix(in srgb, #7c3aed 70%, var(--pst-color-on-background));
}

/* The title's bell icon is the theme's own default-admonition glyph
   (pydata-sphinx-theme's `.admonition-title:after`, an icon font glyph
   coloured `--pst-color-info` -- generic theme blue, unrelated to any of
   the purple above it). currentColor rather than a colour of its own,
   so the icon always matches whatever the title's text ends up being
   (inherited from .mg-holdback-notice.admonition -- see that rule) in
   both modes automatically, with nothing here to keep in sync by hand. */
.mg-holdback-notice.admonition > .admonition-title::after {
  color: currentColor;
}

/* The short "(preview)" remark _holdback_role() appends after a highlighted
   inline clause -- deliberately muted/small, since the highlight already
   marks the clause itself; this just names what the highlight means, for a
   reader who lands here without having read the homepage banner or the
   block-level notice above. */
.mg-holdback-inline-notice {
  font-size: 0.85em;
  opacity: 0.75;
}

/* ── Link highlighting (source/_ext/holdback_link_highlight.py) ─────────── */

/* Marks a link/toctree-entry/card whose target is (or, for a toctree
   ancestor, leads toward) currently-highlighted holdback content --
   deliberately a separate class from .mg-holdback above, not shared with
   it: that one's div/span rules (padding, margin, border-left, sized for
   a prose block) would misapply to whatever structural element ends up
   carrying this one (a sidebar <li>, a sphinx-design card), distorting
   its layout.

   An <li> is the WHOLE subtree below it in the toctree/sidebar -- its own
   row plus every nested <ul> of descendant pages, since a toctree/sidebar
   <li> always has the shape <li><a>Row</a><ul>...children...</ul></li>.
   Colouring the <li> itself (its full box, including the height taken by
   that nested <ul>) would tint every descendant page's row too, not just
   this one -- exactly the "whole chapter turns purple, not just the
   breadcrumb path to the held-back page" bug this is written to avoid.
   Styling only the <li>'s own row -- not the nested <ul> beside it --
   keeps the highlight to that single row.

   Two shapes for that row, both handled: a plain sidebar/toctree entry is
   <li><a>Row</a><ul>...</ul></li> (<a> a direct child of <li>); an
   in-page toctree entry that itself has children is instead
   <li><div class="toc-page-row"><button class="toc-page-toggle">...
   </button><a>Row</a></div><ul hidden>...</ul></li> (collapsible-
   toctree.css/js's expand/collapse toggle button -- <a> one level deeper,
   inside that row div, not a direct child of <li>). Missing the second
   shape was the earlier "History Files itself never highlights, only its
   ancestors do" bug: that specific entry (it has its own "The Options
   File" subsection, so it gets a toggle button) uses the wrapped shape,
   while its childless siblings use the plain one -- so both must be
   matched, not just the more common plain case. */
li.mg-holdback-link > a:first-of-type,
li.mg-holdback-link > .toc-page-row > a:first-of-type {
  background-color: color-mix(in srgb, var(--mg-purple) 20%, transparent);
  border-radius: 3px;
  padding: 0.05em 0.35em;
}

/* An inline cross-reference in running prose has no <li>/<sd-card> parent
   to prefer -- the <a> itself is the whole highlighted element (see
   _highlight_links()'s target selection), so it needs its own background,
   same as the <li> row case above. */
a.mg-holdback-link {
  background-color: color-mix(in srgb, var(--mg-purple) 20%, transparent);
  border-radius: 3px;
  padding: 0.05em 0.35em;
}

/* A grid-item-card's own link is an invisible stretched-link overlay with
   no box of its own -- the visible surface is the card, so that gets the
   accent instead (recolouring the flat border custom.css already gives
   every .sd-card, plus a fainter tint than the row/link cases above since
   a whole card is a much larger area than an <li> row). No descendant-leak
   risk here: a card has no nested toctree inside it. */
.sd-card.mg-holdback-link {
  border-radius: 4px;
  border-color: var(--mg-purple);
  background-color: color-mix(in srgb, var(--mg-purple) 12%, transparent);
}
