/* Charts in the posts and on the vario page, made by .claude/build/charts/charts.py.
   Bars and columns are HTML, the vario curves are inline SVG; charts.js adds the tooltips. */

.wm-chart {
	position: relative;
	max-width: 640px;
	margin: 2rem auto;
	font-size: 0.95rem;
	line-height: 1.4;
	color: #333;
}

/* The SVG charts scale with the column, text included: narrower, so their text stays at a normal size */
.wm-chart-narrow {
	max-width: 480px;
}

/* Over blog.css's style for image captions */
figure.wm-chart figcaption.wm-chart-title {
	margin: 0 0 0.75rem;
	font-size: 0.95rem;
	font-weight: 600;
	color: #222;
}

.wm-chart-source {
	margin: 0.75rem 0 0;
	font-size: 0.85rem;
	color: #6f6e69;
}

/* Legend: a short line in the series colour before each name */
.wm-chart-legend {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25rem 1.25rem;
	margin: 0 0 0.5rem;
	padding: 0;
	list-style: none;
	font-size: 0.85rem;
	color: #52514e;
}

.wm-chart-legend li {
	display: flex;
	align-items: center;
	gap: 0.4rem;
	margin: 0;
}

.wm-chart-legend i {
	display: inline-block;
	width: 18px;
	height: 2px;
}

/* White gaps over the colour make the key dashed */
.wm-chart-legend i.wm-key-dashed {
	background-image: repeating-linear-gradient(90deg, transparent 0 5px, #fff 5px 8px);
}

/* Horizontal bars: name, then the bar from the baseline with its value at the tip */
.wm-bars {
	display: grid;
	grid-template-columns: max-content 1fr;
	gap: 0.6rem 0.9rem;
	align-items: center;
}

.wm-bar-track {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	border-left: 1px solid #c3c2b7;
}

.wm-bar {
	flex-shrink: 0;
	height: 20px;
	border-radius: 0 4px 4px 0;
	background: #007AFF;
}

.wm-bar-muted {
	background: #8f8e88;
}

.wm-bar-value {
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
	color: #222;
}

/* Columns over time, with a y axis and hairline gridlines */
.wm-cols {
	padding-left: 3.6em;
}

.wm-cols-plot {
	position: relative;
	display: flex;
	align-items: flex-end;
	height: 190px;
	border-bottom: 1px solid #c3c2b7;
}

.wm-cols-grid {
	position: absolute;
	inset: 0;
	pointer-events: none;
}

.wm-cols-grid span {
	position: absolute;
	left: 0;
	right: 0;
	border-top: 1px solid #e1e0d9;
}

.wm-cols-grid b {
	position: absolute;
	right: 100%;
	transform: translateY(-50%);
	padding-right: 0.5em;
	font-weight: normal;
	font-size: 0.8rem;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
	color: #6f6e69;
}

/* Positioned, so the columns are drawn over the gridlines */
.wm-col {
	position: relative;
	display: flex;
	flex: 1;
	flex-direction: column;
	justify-content: flex-end;
	align-items: center;
	height: 100%;
}

.wm-col-bar {
	width: 60%;
	max-width: 24px;
	border-radius: 4px 4px 0 0;
	background: #007AFF;
}

.wm-col-value {
	margin-bottom: 0.25rem;
	font-size: 0.8rem;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
	color: #222;
}

.wm-cols-x {
	display: flex;
	margin-top: 0.3rem;
	font-size: 0.8rem;
	font-variant-numeric: tabular-nums;
	color: #6f6e69;
}

.wm-cols-x span {
	flex: 1;
	text-align: center;
}

/* Inline SVG: its coordinates and text scale with the width of the figure */
.wm-chart svg {
	display: block;
	width: 100%;
	height: auto;
	overflow: visible;
}

/* Labels over gridlines get a white outline */
.wm-chart .wm-halo {
	paint-order: stroke;
	stroke: #fff;
	stroke-width: 3px;
	stroke-linejoin: round;
}

/* Hover: the crosshair of the vario chart, a lighter bar or column */
.wm-band .wm-cross {
	visibility: hidden;
}

.wm-band:hover .wm-cross {
	visibility: visible;
}

.wm-bar:hover,
.wm-col:hover .wm-col-bar {
	filter: brightness(1.15);
}

/* The tooltip that charts.js fills in */
.wm-chart-tip {
	position: absolute;
	z-index: 2;
	display: none;
	padding: 0.4rem 0.65rem;
	border: 1px solid rgba(11, 11, 11, 0.1);
	border-radius: 6px;
	background: #fff;
	box-shadow: 0 2px 8px rgba(11, 11, 11, 0.12);
	font-size: 0.85rem;
	line-height: 1.35;
	white-space: nowrap;
	pointer-events: none;
}

.wm-chart-tip strong {
	display: block;
	color: #111;
}

.wm-chart-tip span {
	color: #52514e;
}

/* The figures as a table, folded under the chart */
.wm-chart details {
	margin-top: 0.5rem;
	font-size: 0.85rem;
}

.wm-chart summary {
	cursor: pointer;
	color: #007AFF;
}

.wm-chart details .table-responsive {
	margin-top: 0.5rem;
}

.wm-chart details table {
	margin: 0;
	font-variant-numeric: tabular-nums;
}

/* Smaller than the posts' tables (blog.css), so the table fits a phone */
.entry-content .wm-chart details .table th,
.entry-content .wm-chart details .table td {
	padding: 0.3rem 0.5rem;
	font-size: 0.85rem;
}

@media (max-width: 480px) {
	/* The name goes above its bar */
	.wm-bars {
		grid-template-columns: 1fr;
		gap: 0.15rem;
	}

	.wm-bar-track {
		margin-bottom: 0.5rem;
	}

	/* Every other year under the columns */
	.wm-cols-x span:nth-child(even) {
		visibility: hidden;
	}
}
