.p-scan .rs-reads__animation {
  --bt-accent: var(--action);
  --bt-sig: var(--datum-active);
  --bt-sig-2: var(--datum);
  --bt-sig-3: var(--datum-idle);
  container-type: inline-size;
  min-width: 0;
  display: grid;
  justify-items: center;
}

/* Keep the rail glow inside the illustration so narrow screens never scroll sideways. */
.p-scan .bt-viz {
  width: 100%;
  display: grid;
  justify-items: center;
  overflow: clip;
  overflow-clip-margin: 12px;
}


/* Stage — fixed-pixel drawing so the motion paths stay exact */

.bt-stage {
  position: relative;
  width: 560px;
  height: 330px;
  isolation: isolate;
}
.bt-svg {
  position: absolute;
  left: 0;
  top: 0;
  overflow: visible;
}
.bt-rails {
  z-index: 0;
}
.bt-glow {
  z-index: 2;
  stroke: var(--bt-sig);
  filter: drop-shadow(
      0 0 2px color-mix(in srgb, var(--bt-sig-2) 90%, transparent)
    )
    drop-shadow(0 0 8px color-mix(in srgb, var(--bt-sig-2) 55%, transparent));
}
.bt-svg--narrow {
  display: none;
}
.bt-lit {
  stroke-dasharray: 100 100;
  stroke-dashoffset: 0;
}

/* Nodes */
.bt-node {
  position: absolute;
}
.bt-node--jt {
  left: 38px;
  top: 140px;
  width: 84px;
  height: 84px;
}
.bt-node--bt {
  left: 394px;
  top: 36px;
  width: 92px;
  height: 92px;
}
.bt-face {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  border-radius: 10px;
}
.bt-face::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 16px;
  border: 1px solid #2e353c;
  pointer-events: none;
}
.bt-node--jt .bt-face {
  background: #ff5600;
  color: #ffffff;
}
.bt-jt {
  display: block;
  width: 53px;
  height: 53px;
}
.bt-ack {
  position: absolute;
  inset: -6px;
  border-radius: 16px;
  border: 1px solid var(--bt-sig);
  box-shadow: 0 0 12px 1px color-mix(in srgb, var(--bt-sig-2) 60%, transparent);
  opacity: 0;
  pointer-events: none;
}
.bt-node--bt .bt-face::after {
  border-color: color-mix(in srgb, var(--bt-sig) 40%, transparent);
}
.bt-icon {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 10px;
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
}
.bt-halo,
.bt-flash {
  position: absolute;
  z-index: 1;
  border-radius: 50%;
  pointer-events: none;
}
.bt-halo {
  inset: -56px;
  background: radial-gradient(
    closest-side,
    color-mix(in srgb, var(--bt-sig-2) 36%, transparent),
    color-mix(in srgb, var(--bt-sig-2) 12%, transparent) 55%,
    transparent
  );
}
.bt-flash {
  inset: -26px;
  opacity: 0;
  background: radial-gradient(
    closest-side,
    color-mix(in srgb, var(--bt-sig) 60%, transparent),
    transparent
  );
}

/* Chips — the glowing square rides the rail (offset-anchor). The box + label dissolve before
   they could touch a tile; the light keeps going in, so no letter is ever clipped by an app. */
.bt-chip {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 9px 0 8px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.01em;
  color: var(--text-1);
  white-space: nowrap;
  offset-rotate: 0deg;
  offset-anchor: 11px 50%;
  offset-distance: var(--s);
  animation: bt-run 10s linear var(--d) infinite both;
}
.bt-chip::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border: 1px solid #3c444c;
  border-radius: 4px;
  background: var(--graphite);
  box-shadow: inset 0 1px 0 #2a3136;
  animation: bt-box 10s linear var(--d) infinite both;
}
.bt-chip::before {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 1px;
  background: var(--bt-sig);
  box-shadow:
    0 0 6px 1px color-mix(in srgb, var(--bt-sig-2) 85%, transparent),
    0 0 16px 3px color-mix(in srgb, var(--bt-sig-2) 40%, transparent);
}
.bt-chip--in {
  offset-path: path("M122 166 H168 Q180 166 180 154 V78 Q180 66 192 66 H394");
}
.bt-chip--out {
  flex-direction: row-reverse;
  padding: 0 8px 0 9px;
  offset-anchor: calc(100% - 11px) 50%;
  offset-path: path("M394 98 H296 Q284 98 284 110 V186 Q284 198 272 198 H122");
}

