/*
 * On-demand relation map.
 *
 * Scoped under `.radiology-study-graph` and the `[data-radst-graph-open]`
 * control. Like the toolbar, this only ever adds a block to a question
 * section: it never changes the article's own layout, anchors or navigation.
 *
 * The drawing is sized in viewBox units and scaled to its container, so it
 * cannot push the page wider than the column it sits in at any width.
 */

[data-radst-graph-open] {
	align-items: center;
	background: #fff;
	border: 1px solid #4f8a8d;
	border-radius: 8px;
	color: #203746;
	cursor: pointer;
	display: inline-flex;
	font: inherit;
	font-size: 0.9em;
	justify-content: center;
	line-height: 1.4;
	margin: 10px 0 0;
	min-height: 44px;
	min-width: 44px;
	padding: 8px 14px;
	transition: border-color 140ms ease, box-shadow 120ms ease;
}

[data-radst-graph-open]:hover {
	border-color: #176c70;
	box-shadow: 0 3px 8px rgba(32, 55, 70, 0.16);
}

[data-radst-graph-open]:focus-visible {
	outline: 3px solid #c48626;
	outline-offset: 2px;
}

.radiology-study-graph {
	--radst-ink: #203746;
	--radst-muted: #536875;
	--radst-accent: #176c70;
	--radst-line: #d7e3e6;
	--radst-bg: #f2f6f7;
	--radst-paper: #fff;
	--radst-focus: #c48626;

	background: var(--radst-bg);
	border: 1px solid var(--radst-line);
	border-radius: 8px;
	box-sizing: border-box;
	clear: both;
	color: var(--radst-ink);
	font-size: 16px;
	line-height: 1.8;
	margin: 10px 0 8px;
	max-width: 100%;
	/* The list can be long; the section scrolls rather than the page widening. */
	overflow-x: hidden;
	padding: 12px;
}

.radiology-study-graph[hidden] {
	display: none;
}

.radiology-study-graph *,
.radiology-study-graph *::before,
.radiology-study-graph *::after {
	box-sizing: border-box;
}

.radiology-study-graph__title {
	font-size: 0.82em;
	font-weight: 700;
	margin: 0 0 8px;
}

/* ------------------------------------------------------------- drawing */

.radiology-study-graph__canvas {
	background: var(--radst-paper);
	border: 1px solid var(--radst-line);
	border-radius: 8px;
	margin: 0 0 10px;
	max-width: 100%;
	overflow: hidden;
	padding: 6px;
}

.radiology-study-graph__canvas:empty {
	display: none;
}

.radiology-study-graph__svg {
	display: block;
	height: auto;
	max-width: 100%;
	width: 100%;
}

.radiology-study-graph__edge {
	stroke: #9fb9bd;
	stroke-width: 2;
}

.radiology-study-graph__shape {
	fill: var(--radst-paper);
	stroke: #4f8a8d;
	stroke-width: 2;
}

.radiology-study-graph__node.is-root .radiology-study-graph__shape {
	fill: var(--radst-accent);
	stroke: var(--radst-accent);
}

.radiology-study-graph__node.is-card .radiology-study-graph__shape {
	fill: #fbf4e6;
	stroke: #9c7c3c;
}

.radiology-study-graph__label {
	fill: var(--radst-ink);
	font-family: inherit;
	font-size: 15px;
}

.radiology-study-graph__node.is-root .radiology-study-graph__label {
	fill: var(--radst-paper);
	font-weight: 700;
}

/* ---------------------------------------------------------------- list */

/*
 * The list is the accessible form of the drawing, not a summary of it: every
 * node above appears here with its exact year and question number, the reason
 * the article gave, and a real link when the explanation is published.
 */
.radiology-study-graph__list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.radiology-study-graph__item {
	background: var(--radst-paper);
	border: 1px solid var(--radst-line);
	border-radius: 8px;
	margin: 0 0 8px;
	padding: 10px 12px;
}

.radiology-study-graph__item:last-child {
	margin-bottom: 0;
}

.radiology-study-graph__item-title {
	font-size: 0.92em;
	font-weight: 700;
	margin: 0;
}

.radiology-study-graph__item-topic {
	color: var(--radst-muted);
	font-size: 0.82em;
	margin: 2px 0 0;
}

.radiology-study-graph__item-reason {
	font-size: 0.85em;
	margin: 4px 0 0;
	overflow-wrap: anywhere;
}

.radiology-study-graph__item-actions {
	align-items: center;
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 6px 0 0;
}

.radiology-study-graph__link,
.radiology-study-graph__expand {
	align-items: center;
	border-radius: 8px;
	display: inline-flex;
	font: inherit;
	font-size: 0.85em;
	justify-content: center;
	line-height: 1.4;
	min-height: 44px;
	min-width: 44px;
	padding: 8px 12px;
	text-decoration: none;
}

.radiology-study-graph__link {
	border: 1px solid var(--radst-accent);
	color: var(--radst-accent);
}

.radiology-study-graph__expand {
	background: var(--radst-paper);
	border: 1px solid #4f8a8d;
	color: var(--radst-ink);
	cursor: pointer;
	transition: box-shadow 120ms ease, transform 120ms ease;
}

.radiology-study-graph__expand:hover {
	box-shadow: 0 3px 8px rgba(32, 55, 70, 0.16);
}

.radiology-study-graph__expand:active {
	transform: scale(0.97);
}

.radiology-study-graph__unpublished,
.radiology-study-graph__expanded {
	color: var(--radst-muted);
	display: inline-flex;
	align-items: center;
	font-size: 0.82em;
	min-height: 44px;
}

.radiology-study-graph a:focus-visible,
.radiology-study-graph button:focus-visible {
	outline: 3px solid var(--radst-focus);
	outline-offset: 2px;
}

.radiology-study-graph__status {
	color: var(--radst-muted);
	font-size: 0.82em;
	margin: 8px 0 0;
}

.radiology-study-graph__status:empty {
	display: none;
}

.radiology-study-graph__status[data-radst-state="error"] {
	background: var(--radst-paper);
	border: 1px solid var(--radst-line);
	border-left: 4px solid #8c3a44;
	border-radius: 8px;
	color: var(--radst-ink);
	padding: 6px 10px;
}

/* --------------------------------------------------------- narrow screens */

@media (max-width: 480px) {
	.radiology-study-graph {
		padding: 10px;
	}

	.radiology-study-graph__item-actions .radiology-study-graph__link,
	.radiology-study-graph__item-actions .radiology-study-graph__expand {
		flex: 1 1 100%;
	}
}

/* ------------------------------------------------------- reduced motion */

@media (prefers-reduced-motion: reduce) {
	[data-radst-graph-open],
	[data-radst-graph-open]:hover,
	.radiology-study-graph__expand,
	.radiology-study-graph__expand:hover,
	.radiology-study-graph__expand:active {
		transform: none;
		transition: none;
	}
}
