/* /design (lld.md §7), loaded after site.css. Pattern from the qrypt-quickstart design page: framed diagram panels with
   a control bar, a narration caption, inline SVG and a box card. Every diagram colour is a site.css token, in every
   state: idle, seen (done), on (active step), selected, callee. No transitions between themes. */
[id] { scroll-margin-top: calc(var(--head-h, 120px) + 8px); } /* header height measured by common.js */
.views { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; padding-bottom: 8px; }
.views a { font-size: 13.5px; padding: 4px 10px; }
.label { font-weight: 600; font-size: 14px; }
.pill[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }

/* overflow: clip, not hidden: hidden would make the figure a scroll container and switch the sticky dock off */
.diagram { margin: 0 0 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; overflow: hidden; overflow: clip; }
.diagram > h3 { margin: 0; padding: 14px 18px 0; font-size: 16px; }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.pills, .buttons { display: flex; flex-wrap: wrap; gap: 4px; }
.buttons { margin-left: auto; }
.controls button { font-size: 13.5px; padding: 5px 13px; min-height: 32px; }
.caption {
  margin: 0; min-height: 3em; padding: 12px 18px; font-size: 14.5px; background: var(--bg);
  border-bottom: 1px solid var(--line); border-left: 3px solid var(--ink);
}
/* DSN-R3-01: the step caption and Play/Step/Reset stick under the site header at every width (--head-h is measured by
   common.js), so a playing flow never scrolls its narration or its buttons away; design.js reveal() keeps the lit box
   below this dock. */
.dock {
  position: sticky; top: var(--head-h, 64px); z-index: 5; display: flex; flex-wrap: wrap; align-items: center;
  gap: 8px 12px; padding: 8px 16px; background: var(--bg); border-bottom: 1px solid var(--line);
}
.dock .caption { flex: 1 1 280px; min-height: 2.6em; padding: 4px 0 4px 12px; border-bottom: 0; background: none; }
.diagram .card { margin: 0; padding: 14px 18px; border: 0; border-top: 1px solid var(--line); border-radius: 0; background: var(--bg); }
.diagram .card h4 { margin: 0 0 6px; font-size: 15px; }
.diagram .card p { margin: 2px 0; font-size: 14px; color: var(--muted); }
.diagram figcaption { padding: 10px 18px 14px; font-size: 13.5px; color: var(--muted); border-top: 1px solid var(--line); }
.steps { list-style: none; margin: 0; padding: 8px 10px 12px; font-size: 14px; border-top: 1px solid var(--line); counter-reset: s; }
.steps li { padding: 4px 10px; border-left: 3px solid transparent; border-radius: 0 6px 6px 0; }
.steps li::before { counter-increment: s; content: counter(s) ". "; color: var(--muted); }
.steps li.on { background: var(--soft); border-left-color: var(--ink); }
th[data-col].active { color: var(--ink); }
td.active { background: var(--soft); }

