/* source-glossary-map.css - the structure map of the Sources workspace (web/modules/source-glossary-map.js).
   Theme tokens only. Colour encodes a link's state; the dash pattern, weight, end marker and the word on the line
   carry the same meaning without colour. */

.sg-map { display: grid; gap: var(--space-3); min-width: 0; }

.sg-map-controls { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: flex-end; }
.sg-map-control { display: grid; gap: 4px; font-size: var(--fs-small); color: var(--text-secondary); }
.sg-map-control select { min-height: 30px; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 4px 8px; }
.sg-map-classes { display: flex; gap: var(--space-3); align-items: center; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 4px 10px 6px; margin: 0; }
.sg-map-classes legend { padding: 0 4px; }
.sg-map-classes label { display: inline-flex; gap: 5px; align-items: center; color: var(--text-body); }

.sg-map-notices { margin: 0; padding: var(--space-2) var(--space-3); list-style: none; display: grid; gap: 4px; font-size: var(--fs-small); color: var(--text-secondary); background: var(--surface-subtle); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.sg-map-code { margin: var(--space-2) 0 0; font-size: var(--fs-small); color: var(--text-secondary); text-align: center; }

/* The list sits beside the figure only on a wide screen; below that it follows the figure, so the figure gets the width. */
.sg-map-split { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); align-items: start; }
@media (min-width: 1600px) { .sg-map-split { grid-template-columns: minmax(0, 1fr) minmax(240px, 320px); } }
.sg-map-figure { display: grid; gap: var(--space-2); min-width: 0; }
.sg-map-scroll { overflow: auto; max-height: 72vh; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); }
.sg-map-scroll[data-zoom="fit"] { max-height: none; overflow: hidden; }
.sg-map-scroll[data-zoom="fit"] .sg-map-svg { width: 100%; height: auto; }
.sg-map-zoom[aria-pressed="true"] { background: var(--surface-sunken); border-color: var(--border-strong); }
.sg-map-svg { display: block; font-family: var(--font); }
/* The page gives every svg "stroke: currentColor; stroke-width: 1.7" and round caps (command-center.css). The map and its
   legend swatches start from no stroke, so a label is never outlined and a dash pattern keeps its own caps; each part
   below sets its own stroke. Text never takes a stroke, except the halo of a word on a line (more specific, below). */
.sg-map-svg, .sg-map-swatch { fill: var(--text); stroke: none; stroke-width: 1; stroke-linecap: butt; stroke-linejoin: miter; }
.sg-map-svg text, .sg-map-swatch text { stroke: none; }
.sg-map-caption { fill: var(--text-secondary); font-size: 11px; }

/* Lanes and groups */
.sg-map-lane-band { fill: var(--surface); }
.sg-map-lane-band[data-alt="1"] { fill: var(--surface-subtle); }
.sg-map-lane-label { fill: var(--text); font-size: 12px; font-weight: 600; }
.sg-map-lane-count { fill: var(--text-faint); font-size: 11px; }
.sg-map-island-box { fill: none; stroke: var(--border-strong); stroke-width: 1.25; stroke-dasharray: 4 3; }

