/**
 * Note/endnote plumbing (GAP-384) — additions on top of bb-library.css.
 *
 * bb-library.css already carries the base look of .bb-noteref, .bb-endnotes,
 * .bb-bibliography, .bb-missing, .bb-caveat and .bb-backref, and class-bb-
 * notes.php deliberately reuses those exact class names so a note or an
 * endnote looks identical whether it came from BB_Citations or from here.
 * This file is additive only: the three things that trio did not yet cover.
 *
 * Its own tokens are named --bbn-* rather than reusing --bb-*. The theme
 * bridges --bb-* to the palette in style.css's "Plugin bridge" block, but
 * bb-library.css also sets --bb-* itself, unconditionally, at :root — and
 * because bb-library.css is enqueued after the theme stylesheet, its literal
 * hex currently wins the cascade rather than the theme's bridge. That is a
 * pre-existing condition in a file GAP-384 does not touch. Naming fresh
 * tokens here and bridging them directly, once, at bare :root (the same
 * technique the theme uses) keeps this file's own colour honestly on-token
 * in both themes without either depending on that cascade outcome or
 * silently overriding it site-wide as a side effect of an unrelated fix.
 */

:root {
	--bbn-focus: var(--wp--preset--color--accent-1);  /* verdigris — same accent as running-text links */
	--bbn-warn:  var(--bab-reported);                 /* honey — a gap to close, not a contradiction ("miss") */
}

/* --- keyboard focus ----------------------------------------------------
   A hover rule is not a focus rule: .bb-noteref and .bb-backref links
   otherwise carry no visible state at all for a keyboard user tabbing
   through, which fails "keyboard-accessible, with a visible focus state"
   outright regardless of how good the mouse experience is. */

.bb-noteref a:focus-visible,
.bb-backref:focus-visible {
	outline: 2px solid var(--bbn-focus);
	outline-offset: 2px;
	border-radius: 2px;
}

/* --- unclassified bibliography group ------------------------------------
   Same heading style as "Primary"/"Secondary" (h3 styling is inherited from
   bb-library.css), plus the same honesty-marker colour bb-index.css already
   gives an "unclear" tag — this group is a task, not a scholarly tier. */

.bb-bibliography h3.bb-unclassified {
	color: var(--bbn-warn);
}

/* --- long self-evident URLs ----------------------------------------------
   .bb-cite-selfurl (set once, in BB_Citations::full()) marks a link whose
   visible text is its own href — an archive.org or Tarisio permalink with
   no spaces for the browser to break on. A narrow viewport has no room for
   a ~50-character URL on one line, and with no break opportunity in an
   unbroken run of letters the line does not wrap at all: it runs past the
   measure and takes the whole page body into horizontal scroll with it.
   overflow-wrap lets the browser break inside the URL only when it must,
   rather than every character or not at all. */

.bb-cite-selfurl {
	overflow-wrap: anywhere;
}

/* --- print --------------------------------------------------------------
   An appraiser or reviewer reads these pages on paper. Every link
   BB_Citations::full() writes already shows its own URL as its visible
   text, so it survives printing by construction. A literal [note] can carry
   hand-written link text instead ("the digital archive" rather than the
   bare address) — this is the case that needs the address spelled out, so
   it is not lost the moment the page leaves the screen. */

@media print {

	.bb-endnotes a[href]:not(.bb-backref):not([href^="#"]):not(.bb-cite-selfurl)::after,
	.bb-bibliography a[href]:not([href^="#"]):not(.bb-cite-selfurl)::after {
		content: " (" attr(href) ")";
		font-size: 0.85em;
	}

	/* Keep a heading from stranding itself at the foot of a page with its
	   own list pushed to the next one. */
	.bb-endnotes h2,
	.bb-bibliography h2 {
		break-after: avoid-page;
	}

	.bb-endnotes li,
	.bb-bibliography li {
		break-inside: avoid-page;
	}
}
