/* The live network (public/network.html, network.js). It loads /site.css first (tokens, navigation, footer, buttons,
   labels, tables) and holds only what is its own. Who runs an agent is a shape with words beside it, never a colour
   alone: a diamond (operator-run), a hollow circle (a team test agent, by its operator field), a filled circle (anyone
   else). The rainbow is only for a loop that cleared. Nothing moves but a changed IOU's one brief highlight, and
   nothing at all under prefers-reduced-motion (site.css). */

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
main > section { border-top: 1px solid var(--rule); padding: 2.2rem 0 1.6rem; }
.head { padding: 1.2rem 0 1.4rem; }
.head > section { padding: 0; }
.head > .who { margin-top: 1.8rem; }
main h2 { font-size: clamp(1.35rem, 3.4vw, 1.75rem); }
.small code, .caption code { font-size: 0.84em; }

/* ---------- the status line: what it reads, and when ---------- */
.status { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.6rem 1.2rem; padding-top: 1.2rem; }
.state { display: inline-flex; align-items: center; gap: 0.6rem; margin: 0; font: 400 0.82rem/1.45 var(--mono); color: var(--dust); }
.state .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--rule-strong); }
.state.ok { color: var(--line); }
.state.ok .dot { background: var(--live); }
.state.err { color: var(--caution); }
.state.err .dot { background: var(--caution); }
.state.paused .dot { background: transparent; border: 1.5px solid var(--dust); }
.btn.pause { font-size: 0.92rem; }
.btn.pause[hidden] { display: none; }
.intro h1 { font-size: clamp(2.1rem, 5.4vw, 3.1rem); margin-bottom: 0.6rem; }
.intro .lede { margin-bottom: 0; }

/* ---------- who is here ---------- */
.who h2 { font-size: 1.05rem; font-weight: 400; margin-bottom: 0.7rem; }
.classes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0 0 0.9rem; border-top: 1px solid var(--rule-strong); }
.cl.all { grid-column: 1 / -1; display: flex; align-items: baseline; gap: 0.9rem; border-bottom: 1px solid var(--rule); padding: 0.4rem 0 0.5rem; }
.cl.all .n { margin: 0; }
.cl.all + .cl { padding-left: 0; border-left: 0; }
.cl { padding: 0.7rem 1rem 0.6rem 0; min-width: 0; }
.cl + .cl { padding-left: 1rem; border-left: 1px solid var(--rule); }
.cl dt { display: flex; align-items: center; gap: 0.5rem; font: 400 0.75rem/1.4 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--dust); white-space: nowrap; }
.cl dd { margin: 0; }
.cl .n { font: 200 clamp(1.8rem, 3.6vw, 2.5rem)/1.1 var(--sans); font-variant-numeric: tabular-nums; margin: 0.25rem 0 0.2rem; }
.cl.all .n { font-weight: 300; }
.cl .d { font-size: 0.84rem; color: var(--dust); line-height: 1.4; }
.caption { max-width: 46em; color: var(--line); margin: 0; font-size: 0.92rem; line-height: 1.5; }

/* shapes (also the picture's): who runs an agent */
.shape { display: inline-block; width: 10px; height: 10px; flex: none; border: 1.5px solid var(--line); border-radius: 50%; vertical-align: -1px; }
.shape.w-operator { border-color: var(--work); border-radius: 0; transform: rotate(45deg) scale(0.84); }
.shape.w-team { border-color: var(--dust); }
.shape.w-other { background: var(--line); }
.shape.w-unknown { border-style: dashed; border-color: var(--rule-strong); }

/* ---------- recent activity: the picture and the loops ---------- */
.activity-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.2rem 1.6rem; margin-bottom: 0.9rem; }
main > section.activity { padding-top: 1.6rem; }
.activity-head h2 { margin: 0; }
.activity-head .small { margin: 0; max-width: 40em; }
.activity-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.6rem 2.4rem; }
figure.graph { margin: 0; min-width: 0; }
.graph-box { position: relative; height: clamp(400px, 46vw, 600px); border: 1px solid var(--rule); border-radius: 2px; background: var(--space); }
#graph { position: absolute; inset: 0; width: 100%; height: 100%; display: block; font-family: var(--mono); }
.graph-empty { position: absolute; inset: auto 16px 16px; margin: 0; color: var(--dust); font-size: 0.9rem; }
.graph-empty[hidden] { display: none; }
figure.graph figcaption { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.7rem; margin: 0.8rem 0 0; font-size: 0.92rem; color: var(--line); }
figure.graph figcaption .tag[hidden] { display: none; }   /* Live only while the reads are live (network.js status) */

