.hero-demo {
  container: overview-demo / inline-size;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--stroke-strong);
  border-radius: 13px;
  background: var(--sheet);
  box-shadow: 0 24px 65px #08080d80;
}

.hero-demo-head {
  display: flex;
  align-items: center;
  min-height: 3.25rem;
  padding: 6px 13px;
  border-bottom: 1px solid var(--stroke);
  background: var(--chrome);
}

.hero-demo-file {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--text);
  font: .8125rem/1.4 var(--mono);
}

.hero-demo-steps button {
  padding: 4px 8px;
  min-height: 2rem;
  border: 1px solid transparent;
  border-radius: 5px;
  color: var(--muted);
  background: transparent;
  font-size: .875rem;
  font-weight: 600;
}

.hero-demo-steps button:hover { color: var(--text); background: var(--hover); }
.hero-demo-steps button:focus-visible { outline-offset: 1px; }

.hero-demo-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-height: 15.5rem;
  background: var(--code);
}

.hero-demo-stage > :is(.hero-demo-editor, .hero-demo-graph, .hero-demo-handoff) { grid-area: 1 / 1; }
.hero-demo-stage > [hidden] { display: block !important; visibility: hidden; }

.hero-demo-editor {
  padding: 18px 12px;
  color: var(--text);
  font: clamp(.75rem, 1vw, .875rem)/1.75 var(--mono);
}

.hero-demo-line {
  display: grid;
  grid-template-columns: 2ch minmax(0, 1fr);
  align-items: baseline;
  gap: 10px;
  padding: 2px 6px;
  border-radius: 4px;
}

