/*
 * Footnotes — reference marker, tooltip, end-of-article list.
 * Enqueued only on entries whose content carries the [nota] shortcode
 * (see includes/footnotes.php). Replaces the Modern Footnotes stylesheet.
 */

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

.ali-fn > a {
	color: var(--ali-teal-text);
	font-weight: 700;
	text-decoration: none;
	border: 0;
	padding: 0 .18em;
	border-radius: 3px;
	cursor: pointer;
	scroll-margin-top: 110px; /* clears the sticky topbar on backlink jumps */
	transition: background .18s ease, color .18s ease;
}

/* Hover is scoped away from the open state: the open marker is white ink on a
   teal fill, so letting the pale hover background win made the number vanish. */
.ali-fn:not(.ali-fn--open) > a:hover,
.ali-fn:not(.ali-fn--open) > a:focus-visible {
	background: var(--ali-teal-glow);
}

/* Every article template styles in-article links through a four-class :not()
   chain (.riv-article / .blog-single-article / .agg-article / .com-article),
   and the rivista copy is inline in the template, so it also wins ties. Only
   the declarations the marker cannot live without are forced: its underline,
   and the open state's fill and ink. The resting colour stays the template's. */
.ali-fn > a {
	border-bottom: 0 !important;
	padding-bottom: 0 !important;
}

.ali-fn--open > a,
.ali-fn--open > a:hover,
.ali-fn--open > a:focus-visible {
	background: var(--ali-teal-text) !important;
	color: #fff !important;
}

/* ── Tooltip ─────────────────────────────────────── */
.ali-fn-tip {
	position: absolute;
	z-index: 900;
	display: flex;
	align-items: flex-start;
	gap: .7rem;
	box-sizing: border-box;
	padding: .8rem .9rem;
	background: var(--ali-navy);
	color: #fff;
	border-radius: var(--ali-radius-sm);
	box-shadow: 0 12px 30px rgba(26, 35, 50, .28);
	font-family: 'Karla', sans-serif;
	font-size: .85rem;
	font-weight: 400;
	line-height: 1.55;
	text-align: left;
	animation: aliFnTipIn .16s ease;
}

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

.ali-fn-tip--below {
	animation-name: aliFnTipInBelow;
}

@keyframes aliFnTipInBelow {
	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. */
.ali-fn-tip__arrow {
	position: absolute;
	width: 12px;
	height: 12px;
	background: var(--ali-navy);
	transform: rotate(45deg);
	bottom: -5px;
}

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

.ali-fn-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(--ali-teal);
	color: var(--ali-navy);
	font-size: .7rem;
	font-weight: 700;
	margin-top: .1rem;
}

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

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

.ali-fn-tip__body a {
	color: var(--ali-teal-light) !important;
	text-decoration: underline;
	text-underline-offset: 2px;
	border: 0 !important;
}

.ali-fn-tip__body a:hover {
	color: #fff !important;
}

.ali-fn-tip__close {
	flex: 0 0 auto;
	background: none;
	border: 0;
	padding: 0 .1rem;
	font-size: 1.1rem;
	line-height: 1;
	color: rgba(255, 255, 255, .65);
	cursor: pointer;
	border-radius: 4px;
}

.ali-fn-tip__close:hover,
.ali-fn-tip__close:focus-visible {
	color: #fff;
	background: rgba(255, 255, 255, .12);
}

/* ── End-of-article list (canonical copy, no-JS target) ── */
.ali-fn-list {
	margin: 3rem 0 0;
	padding-top: 1.6rem;
	border-top: 1px solid rgba(0, 0, 0, .1);
	font-family: 'Karla', sans-serif;
}

.ali-fn-list__title {
	font-size: .74rem !important;
	letter-spacing: .12em;
	text-transform: uppercase;
	color: var(--ali-text-secondary);
	margin: 0 0 1rem !important;
	font-family: 'Karla', sans-serif !important;
}

.ali-fn-list__title::before {
	content: none !important; /* the rivista template decorates h2 with a rule */
}

.ali-fn-list__items {
	margin: 0;
	padding-left: 1.4rem;
	font-size: .88rem;
	line-height: 1.65;
	color: var(--ali-text-secondary);
	overflow-wrap: anywhere;
}

.ali-fn-list__item {
	margin-bottom: .7rem;
	scroll-margin-top: 110px;
}

.ali-fn-list__item:target {
	background: var(--ali-teal-glow);
	border-radius: 4px;
}

.ali-fn-back {
	text-decoration: none;
	border: 0;
	color: var(--ali-teal-text);
	font-size: .9em;
	white-space: nowrap;
}

.ali-fn-back:hover {
	color: var(--ali-navy);
}

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

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