/* Headings Link — front end */

:root {
	--hl-offset: 90px;
	--hl-highlight: #fff2b2;
}

.hl-heading {
	--hl-icon: currentColor;
	--hl-icon-hover: #4d3df7;
	--hl-icon-hover-bg: rgba(77, 61, 247, 0.13);
	--hl-icon-active-bg: rgba(77, 61, 247, 0.26);
	--hl-icon-done: #0f9d6b;

	scroll-margin-top: calc(var(--hl-offset) + 10px);
	position: relative;
}

.hl-heading:focus {
	outline: none;
}

.hl-actions {
	display: inline-flex;
	align-items: center;
	gap: 0.15em;
	margin-inline-start: 0.35em;
	vertical-align: baseline;
	opacity: 0;
	transition: opacity 0.16s ease;
	font-size: max(0.62em, 13px);
	font-weight: 400;
	line-height: 1;
	white-space: nowrap;
	user-select: none;
}

.hl-heading:hover .hl-actions,
.hl-heading:focus-within .hl-actions {
	opacity: 1;
}

/*
 * Themes love to restyle links on hover — gradient text fills, matching
 * colours, underline images. Everything below is pinned so the control keeps
 * its own look no matter what the theme does around it.
 */
.hl-heading .hl-anchor,
.hl-heading .hl-copy {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 1.7em;
	height: 1.7em;
	padding: 0;
	border: 0;
	border-radius: 0.4em;
	background: transparent;
	background-image: none !important;
	color: var(--hl-icon) !important;
	-webkit-text-fill-color: currentColor !important;
	opacity: 0.55;
	visibility: visible !important;
	cursor: pointer;
	text-decoration: none !important;
	box-shadow: none;
	transform: scale(1);
	transition: opacity 0.15s ease, color 0.15s ease, background-color 0.15s ease,
		transform 0.12s ease, box-shadow 0.15s ease;
	-webkit-tap-highlight-color: transparent;
}

.hl-heading .hl-anchor::before,
.hl-heading .hl-anchor::after,
.hl-heading .hl-copy::before,
.hl-heading .hl-copy::after {
	content: none !important;
}

/* Hover / keyboard focus */
.hl-heading .hl-anchor:hover,
.hl-heading .hl-anchor:focus,
.hl-heading .hl-anchor:focus-visible,
.hl-heading .hl-copy:hover,
.hl-heading .hl-copy:focus,
.hl-heading .hl-copy:focus-visible {
	opacity: 1 !important;
	color: var(--hl-icon-hover) !important;
	-webkit-text-fill-color: var(--hl-icon-hover) !important;
	background-color: var(--hl-icon-hover-bg) !important;
	text-decoration: none !important;
	transform: translateY(-1px);
}

.hl-heading .hl-anchor:focus-visible,
.hl-heading .hl-copy:focus-visible {
	outline: 2px solid var(--hl-icon-hover);
	outline-offset: 1px;
}

/* Press — pointer, keyboard and touch all end up here */
.hl-heading .hl-anchor:active,
.hl-heading .hl-copy:active,
.hl-heading .hl-anchor.is-pressed,
.hl-heading .hl-copy.is-pressed {
	opacity: 1 !important;
	color: var(--hl-icon-hover) !important;
	-webkit-text-fill-color: var(--hl-icon-hover) !important;
	background-color: var(--hl-icon-active-bg) !important;
	transform: scale(0.86);
	transition-duration: 0.06s;
}

.hl-heading .hl-anchor.is-pressed,
.hl-heading .hl-copy.is-pressed {
	animation: hl-press-ring 0.45s ease-out 1;
}

@keyframes hl-press-ring {
	from {
		box-shadow: 0 0 0 0 var(--hl-icon-active-bg);
	}

	to {
		box-shadow: 0 0 0 0.55em rgba(0, 0, 0, 0);
	}
}

.hl-heading .hl-anchor > span {
	display: block;
	line-height: 1;
}

.hl-heading .hl-copy svg {
	width: 1em;
	height: 1em;
	fill: none;
}

/* The check mark only appears after a successful copy. */
.hl-heading .hl-copy .hl-copy__link {
	display: block;
}

.hl-heading .hl-copy .hl-copy__done {
	display: none;
}

/* Copied confirmation */
.hl-heading .hl-copy.is-done,
.hl-heading .hl-copy.is-done:hover {
	opacity: 1 !important;
	color: var(--hl-icon-done) !important;
	-webkit-text-fill-color: var(--hl-icon-done) !important;
	background-color: rgba(15, 157, 107, 0.14) !important;
	transform: scale(1);
}

.hl-heading .hl-copy.is-done .hl-copy__link {
	display: none;
}

.hl-heading .hl-copy.is-done .hl-copy__done {
	display: block;
	animation: hl-pop 0.28s ease-out 1;
}

@keyframes hl-pop {
	from {
		transform: scale(0.5);
		opacity: 0;
	}

	to {
		transform: scale(1);
		opacity: 1;
	}
}

/* Touch devices never get hover, so keep the controls available. */
@media (hover: none) {
	.hl-actions {
		opacity: 0.75;
	}

	.hl-heading .hl-anchor,
	.hl-heading .hl-copy {
		opacity: 0.7;
	}
}

@media (prefers-reduced-motion: reduce) {
	.hl-heading .hl-anchor,
	.hl-heading .hl-copy {
		transition: none;
		transform: none !important;
		animation: none !important;
	}
}

/* ---------- landing highlight ---------- */

.hl-heading.hl-is-target {
	animation: hl-pulse 2s ease-out 1;
	border-radius: 4px;
}

@keyframes hl-pulse {
	0% {
		background-color: var(--hl-highlight);
		box-shadow: 0 0 0 6px var(--hl-highlight);
	}

	70% {
		background-color: var(--hl-highlight);
		box-shadow: 0 0 0 6px var(--hl-highlight);
	}

	100% {
		background-color: transparent;
		box-shadow: 0 0 0 6px transparent;
	}
}

@media (prefers-reduced-motion: reduce) {
	.hl-heading.hl-is-target {
		animation: none;
		background-color: var(--hl-highlight);
		box-shadow: 0 0 0 6px var(--hl-highlight);
	}
}

/* ---------- toast ---------- */

.hl-toast {
	position: fixed;
	left: 50%;
	bottom: 28px;
	z-index: 99999;
	transform: translate(-50%, 12px);
	padding: 10px 18px;
	border-radius: 999px;
	background: #10131a;
	color: #fff;
	font-size: 14px;
	line-height: 1.3;
	letter-spacing: 0.01em;
	box-shadow: 0 8px 28px rgba(16, 19, 26, 0.28);
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.18s ease, transform 0.18s ease;
}

.hl-toast.is-visible {
	opacity: 1;
	transform: translate(-50%, 0);
}

@media (prefers-reduced-motion: reduce) {
	.hl-toast {
		transition: none;
	}
}