/* Nodes */
.sg-map-node { cursor: pointer; outline: none; }
.sg-map-node-box { fill: var(--surface-raised); stroke: var(--border-strong); stroke-width: 1; }
.sg-map-node-box[data-kind="category"] { fill: var(--surface-raised); stroke-width: 1.5; }
.sg-map-node-box[data-kind="hub"] { stroke-width: 2; stroke-dasharray: 2 2; }
.sg-map-node-box[data-kind="spine"] { stroke: var(--text); stroke-width: 3; }
.sg-map-node-stat { fill: var(--text-secondary); font-size: 10.5px; }
/* Attention (unlinked or island tables) is a bold count with "!", never the suggestion amber or a dash. */
.sg-map-node-stat[data-attention="true"],
.sg-map-node-tag[data-attention="true"] { fill: var(--text); font-weight: 700; }
.sg-map-node-stat[data-hub="true"] { fill: var(--text-secondary); font-style: italic; }
.sg-map-summary-box { fill: var(--surface-raised); stroke: var(--border-strong); stroke-width: 1; }
.sg-map-summary-box[data-attention="true"] { stroke: var(--text-secondary); stroke-width: 2; }
.sg-map-summary .sg-map-node-tag[data-attention="true"] { fill: var(--text); font-weight: 700; }
.sg-map-node-box[data-kind="restricted"] { fill: var(--surface-muted); stroke: var(--text-faint); stroke-dasharray: 3 2; }
.sg-map-hatch line { stroke: var(--border-strong); stroke-width: 1; }
.sg-map-node:hover .sg-map-node-box, .sg-map-node:focus-visible .sg-map-node-box { stroke: var(--brand); stroke-width: 2; }
.sg-map-node:focus-visible .sg-map-node-box { stroke-width: 3; }
.sg-map-node-label { fill: var(--text); font-size: 12px; font-weight: 600; }
.sg-map-node-tag { fill: var(--text-secondary); font-size: 10.5px; }
/* Around one table: the links of a box that are not drawn are said in italics under its tag ("not drawn: 7 other links"). */
.sg-map-node-tag[data-held="true"] { font-style: italic; }
.sg-map-col-head { fill: var(--text-secondary); font-size: 11px; font-weight: 600; }
.sg-map-badge-box { fill: var(--surface-sunken); stroke: var(--border-strong); stroke-width: 1; }
.sg-map-badge-text { fill: var(--text-body); font-size: 10px; }
.sg-map-badge-box[data-kind="stub"] { fill: var(--surface); }
/* The suggested part of a badge: dashed outline and the suggestion tint, as a suggested line is dashed. */
.sg-map-badge-box[data-kind="suggested"],
.sg-map-badge-box[data-kind="stub-suggested"] { fill: var(--warn-tint); stroke: var(--warn-border); stroke-dasharray: 3 2; }
.sg-map-badge-text[data-suggested="true"] { fill: var(--warn-text); font-style: italic; }
/* Views reading a table: a dotted grey badge in plain text, never the suggestion amber (a view read is not a join). */
.sg-map-badge-box[data-kind="view-read"] { fill: var(--surface); stroke: var(--text-dim); stroke-dasharray: 1 2; }
/* A view: cut corner, lighter fill. A table the last read did not list: dotted border. The focus table: a ring. */
.sg-map-node-box[data-kind="view"] { fill: var(--surface-subtle); stroke: var(--text-dim); }
.sg-map-node-box[data-observation="not-listed"] { stroke-dasharray: 1.5 2.5; stroke-width: 1.5; }
.sg-map-focus-ring { fill: none; stroke: var(--text); stroke-width: 1.5; }
/* The bar under the focus table: its own edge drawn long, in the weight of its ring; every line of the picture ends on it. */
.sg-map-rail-bar { fill: var(--text); stroke: none; }
/* The words under a table with a loop on its corner ("links to its own rows"), italic like the other counted links. */
.sg-map-node-tag[data-self="true"] { font-style: italic; }
.sg-map-self .sg-map-edge { fill: none; }
/* The overview: a system is a large box with its tiles inside. */
.sg-map-node-box[data-kind="system"] { fill: var(--surface-subtle); stroke: var(--border-strong); stroke-width: 1.5; }
.sg-map-node-box[data-kind="component"] { fill: var(--surface-raised); stroke: var(--border-strong); }
.sg-map-node-box[data-kind="component"][data-main="true"] { stroke: var(--text); stroke-width: 2; }
.sg-map-node-box[data-kind="lane"] { fill: var(--surface-sunken); stroke: var(--border); }
.sg-map-system-label { fill: var(--text); font-size: 14px; font-weight: 700; }
.sg-map-cross-end { fill: var(--surface); stroke: var(--ok); stroke-width: 2; }
.sg-map-leader { fill: none; stroke: var(--border-strong); stroke-width: 1; stroke-dasharray: 1 2; }
/* The grid of categories. */
.sg-map-grid-cell { fill: var(--surface); stroke: var(--border); stroke-width: 1; }
.sg-map-grid-cell[data-diagonal="true"] { fill: var(--surface-sunken); }
.sg-map-grid-number { fill: var(--text-secondary); font-size: 11px; font-weight: 600; }
/* The name of a grid column, turned up to the right above its number. */
.sg-map-grid-name { fill: var(--text-body); font-size: 10.5px; }
.sg-map-cell-part { fill: var(--surface-raised); stroke: var(--text-dim); }
.sg-map-cell-part[data-style="declared"] { stroke: var(--info); }
.sg-map-cell-part[data-style="verified"] { stroke: var(--ok); }
.sg-map-cell-part[data-style="module-reviewed"] { stroke: var(--ref); }
.sg-map-cell-part[data-style="suggested-source"],
.sg-map-cell-part[data-style="suggested-rule"],
.sg-map-cell-part[data-style="suggested-other"] { fill: var(--warn-tint); stroke: var(--warn-border); }
.sg-map-cell-part[data-style="rejected"] { fill: var(--down-tint); stroke: var(--down-border); }
.sg-map-cell-part[data-style="view-read"] { fill: var(--surface); stroke: var(--text-dim); }
.sg-map-svg .sg-map-edge-word[data-cell="true"] { font-size: 10px; stroke: none; }
.sg-map-svg .sg-map-edge-word[data-cell="true"][data-part="word"] { font-style: italic; }
.sg-map-grid-mirror { opacity: 0.85; }
/* A folded category at table depth: a rounded box, no table border style, opens on click. */
.sg-map-chip { cursor: pointer; outline: none; }
.sg-map-chip-box { fill: var(--surface-sunken); stroke: var(--border-strong); stroke-width: 1; }
/* A folded repeated group: the chip box with a double-weight dashed border, so it reads apart from a folded category. */
.sg-map-chip-box[data-like="true"] { stroke-width: 1.5; stroke-dasharray: 6 3; }
/* The act of a lane (read the rest of its category): a small outlined button with link-coloured words. */
.sg-map-lane-act { cursor: pointer; outline: none; }
.sg-map-lane-act-box { fill: var(--surface-raised); stroke: var(--border-strong); stroke-width: 1; }
.sg-map-lane-act-text { fill: var(--brand); font-size: 11px; font-weight: 600; text-decoration: underline; }
.sg-map-lane-act:hover .sg-map-lane-act-box, .sg-map-lane-act:focus-visible .sg-map-lane-act-box { stroke: var(--brand); stroke-width: 2; }
.sg-map-grid-diagonal { cursor: help; }
.sg-map-chip:hover .sg-map-chip-box, .sg-map-chip:focus-visible .sg-map-chip-box { stroke: var(--brand); stroke-width: 2; }

