routing-line {
  display: block;
}

.routing-line {
  --route-line: var(--border);
  --route-active: var(--amber);
  --route-node-size: 12px;
  color: var(--text);
}

.routing-line__sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.routing-line__track {
  position: relative;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  align-items: center;
  gap: 0;
}

.routing-line__track::before,
.routing-line__progress {
  content: "";
  position: absolute;
  left: calc(var(--route-node-size) / 2);
  right: calc(var(--route-node-size) / 2);
  top: 50%;
  height: 1px;
  transform: translateY(-50%);
  background: var(--route-line);
}

.routing-line__progress {
  right: auto;
  width: var(--route-progress, 0%);
  background: linear-gradient(90deg, var(--amber), var(--signal));
  box-shadow: 0 0 18px rgba(244, 169, 60, 0.28);
  transition: width 900ms cubic-bezier(0.2, 0.8, 0.2, 1), height 900ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.routing-line__node {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  gap: 10px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: none;
  border: 0;
  padding: 0;
  cursor: default;
}

.routing-line__dot {
  width: var(--route-node-size);
  height: var(--route-node-size);
  border-radius: 999px;
  background: var(--ink);
  border: 1px solid var(--route-line);
  box-shadow: 0 0 0 5px var(--ink);
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.routing-line__node.is-active,
.routing-line__node.is-complete {
  color: var(--text);
}

.routing-line__node.is-active .routing-line__dot,
.routing-line__node.is-complete .routing-line__dot {
  background: var(--route-active);
  border-color: var(--route-active);
  box-shadow: 0 0 0 5px var(--ink), 0 0 22px rgba(244, 169, 60, 0.44);
  transform: scale(1.06);
}

.routing-line__node:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 8px;
  border-radius: 4px;
}

.routing-line--full {
  max-width: 980px;
  margin: 0 auto;
  padding: 18px 0 4px;
}

.routing-line--full .routing-line__track {
  min-height: 76px;
}

.routing-line--rail {
  position: sticky;
  top: 92px;
}

.routing-line--rail .routing-line__track {
  grid-template-columns: 1fr;
  grid-template-rows: repeat(6, 72px);
  align-items: start;
}

.routing-line--rail .routing-line__track::before,
.routing-line--rail .routing-line__progress {
  left: 6px;
  right: auto;
  top: 6px;
  bottom: 6px;
  width: 1px;
  height: auto;
  transform: none;
}

.routing-line--rail .routing-line__progress {
  height: var(--route-progress, 0%);
}

.routing-line--rail .routing-line__node {
  grid-template-columns: 12px 1fr;
  justify-items: start;
  align-items: center;
  gap: 14px;
  text-align: left;
}

.routing-line--rail .routing-line__dot {
  box-shadow: 0 0 0 5px var(--ink);
}

.routing-line--ambient {
  position: absolute;
  inset: auto 10vw 18vh;
  opacity: 0.36;
  pointer-events: none;
}

.routing-line--ambient .routing-line__track {
  min-height: 46px;
}

.routing-line--ambient .routing-line__label {
  display: none;
}

.routing-line--ambient .routing-line__dot {
  width: 7px;
  height: 7px;
  box-shadow: 0 0 0 6px var(--ink);
}

.routing-line--ambient .routing-line__progress {
  width: 100%;
  animation: ambient-route 5.5s ease-in-out infinite;
}

@keyframes route-draw {
  from { width: 0; }
  to { width: var(--route-progress, 100%); }
}

@keyframes ambient-route {
  0%, 100% { opacity: 0.24; box-shadow: 0 0 8px rgba(244, 169, 60, 0.14); }
  50% { opacity: 0.82; box-shadow: 0 0 28px rgba(91, 200, 190, 0.22); }
}

@media (max-width: 720px) {
  .routing-line--full .routing-line__track {
    grid-template-columns: 1fr;
    grid-template-rows: repeat(6, 54px);
    align-items: start;
    width: min(260px, 100%);
    margin: 0 auto;
  }

  .routing-line--full .routing-line__track::before,
  .routing-line--full .routing-line__progress {
    left: 6px;
    right: auto;
    top: 6px;
    bottom: 6px;
    width: 1px;
    height: auto;
    transform: none;
  }

  .routing-line--full .routing-line__progress {
    height: var(--route-progress, 0%);
  }

  .routing-line--full .routing-line__node {
    grid-template-columns: 12px 1fr;
    justify-items: start;
    align-items: center;
    gap: 12px;
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  .routing-line__progress,
  .routing-line__dot,
  .routing-line--ambient .routing-line__progress {
    animation: none;
    transition: none;
  }
}
