/*
 * Citations. Inherits your theme's fonts and text color.
 * Override the custom properties below in your theme to match it.
 */
:root {
	--cite-accent: #2f5d8a;
	--cite-surface: #fff;
	--cite-border: #c8ccd1;
	--cite-muted: #54595d;
	--cite-highlight: #eaf3ff;
	--cite-radius: calc(.25rem - 1px);
	--cite-shadow: 0 0.2rem 0.3rem 0.1rem rgb(0 0 0 / 18%);
}

/* ---------- Inline links ---------- */

.cite-ref {
	line-height: 1;
	font-size: 0.75em;
	white-space: nowrap;
}

.cite-ref a {
	text-decoration: none;
}

a.cite-link:not(.cite-ref a) {
	text-decoration-style: dotted;
	text-underline-offset: 0.2em;
}

a.cite-link:focus-visible {
	outline: 2px solid var(--cite-accent);
	outline-offset: 2px;
}

/* ---------- References list ---------- */

.cite-references {
	margin-block: 2.5rem 1rem;
	font-size: 0.9em;
}

.cite-references__heading {
	margin-bottom: 0.75rem;
}

.cite-list {
	margin: 0;
	padding: 0;
	list-style: none;
}

.cite-list li {
	margin-bottom: 0.4em;
	padding: 0.1em 0.3em;
	border-radius: var(--cite-radius);
	scroll-margin-top: 6rem; /* room for sticky headers when jumping here */
	overflow-wrap: anywhere;
}

.cite-list li:target {
	background: var(--cite-highlight);
}

.cite-label {
	margin-right: 0.4em;
	font-weight: 700;
	white-space: nowrap;
}

.cite-backlinks {
	margin-right: 0.35em;
	font-weight: 700;
	font-size: 0.9em;
}

.cite-backlinks a {
	text-decoration: none;
}

.cite-publisher {
	font-style: italic;
}

[id^="cite-ref-"] {
	scroll-margin-top: 6rem;
}

.cite-placeholder {
	padding: 1rem;
	border: 1px dashed var(--cite-border);
	color: var(--cite-muted);
}

/* ---------- Popup ---------- */

.cite-popup {
	position: absolute;
	z-index: 9999;
	width: min(24rem, calc(100vw - 16px));
	padding: 0.85rem 1rem 0.75rem;
	background: var(--cite-surface);
	border: 1px solid var(--cite-border);
	border-radius: var(--cite-radius);
	box-shadow: var(--cite-shadow);
	font-size: 0.875rem;
	line-height: 1.5;
	overflow-wrap: anywhere;
}

.cite-popup[hidden] {
	display: none;
}

.cite-popup::before {
	content: "";
	position: absolute;
	left: clamp(12px, var(--cite-arrow-x, 50%), calc(100% - 12px));
	width: 10px;
	height: 10px;
	background: inherit;
	border: inherit;
	border-width: 1px 0 0 1px;
	transform: translateX(-50%) rotate(45deg);
}

.cite-popup[data-placement="below"]::before {
	top: -6px;
}

.cite-popup[data-placement="above"]::before {
	bottom: -6px;
	transform: translateX(-50%) rotate(225deg);
}

.cite-popup__label {
	font-weight: 700;
}

.cite-popup__body {
	padding-right: 1.25rem; /* room for the close button */
}

.cite-popup__image {
	float: left;
	width: 5.5rem;
	height: auto;
	margin: 0.15rem 0.75rem 0.25rem 0;
	border-radius: var(--cite-radius);
}

.cite-popup__actions {
	clear: both;
}

.cite-popup__close {
	position: absolute;
	top: 0.25rem;
	right: 0.25rem;
	width: 1.75rem;
	height: 1.75rem;
	padding: 0;
	border: 0;
	border-radius: var(--cite-radius);
	background: transparent;
	color: var(--cite-muted);
	font-size: 1.25rem;
	line-height: 1;
	cursor: pointer;
}

.cite-popup__close:hover,
.cite-popup__close:focus-visible {
	background: var(--cite-highlight);
	color: inherit;
}

.cite-popup__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem 1rem;
	margin-top: 0.6rem;
	padding-top: 0.5rem;
	border-top: 1px solid var(--cite-border);
}

.cite-popup__actions:empty {
	display: none;
}

.cite-popup__action {
	color: var(--cite-accent);
	font-weight: 600;
}

@media (prefers-reduced-motion: no-preference) {
	.cite-popup:not([hidden]) {
		animation: cite-pop 120ms ease-out;
	}
	@keyframes cite-pop {
		from { opacity: 0; }
		to { opacity: 1; }
	}
}

@media (hover: none) {
	.cite-popup {
		font-size: 0.95rem;
	}
	.cite-popup__action {
		padding-block: 0.35rem; /* bigger tap targets */
	}
}

/* ---------- /citations/ archive ---------- */

.cite-archive {
	max-width: 52rem;
	margin-inline: auto;
	--cite-sticky-offset: 230px; /* sticky bar height + a little breathing room */
}

.cite-archive__header {
	position: sticky;
	top: 0;
	z-index: 2;
	padding-block: 1rem 0.75rem;
	background: var(--cite-surface);
	border-bottom: 1px solid var(--cite-border);
}

.cite-archive__label {
	display: block;
	margin-bottom: 0.3rem;
	font-weight: 600;
}

.cite-archive__search {
	width: 100%;
	padding: 0.6rem 0.75rem;
	font: inherit;
	border: 1px solid var(--cite-border);
	border-radius: var(--cite-radius);
}

.cite-archive__search:focus-visible {
	outline: 2px solid var(--cite-accent);
	outline-offset: 1px;
}

.cite-archive__count {
	margin: 0.4rem 0 0;
	color: var(--cite-muted);
	font-size: 0.875rem;
}

.cite-archive__letters {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25rem 0.6rem;
	margin-top: 0.6rem;
}

.cite-archive__letters a {
	text-decoration: none;
	font-weight: 600;
}

.cite-archive__group,
.cite-archive__item {
	scroll-margin-top: var(--cite-sticky-offset);
}

.cite-archive__letter {
	margin: 1.75rem 0 0.5rem;
	color: var(--cite-muted);
}

.cite-archive .cite-archive__list {
	margin: 0;
	padding: 0;
	list-style: none;
}

.cite-archive__item {
	display: inline-block; 
	padding: 0.6rem;
	border-bottom: 1px solid var(--cite-border);
	overflow-wrap: anywhere;
}

.cite-archive__item:target {
	background: var(--cite-highlight);
}


.cite-archive__empty {
	padding: 2rem 0;
	color: var(--cite-muted);
}

@media (max-width: 782px) {
	.cite-archive {
		--cite-sticky-offset: 260px;
	}
}

/* ---------- Single citation ---------- */

.cite-single__tags {
	color: var(--cite-muted);
	font-size: 0.9em;
}

.cite-single__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 1rem;
}