#graph .guide { fill: none; stroke: #2a2f3a; stroke-width: 1; stroke-dasharray: 1 6; }
#graph .edge { fill: none; stroke: var(--dust); stroke-opacity: 0.72; stroke-linecap: round; }   /* 4.2:1 on the field (WCAG 1.4.11) */
#graph .edge.hot { stroke: var(--line); stroke-opacity: 1; }
#graph .edge.flash { animation: flash 2.4s ease-out 1; }
@keyframes flash { 0% { stroke-opacity: 1; stroke: #ffffff; } 40% { stroke-opacity: 0.35; } 100% { stroke-opacity: 1; } }
#graph .ah { fill: none; stroke: var(--dust); stroke-width: 1.4; stroke-linejoin: round; stroke-linecap: round; }
#graph .ah.hot, #graph .ah.loop { stroke: var(--line); }
/* Only the newest loop is drawn (the others are in "Loops cleared"); in a narrow frame, fainter, so the arrows stay legible. */
#graph .loop-arc { fill: none; stroke: url(#rainbow); stroke-width: 2.4; stroke-linecap: round; }
#graph .loop.narrow .loop-arc { stroke-width: 1.8; opacity: 0.6; }
#graph .node .hit { fill: transparent; stroke: none; }
#graph .node .glyph { fill: var(--space); stroke: var(--line); stroke-width: 1.5; }
#graph .node.w-operator .glyph { stroke: var(--work); stroke-width: 1.7; }
#graph .node.w-team .glyph { stroke: var(--dust); }
#graph .node.w-other .glyph { fill: var(--line); }
#graph .node.w-unknown .glyph { stroke: var(--rule-strong); stroke-dasharray: 2 2; }
#graph .label { fill: var(--line); paint-order: stroke; stroke: var(--space); stroke-width: 4px; stroke-linejoin: round; }
#graph .node.w-team .label { fill: #c8ccd3; }
#graph a.node { cursor: pointer; }
#graph a.node:focus { outline: none; }
#graph a.node:focus .hit, #graph a.node:hover .hit { stroke: var(--line); stroke-width: 1.5; }
#graph.focusing .edge { stroke-opacity: 0.16; }
#graph.focusing .edge.on { stroke: var(--line); stroke-opacity: 1; }
#graph.focusing .node:not(.on) .label { fill: var(--dust); }
#graph.focusing .node.on .label { fill: #ffffff; }

.detail { min-height: 3.4rem; margin: 0.7rem 0 0; padding: 0.6rem 0 0; border-top: 1px solid var(--rule); }
.detail p { margin: 0; }
.detail .hint { color: var(--dust); font-size: 0.9rem; }
.detail-line { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.7rem; font-size: 0.95rem; }
.detail-line .h { font-family: var(--mono); }
.detail-line .who-words { color: var(--dust); font-size: 0.86rem; }
.detail-line .ties { flex-basis: 100%; color: var(--line); }
.quiet { margin: 0.6rem 0 0; color: var(--dust); font-size: 0.9rem; }
.legend { display: flex; flex-wrap: wrap; gap: 0.4rem 1.3rem; list-style: none; margin: 0.8rem 0 0; padding: 0; font: 400 0.78rem/1.6 var(--mono); color: var(--dust); }
.legend li { display: inline-flex; align-items: center; gap: 0.5rem; }
.key-owes { position: relative; display: inline-block; width: 24px; height: 0; border-top: 1.5px solid var(--dust); }
.key-owes::after { content: ""; position: absolute; right: 0; top: -4.5px; width: 6px; height: 6px; border-top: 1.5px solid var(--dust); border-right: 1.5px solid var(--dust); transform: rotate(45deg); }
.key-loop { display: inline-block; width: 24px; height: 2px; background: var(--rainbow); }

.loops-panel { min-width: 0; }
.loops-panel h3 { font-size: 1.15rem; margin-bottom: 0.3rem; }
.loops-panel > .small { margin: 0 0 0.8rem; }
.loops { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.loops li { padding: 0.75rem 0 0.1rem; border-bottom: 1px solid var(--rule); }
.loop-route { display: flex; flex-wrap: wrap; align-items: center; gap: 0.15rem 0.4rem; margin: 0 0 0.25rem; font: 400 0.84rem/1.5 var(--mono); }
.loop-route .h { overflow-wrap: anywhere; }
.loop-route .arr { color: var(--dust); }
.loop-meta { margin: 0; font-size: 0.86rem; color: var(--line); }
.loop-who { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0 1rem; margin: 0; font-size: 0.86rem; color: var(--dust); }
.loop-card { display: inline-flex; align-items: center; min-height: 44px; font-size: 0.9rem; margin-left: auto; }   /* at the right, on its own line too */

/* ---------- the tables ---------- */
.changes > .small, .totals > .small { max-width: 46em; }
td.pair { font-family: var(--mono); font-size: 0.86rem; }
td.pair .shape { margin-right: 0.35rem; }
td.pair .h { overflow-wrap: anywhere; }
td.pair .arr { font-family: var(--sans); color: var(--dust); }
td.what { color: var(--dust); }
.meta-sm { display: none; }
#changes time { font-family: var(--mono); font-size: 0.84rem; white-space: nowrap; }
details#all-open { margin-top: 0.4rem; }
details#all-open .table-wrap { margin-top: 0.6rem; max-height: 32rem; overflow-y: auto; }

.totals .facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0 0 1rem; border-top: 1px solid var(--rule-strong); }
.totals .facts > div { padding: 0.9rem 1.2rem 0.9rem 0; min-width: 0; }
.totals .facts > div + div { padding-left: 1.2rem; border-left: 1px solid var(--rule); }
.totals dt { font: 400 0.75rem/1.4 var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--dust); }
.totals dd { margin: 0.35rem 0 0; }
.totals .v { display: block; font: 300 1.55rem/1.2 var(--sans); font-variant-numeric: tabular-nums; }
.totals .s { display: block; font-size: 0.86rem; color: var(--dust); margin-top: 0.15rem; }
.totals .bad .v { color: var(--caution); }

.ergo[hidden] { display: none; }
.ergo-list { list-style: none; margin: 0; padding: 0; max-width: 46em; }
.ergo-list li { padding: 0.6rem 0; border-bottom: 1px solid var(--rule); }
.ergo-list li.links { display: flex; flex-wrap: wrap; gap: 0.2rem 1.4rem; border-bottom: 0; }
.ergo-list li.links a { display: inline-block; padding: 0.3rem 0; }

/* the join command wraps only between its parts, each part kept whole; the token file's path (.path) may also break
   after "$HOME/", only where the whole path is wider than the line (phones narrower than 380 px): its two halves are
   inline blocks, which wrap between them only where .path allows it (a <wbr> would break even inside nowrap in Chrome,
   and a character would end up in what Copy copies). The pre keeps site.css's room for its Copy button. */
#join-cmd { white-space: normal; }
#join-cmd span { white-space: nowrap; }
#join-cmd .path > span { display: inline-block; }
@media (max-width: 380px) { #join-cmd .path { white-space: normal; } }

@media (min-width: 1000px) {
  .head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); column-gap: 56px; align-items: start; }
  .head .intro { padding-top: 1.6rem; }
  .head > .who { margin-top: 0; }
  .activity-grid { grid-template-columns: minmax(0, 1fr) minmax(260px, 300px); }
}
@media (max-width: 999px) {
  .loops li:nth-child(n + 4) { display: none; }
}
@media (max-width: 640px) {
  #changes .when, #changes .what { display: none; }
  #changes .meta-sm { display: block; margin-top: 0.15rem; font: 400 0.78rem/1.4 var(--sans); color: var(--dust); }
  #changes-body tr:nth-child(n + 11) { display: none; }
}
@media (max-width: 760px) {
  .classes { grid-template-columns: minmax(0, 1fr); }
  .cl, .cl + .cl { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 1rem; align-items: baseline; padding: 0.55rem 0; border-left: 0; border-top: 1px solid var(--rule); }
  .cl dt { grid-column: 1; grid-row: 1; }
  .cl .n { grid-column: 2; grid-row: 1 / span 2; margin: 0; font-size: 1.9rem; }
  .cl .d { grid-column: 1; grid-row: 2; }
  .cl.all { display: grid; border-top: 0; border-bottom: 0; }
  .totals .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .totals .facts > div:nth-child(3) { padding-left: 0; border-left: 0; }
  .totals .facts > div:nth-child(n + 3) { border-top: 1px solid var(--rule); }
  .graph-box { height: clamp(380px, 112vw, 480px); }
}
@media (max-width: 480px) {
  .cl .d { font-size: 0.82rem; }
  #changes th:first-child, #changes td:first-child { padding-right: 0.5rem; }
}

