/* Inline Footnotes — reference marker, tooltip, end-of-article list.
   Enqueued only on entries whose content carries the [nota] shortcode.

   Re-skin through the --footnote-* properties in the theme's :root; never
   re-declare these classes in a theme. Unset, each one falls back to the
   matching ali-blocks --block-* token (so a site running ali-blocks is themed
   for free), then to a neutral value:
     accent        marker ink, back link, open-marker fill
     accent-ink    marker ink while its tooltip is open
     accent-soft   marker hover fill, :target highlight in the list
     ink           strong text (back-link hover)
     muted         list text and heading
     rule          list top border
     tip-bg / tip-text / tip-link   tooltip panel
     num-bg / num-text              number badge in the tooltip
     radius, shadow, font, scroll-offset (clears a sticky header) */

/* ── Reference marker ────────────────────────────── */
.footnote-ref {
	font-size: .72em;
	line-height: 0;
	vertical-align: super;
}

.footnote-ref > a {
	color: var(--footnote-accent, var(--block-accent-text, #1a5fb4));
	font-weight: 700;
	text-decoration: none;
	border: 0;
	padding: 0 .18em;
	border-radius: 3px;
	cursor: pointer;
	scroll-margin-top: var(--footnote-scroll-offset, 80px);
	transition: background .18s ease, color .18s ease;
}

/* Hover is scoped away from the open state: the open marker is light ink on
   an accent fill, so letting the pale hover background win made the number
   vanish. */
.footnote-ref:not(.footnote-ref--open) > a:hover,
.footnote-ref:not(.footnote-ref--open) > a:focus-visible {
	background: var(--footnote-accent-soft, var(--block-accent-glow, rgba(0, 0, 0, .08)));
}

/* Article templates usually style in-content links through long, specific
   selectors (underline borders, colours). Only the declarations the marker
   cannot live without are forced: no underline, and the open state's fill
   and ink. The resting colour stays the template's. */
.footnote-ref > a {
	border-bottom: 0 !important;
	padding-bottom: 0 !important;
}

.footnote-ref--open > a,
.footnote-ref--open > a:hover,
.footnote-ref--open > a:focus-visible {
	background: var(--footnote-accent, var(--block-accent-text, #1a5fb4)) !important;
	color: var(--footnote-accent-ink, #fff) !important;
}

/* ── Tooltip ─────────────────────────────────────── */
.footnote-tip {
	position: absolute;
	z-index: 900;
	display: flex;
	align-items: flex-start;
	gap: .7rem;
	box-sizing: border-box;
	padding: .8rem .9rem;
	background: var(--footnote-tip-bg, var(--block-dark, #222));
	color: var(--footnote-tip-text, #fff);
	border-radius: var(--footnote-radius, var(--block-radius-sm, 8px));
	box-shadow: var(--footnote-shadow, 0 12px 30px rgba(0, 0, 0, .28));
	font-family: var(--footnote-font, var(--block-font-body, inherit));
	font-size: .85rem;
	font-weight: 400;
	line-height: 1.55;
	text-align: left;
	animation: footnoteTipIn .16s ease;
}

@keyframes footnoteTipIn {
	from { opacity: 0; transform: translateY(4px); }
	to   { opacity: 1; transform: none; }
}

.footnote-tip--below {
	animation-name: footnoteTipInBelow;
}

@keyframes footnoteTipInBelow {
	from { opacity: 0; transform: translateY(-4px); }
	to   { opacity: 1; transform: none; }
}

/* The arrow: a rotated square tucked under the panel, moved horizontally by
   the script so it keeps pointing at the marker even when the tooltip is
   clamped against a screen edge. */
.footnote-tip__arrow {
	position: absolute;
	width: 12px;
	height: 12px;
	background: var(--footnote-tip-bg, var(--block-dark, #222));
	transform: rotate(45deg);
	bottom: -5px;
}

.footnote-tip--below .footnote-tip__arrow {
	bottom: auto;
	top: -5px;
}

.footnote-tip__num {
	flex: 0 0 auto;
	min-width: 1.3rem;
	height: 1.3rem;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	background: var(--footnote-num-bg, var(--block-accent, #fff));
	color: var(--footnote-num-text, var(--block-accent-ink, #222));
	font-size: .7rem;
	font-weight: 700;
	margin-top: .1rem;
}

.footnote-tip__body {
	flex: 1 1 auto;
	min-width: 0;
	overflow-wrap: anywhere;
}

.footnote-tip__body > *:last-child {
	margin-bottom: 0;
}

.footnote-tip__body a {
	color: var(--footnote-tip-link, var(--block-accent-pale, currentColor)) !important;
	text-decoration: underline;
	text-underline-offset: 2px;
	border: 0 !important;
}

.footnote-tip__body a:hover {
	color: var(--footnote-tip-text, #fff) !important;
}

.footnote-tip__close {
	flex: 0 0 auto;
	background: none;
	border: 0;
	padding: 0 .1rem;
	font-size: 1.1rem;
	line-height: 1;
	color: inherit;
	opacity: .65;
	cursor: pointer;
	border-radius: 4px;
}

.footnote-tip__close:hover,
.footnote-tip__close:focus-visible {
	opacity: 1;
	background: rgba(255, 255, 255, .12);
}

/* ── End-of-article list (canonical copy, no-JS target) ── */
.footnote-list {
	margin: 3rem 0 0;
	padding-top: 1.6rem;
	border-top: 1px solid var(--footnote-rule, rgba(0, 0, 0, .1));
	font-family: var(--footnote-font, var(--block-font-body, inherit));
}

.footnote-list__title {
	font-size: .74rem !important;
	letter-spacing: .12em;
	text-transform: uppercase;
	color: var(--footnote-muted, var(--block-text-secondary, #555));
	margin: 0 0 1rem !important;
	font-family: var(--footnote-font, var(--block-font-body, inherit)) !important;
}

.footnote-list__title::before,
.footnote-list__title::after {
	content: none !important; /* templates that decorate content h2s */
}

.footnote-list__items {
	margin: 0;
	padding-left: 1.4rem;
	font-size: .88rem;
	line-height: 1.65;
	color: var(--footnote-muted, var(--block-text-secondary, #555));
	overflow-wrap: anywhere;
}

.footnote-list__item {
	margin-bottom: .7rem;
	scroll-margin-top: var(--footnote-scroll-offset, 80px);
}

.footnote-list__item:target {
	background: var(--footnote-accent-soft, var(--block-accent-glow, rgba(0, 0, 0, .08)));
	border-radius: 4px;
}

.footnote-back {
	text-decoration: none;
	border: 0;
	color: var(--footnote-accent, var(--block-accent-text, #1a5fb4));
	font-size: .9em;
	white-space: nowrap;
}

.footnote-back:hover {
	color: var(--footnote-ink, var(--block-text, #222));
}

/* ── Print: the list carries everything ──────────── */
@media print {
	.footnote-tip { display: none; }
	.footnote-list { break-inside: avoid; }
}

@media (prefers-reduced-motion: reduce) {
	.footnote-tip { animation: none; }
	.footnote-ref > a { transition: none; }
}
