/*
 * NMCSAP Chart widget (includes/class-chart-widget.php) — M29 Data Tabs.
 * Defaults reproduce the Figma bars / donuts the widget replaced; the widget's Style tab
 * overrides the variables per breakpoint.
 */

.nmc-chart {
	--nmc-bar-max: 237px;
	--nmc-bar-w: 68px;
	--nmc-bar-gap: 8px;
	--nmc-group-gap: 88px;
	--nmc-label-gap: 27px;
	--nmc-donut: 320px;
}

/* ---------- Bars ---------- */

.nmc-bars {
	display: flex;
	justify-content: center;
	align-items: flex-end;
	gap: var(--nmc-group-gap);
	width: 100%;
}

.nmc-bars__group {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: var(--nmc-label-gap);
	min-width: 0;
}

.nmc-bars__bars {
	display: flex;
	align-items: flex-end;
	gap: var(--nmc-bar-gap);
}

.nmc-bars__bar {
	display: block;
	width: var(--nmc-bar-w);
	height: calc(var(--nmc-bar-max) * var(--nmc-h));
	border-radius: 4px 4px 0 0;
	background: var(--nmc-c);
	cursor: pointer;
	transition: filter .15s ease;
}

.nmc-bars__label {
	font-family: "Public Sans", sans-serif;
	font-size: 18px;
	line-height: 16px;
	color: #111;
	white-space: nowrap;
}

/* ---------- Donut ---------- */

.nmc-donut {
	width: var(--nmc-donut);
	max-width: 100%;
	margin: 0 auto;
}

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

.nmc-donut__seg {
	cursor: pointer;
	transform-origin: 80px 80px;
	transition: transform .15s ease, opacity .15s ease;
}

.nmc-donut svg:has(.nmc-donut__seg.is-active) .nmc-donut__seg:not(.is-active) {
	opacity: .55;
}

/* ---------- Hover / focus state ---------- */

.nmc-bars__bar.is-active {
	filter: brightness(.92);
}

.nmc-donut__seg.is-active {
	transform: scale(1.04);
}

.nmc-tip:focus {
	outline: none;
}

.nmc-bars__bar:focus-visible {
	outline: 2px solid #111;
	outline-offset: 2px;
}

.nmc-donut__seg:focus-visible {
	stroke: #111;
	stroke-width: 1.5;
}

/* ---------- Tooltip (one per page, created by assets/js/charts.js) ---------- */

.nmc-tooltip {
	position: fixed;
	z-index: 9999;
	top: 0;
	left: 0;
	max-width: 240px;
	padding: 8px 12px;
	border-radius: 6px;
	background: #111;
	color: #fff;
	font-family: "Public Sans", sans-serif;
	font-size: 14px;
	line-height: 20px;
	pointer-events: none;
	opacity: 0;
	transform: translate(-50%, calc(-100% - 12px));
	transition: opacity .12s ease;
}

.nmc-tooltip.is-visible {
	opacity: 1;
}

.nmc-tooltip::after {
	content: "";
	position: absolute;
	top: 100%;
	left: 50%;
	margin-left: -6px;
	border: 6px solid transparent;
	border-top-color: #111;
}

.nmc-tooltip__title {
	display: block;
	font-weight: 700;
}

/* ---------- Responsive ---------- */

@media (max-width: 1024px) {
	/* Figma has no tablet frame: bars shrink with the card so the chart stays inside it. */
	.nmc-chart {
		--nmc-bar-w: clamp(24px, 5.2vw, 68px);
		--nmc-group-gap: clamp(20px, 4.5vw, 48px);
	}
}

@media (max-width: 767px) {
	.nmc-chart {
		--nmc-bar-max: 149px;
		--nmc-bar-w: 14px;
		--nmc-bar-gap: 4px;
		--nmc-group-gap: 20px;
		--nmc-label-gap: 8px;
		--nmc-donut: 160px;
	}

	.nmc-bars__bar {
		border-radius: 3px;
	}

	.nmc-bars__label {
		font-size: 11px;
		font-weight: 700;
	}
}