/* Links: colour by state, dash and weight set on the element as the second sign */
.sg-map-edge { fill: none; stroke: var(--text-dim); }
.sg-map-edge[data-style="declared"] { stroke: var(--info); }
.sg-map-edge[data-style="verified"] { stroke: var(--ok); }
.sg-map-edge[data-style="module-reviewed"] { stroke: var(--ref); }
.sg-map-edge[data-style="suggested-source"],
.sg-map-edge[data-style="suggested-rule"],
.sg-map-edge[data-style="suggested-other"] { stroke: var(--warn); }
.sg-map-edge[data-style="rejected"] { stroke: var(--down); }
.sg-map-edge[data-style="view-read"] { stroke: var(--text-dim); }
.sg-map-edge[data-style="neutral"] { stroke: var(--text-dim); }
.sg-map-edge-hit { fill: none; stroke: transparent; stroke-width: 9; pointer-events: stroke; }
.sg-map-edge-g:hover .sg-map-edge { stroke-width: 3.5; }
/* A line opens its link (its evidence, or the tables of two categories): a pointer, and a focus mark for the keyboard. */
.sg-map-edge-g[data-action] { cursor: pointer; outline: none; }
.sg-map-edge-g[data-action]:focus-visible .sg-map-edge { stroke-width: 4; }
.sg-map-edge-g[data-action]:focus-visible .sg-map-cell-part { stroke-width: 2.5; }
.sg-map-edge-word { font-size: 10px; fill: var(--text-secondary); }
/* The halo of a word on a line: more specific than the text reset above, so it survives the page's svg rule. */
.sg-map-svg .sg-map-edge-word:not([data-cell="true"]) { paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round; }
.sg-map-edge-word[data-style="suggested-source"],
.sg-map-edge-word[data-style="suggested-rule"],
.sg-map-edge-word[data-style="suggested-other"] { fill: var(--warn-text); font-style: italic; }
.sg-map-edge-word[data-style="rejected"] { fill: var(--down-text); }
.sg-map-pill-halo { fill: var(--surface); }
.sg-map-pill { fill: var(--surface-raised); stroke: var(--border-strong); stroke-width: 1; }
.sg-map-pill[data-style="suggested-source"],
.sg-map-pill[data-style="suggested-rule"],
.sg-map-pill[data-style="suggested-other"] { fill: var(--warn-tint); stroke: var(--warn-border); }
.sg-map-pill[data-style="rejected"] { fill: var(--down-tint); stroke: var(--down-border); }
/* "+2 suggested" on a stated line: the suggestions beside the fact keep the suggestion tint and a dashed outline. */
.sg-map-pill[data-beside="true"] { fill: var(--warn-tint); stroke: var(--warn-border); stroke-dasharray: 3 2; }
.sg-map-edge-word[data-beside="true"] { fill: var(--warn-text); font-style: italic; }
.sg-map-list-beside { margin-top: 2px; }
.sg-map-word .sg-map-edge-word { pointer-events: none; }
/* End markers take the colour of their line, so the direction reads on a coloured line; the shape is the second sign. */
.sg-map-marker { fill: var(--text-dim); stroke: none; }
.sg-map-marker[data-style="declared"] { fill: var(--info); }
.sg-map-marker[data-style="verified"] { fill: var(--ok); }
.sg-map-marker[data-style="module-reviewed"] { fill: var(--ref); }
.sg-map-marker[data-style="suggested-source"],
.sg-map-marker[data-style="suggested-rule"],
.sg-map-marker[data-style="suggested-other"] { fill: var(--warn); }
.sg-map-marker[data-style="rejected"] { fill: var(--down); }
.sg-map-marker.is-open { fill: var(--surface); stroke: var(--text-dim); stroke-width: 1.5; }
.sg-map-marker.is-open[data-style="declared"] { stroke: var(--info); }
.sg-map-marker.is-open[data-style="verified"] { stroke: var(--ok); }
.sg-map-marker.is-open[data-style="module-reviewed"] { stroke: var(--ref); }
.sg-map-marker.is-open[data-style="suggested-source"],
.sg-map-marker.is-open[data-style="suggested-rule"],
.sg-map-marker.is-open[data-style="suggested-other"] { stroke: var(--warn); }
.sg-map-marker.is-open[data-style="rejected"] { stroke: var(--down); }
.sg-map-marker.is-open[data-style="view-read"] { stroke: var(--text-dim); }
/* A row of the narrow category list: the words start at the left, after the swatch. */
.sg-map-edge-word[data-row="true"] { font-size: 11px; fill: var(--text-body); }
.sg-map-edge-word[data-row="true"][data-style="suggested-source"],
.sg-map-edge-word[data-row="true"][data-style="suggested-rule"],
.sg-map-edge-word[data-row="true"][data-style="suggested-other"] { fill: var(--warn-text); }

