/**
 * hashIT by Seresa - Anchor Link Styles
 *
 * Minimal, elegant hover-reveal for H2 anchor links.
 *
 * @package HashIT
 * @since   1.0.0
 */

/* H2 wrapper - enable anchor positioning */
h2:has(.hashit-link) {
	position: relative;
	scroll-margin-top: 2rem;
}

/* Anchor link - hidden by default, no-wrap to prevent orphan */
.hashit-link {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	margin-inline-start: 0.25em;
	padding: 0.1em 0.3em;
	font-family: ui-monospace, 'SF Mono', 'Cascadia Code', 'Segoe UI Mono', monospace;
	font-size: 0.75em;
	font-weight: 600;
	line-height: 1;
	color: var(--hashit-color, #DE3163);
	text-decoration: none;
	vertical-align: middle;
	white-space: nowrap;
	background: var(--hashit-bg, #F5D7DC);
	border-radius: 0.25em;
	opacity: 0;
	transition:
		opacity 0.2s ease,
		transform 0.2s ease,
		background-color 0.2s ease;
	transform: translateX(-0.25em);
}

/* Reveal on heading hover */
h2:hover .hashit-link,
h2:focus-within .hashit-link,
.hashit-link:focus {
	opacity: 1;
	transform: translateX(0);
}

/* Hover state for the link itself */
.hashit-link:hover {
	color: var(--hashit-color-hover, #C41E3A);
	background: var(--hashit-bg-hover, #F0C4CA);
	text-decoration: none;
}

/* Focus visible for accessibility */
.hashit-link:focus-visible {
	opacity: 1;
	outline: 2px solid var(--hashit-color, #DE3163);
	outline-offset: 2px;
	transform: translateX(0);
}

/* Active/click state */
.hashit-link:active {
	transform: translateX(0) scale(0.95);
}

/* Tooltip on hover - optional enhancement */
.hashit-link::after {
	content: 'Copy link';
	position: absolute;
	bottom: 100%;
	left: 50%;
	z-index: 10;
	padding: 0.4em 0.6em;
	font-family: system-ui, -apple-system, sans-serif;
	font-size: 0.7rem;
	font-weight: 500;
	color: #fff;
	white-space: nowrap;
	pointer-events: none;
	background: #1e293b;
	border-radius: 0.25em;
	opacity: 0;
	transition: opacity 0.15s ease;
	transform: translateX(-50%);
}

.hashit-link:hover::after {
	opacity: 1;
}

/* Copied state - show confirmation */
.hashit-link.hashit-copied {
	color: #16a34a;
	background: #dcfce7;
}

.hashit-link.hashit-copied::after {
	content: 'Copied!';
	opacity: 1;
	background: #16a34a;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
	.hashit-link {
		--hashit-color: #DE3163;
		--hashit-bg: #3D2A2D;
		--hashit-color-hover: #E75480;
		--hashit-bg-hover: #4A3336;
	}

	.hashit-link.hashit-copied {
		color: #4ade80;
		background: #14532d;
	}
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
	.hashit-link {
		transition: none;
	}

	.hashit-link::after {
		transition: none;
	}
}

/* Print - hide anchor links */
@media print {
	.hashit-link {
		display: none;
	}
}