/* Estimating Playbook */
.bt-pb {
  position: absolute;
  z-index: 4;
  left: 340px;
  top: 152px;
  width: 208px;
  padding: 11px 14px 12px;
  border-radius: 10px;
  background: var(--graphite);
  box-shadow:
    inset 0 1px 0 #2e353c,
    0 0 0 1px #2e353c;
}
.bt-pb__ring {
  position: absolute;
  inset: 0;
  border-radius: 10px;
  box-shadow:
    0 0 0 1px var(--bt-accent),
    0 0 20px -6px var(--bt-accent);
  opacity: 0;
  pointer-events: none;
}
.bt-pb__head {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 16px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--text-1);
}
.bt-pb__head svg {
  flex: none;
  color: var(--text-3);
}
.bt-pb__rows {
  list-style: none;
  margin: 10px -14px 0;
  padding: 8px 14px 0;
  border-top: 1px solid #2e353c;
}
.bt-pb__row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 18px;
  font-size: 12px;
  font-weight: 500;
}
.bt-pb__tick {
  flex: none;
  display: grid;
  place-items: center;
  width: 12px;
  height: 12px;
  border: 1px solid var(--bt-sig-3);
  border-radius: 3px;
  color: var(--bt-sig-2);
}
.bt-pb__tick svg {
  display: block;
}
.bt-pb__label {
  color: var(--text-2);
}
.bt-pb__skel {
  position: absolute;
  left: 20px;
  top: 6px;
  width: var(--w);
  height: 6px;
  border-radius: 2px;
  background: #262c30;
  opacity: 0;
}
.bt-pb__status {
  margin: 8px -14px 0;
  padding: 9px 14px 0;
  border-top: 1px solid #2e353c;
}
.bt-pb__line {
  position: relative;
  height: 16px;
}
.bt-pb__line .bt-pb__skel {
  left: 0;
  top: 5px;
}
.bt-pb__ready {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 16px;
  /* Wide diagram uses the 208px card. 12px overflows that inset; 10.5px stays inside it. */
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-1);
  white-space: nowrap;
}
.bt-pb__dot {
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 1px;
  background: var(--bt-accent);
  box-shadow: 0 0 8px 1px color-mix(in srgb, var(--bt-accent) 70%, transparent);
}

/* 10s loop. Base styles above ARE the final state; these only animate toward it.
   0.3–5.25s four chips in (the in-lane lights up) · 5.55s ready · 5.65–9.95s three chips out.
   The playbook writes in once; after that each arrival re-lights its checkbox. */
