/* -- References page: the Handbook's parts of web-base's citation cards ---
   references_format.py rebuilds each entry from the raw .bib fields as
   web-base's citation card (its README's "Citation cards": mg-citation-*,
   data-type), which web-base.css styles, type colours included. What is
   left here is what the card leaves to its host: the text of an entry not
   rebuilt from the .bib, the "Cited in" list, and the repaired state. */

/* -- Search layout --------------------------------------------------------
   references_search.py puts web-base's search layout round the list and
   search-list.js drives it, so all that belongs here is fitting the layout
   to the article column: it is already inside the theme's own padding, and
   the page has no secondary sidebar to centre it against. */

.handbook-references {
  /* web-base's own width, less the 2rem side padding this page does not
     need: the article column is already inside the theme's, and the
     handbook's does not cap itself, so without this the cards would run
     the width of the window -- 1914px on a 2560px screen. At this width a
     card measures the 756px it does on magma-maths.org's /citations/.
     Left, not centred, so the layout starts where the page's title does. */
  --mg-search-layout-max: calc(1120px - 2 * 2rem);
  --mg-search-layout-pad: 1rem 0 0;
  --mg-search-layout-pad-narrow: 1rem 0 0;
  --mg-search-layout-margin: 0;
}

/* -- A chapter's own Bibliography page (#3210) ----------------------------
   It has no search layout round its list, so its cards would take the whole
   article column (1254px at a 1600px viewport) where a References card
   measures 756px. .mg-citation is an inline-size container query, so the
   width is what drives the card's internal layout: matching it here is what
   makes a chapter's cards the same cards, not merely similar ones. The
   list keeps web-base's zero margin, so it starts where the page's title
   does. 756px is the width the rule above works out to, and the one the
   printed measurement in web-base's own /citations/ page reports; the two
   are kept the same by hand, so change them together.
   The list itself, not a wrapper: a `:list: bullet` bibliography replaces
   the directive's node outright, so the `.docutils container` the default
   list type wraps it in is not there to hang a width on. */
#bibliography > .citation-list {
  max-width: 756px;
}

/* The entry's label ("[AHU74]"): the key its in-text citations show. */
.citation-list .citation > .label {
  flex: none;
  margin-inline-end: 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--pst-color-text-muted, #68635f);
}

/* pybtex's own text, for an entry not rebuilt from the .bib */
.citation-list .citation-text {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.7;
  color: var(--pst-color-text-base, #212529);
}

/* Repaired entries (legacy pybtex-text fallback): an amber strip and a help
   cursor, to hint at the tooltip carrying the original bibtex error. The
   card reads the strip's colour from --mg-citation-accent. */
.mg-citation.citation-repaired {
  --mg-citation-accent: #f59e0b;
  --mg-citation-accent-text: var(--mg-amber-text);
  cursor: help;
}

/* -- "Cited in" lists (#3310) ---------------------------------------------
   citation_backlinks.py puts one in each cited bibliography entry, on the
   References page and a chapter's Bibliography alike, and
   references_format.py moves it into the card's body, a column, so it sits
   under the entry's text and wraps with it. It is closed until opened. */
.handbook-cited-in {
  margin-top: 0.75rem;
  font-size: 0.875rem;
}

.handbook-cited-in-list {
  margin: 0;
  padding-left: 1.25rem;
}

/* Chosen over the theme's `ul li > p:first-child`, which puts 4px above and
   below each page and so would leave 28px between them (#3541). */
.handbook-cited-in-list > .handbook-cited-in-item > p {
  margin: 0;
  /* Lines 24px apart: a link is one line of small type, under WCAG 2.2's
     24px minimum target size, which it meets by spacing where an item
     wraps. */
  line-height: 1.5rem;
}

/* The first page sits 1px under the summary, as a link under 24px needs a
   24px circle clear of the summary's box (WCAG 2.5.8), which the theme's
   rule above and Sphinx's basic.css would both take away. */
.handbook-cited-in-list > .handbook-cited-in-item:first-child > p {
  margin-top: 1px;
}

.handbook-cited-in-chapter {
  color: var(--pst-color-text-muted);
}

.handbook-cited-in-reference-line {
  margin: 0.5rem 0 0;
}