/* Focus on one table or category: the rest dims, so its own lines can be followed. */
.sg-map-svg.is-focus .sg-map-edge-g:not(.is-near), .sg-map-svg.is-focus .sg-map-word:not(.is-near) { opacity: 0.1; }
.sg-map-svg.is-focus .sg-map-node:not(.is-near) { opacity: 0.4; }
.sg-map-svg.is-focus .sg-map-edge-g.is-near .sg-map-edge { stroke-width: 3; }

.sg-map-identity-node { fill: var(--csl-tint); stroke: var(--csl); stroke-width: 1.5; }
.sg-map-identity-label { fill: var(--text); font-size: 11px; font-weight: 600; }
.sg-map-identity-number { fill: var(--text); font-size: 10px; font-weight: 700; }

/* Where you are, the zoom steps and the find box. */
.sg-map-head { display: grid; gap: var(--space-2); }
.sg-map-crumbs ol { display: flex; flex-wrap: wrap; gap: 4px; margin: 0; padding: 0; list-style: none; font-size: var(--fs-small); color: var(--text-secondary); }
.sg-map-crumbs li + li::before { content: "\203A"; margin-right: 4px; color: var(--text-faint); }
.sg-map-crumbs li[aria-current="page"] span { color: var(--text); font-weight: 600; }
.sg-map-crumb { border: 0; background: none; padding: 0; font: inherit; color: var(--brand); cursor: pointer; }
.sg-map-crumb:hover { text-decoration: underline; }
.sg-map-crumb:focus-visible, .sg-map-step:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-xs); }
.sg-map-steps { display: inline-flex; gap: 4px; }
.sg-map-step[aria-pressed="true"] { background: var(--surface-sunken); border-color: var(--border-strong); font-weight: 600; }
.sg-map-find { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: flex-end; }
.sg-map-find input { min-height: 30px; min-width: min(280px, 100%); font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 4px 8px; }
.sg-map-find-results { flex-basis: 100%; }
.sg-map-find-list { margin: 0; padding-left: 18px; display: grid; gap: 3px; font-size: var(--fs-small); }
.sg-map-find-note { margin: 0; font-size: var(--fs-small); color: var(--text-secondary); }
.sg-map-list-around { margin-left: 6px; font-size: var(--fs-small); }
.sg-map-list-more-row { list-style: none; margin-top: 4px; }

