/* Offer Ready: architecture and class diagrams (js/diagram.js). Colors are tokens only, so light and dark follow the theme. */
.dg { container-type: inline-size; display: grid; gap: var(--s-4); min-width: 0; }
.dg-scen { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-1); padding: 3px; border: 1px solid var(--line); border-radius: var(--r-2); background: var(--surface-2); width: fit-content; max-width: 100%; }
.dg-scen-label { padding: 0 var(--s-3) 0 var(--s-2); font-size: var(--text-xs); font-weight: 600; color: var(--ink-3); }
.dg-scen button { height: 30px; padding: 0 var(--s-3); border: 0; border-radius: var(--r-1); background: transparent; color: var(--ink-2); font: 600 var(--text-sm) var(--font-ui); cursor: pointer; }
.dg-scen button:hover { color: var(--ink); }
.dg-scen button[aria-checked="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.dg-scen button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.dg-main { display: grid; gap: var(--s-4); min-width: 0; }
@container (min-width: 1000px) { .dg-main { grid-template-columns: minmax(0, 1fr) 300px; align-items: start; } }
.dg-canvas { min-width: 0; border-block: 1px solid var(--line); padding-block: var(--s-3); }
.dg-svg { display: block; width: 100%; height: auto; margin-inline: auto; overflow: visible; user-select: none; }

/* Nodes */
.dg-node { cursor: pointer; outline: none; --k: var(--ink-3); }
.dg-node .dg-box { fill: var(--surface); stroke: var(--line-strong); stroke-width: 1.25; transition: fill var(--dur-2), stroke var(--dur-2); }
.dg-node:hover .dg-box { stroke: var(--k); }
.dg-stripe { fill: var(--k); }
.dg-tag { font: 600 9px var(--font-ui); letter-spacing: 0.06em; fill: var(--ink-3); pointer-events: none; }
.dg-lbl { font: 650 12.5px var(--font-ui); fill: var(--ink); pointer-events: none; }
.dg-ring { fill: none; stroke: var(--accent); stroke-width: 2.5; display: none; }
.dg-node:focus-visible .dg-ring { display: block; }
.dg-node.is-sel .dg-box { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 2; }
.dg-k-client { --k: var(--ink-3); }
.dg-k-lb { --k: var(--accent); }
.dg-k-service { --k: var(--accent-line); }
.dg-k-cache { --k: var(--medium); }
.dg-k-db { --k: var(--easy); }
.dg-k-queue { --k: color-mix(in srgb, var(--hard) 55%, var(--accent)); }
.dg-k-cdn { --k: color-mix(in srgb, var(--accent) 50%, var(--easy)); }
.dg-k-storage { --k: color-mix(in srgb, var(--medium) 55%, var(--ink-3)); }
.dg-k-search { --k: color-mix(in srgb, var(--hard) 50%, var(--medium)); }
.dg-k-external .dg-box { stroke-dasharray: 4 3; }

/* Edges */
.dg-edges { pointer-events: none; }
.dg-line { fill: none; stroke: var(--ink-3); stroke-width: 1.5; transition: stroke var(--dur-2), opacity var(--dur-2); }
.dg-e-async .dg-line, .dg-line.is-dash { stroke-dasharray: 6 4; }
.dg-e-replication .dg-line { stroke: var(--medium); stroke-dasharray: 2 4; stroke-width: 2; }
.dg-ah { fill: var(--ink-3); }
.dg-ah-replication { fill: var(--medium); }
.dg-elabel { font: 500 10.5px var(--font-ui); fill: var(--ink-2); paint-order: stroke; stroke: var(--bg); stroke-width: 4px; stroke-linejoin: round; pointer-events: none; }

/* Scenario highlight */
.dg-node, .dg-edge { transition: opacity var(--dur-2); }
.dg-node.is-dim, .dg-edge.is-dim { opacity: 0.35; }
.dg-node.is-done .dg-box { stroke: var(--accent-line); }
.dg-node.is-active .dg-box { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 2.5; }
.dg-edge.is-done .dg-line { stroke: var(--accent-line); }
.dg-edge.is-active .dg-line { stroke: var(--accent); stroke-width: 2.75; stroke-dasharray: 7 5; }
.dg-edge.is-active .dg-ah, .dg-edge.is-done .dg-ah { fill: var(--accent); }
@media (prefers-reduced-motion: no-preference) {
  :root:not([data-motion="reduce"]) .dg-edge.is-active .dg-line { animation: dg-flow 0.9s linear infinite; }
}
@keyframes dg-flow { to { stroke-dashoffset: -24; } }

/* Detail panel */
.dg-panel { min-width: 0; padding: var(--s-4) 0 var(--s-2); border-bottom: 1px solid var(--line); outline: none; }
@container (min-width: 1000px) { .dg-panel { padding: 0 0 0 var(--s-4); border-bottom: 0; border-left: 1px solid var(--line); } }
.dg-hint { color: var(--ink-2); font-size: var(--text-sm); max-width: 62ch; }
.dg-p-title { font: 700 var(--text-lg)/1.2 var(--font-ui); display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s-2); }
.dg-kind { font: 600 var(--text-xs) var(--font-ui); color: var(--accent-soft-ink); background: var(--accent-soft); padding: 2px 8px; border-radius: 999px; }
.dg-p-why { margin-top: var(--s-2); font-size: 1rem; }
.dg-p-cols { display: grid; gap: var(--s-3) var(--s-6); margin-top: var(--s-3); grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.dg-p-cols h4 { font: 700 var(--text-xs) var(--font-ui); letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-3); margin-bottom: var(--s-1); }
.dg-p-cols p, .dg-p-list { font-size: var(--text-sm); color: var(--ink); }
.dg-p-list { margin: 0; padding-left: 1.1em; }
.dg-p-list li + li { margin-top: 3px; }

/* Scenario player: the diagram itself is the stage */
.dg-play .player-stage { display: none; }
.dg-play:empty { display: none; }

/* Class diagrams */
.dg-class .dg-box { fill: var(--surface); stroke: var(--ink-3); stroke-width: 1.25; }
.dg-sep { fill: none; stroke: var(--line-strong); stroke-width: 1; }
.dg-cname { font: 700 12.5px var(--font-ui); fill: var(--ink); pointer-events: none; }
.dg-cname.is-ital { font-style: italic; }
.dg-cstar { font: 500 10px var(--font-ui); fill: var(--ink-3); pointer-events: none; }
.dg-cmem { font: 400 11px var(--font-mono); font-stretch: var(--stretch-mono); fill: var(--ink); white-space: pre; pointer-events: none; }
.dg-c-interface .dg-box, .dg-c-abstract .dg-box { stroke-dasharray: 5 3; }
.dg-c-enum .dg-box { fill: var(--surface-2); }
.dg-class .dg-line { stroke: var(--ink-2); }
.dg-cm { stroke: var(--ink-2); stroke-width: 1.2; stroke-linejoin: round; }
.dg-cm-hollow { fill: var(--surface); }
.dg-cm-fill { fill: var(--ink-2); }
.dg-cm-open { fill: none; }
.dg-class .dg-node:hover .dg-box { stroke: var(--accent); }

@media print { .dg-scen, .dg-play { display: none; } }
