/* Block demo "Leave LabVIEW behind": Your LabVIEW → Python → Your rack, in one dark editor-like panel.
   Page tokens (assets/css/site.css). Sizes are in em on a panel whose font-size follows the container, so it
   scales like a screenshot. From 940px of container the steps are three columns that light up in turn; below
   that, one step at a time, crossfading. Every piece of text is in the DOM from the first frame (hidden until
   its turn), so nothing on the page moves while it plays. */

.kd-python {
  --kp-bg: var(--bg-raise, #0d1016);
  --kp-line: var(--line, rgba(255, 255, 255, 0.075));
  --kp-line-hi: var(--line-hi, rgba(255, 255, 255, 0.14));
  --kp-text: var(--text, #f2f5f9);
  --kp-text-2: var(--text-2, rgba(242, 245, 249, 0.64));
  --kp-dim: rgba(242, 245, 249, 0.54); /* small text that still carries meaning: 5:1 on the panel */
  --kp-text-3: var(--text-3, rgba(242, 245, 249, 0.42));
  --kp-accent: var(--accent, #5aa2e6);
  --kp-ok: var(--ok, #46c48a);
  --kp-sans: var(--font, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
  --kp-mono: var(--mono, ui-monospace, "SFMono-Regular", Consolas, monospace);
  --kp-ease: var(--ease, cubic-bezier(0.2, 0.7, 0.2, 1));
  /* code */
  --kp-code: #d3dae2;
  --kp-kw: #8cc4f2;
  --kp-str: #a8d8a9;
  --kp-num: #f2c66d;
  --kp-dec: #c4b3f6;
  --kp-com: var(--kp-text-3);
  /* layout */
  --kp-cols: minmax(0, 1.05fr) minmax(0, 1.38fr) minmax(0, 0.8fr);
  --kp-pad: 1.45em;
  --kp-row: 2.35em;

  position: relative;
  container-type: inline-size;
  color: var(--kp-text);
  text-align: left;
}
.kd-python [hidden] { display: none !important; }
.kd-python svg { flex: none; }
.kd-python code { font-family: var(--kp-mono); font-size: max(11px, 0.96em); color: inherit; background: none; padding: 0; }
.kd-python.now *,
.kd-python.now *::before,
.kd-python.now *::after,
.kd-python-line.now { transition: none !important; }

.kd-python-panel {
  position: relative;
  display: flex; flex-direction: column;
  aspect-ratio: 16 / 7.2;
  font: 400 clamp(12px, 1.28cqw, 14.5px) / 1.5 var(--kp-sans);
  background: var(--kp-bg);
  border: 1px solid var(--kp-line-hi);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 2.4em 6em -1.2em rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.035);
  -webkit-font-smoothing: antialiased;
}
.kd-python-ico { width: 1.2em; height: 1.2em; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- the step indicator ---------- */

.kd-python-steps {
  position: relative; flex: none;
  display: grid; grid-template-columns: var(--kp-cols);
  border-bottom: 1px solid var(--kp-line);
}
.kd-python-stepcell { position: relative; display: flex; align-items: center; min-width: 0; padding: 1.3em var(--kp-pad) 1.2em; }
.kd-python-step {
  font-size: 1.2em; font-weight: 500; line-height: 1.3; letter-spacing: -0.012em; white-space: nowrap;
  color: var(--kp-text-3); transition: color 0.5s var(--kp-ease);
}
.kd-python-step.done { color: var(--kp-text-2); }
.kd-python-step.on { color: var(--kp-text); }
.kd-python-arrow {
  position: absolute; right: 0; top: 50%; transform: translate(50%, -52%);
  font-size: 1.1em; line-height: 1; color: var(--kp-text-3); transition: color 0.5s var(--kp-ease);
}
.kd-python-stepcell.past .kd-python-arrow { color: var(--kp-text-2); }
.kd-python-line {
  position: absolute; left: 0; bottom: -1px; width: 1px; height: 2px;
  background: var(--kp-accent); transform-origin: 0 50%;
  transition: transform 0.6s var(--kp-ease);
}

/* ---------- the three steps ---------- */

.kd-python-cols {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: var(--kp-cols);
  transition: opacity 0.55s var(--kp-ease);
}
.kd-python.out .kd-python-cols { opacity: 0; }
.kd-python-col {
  position: relative; min-width: 0;
  display: flex; flex-direction: column;
  padding: 1.3em var(--kp-pad) 1.35em;
  transition: opacity 0.6s var(--kp-ease), transform 0.6s var(--kp-ease);
}
.kd-python-ptitle { display: none; margin: 0 0 0.7em; font-size: 1.12em; font-weight: 500; color: var(--kp-text); }
.kd-python-head {
  flex: none; display: flex; align-items: baseline; gap: 0.9em; margin-bottom: 0.95em;
  font-size: max(11px, 0.9em); line-height: 1.4; white-space: nowrap;
}
.kd-python-head b { font-weight: 500; color: var(--kp-text-2); }
.kd-python-head > span { margin-left: auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--kp-dim); }
.kd-python-later { opacity: 0; transition: opacity 0.5s var(--kp-ease); }
.kd-python-later.on { opacity: 1; }

/* a closing line at the foot of each step */
.kd-python-foot {
  flex: none; margin: auto 0 0; padding-top: 0.9em;
  border-top: 1px solid var(--kp-line);
  font-size: max(11px, 0.92em); line-height: 1.45; color: var(--kp-dim);
  opacity: 0; transform: translateY(0.35em);
  transition: opacity 0.5s var(--kp-ease), transform 0.5s var(--kp-ease);
}
.kd-python-foot.on { opacity: 1; transform: none; }

/* 1. Your LabVIEW */

.kd-python-files { position: relative; display: grid; gap: 0.2em; margin-bottom: 1.3em; }
.kd-python-file {
  position: relative;
  display: grid; grid-template-columns: 1.15em minmax(0, 1fr) auto; grid-template-rows: var(--kp-row) auto;
  align-items: center; column-gap: 0.7em;
  padding: 0 0.65em; border-radius: 0.5em;
  transition: background-color 0.4s var(--kp-ease);
}
.kd-python-file > .kd-python-ico { width: 1.15em; height: 1.15em; color: var(--kp-text-3); transition: color 0.4s; }
.kd-python-fname {
  font: 400 max(11px, 0.97em) / 1.3 var(--kp-mono); color: var(--kp-text-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: color 0.4s;
}
.kd-python-file.read .kd-python-fname { color: var(--kp-text); }
.kd-python-file.read > .kd-python-ico { color: var(--kp-text-2); }
.kd-python-chip {
  justify-self: end; font-size: max(11px, 0.86em); line-height: 1; white-space: nowrap;
  padding: 0.4em 0.65em; border-radius: 999px; border: 1px solid transparent;
  opacity: 0; transform: translateX(-0.4em);
  transition: opacity 0.4s var(--kp-ease), transform 0.4s var(--kp-ease);
}
.kd-python-file.read .kd-python-chip { opacity: 1; transform: none; }
.kd-python-chip.inst { color: var(--kp-text-2); background: rgba(255, 255, 255, 0.045); border-color: rgba(255, 255, 255, 0.12); }
.kd-python-chip.scan { color: #a3cbf6; background: rgba(79, 149, 234, 0.13); border-color: rgba(79, 149, 234, 0.32); }
.kd-python-chip.no { color: var(--kp-dim); border: 1px dashed rgba(255, 255, 255, 0.2); }
.kd-python-why {
  grid-column: 2 / -1; margin: -0.3em 0 0.5em;
  font-size: max(11px, 0.86em); line-height: 1.4; color: var(--kp-dim);
  opacity: 0; transition: opacity 0.45s 0.12s var(--kp-ease);
}
.kd-python-file.read .kd-python-why { opacity: 1; }
/* the VI picked for Python */
.kd-python-file::before {
  content: ""; position: absolute; left: 0; top: 0.6em; height: calc(var(--kp-row) - 1.2em); width: 2px;
  border-radius: 2px; background: var(--kp-accent); opacity: 0; transition: opacity 0.4s var(--kp-ease);
}
.kd-python-file.picked { background-color: rgba(90, 162, 230, 0.1); }
.kd-python-file.picked::before { opacity: 1; }

/* the read head: a soft band that moves row to row, a line running across the row it reads */
.kd-python-band {
  position: absolute; left: 0; right: 0; top: 0; height: var(--kp-row); border-radius: 0.5em;
  background: rgba(90, 162, 230, 0.075); pointer-events: none;
  opacity: 0; transform: translateY(calc(var(--row, 0) * (var(--kp-row) + 0.2em)));
  transition: transform 0.32s var(--kp-ease), opacity 0.3s var(--kp-ease);
}
.kd-python-band.on { opacity: 1; }
.kd-python-band::before {
  content: ""; position: absolute; left: 0; top: 0.6em; bottom: 0.6em; width: 2px; border-radius: 2px;
  background: var(--kp-accent);
}
.kd-python-scan {
  position: absolute; left: 0.65em; right: 0.65em; bottom: 0; height: 1px;
  background: linear-gradient(90deg, rgba(90, 162, 230, 0), var(--kp-accent));
  transform: scaleX(0); transform-origin: 0 50%;
}
.kd-python-band.sweep .kd-python-scan { transform: scaleX(1); transition: transform 0.4s cubic-bezier(0.4, 0, 0.3, 1); }

/* 2. Python */

.kd-python-code {
  position: relative; isolation: isolate; margin-bottom: 1.3em;
  font: 400 max(11px, 0.96em) / 1.9 var(--kp-mono); color: var(--kp-code);
  font-variant-ligatures: none; tab-size: 4;
}
.kd-python-ln {
  position: relative; display: grid; grid-template-columns: 2ch minmax(0, 1fr); column-gap: 1.5em;
  min-height: 1.9em; white-space: pre;
}
.kd-python-no {
  text-align: right; color: var(--kp-text-3); font-variant-numeric: tabular-nums;
  opacity: 0; transition: opacity 0.25s, color 0.4s;
}
.kd-python-ln.on .kd-python-no { opacity: 1; }
.kd-python-tx { padding-left: calc(var(--i, 0) * 1ch); }
.kd-python .x.off { visibility: hidden; }
.kd-python .x.cur { box-shadow: 2px 0 0 var(--kp-accent); }
.kd-python .k { color: var(--kp-kw); }
.kd-python .s { color: var(--kp-str); }
.kd-python .n { color: var(--kp-num); }
.kd-python .d { color: var(--kp-dec); }
.kd-python .m { color: var(--kp-com); }
/* the safety gate: each lab.set marked, its line flagged in the gutter */
.kd-python-gate { position: relative; }
.kd-python-gate::before {
  content: ""; position: absolute; z-index: -1; left: -0.22em; right: -0.22em; top: 0.08em; bottom: 0.02em;
  border-radius: 0.3em; background: rgba(90, 162, 230, 0.2);
  opacity: 0; transition: opacity 0.5s var(--kp-ease);
}
.kd-python-ln.gate .kd-python-gate::before { opacity: 1; }
.kd-python-ln.gate .kd-python-no { color: var(--kp-accent); }
.kd-python-ln::after {
  content: ""; position: absolute; left: -0.75em; top: 0.45em; bottom: 0.45em; width: 2px; border-radius: 2px;
  background: var(--kp-accent); opacity: 0; transform: scaleY(0.3);
  transition: opacity 0.4s var(--kp-ease), transform 0.4s var(--kp-ease);
}
.kd-python-ln.gate::after { opacity: 1; transform: none; }
.kd-python-note { display: flex; align-items: center; gap: 0.6em; color: var(--kp-text-2); }
.kd-python-note .kd-python-ico { width: 1.25em; height: 1.25em; color: var(--kp-accent); stroke-width: 1.7; }
.kd-python-note code { color: var(--kp-text); }

/* 3. Your rack */

/* five empty slots once NI MAX is read; each instrument arrives in its own */
.kd-python-insts { display: grid; gap: 0.32em; margin-bottom: 1.3em; }
.kd-python-inst {
  display: grid; grid-template-columns: 0.55em minmax(0, 1fr) auto; align-items: center; column-gap: 0.7em; row-gap: 0.08em;
  padding: 0.45em 0.75em 0.5em; border: 1px solid rgba(255, 255, 255, 0.07); border-radius: 0.6em; background: rgba(255, 255, 255, 0);
  opacity: 0;
  transition: opacity 0.6s var(--kp-ease), background-color 0.45s var(--kp-ease), border-color 0.45s var(--kp-ease);
}
.kd-python-insts.found .kd-python-inst { opacity: 1; }
.kd-python-inst > * { opacity: 0; transform: translateY(0.4em); transition: opacity 0.45s var(--kp-ease), transform 0.45s var(--kp-ease); }
.kd-python-inst.on { background-color: rgba(255, 255, 255, 0.02); border-color: var(--kp-line); }
.kd-python-inst.on > * { opacity: 1; transform: none; }
.kd-python-dot { width: 0.55em; height: 0.55em; border-radius: 50%; background: var(--kp-ok); }
.kd-python-inst.on .kd-python-dot { animation: kd-python-ping 1.1s ease-out 0.15s both; }
@keyframes kd-python-ping {
  from { box-shadow: 0 0 0 0 rgba(70, 196, 138, 0.45); }
  to { box-shadow: 0 0 0 0.55em rgba(70, 196, 138, 0); }
}
.kd-python-iname { font: 500 max(11px, 0.97em) / 1.35 var(--kp-mono); color: var(--kp-text); } /* the page loads Geist Mono 400 and 500 only */
.kd-python-ival { font: 400 max(11px, 0.97em) / 1.35 var(--kp-mono); font-variant-numeric: tabular-nums; color: var(--kp-text); text-align: right; white-space: nowrap; }
.kd-python-imeta {
  grid-column: 2 / -1; font-size: max(11px, 0.86em); line-height: 1.35; color: var(--kp-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kd-python-watch { display: flex; align-items: center; gap: 0.75em; color: var(--kp-text); }
.kd-python-wlabel { color: var(--kp-dim); }
.kd-python-tick { margin-left: auto; width: 1.3em; height: 1.3em; color: var(--kp-ok); stroke-width: 2.4; }
.kd-python-tick path { stroke-dasharray: 21; stroke-dashoffset: 21; transition: stroke-dashoffset 0.55s 0.3s var(--kp-ease); }
.kd-python-watch.on .kd-python-tick path { stroke-dashoffset: 0; }

/* ---------- wide: three columns that light up in turn ---------- */

@container (min-width: 940px) {
  .kd-python-col + .kd-python-col { border-left: 1px solid var(--kp-line); }
  .kd-python-col { opacity: 0.5; }
  .kd-python-col.on,
  .kd-python.all .kd-python-col { opacity: 1; }
}

/* ---------- narrow: one step at a time ---------- */

@container (max-width: 939.98px) {
  .kd-python-panel { aspect-ratio: auto; font-size: clamp(11px, 3.3cqw, 13.5px); }
  .kd-python-steps { display: flex; justify-content: center; padding: 0 1em; }
  .kd-python-stepcell { padding: 1em 0 0.95em; }
  .kd-python-step { font-size: 1.15em; }
  .kd-python-arrow { position: static; transform: none; margin: 0 0.8em; }
  .kd-python-cols { grid-template-columns: minmax(0, 1fr); }
  /* the step leaving fades first, the next comes in after it, so their text never overlaps */
  .kd-python-col {
    grid-area: 1 / 1; justify-self: center; width: 100%; max-width: 38em;
    padding: 1.15em 1.1em 1.25em;
    opacity: 0; transform: translateY(0.6em);
    transition: opacity 0.28s var(--kp-ease), transform 0.28s var(--kp-ease);
  }
  .kd-python-col.done { transform: translateY(-0.6em); }
  .kd-python-col.on {
    opacity: 1; transform: none;
    transition: opacity 0.5s var(--kp-ease) 0.2s, transform 0.5s var(--kp-ease) 0.2s;
  }
  /* the code wraps as an editor's soft wrap does: no line numbers, a hanging indent */
  .kd-python-no { display: none; }
  .kd-python-ln { grid-template-columns: minmax(0, 1fr); white-space: pre-wrap; }
  .kd-python-tx { padding-left: calc((var(--i, 0) + 2) * 1ch); text-indent: -2ch; }
}
@container (max-width: 360px) {
  .kd-python-steps { padding: 0 0.6em; }
  .kd-python-arrow { margin: 0 0.5em; }
  .kd-python-col { padding-inline: 0.9em; }
}

@media (prefers-reduced-motion: reduce) {
  .kd-python *, .kd-python *::before, .kd-python *::after { animation: none !important; transition: none !important; }
  /* nothing moves, so a narrow panel shows the three steps one under another */
  @container (max-width: 939.98px) {
    .kd-python-steps { display: none; }
    .kd-python-col { grid-area: auto; max-width: none; opacity: 1; transform: none; }
    .kd-python-col + .kd-python-col { border-top: 1px solid var(--kp-line); }
    .kd-python-ptitle { display: block; }
  }
}
