/* RRGI · an algorithm's development tree (algo-tree.js): its rows, one link a version, beside the drawn gutter (an
   aria-hidden SVG). On site.css: the focus algorithm's lane in --accent, every other in --text-2 (both above 3:1 on
   --bg and --surface), another group's dashed; CanvasText under forced colours. No animation. The rows' height and
   the gutter's width come from the script (--tree-row, --tree-gutter), so the rows and the drawing line up. */

.algo-tree {
  --tree-row: 56px; --tree-gutter: 24px;
  --tree-focus: var(--accent); --tree-other: var(--text-2); --tree-bg: var(--bg);
  min-width: 0;
}
.card .algo-tree { --tree-bg: var(--surface); }
.tree-key, .tree-key-print { margin: 0 0 4px; font-size: 14px; color: var(--text-2); }
/* the legend for a printed tree, whose drawing is left out (algorithm.css print rules) */
.tree-key-print { display: none; }
.tree-forks { margin: 0 0 4px; font-size: 14px; color: var(--text-2); font-weight: 500; }
.tree-body { position: relative; min-width: 0; margin-top: 12px; }

/* the drawing */
.tree-lines { position: absolute; left: 0; top: 0; display: block; overflow: visible; pointer-events: none; }
.tree-lines .seg { fill: none; stroke-width: 2; stroke-linecap: butt; }
.tree-lines .seg.is-focus { stroke: var(--tree-focus); }
.tree-lines .seg.is-other { stroke: var(--tree-other); }
.tree-lines .seg.is-dashed { stroke-dasharray: 4 3; }
.tree-lines .seg.is-dotted { stroke-dasharray: 0 5; stroke-linecap: round; }
.tree-lines .dot.is-focus { fill: var(--tree-focus); }
.tree-lines .dot.is-other { fill: var(--tree-other); }
.tree-lines .ring, .tree-lines .box { fill: var(--tree-bg); stroke-width: 2; }
.tree-lines .ring.is-focus, .tree-lines .box.is-focus { stroke: var(--tree-focus); }
.tree-lines .ring.is-other, .tree-lines .box.is-other { stroke: var(--tree-other); }

/* the rows: each a link, its words two lines at most (the whole of them stay in the link's name) */
.tree-rows { list-style: none; margin: 0; padding: 0 0 0 calc(var(--tree-gutter) + 4px); min-width: 0; }
.tree-row { height: var(--tree-row); display: flex; min-width: 0; }
.tree-link { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; padding: 0 10px; color: var(--text); }
.tree-link:hover { background: var(--surface-2); text-decoration: none; }
.tree-link:hover .tree-v { text-decoration: underline; text-underline-offset: 3px; }
.tree-link:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.tree-text {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
  min-width: 0; font-size: 15px; line-height: 1.35; overflow-wrap: anywhere;
}
.tree-v { color: var(--accent); font-weight: 600; }
.tree-row.is-other .tree-text { color: var(--text-2); }
.tree-row.is-other .tree-v { font-weight: 500; }
.tree-row.is-current .tree-link { background: var(--accent-soft); }
.tree-text .tag { font-size: 10px; padding: 3px 5px; margin: 0 0 0 4px; color: var(--accent); }

@media (max-width: 560px) {
  .tree-text { font-size: 14px; }
  .tree-link { padding: 0 6px; }
}

@media (forced-colors: active) {
  .algo-tree .tree-lines .seg, .algo-tree .tree-lines .ring, .algo-tree .tree-lines .box { stroke: CanvasText; }
  .algo-tree .tree-lines .dot { fill: CanvasText; }
  .algo-tree .tree-lines .ring, .algo-tree .tree-lines .box { fill: Canvas; }
  .tree-row.is-current .tree-link { outline: 2px solid CanvasText; outline-offset: -2px; }
}
