/* Manual diagrams use semantic roles from site-shell.css. Meaning never rests
   on hue alone: a refusal is also a ✕ and a word, an allowed connection a ✓,
   and their sandbox is dashed where ours is solid. */
.dg-fig {
  margin: 22px 0 28px;
  border: 1px solid var(--line);
  background: var(--inset);
  padding: 12px;
  overflow-x: auto;
}
.dg-fig figcaption {
  margin-top: 10px;
  font-size: 11px;
  line-height: 1.7;
  color: var(--metadata);
}
.dg {
  display: block;
  width: 100%;
  min-width: 620px;
  height: auto;
  font-family: var(--mono);
}
.dg text {
  font-family: var(--mono);
}
.dg .frame {
  fill: var(--panel);
  stroke: var(--line);
}
.dg .chip {
  fill: var(--overlay);
  stroke: var(--line);
}
.dg .out {
  fill: none;
  stroke: var(--line);
  stroke-dasharray: 2 3;
}
.dg .wall {
  fill: none;
  stroke: var(--focus);
  stroke-width: 2;
}
.dg .dashed {
  stroke-dasharray: 7 5;
}
.dg .link {
  fill: none;
  stroke: var(--line);
  stroke-width: 1.5;
}
.dg .port {
  fill: var(--focus);
}
.dg .dot {
  fill: var(--active);
}
.dg .askbox {
  fill: var(--panel);
  stroke: var(--warning);
}
.dg .t {
  fill: var(--ink);
  font-size: 13px;
}
.dg .m {
  fill: var(--muted);
  font-size: 11.5px;
}
.dg .dim {
  fill: var(--metadata);
  font-size: 11.5px;
}
.dg .meta {
  fill: var(--metadata);
  font-size: 10px;
  letter-spacing: 0.12em;
}
.dg .ok {
  fill: var(--success);
  font-size: 12px;
}
.dg .no {
  fill: var(--danger);
  font-size: 12px;
}
.dg .ask {
  fill: var(--warning);
  font-size: 12px;
}
.dg .pick {
  fill: var(--ink);
  font-weight: bold;
}
.dg-pause {
  float: right;
  margin: 0 0 4px 12px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  background: var(--chrome);
  color: var(--action);
  font: inherit;
  font-size: 10px;
  cursor: pointer;
}
.dg-pause:hover,
.dg-pause:focus-visible {
  color: var(--ink);
}

/* A phone shows the whole diagram, fitted to the column; a tap opens it full
   screen, turned sideways when that shows it larger (site.js). */
.dg-expand { display: none; }
@media (max-width: 700px) {
  .dg-fig { overflow: visible; }
  .dg { min-width: 0; cursor: zoom-in; }
  .dg-expand {
    display: inline-block;
    float: right;
    margin: 0 0 4px 8px;
    padding: 2px 8px;
    border: 1px solid var(--line);
    background: var(--chrome);
    color: var(--action);
    font: inherit;
    font-size: 10px;
    cursor: pointer;
  }
}
.dg-viewer {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--inset);
  color: var(--ink);
  overflow: hidden;
}
.dg-viewer::backdrop { background: #000; }
.dg-viewer-stage {
  position: absolute;
  inset: 0;
}
/* Centred by its own middle, so a turned diagram wider than the screen still
   sits in the middle of it. */
.dg-viewer-stage .dg {
  position: absolute;
  left: 50%;
  top: 50%;
  min-width: 0;
  max-width: none;
  cursor: auto;
  transform: translate(-50%, -50%);
}
.dg-viewer-stage .dg.is-turned { transform: translate(-50%, -50%) rotate(90deg); }
.dg-viewer-close {
  position: absolute;
  z-index: 1;
  top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--chrome);
  color: var(--ink);
  font: 20px/1 var(--sans);
  cursor: pointer;
}
.dg-viewer-close:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