/* Legend and list */
.sg-map-legend { display: flex; flex-wrap: wrap; gap: 6px var(--space-4); margin: 0; padding: 0; list-style: none; font-size: var(--fs-small); color: var(--text-secondary); }
.sg-map-legend-item { display: inline-flex; gap: 6px; align-items: center; }
.sg-map-swatch { flex: none; overflow: visible; }
.sg-map-key { display: grid; gap: 4px; }
.sg-map-key-head { margin: 0; font-size: var(--fs-small); font-weight: 600; color: var(--text); }
.sg-map-legend.is-key { gap: 4px var(--space-4); }
.sg-map-key-term { color: var(--text); font-weight: 600; }
.sg-map-list-note { margin: var(--space-2) 0 0; font-size: var(--fs-small); color: var(--text-secondary); }

.sg-map-aside { border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); padding: var(--space-2) var(--space-3); max-height: 78vh; overflow: auto; }
.sg-map-aside > summary { cursor: pointer; font-weight: 600; color: var(--text); }
.sg-map-list-head { margin: var(--space-3) 0 4px; font-size: var(--fs-small); color: var(--text); }
.sg-map-list-items { margin: 0; padding-left: 18px; display: grid; gap: 3px; font-size: var(--fs-small); color: var(--text-body); }
.sg-map-list-items.is-suggested { font-style: italic; }
.sg-map-list-meta { color: var(--text-faint); }
.sg-map-list-open { border: 0; background: none; padding: 0; font: inherit; color: var(--brand); cursor: pointer; text-align: left; }
.sg-map-list-open:hover { text-decoration: underline; }
.sg-map-list-open:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-xs); }
/* What a link of the list opens: its evidence, its decision, or the tables of two categories. Upright in a suggested list. */
.sg-map-list-acts { display: inline-flex; flex-wrap: wrap; gap: 2px var(--space-3); margin-left: 6px; font-style: normal; }
.sg-map-list-act { font-size: var(--fs-small); }
.sg-map-list-act:disabled { color: var(--text-faint); cursor: progress; }

@media (prefers-reduced-motion: reduce) { .sg-map * { transition: none; } }

/* Round 4 (the map as a demo's centrepiece): one sentence above the drawing, the caveats closed under it, a category's
   size as a bar in its box, a table's counts as one small badge, names in full contrast. */
.sg-map-lead { margin: 0 0 var(--space-2); font-size: var(--fs-small); color: var(--text-body); max-width: 96ch; }
.sg-map-about { font-size: var(--fs-small); color: var(--text-dim); }
.sg-map-about > summary { cursor: pointer; width: max-content; }
.sg-map-about[open] > summary { margin-bottom: var(--space-2); }
.sg-map-size-track { fill: var(--surface-muted); }
.sg-map-size-bar { fill: var(--info-border); }
.sg-map-node-tag { fill: var(--text-body); }
.sg-map-node-box[data-kind="hub"] { stroke: var(--text-dim); }
.sg-map-legend-more { font-size: var(--fs-small); color: var(--text-dim); }
.sg-map-legend-more > summary { cursor: pointer; width: max-content; }
/* A table gone from the source (its removal confirmed): drawn for its history only, never as present. */
.sg-map-node-box[data-observation="gone"] { fill: var(--surface-muted); stroke: var(--text-faint); stroke-dasharray: 8 3; }