.bt-flash {
  animation: bt-absorb 10s ease-out 2.7s infinite;
}
.bt-halo {
  animation: bt-halo 0.9s var(--ease-out) 5.55s both;
}
.bt-ack {
  animation: bt-ack 10s ease-out 8.05s infinite;
}
.bt-lit--in {
  animation: bt-lit-in 10s linear 0.3s infinite both;
}
.bt-lit--out {
  animation: bt-lit-out 10s linear 5.65s infinite both;
}
.bt-pb__tick {
  animation:
    bt-in 0.4s var(--ease-out) var(--t) both,
    bt-tick 10s ease-out var(--t) infinite;
}
.bt-pb__label {
  animation:
    bt-in 0.45s var(--ease-out) var(--t) both,
    bt-lbl 10s ease-out var(--t) infinite;
}
.bt-pb__skel {
  animation: bt-out 0.3s ease-out var(--t) both;
}
.bt-pb__ready {
  animation: bt-in 0.5s var(--ease-out) 5.55s both;
}
.bt-pb__ring {
  animation: bt-ring 1.8s ease-out 5.55s both;
}
@keyframes bt-run {
  0% {
    offset-distance: 0%;
    opacity: 0;
    color: transparent;
  }
  0.8% {
    opacity: 1;
  }
  1.85% {
    color: transparent;
  }
  3.35% {
    color: var(--text-1);
  }
  15.06% {
    color: var(--text-1);
  }
  16.56% {
    color: transparent;
  }
  23.2% {
    opacity: 1;
  }
  24% {
    offset-distance: 100%;
    opacity: 0;
    color: transparent;
  }
  100% {
    offset-distance: 100%;
    opacity: 0;
    color: transparent;
  }
}
@keyframes bt-box {
  0%,
  1.85% {
    opacity: 0;
  }
  3.35%,
  15.06% {
    opacity: 1;
  }
  16.56%,
  100% {
    opacity: 0;
  }
}
@keyframes bt-lit-in {
  0% {
    stroke-dashoffset: 100;
    opacity: 1;
  }
  24% {
    stroke-dashoffset: 0;
  }
  52% {
    opacity: 1;
  }
  58% {
    opacity: 0;
  }
  100% {
    stroke-dashoffset: 0;
    opacity: 0;
  }
}
@keyframes bt-lit-out {
  0% {
    stroke-dashoffset: 100;
    opacity: 1;
  }
  24% {
    stroke-dashoffset: 0;
  }
  45.5% {
    opacity: 1;
  }
  51.5% {
    opacity: 0;
  }
  100% {
    stroke-dashoffset: 0;
    opacity: 0;
  }
}
@keyframes bt-in {
  from {
    opacity: 0;
    transform: translateX(-4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes bt-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}
@keyframes bt-tick {
  0%,
  8% {
    border-color: var(--bt-sig);
    color: var(--bt-sig);
    box-shadow:
      0 0 0 3px color-mix(in srgb, var(--bt-sig-2) 24%, transparent),
      0 0 14px 2px color-mix(in srgb, var(--bt-sig-2) 75%, transparent);
  }
  22%,
  100% {
    border-color: var(--bt-sig-3);
    color: var(--bt-sig-2);
    box-shadow:
      0 0 0 3px transparent,
      0 0 14px 2px transparent;
  }
}
@keyframes bt-lbl {
  0%,
  8% {
    color: var(--text-1);
  }
  22%,
  100% {
    color: var(--text-2);
  }
}
@keyframes bt-halo {
  from {
    opacity: 0.45;
  }
  to {
    opacity: 1;
  }
}
@keyframes bt-ring {
  0% {
    opacity: 0;
  }
  12% {
    opacity: 0.85;
  }
  100% {
    opacity: 0;
  }
}
@keyframes bt-absorb {
  0% {
    opacity: 1;
  }
  4% {
    opacity: 0;
  }
  8.3% {
    opacity: 0;
  }
  8.5% {
    opacity: 1;
  }
  12.5% {
    opacity: 0;
  }
  16.8% {
    opacity: 0;
  }
  17% {
    opacity: 1;
  }
  21% {
    opacity: 0;
  }
  25.3% {
    opacity: 0;
  }
  25.5% {
    opacity: 1;
  }
  29.5% {
    opacity: 0;
  }
  100% {
    opacity: 0;
  }
}
@keyframes bt-ack {
  0% {
    opacity: 1;
  }
  4% {
    opacity: 0;
  }
  9.3% {
    opacity: 0;
  }
  9.5% {
    opacity: 1;
  }
  13.5% {
    opacity: 0;
  }
  18.8% {
    opacity: 0;
  }
  19% {
    opacity: 1;
  }
  23% {
    opacity: 0;
  }
  100% {
    opacity: 0;
  }
}

/* Phone — JobTread left, Biltum right; data goes over the top, comes back underneath */
@container (width < 560px) {
  .bt-stage {
    width: 320px;
    height: 432px;
  }
  .bt-svg--wide {
    display: none;
  }
  .bt-svg--narrow {
    display: block;
  }
  .bt-node--jt {
    left: 24px;
    top: 92px;
    width: 76px;
    height: 76px;
  }
  .bt-node--bt {
    left: 220px;
    top: 92px;
    width: 76px;
    height: 76px;
  }
  .bt-jt {
    width: 48px;
    height: 48px;
  }
  .bt-halo {
    inset: -48px;
  }
  .bt-pb {
    left: 36px;
    top: 264px;
    width: 248px;
  }
  .bt-pb__ready {
    font-size: 12px;
  }
  .bt-chip {
    offset-distance: var(--sm);
  }
  .bt-chip--in {
    offset-path: path("M62 92 V40 Q62 28 74 28 H246 Q258 28 258 40 V92");
  }
  .bt-chip--out {
    offset-path: path("M258 168 V220 Q258 232 246 232 H74 Q62 232 62 220 V168");
  }
}

@container (width < 320px) {
  .bt-stage {
    zoom: 0.8;
  }
}

/* Show the complete diagram until playback can start, including with scripts disabled. */
.rs-reads__animation:not([data-motion]) .bt-stage *,
.rs-reads__animation:not([data-motion]) .bt-stage *::after {
  animation: none !important;
}
.rs-reads__animation[data-motion="paused"] .bt-stage *,
.rs-reads__animation[data-motion="paused"] .bt-stage *::after {
  animation-play-state: paused !important;
}
@media (prefers-reduced-motion: reduce) {
  .rs-reads__animation .bt-stage *,
  .rs-reads__animation .bt-stage *::after {
    animation: none !important;
  }
}
@supports not (offset-path: path("M0 0")) {
  .bt-chip {
    display: none;
  }
}