.diagram-svg { display: block; width: 100%; min-width: 820px; height: auto; font-size: 12px; font-family: inherit; }
/* sequences keep 1 viewBox unit = 1 px (width set from the viewBox by design.js), so every one has the same text size */
.seq-svg { min-width: 0; max-width: none; font-size: 11px; }
.diagram-svg text { fill: var(--ink); }
.diagram-svg .sub { fill: var(--muted); font-size: 10.5px; }
.diagram-svg .key { fill: var(--accent); font-weight: 700; font-size: 10px; }
.region rect { fill: none; stroke: var(--faint); stroke-width: 1.2; }
.region.dashed rect { stroke-dasharray: 6 5; }
.region text { fill: var(--muted); font-size: 11px; }
.region.callee rect { stroke: var(--ink); stroke-width: 2; }
.node rect { fill: var(--surface); stroke: var(--wire); stroke-width: 1.4; }
.node.person rect, .node.store rect { fill: var(--soft); }
.node.ext rect { stroke-dasharray: 3 3; }
.node.table line { stroke: var(--wire); }
.node.table .col { font-size: 10.5px; fill: var(--muted); }
.node.table .pk { fill: var(--ink); font-weight: 600; }
.node[tabindex] { cursor: pointer; }
.node[tabindex]:hover rect { stroke: var(--ink); }
.node:focus { outline: none; }
.node:focus-visible rect { stroke: var(--accent); stroke-width: 3; }
.node.seen rect { fill: var(--soft); }
.node.callee rect { fill: var(--soft); stroke: var(--ink); stroke-width: 2; }
.node.selected rect { stroke: var(--ink); stroke-width: 2; stroke-dasharray: 5 3; }
.node.on rect { fill: var(--surface); stroke: var(--accent); stroke-width: 2.5; stroke-dasharray: none; filter: drop-shadow(0 0 8px var(--glow)); }
.edge path, .lifeline line, .msg path { fill: none; stroke: var(--wire); stroke-width: 1.3; }
.edge.async path, .msg.reply path { stroke-dasharray: 5 4; }
.edge text, .msg text {
  font-size: 10.5px; fill: var(--muted); paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round;
}
.msg text { font-size: 11px; fill: var(--ink); }
.arrowhead { fill: var(--wire); }
/* Two highlights that never share a look (D8): a playing flow is the accent colour and moves; a clicked box's calls
   are solid ink and still. Starting one clears the other (design.js). */
.edge.on path, .msg.on path { stroke: var(--accent); stroke-width: 2.6; stroke-dasharray: 6 5; animation: flow .9s linear infinite; }
.edge.call path { stroke: var(--ink); stroke-width: 2; stroke-dasharray: none; }
.edge.on text, .msg.on text { fill: var(--accent); font-weight: 700; }
.edge.call text { fill: var(--ink); font-weight: 700; }
.region.on rect { stroke: var(--accent); stroke-width: 2; }
.region.on text { fill: var(--accent); font-weight: 700; }
.quiet .edge text { display: none; }
.quiet .edge.call text { display: inline; }
.quiet .edge path { stroke-opacity: .45; }
.quiet .edge.call path { stroke-opacity: 1; }
.edge.rel text.cardinality { fill: var(--accent); font-weight: 700; }
.lifeline rect { fill: var(--soft); stroke: var(--wire); }
.lifeline line { stroke-dasharray: 3 4; }
.msg.on .bar { fill: var(--ink); }
@keyframes flow { to { stroke-dashoffset: -22; } }
@media (prefers-reduced-motion: reduce) { .edge.on path, .msg.on path { animation: none; } }
.pills.env { margin-left: 4px; }
td.ok { color: var(--ok); font-weight: 600; }
td.muted { color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0; padding: 8px 18px; font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); }
.legend i { display: inline-block; width: 22px; height: 0; margin-right: 6px; vertical-align: middle; border-top: 2.6px dashed var(--accent); }
.legend i.lg-call { border-top: 2px solid var(--ink); }


/* ---------- QA round 2 (M1-T012) ---------- */
.views-phone { display: none; }
@media (max-width: 640px) {
  /* DSN-R2-03: a compact two-row sticky header on a phone; the design views move to the top of the page */
  header.top .views { display: none; }
  .views-phone { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 14px; padding: 0; }
  .views-phone a { display: inline-flex; align-items: center; min-height: 44px; border: 1px solid var(--line); }
  .controls button, .dock button { min-height: 44px; }
  /* Play/Step stay in reach: on a phone the buttons take the dock's first row, the caption the row under it */
  .dock { padding: 6px 12px; }
  .dock .buttons { order: -1; margin-left: 0; }
  .dock .caption { flex-basis: 100%; font-size: 14px; }
  /* DSN-R3-06: on a phone each diagram is drawn wide enough that its smallest text is at least 11 px and every
     clickable box at least 44 px tall (tests/test_design.py computes both); the diagram pans sideways inside its
     .scroll box and the page itself never scrolls sideways. */
  [data-svg="hld"] .diagram-svg { min-width: 1180px; }
  [data-svg="lld"] .diagram-svg { min-width: 1200px; }
  [data-svg="erd"] .diagram-svg { min-width: 1180px; }
}