.hero-demo-line.is-active { background: var(--inset); }
.hero-demo-line-number { color: var(--subtle); text-align: right; user-select: none; }
.hero-demo-line.is-active .hero-demo-line-number { color: var(--accent-ink); }
.hero-demo-line-body { position: relative; min-width: 0; overflow-wrap: anywhere; }
.hero-demo-line-body > code { font: inherit; white-space: pre-wrap; }
.hero-demo-keyword { color: #c7adff; font-weight: 600; }
.hero-demo-jinja { color: #ffc29c; }
.hero-demo-string { color: #a9d9a8; }
.hero-demo-inserted { border-radius: 3px; background: var(--soft-accent); color: var(--accent-ink); }
.hero-demo-caret { display: inline-block; width: 2px; height: 1em; margin-left: 1px; vertical-align: -.2em; background: var(--accent); }
.hero-demo[data-playing] .hero-demo-caret { animation: hero-demo-blink 1.1s steps(1) infinite; }

@keyframes hero-demo-blink { 60% { opacity: 0; } }

.hero-demo-popover {
  position: absolute;
  z-index: 2;
  top: calc(100% + 3px);
  left: 0;
  width: max-content;
  max-width: 100%;
  overflow: hidden;
  border: 1px solid var(--stroke-strong);
  border-radius: 7px;
  background: var(--sheet);
  box-shadow: 0 8px 22px #08080dc0;
  white-space: normal;
}

.hero-demo-popover-title {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 3px 12px;
  padding: 4px 9px;
  border-bottom: 1px solid var(--stroke);
  color: var(--muted);
  background: var(--chrome);
  font: 600 .75rem/1.5 var(--sans);
}

.hero-demo-choice {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1px 12px;
  border-left: 2px solid transparent;
  padding: 5px 8px 5px 7px;
  font: .75rem/1.45 var(--sans);
}

.hero-demo-choice code { color: var(--text); }
.hero-demo-choice span { color: var(--muted); }
.hero-demo-choice.is-picked { border-color: var(--accent); background: var(--soft-accent); }
.hero-demo-choice.is-picked code { color: var(--accent-ink); }
.hero-demo-choice + .hero-demo-choice { border-top: 1px solid var(--stroke); }

.hero-demo-graph, .hero-demo-handoff {
  min-width: 0;
  padding: 16px 14px;
  background: radial-gradient(circle, var(--stroke) 1px, transparent 1.1px) 0 0 / 16px 16px;
}

.hero-demo-graph-head { display: grid; gap: 2px; }
.hero-demo-graph-head h2 { font-size: .9375rem; letter-spacing: -.01em; }
.hero-demo-graph-head p, .hero-demo-handoff-note { color: var(--muted); font-size: .8125rem; }
.hero-demo-trail {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(2.3rem, .37fr) minmax(0, 1.2fr) minmax(2.3rem, .37fr) minmax(0, 1fr);
  align-items: center;
  padding-block: 25px 15px;
}

.hero-demo-node {
  display: grid;
  min-width: 0;
  gap: 4px;
  padding: 9px 8px;
  border: 1px solid var(--stroke-strong);
  border-radius: 7px;
  background: var(--sheet);
  box-shadow: 0 4px 14px #09090d90;
  overflow-wrap: anywhere;
  font: .8125rem/1.35 var(--mono);
}

.hero-demo-node strong { color: var(--text); font-weight: 650; }
.hero-demo-node code { color: var(--accent-ink); font-size: .75rem; }
.hero-demo-node:nth-child(3) { border-color: var(--accent-border); }

.hero-demo-edge {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 20px;
  align-items: center;
  color: var(--accent);
}

.hero-demo-edge:nth-child(2) { color: var(--subtle); }
.hero-demo-edge:nth-child(2) span { color: var(--muted); }

.hero-demo-edge span {
  position: absolute;
  inset: auto 0 17px;
  color: var(--accent-ink);
  background: var(--code);
  text-align: center;
  white-space: nowrap;
  font: 650 .75rem/1.4 var(--mono);
}

.hero-demo-edge svg { display: block; width: 100%; height: 15px; overflow: visible; }
.hero-demo-edge :is(line, path, polyline) { fill: none; stroke: currentColor; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.hero-demo-edge [pathLength] { stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset 380ms ease; }
.hero-demo-edge[data-revealed] [pathLength] { stroke-dashoffset: 0; }
.hero-demo-trail > :is(.hero-demo-node, .hero-demo-edge), .hero-demo-evidence { opacity: 0; transition: opacity 230ms ease-out; }
.hero-demo-trail > [data-revealed], .hero-demo-evidence[data-revealed] { opacity: 1; }

.hero-demo-evidence {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.hero-demo-evidence div, .hero-demo-mapping > div {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--stroke-strong);
  border-radius: 6px;
  background: var(--sheet);
}

.hero-demo-evidence dt, .hero-demo-mapping span {
  display: block;
  color: var(--muted);
  font-size: .75rem;
  line-height: 1.3;
}

.hero-demo-evidence dd {
  margin: 5px 0 0;
  color: var(--accent-ink);
  font: 650 .875rem/1.2 var(--mono);
}

.hero-demo-mapping {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin: 22px 0 14px;
}

.hero-demo-mapping > div { position: relative; }
.hero-demo-mapping > div:first-child::after {
  position: absolute;
  top: 50%;
  left: calc(100% + 1px);
  width: 18px;
  border-top: 1px solid var(--accent);
  content: "";
}

.hero-demo-mapping > div:last-child { border-color: var(--accent-border); }
.hero-demo-mapping code {
  display: block;
  margin-top: 5px;
  color: var(--accent-ink);
  overflow-wrap: anywhere;
  font: .8125rem/1.45 var(--mono);
}

.hero-demo-note {
  min-height: 4.25rem;
  padding: 8px 13px;
  border-top: 1px solid var(--stroke);
  background: var(--inset);
  color: var(--muted);
  font-size: .875rem;
  line-height: 1.45;
}

.hero-demo-note strong { margin-right: .28em; color: var(--text); }

.hero-demo-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 6px;
  border-top: 1px solid var(--stroke);
  background: var(--sheet);
}

.hero-demo-steps button { padding-inline: 4px; text-align: center; overflow-wrap: anywhere; }
.hero-demo-steps button[aria-current="step"] { border-color: var(--accent-border); color: var(--accent-ink); background: var(--soft-accent); }

@container overview-demo (max-width: 430px) {
  .hero-demo-note { min-height: 5.05rem; }
  .hero-demo-stage { min-height: 18rem; }
  .hero-demo-graph, .hero-demo-handoff { padding: 12px 14px; }
  .hero-demo-trail { grid-template-columns: minmax(0, 1fr); justify-items: center; padding-block: 10px; }
  .hero-demo-node {
    grid-auto-flow: column;
    justify-content: start;
    align-items: baseline;
    gap: 6px 12px;
    width: min(100%, 21rem);
    padding: 6px 8px;
  }
  .hero-demo-edge { justify-items: center; }
  .hero-demo-edge span { inset: auto auto auto calc(100% + 4px); }
  .hero-demo-edge svg { width: 20px; transform: rotate(90deg); }
  .hero-demo-mapping { grid-template-columns: minmax(0, 1fr); margin-top: 16px; }
  .hero-demo-mapping > div:first-child::after { top: 100%; left: 22px; width: 0; height: 18px; border-left: 1px solid var(--accent); }
}

@container overview-demo (max-width: 355px) {
  .hero-demo-note { min-height: 6.25rem; }
  .hero-demo-stage { min-height: 20.5rem; }
  .hero-demo-editor { padding-inline: 7px; }
  .hero-demo-node { grid-auto-flow: row; gap: 2px; }
  .hero-demo-evidence { gap: 5px; }
  .hero-demo-evidence div { padding-inline: 7px; }
}

@media (prefers-reduced-motion: reduce) {
  .hero-demo-trail > :is(.hero-demo-node, .hero-demo-edge), .hero-demo-edge [pathLength], .hero-demo-evidence { transition: none; }
  .hero-demo[data-playing] .hero-demo-caret { animation: none; }
}
