/* Hierarchy animation: four stage cards, the active one widens; elements with data-s appear from that step on. */
.dz { --gap: 12px; }
.dz-stages { display: flex; gap: var(--gap); align-items: stretch; min-height: 560px; }
.dz-card { flex: 1 1 0; min-width: 0; background: var(--soft); border-radius: 14px; padding: 14px; position: relative;
  border-top: 4px solid var(--c); transition: flex-grow .7s cubic-bezier(.2,.7,.2,1), background .4s, opacity .4s; overflow: hidden; }
.dz-card.on { flex-grow: 2.6; background: #fff; box-shadow: 0 0 0 1px var(--line), 0 20px 40px -28px rgba(0,0,0,.35); }
.dz-card:not(.on) { opacity: .78; cursor: pointer; }
.dz-card:not(.on):hover { opacity: 1; }
.dz-head { margin-bottom: 10px; line-height: 1.3; }
.dz-head b { display: block; font-size: 16px; }
.dz-head small { display: block; font: 11px var(--mono); color: var(--muted); }
.dz-label { font: 600 10px var(--sans); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 10px 0 4px; }

[data-s] { opacity: 0; transform: translateY(8px); transition: opacity .6s, transform .6s; }
[data-s].in { opacity: 1; transform: none; }

/* stage 1: route */
.dz-map { position: relative; width: 100%; max-width: 330px; margin: 0 auto; aspect-ratio: 800 / 1111; border-radius: 8px; overflow: hidden; background: #333; }
.dz-map img, .dz-map svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.dz-route { stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset 2.4s ease-in-out; }
.dz-route.in { stroke-dashoffset: 0; }
.dz-dirs { list-style: none; margin: 8px 0 0; padding: 0; font-size: 13px; }
.dz-dirs li { display: grid; grid-template-columns: 22px 1fr auto; gap: 6px; padding: 4px 6px; border-radius: 6px; color: var(--ink2); }
.dz-dirs li i { font-style: normal; font: 600 11px var(--mono); width: 18px; height: 18px; border-radius: 50%; background: var(--route); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; }
.dz-dirs li em { font-style: normal; font: 12px var(--mono); color: var(--muted); }
.dz-dirs li.next { background: color-mix(in srgb, var(--route) 14%, transparent); color: var(--ink); font-weight: 500; }

/* stage 2: orchestrator */
.dz-cams { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.dz-cams figure { position: relative; }
.dz-cams img { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 4px; display: block; }
.dz-cams figcaption { font: 10px var(--mono); color: var(--muted); margin: 2px 0 0; text-align: center; }
.dz-orow { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 10px; margin-top: 4px; }
.dz-orow img { width: 100%; border-radius: 6px; display: block; }
.dz-text { font: 11px/1.5 var(--mono); background: var(--soft); border-radius: 8px; padding: 8px 10px; white-space: pre-wrap; overflow-wrap: anywhere;
  color: var(--ink2); height: 210px; overflow-y: auto; }
.dz-reason { font: 13px/1.5 var(--sans); background: color-mix(in srgb, var(--cmd) 8%, #fff); border: 1px solid color-mix(in srgb, var(--cmd) 35%, transparent);
  border-radius: 8px; padding: 9px 11px; color: var(--ink); min-height: 4.5em; }
.dz-cmd { display: inline-block; max-width: 100%; font: 600 14px var(--sans); color: #fff; background: var(--cmd); border-radius: 999px; padding: 6px 14px; margin-top: 8px; }
.dz-cmd small { font-weight: 400; opacity: .85; margin-left: 6px; }

/* stage 3: trace predictor */
.dz-hist { display: grid; grid-template-columns: repeat(5, 1fr) 70px; gap: 4px; align-items: end; }
.dz-hist img { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 4px; display: block; }
.dz-hist figcaption { font: 10px var(--mono); color: var(--muted); text-align: center; margin: 2px 0 0; }
.dz-bev { background: #fff; border: 1px solid var(--line); border-radius: 4px; aspect-ratio: 1; }
.dz-cur { position: relative; margin-top: 8px; }
.dz-cur img { width: 100%; display: block; border-radius: 8px; aspect-ratio: 16/9; }
.dz-cur svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.dz-pt { opacity: 0; transform-box: fill-box; transform-origin: center; transform: scale(.2); transition: opacity .25s, transform .35s; }
.dz-pt.in { opacity: 1; transform: none; }
.dz-tline { stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset 1.6s linear; }
.dz-tline.in { stroke-dashoffset: 0; }
.dz-goal { transform-box: fill-box; transform-origin: center; }
.dz-goal.in { animation: dzpulse 1.4s ease-out infinite; }
@keyframes dzpulse { 0% { stroke-width: 3; r: 8; } 70% { stroke-width: 1; r: 18; opacity: 0; } 100% { opacity: 0; } }
.dz-stat { font: 12px var(--mono); color: var(--ink2); margin-top: 6px; }
.dz-stat b { color: var(--ink); }

/* stage 4: execution */
.dz-exec { display: grid; gap: 8px; }
.dz-exec .pair { position: relative; }
.dz-exec img, .dz-exec video { width: 100%; display: block; border-radius: 8px; aspect-ratio: 16/9; object-fit: cover; background: #000; }
.dz-exec svg { position: absolute; inset: 0; width: 100%; height: 100%; transition: opacity .8s; }
.dz-exec svg.off { opacity: 0; }
.dz-tick { display: inline-flex; gap: 4px; vertical-align: middle; margin-left: 6px; }
.dz-tick i { width: 7px; height: 7px; border-radius: 50%; background: var(--driven); opacity: .25; }
.dz-tick i.on { opacity: 1; }

/* collapsed cards show only their key visual */
.dz-card:not(.on) .dz-more { display: none; }
.dz-mini { display: none; }
.dz-card:not(.on) .dz-mini { display: block; }
.dz-mini img { width: 100%; border-radius: 6px; display: block; }
.dz-mini p { font-size: 12.5px; color: var(--ink2); margin: 8px 0 0; line-height: 1.45; }

/* arrows between cards with a travelling token */
.dz-arrow { flex: 0 0 18px; position: relative; align-self: center; height: 2px; background: var(--axis); }
.dz-arrow::after { content: ""; position: absolute; right: -2px; top: -4px; border: 5px solid transparent; border-left-color: var(--axis); }
.dz-token { position: absolute; top: -5px; left: -6px; width: 12px; height: 12px; border-radius: 50%; background: var(--c); opacity: 0; }
.dz-token.go { animation: dzgo .9s ease-in-out; }
@keyframes dzgo { 0% { left: -14px; opacity: 0; } 20% { opacity: 1; } 100% { left: 18px; opacity: 0; } }

/* controls: play/pause and a progress bar grouped by stage; every segment is a step and can be clicked */
.dz-bar { display: flex; gap: 14px; align-items: flex-end; margin-bottom: 10px; }
.dz-play { all: unset; cursor: pointer; flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center;
  justify-content: center; background: var(--ink); color: #fff; font-size: 13px; }
.dz-play:focus-visible { outline: 2px solid var(--route); outline-offset: 2px; }
.dz-prog { flex: 1; display: flex; gap: 10px; min-width: 0; }
.dz-grp { min-width: 0; }
.dz-grp > span { display: block; font: 600 12px var(--sans); color: var(--ink2); margin-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dz-grp > div { display: flex; gap: 4px; }
.dz-grp button { all: unset; cursor: pointer; flex: 1; height: 8px; border-radius: 4px; background: var(--line); position: relative; overflow: hidden; }
.dz-grp button:hover { background: var(--axis); }
.dz-grp button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.dz-grp button i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--c); border-radius: 4px; transition: width .05s linear; }
.dz-cap { font-size: 15px; line-height: 1.55; color: var(--ink2); min-height: 4.8em; margin: 0 0 14px 54px; max-width: 900px; }
.dz-cap b { color: var(--ink); }

/* asynchronous timing strip */
.dz-time { margin-top: 18px; background: var(--soft); border-radius: 12px; padding: 12px 14px 8px; }
.dz-time svg { width: 100%; height: auto; display: block; }
.dz-time .lab { font: 12px var(--sans); fill: var(--ink2); }
.dz-time .tick { font: 10px var(--mono); fill: var(--muted); }

/* narrow screens: only the active card, the control bar stays under the page nav while scrolling */
@media (max-width: 980px) {
  .dz-stages { flex-direction: column; min-height: 0; }
  .dz-arrow, .dz-card:not(.on) { display: none; }
  .dz-card.on { flex: none; }
  .dz-orow { grid-template-columns: 110px minmax(0, 1fr); }
  .dz-cams { grid-template-columns: repeat(3, 1fr); }
  .dz-bar { position: sticky; top: 47px; z-index: 5; background: var(--bg); padding: 8px 0 4px; margin-bottom: 4px; }
  .dz-cap { margin-left: 0; min-height: 0; font-size: 14.5px; }
  .dz-prog { gap: 6px; }
  .dz-grp { flex: 1 1 0 !important; }
  .dz-grp > span { font-size: 10.5px; }
  .dz-grp button { height: 8px; border-top: 9px solid transparent; border-bottom: 9px solid transparent; background-clip: padding-box; }
  .dz-time { overflow-x: auto; }
  .dz-time svg { min-width: 680px; }
}
@media (prefers-reduced-motion: reduce) {
  [data-s], .dz-card, .dz-route, .dz-tline, .dz-pt { transition: none; }
  .dz-goal.in, .dz-token.go { animation: none; }
}
