/* course-widgets/diagram.css
 *
 * the parameterized illustration engine (js/course-widgets/diagram.js): labeled
 * diagrams on a normalized coordinate space -- molecular structures (nodes +
 * edges) and anatomy/cross-section hotspot maps (a themeable line-art background
 * with positioned markers). chrome uses theme tokens; marker/tier fills come from
 * the data and encode meaning. */

.cw-diagram { display: grid; grid-template-columns: 1fr; gap: 16px; align-items: start; }
@media (min-width: 720px) { .cw-diagram { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); } }
.cw-diagram-stage { display: flex; flex-direction: column; gap: 10px; }
/* full-width above both columns so the figure box top-aligns (flush) with the detail box */
.cw-diagram-title { grid-column: 1 / -1; font-size: 0.85rem; font-weight: 600; color: var(--color-text-muted); margin: 0; text-align: center; }
.cw-diagram-canvas { background: var(--glass-bg); border: 1px solid var(--glass-border); border-radius: var(--radius-md, 14px); padding: 10px; }
/* themeable line-art: stroke="currentColor" inherits this token, so the outline
   is dark on light and light on dark with no invert hack and no background box */
.cw-diagram-bg { color: var(--color-text); opacity: 0.85; }
.cw-diagram-svg { width: 100%; height: auto; display: block; }
.cw-diagram-bgimg--invert { } /* light theme: raster outline art shown as-authored */
/* dark: invert the black-on-white art to white lines, then screen-blend so the
   former white background drops out instead of leaving a black box */
html.dark .cw-diagram-bgimg--invert { filter: invert(1); mix-blend-mode: screen; }
.cw-diagram-marker { cursor: pointer; outline: none; transition: transform 0.15s ease; }
.cw-diagram--reduced .cw-diagram-marker { transition: none; }
.cw-diagram-marker:focus-visible circle { outline: none; }
.cw-diagram-marker:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.cw-diagram-pulse { animation: cw-diagram-pulse 1.8s ease-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes cw-diagram-pulse { 0% { transform: scale(0.8); opacity: 0.25; } 70% { transform: scale(1.4); opacity: 0; } 100% { opacity: 0; } }
.cw-diagram--reduced .cw-diagram-pulse { animation: none; }
.cw-diagram-code { font-size: 17px; font-weight: 700; font-family: system-ui, sans-serif; pointer-events: none; }
.cw-diagram-nodelabel { font-size: 14px; font-weight: 600; font-family: system-ui, sans-serif; fill: var(--color-text); pointer-events: none; }
.cw-diagram-hotlabel { font-size: 13.5px; font-weight: 600; font-family: system-ui, sans-serif; fill: var(--color-text); pointer-events: none; }
.cw-diagram-hotlabel.is-selected { fill: var(--color-primary); font-weight: 700; }
/* dark mode: lift the labels off the dim muted tone so they read clearly */
html.dark .cw-diagram-hotlabel { fill: #f1f5f9; }
html.dark .cw-diagram-hotlabel.is-selected { fill: var(--color-primary); }
.cw-diagram-leader { stroke: var(--color-text-muted); stroke-width: 1; opacity: 0.45; stroke-dasharray: 2 2; }
html.dark .cw-diagram-leader { stroke: #94a3b8; opacity: 0.55; }
.cw-diagram-middot { font-size: 11px; font-weight: 700; font-family: system-ui, sans-serif; pointer-events: none; }
.cw-diagram-edgelabel { font-size: 12px; font-family: system-ui, sans-serif; fill: var(--color-text-muted); }
.cw-diagram-stepbar { display: flex; gap: 10px; justify-content: center; align-items: center; flex-wrap: wrap; }
.cw-diagram-playbtn { padding: 5px 14px; border-radius: 8px; font-size: 12.5px; font-weight: 600; border: 1px solid var(--color-primary); background: transparent; color: var(--color-primary); cursor: pointer; }
.cw-diagram-playbtn:hover { background: color-mix(in srgb, var(--color-primary) 12%, transparent); }
.cw-diagram-counter { font-size: 12px; font-weight: 600; color: var(--color-text-muted); font-variant-numeric: tabular-nums; }
.cw-diagram-toggle { display: inline-flex; border: 1px solid var(--color-border); border-radius: 9px; overflow: hidden; }
.cw-diagram-togglebtn { padding: 5px 15px; font-size: 12.5px; font-weight: 500; border: none; background: transparent; color: var(--color-text-muted); cursor: pointer; }
.cw-diagram-togglebtn + .cw-diagram-togglebtn { border-left: 1px solid var(--color-border); }
.cw-diagram-togglebtn:hover { color: var(--color-primary); }
.cw-diagram-togglebtn.is-active { background: color-mix(in srgb, var(--color-primary) 14%, transparent); color: var(--color-primary); font-weight: 600; }
.cw-diagram-views { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.cw-diagram-viewbtn { padding: 5px 13px; border-radius: 8px; font-size: 12.5px; font-weight: 500; border: 1px solid var(--color-border); background: transparent; color: var(--color-text-muted); cursor: pointer; }
.cw-diagram-viewbtn:hover { border-color: var(--color-primary); color: var(--color-primary); }
.cw-diagram-viewbtn.is-active { background: color-mix(in srgb, var(--color-primary) 12%, transparent); border-color: var(--color-primary); color: var(--color-primary); }
.cw-diagram-legend { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; font-size: 11.5px; color: var(--color-text-muted); }
.cw-diagram-legend-item { display: flex; align-items: center; gap: 5px; }
.cw-diagram-legend-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.cw-diagram-detail { background: var(--glass-bg); border: 1px solid var(--glass-border); border-radius: var(--radius-md, 14px); padding: 16px; min-height: 96px; align-self: start; }
.cw-diagram-detail-empty { color: var(--color-text-muted); font-size: 13px; text-align: center; padding: 18px 0; }
.cw-diagram-detail-head { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.cw-diagram-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.cw-diagram-detail-name { font-size: 15px; font-weight: 650; color: var(--color-text); }
.cw-diagram-detail-badge { font-size: 10.5px; font-weight: 600; padding: 2px 8px; border: 1px solid; border-radius: 6px; margin-left: auto; }
.cw-diagram-detail-summary { font-size: 13px; color: var(--color-text-muted); line-height: 1.55; margin: 0 0 8px; }
.cw-diagram-detail-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 5px; }
.cw-diagram-detail-list li { font-size: 12.5px; color: var(--color-text-muted); line-height: 1.45; }
.cw-diagram-detail-meta { font-size: 11.5px; color: var(--color-text-muted); margin: 8px 0 0; }
