/* ============================================================
   Cue — "How Cue works" diagram
   Fixed 1120x860 design stage, scaled to fit. Circular nodes +
   hairline connectors that draw on scroll. Colors from tokens.
   ============================================================ */

.diagram-wrap { position: relative; width: 100%; }
.diagram-scaler { position: relative; transform-origin: top left; }
.dg-stage { position: relative; width: 1120px; height: 860px; }

.dg-svg { position: absolute; inset: 0; width: 1120px; height: 860px; overflow: visible; pointer-events: none; }

/* ---- Connectors ---- */
.dg-path {
  fill: none;
  stroke: var(--cue-color-midgray);
  stroke-width: 2.25;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  transition: stroke-dashoffset 1.05s cubic-bezier(.45,0,.2,1);
}
.run .dg-path { stroke-dashoffset: 0; }
.dg-path.out { stroke: color-mix(in srgb, var(--cue-color-blue) 55%, var(--cue-color-midgray)); }

/* ---- Data packets (gentle flow) ---- */
.dg-packet {
  position: absolute; top: 0; left: 0;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--cue-color-blue);
  box-shadow: 0 0 9px rgba(40,89,225,0.6);
  offset-rotate: 0deg; opacity: 0;
}
.dg-packet.lime { background: var(--cue-color-green); box-shadow: 0 0 9px rgba(226,245,82,0.9); }
.run .dg-packet { animation: pkt 3.4s linear infinite; }
@keyframes pkt {
  0% { offset-distance: 0%; opacity: 0; }
  12% { opacity: 1; }
  88% { opacity: 1; }
  100% { offset-distance: 100%; opacity: 0; }
}

/* ---- Nodes ---- */
.dg-node { position: absolute; transform: translate(-50%, -50%); }
.dg-node__in {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 9px;
  opacity: 0; transform: scale(.9) translateY(10px);
  transition: opacity .6s ease, transform .6s cubic-bezier(.2,.7,.2,1);
}
.run .dg-node__in { opacity: 1; transform: none; }

.dg-circle {
  background: var(--cue-color-white);
  border: 1px solid var(--cue-border-color);
  border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 16px;
  box-shadow: 0 1px 1.5em rgba(0,0,0,0.10);
}
.dg-ico { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; background: rgba(40,89,225,0.10); color: var(--cue-color-blue); flex: none; }
.dg-ico .cue-icon { font-size: 25px; }
.dg-title { font-size: 14px; font-weight: 600; letter-spacing: 0.01em; color: var(--cue-color-darkgray); line-height: 1.15; }
.dg-sub { font-size: 11.5px; line-height: 1.38; color: var(--cue-color-midgray); letter-spacing: 0.01em; max-width: 150px; }

/* consumers */
.dg-consumer .dg-circle { width: 196px; height: 196px; }
.dg-tag-soon { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--cue-color-midgray); border: 1px solid var(--cue-border-color); border-radius: 9999px; padding: 2px 9px; }

/* tuner + sources */
.dg-tuner .dg-circle { width: 172px; height: 172px; }
.dg-ods .dg-circle { width: 120px; height: 120px; padding: 12px; gap: 5px; }
.dg-ods .dg-ico { width: 38px; height: 38px; }
.dg-ods .dg-title { font-size: 12px; max-width: 92px; }

.dg-src .dg-circle { width: 186px; height: 148px; border-radius: 22px; }
.dg-src .dg-ico { background: rgba(0,202,204,0.12); color: #079ea0; }

/* hub */
.dg-hub { z-index: 3; }
.dg-hub .dg-circle {
  width: 226px; height: 226px; gap: 10px;
  border: 1.5px solid color-mix(in srgb, var(--cue-color-blue) 42%, var(--cue-border-color));
  box-shadow: 0 14px 48px rgba(40,89,225,0.18);
}
.dg-hub .dg-sub { max-width: 170px; font-size: 12px; }
.dg-hub__count {
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.02em;
  color: var(--cue-color-blue); font-variant-numeric: tabular-nums;
  background: rgba(40,89,225,0.10); border-radius: 12px; padding: 5px 12px;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  line-height: 1.5; text-align: center;
}
.dg-hub__ring {
  position: absolute; left: 50%; top: 50%;
  width: 226px; height: 226px; border-radius: 50%;
  transform: translate(-50%,-50%); pointer-events: none;
  border: 2px solid var(--cue-color-blue); opacity: 0;
}
.run .dg-hub__ring { animation: hubRing 2.4s ease-out 1.2s 3; }
.run .dg-hub__ring.green { border-color: var(--cue-color-success); animation: hubRing 2.4s ease-out 2.2s 1; }
@keyframes hubRing {
  0% { opacity: .55; transform: translate(-50%,-50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%,-50%) scale(1.45); }
}

/* ---- Legend below diagram ---- */
.dg-legend { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-top: 30px; }
@media (max-width: 820px) { .dg-legend { grid-template-columns: 1fr; gap: 14px; } }
.dg-legend__item { display: flex; gap: 14px; align-items: flex-start; }
.dg-legend__num { font-size: 13px; font-weight: 700; color: var(--cue-color-blue); font-variant-numeric: tabular-nums; padding-top: 1px; }
.dg-legend__t { font-size: 14.5px; font-weight: 600; color: var(--cue-color-darkgray); margin: 0 0 3px; }
.dg-legend__d { font-size: 13px; line-height: 1.5; color: var(--cue-color-midgray); margin: 0; }

@media (prefers-reduced-motion: reduce) {
  .dg-path { transition: none; stroke-dashoffset: 0; }
  .dg-node__in { transition: none; opacity: 1; transform: none; }
  .dg-packet, .dg-hub__ring { animation: none !important; }
}

/* lock final state (renders even if transitions are throttled) */
.run-final .dg-node__in { opacity: 1 !important; transform: none !important; transition: none !important; }
.run-final .dg-path { stroke-dashoffset: 0 !important; transition: none !important; }

/* data-flow tweak: hide the animated packets */
body.no-dataflow .dg-packet { display: none; }
