/**
 * US Map Links — Frontend styles
 * Modern, clean, accessible interactive map styling.
 */

.usml-wrap {
	--usml-fill: #cbd5e1;
	--usml-no-link-fill: #cbd5e1;
	--usml-stroke: #ffffff;
	--usml-stroke-width: 1px;
	--usml-hover-fill: #2563eb;
	--usml-active-fill: #1d4ed8;
	--usml-text: #1e293b;
	--usml-hover-text: #ffffff;
	--usml-tooltip-bg: #0f172a;
	--usml-tooltip-text: #ffffff;

	position: relative;
	width: 100%;
	margin: 0 auto;
	line-height: 0;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	-webkit-font-smoothing: antialiased;
}

.usml-svg {
	display: block;
	width: 100%;
	height: auto;
	overflow: visible;
}

/* Base state shape */
.usml-state-shape {
	fill: var(--usml-fill);
	stroke: var(--usml-stroke);
	stroke-width: var(--usml-stroke-width);
	stroke-linejoin: round;
	transition: fill 160ms ease, transform 160ms ease, filter 160ms ease;
	transform-origin: center;
}

.usml-wrap[data-animation="0"] .usml-state-shape {
	transition: fill 60ms linear;
}

/* States without a configured link render slightly muted and non-interactive */
.usml-state.usml-no-link .usml-state-shape {
	fill: var(--usml-no-link-fill);
	opacity: 0.55;
	cursor: default;
}

.usml-state.usml-has-link {
	cursor: pointer;
}

.usml-state.usml-has-link .usml-state-shape {
	cursor: pointer;
}

/* Hover + keyboard focus state */
.usml-state.usml-has-link:hover .usml-state-shape,
.usml-state.usml-has-link.usml-is-hover .usml-state-shape,
.usml-state.usml-has-link:focus-visible .usml-state-shape {
	fill: var(--usml-hover-fill);
}

.usml-wrap[data-shadow="1"] .usml-state.usml-has-link:hover .usml-state-shape,
.usml-wrap[data-shadow="1"] .usml-state.usml-has-link.usml-is-hover .usml-state-shape {
	filter: drop-shadow(0 3px 6px rgba(15, 23, 42, 0.35));
}

.usml-wrap[data-animation="1"] .usml-state.usml-has-link:hover .usml-state-shape,
.usml-wrap[data-animation="1"] .usml-state.usml-has-link.usml-is-hover .usml-state-shape {
	transform: scale(1.015);
}

/* Active / pressed */
.usml-state.usml-has-link:active .usml-state-shape {
	fill: var(--usml-active-fill);
}

.usml-state:focus {
	outline: none;
}

.usml-state.usml-has-link:focus-visible .usml-state-shape {
	stroke: var(--usml-active-fill);
	stroke-width: calc(var(--usml-stroke-width) + 1px);
}

/* DC marker (rendered as a circle) */
.usml-state-dc {
	stroke-width: 1.5px;
}

/* Optional labels (state abbreviations) layered on top -- populated by JS */
.usml-state-label {
	pointer-events: none;
	font-size: 9px;
	font-weight: 600;
	fill: var(--usml-text);
	text-anchor: middle;
	dominant-baseline: middle;
	opacity: 0;
	transition: opacity 160ms ease, fill 160ms ease;
}

.usml-show-labels .usml-state-label {
	opacity: 0.85;
}

.usml-state.usml-has-link:hover .usml-state-label,
.usml-state.usml-has-link.usml-is-hover .usml-state-label,
.usml-state.usml-has-link:focus-visible .usml-state-label {
	fill: var(--usml-hover-text);
}

/* Tooltip */
.usml-tooltip {
	position: absolute;
	top: 0;
	left: 0;
	z-index: 20;
	pointer-events: none;
	transform: translate(-50%, calc(-100% - 12px));
	background: var(--usml-tooltip-bg);
	color: var(--usml-tooltip-text);
	padding: 7px 12px;
	border-radius: 8px;
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.01em;
	white-space: nowrap;
	box-shadow: 0 8px 24px rgba(15, 23, 42, 0.25);
	opacity: 0;
	visibility: hidden;
	transition: opacity 120ms ease, transform 120ms ease;
	will-change: transform, opacity;
}

.usml-tooltip::after {
	content: "";
	position: absolute;
	top: 100%;
	left: 50%;
	transform: translateX(-50%);
	border: 6px solid transparent;
	border-top-color: var(--usml-tooltip-bg);
}

.usml-tooltip.usml-tooltip-visible {
	opacity: 1;
	visibility: visible;
	transform: translate(-50%, calc(-100% - 18px));
}

/* Small screens: keep things comfortably tappable */
@media (max-width: 480px) {
	.usml-tooltip {
		font-size: 12px;
		padding: 6px 10px;
	}
}

/* Respect users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
	.usml-state-shape,
	.usml-tooltip {
		transition: none !important;
	}
}