/* Forced colours (Windows High Contrast): the UA recolours HTML but not SVG fill and stroke, and it drops backgrounds.
   The picture is drawn in the system colours; a filled circle ("other") stays filled, so it never reads as the team's
   hollow one; the rainbow swatch and the Live dot keep their own colours. */
@media (forced-colors: active) {
  .shape { border-color: CanvasText; }
  .shape.w-other { forced-color-adjust: none; background: CanvasText; border-color: CanvasText; }
  .key-owes, .key-owes::after { border-color: CanvasText; }
  .key-loop, .tag.live::before, .state .dot { forced-color-adjust: none; }
  #graph .guide { stroke: GrayText; }
  #graph .edge, #graph .edge.hot, #graph.focusing .edge.on, #graph .ah, #graph .ah.hot, #graph .ah.loop { stroke: CanvasText; }
  #graph .node .glyph, #graph .node.w-operator .glyph, #graph .node.w-team .glyph { fill: Canvas; stroke: CanvasText; }
  #graph .node.w-other .glyph { fill: CanvasText; }
  #graph .node.w-unknown .glyph { stroke: GrayText; }
  #graph .label, #graph .node.w-team .label, #graph.focusing .node.on .label { fill: CanvasText; stroke: Canvas; }
  #graph.focusing .node:not(.on) .label { fill: GrayText; }
  #graph a.node:focus .hit, #graph a.node:hover .hit { stroke: Highlight; }
}
