/*
 * Agent build chrome (js/motion/agents.js): the cursor swarm, sparkles, rulers, the
 * opening veil, the build progress line and the status pill. Only present while motion
 * is on; everything except the pill buttons is decorative (aria-hidden, no pointer events).
 */

/* Cursors and sparkles live in document coordinates over the page, clipped to its width. */
.ab-stage {
  position: absolute;
  inset: 0;
  z-index: 30;
  overflow: clip;
  pointer-events: none;
}

.ab-cursor {
  position: absolute;
  inset-block-start: 0;
  inset-inline-start: 0;
  margin: -1px 0 0 -1px;
  will-change: transform, opacity;
}

.ab-cursor svg {
  display: block;
  fill: var(--c);
  stroke: #fff;
  stroke-width: 1.2;
  stroke-linejoin: round;
  filter: drop-shadow(0 1px 2px rgb(0 0 0 / 0.55));
}

.ab-cursor__tag {
  position: absolute;
  inset-block-start: 17px;
  inset-inline-start: 11px;
  padding: 1px 5px 2px;
  border-radius: 3px 8px 8px 8px;
  background: var(--c);
  color: var(--accent-on);
  font: 700 10px/13px ui-monospace, 'Cascadia Mono', Consolas, monospace;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.ab-spark {
  position: absolute;
  inset-block-start: -6px;
  inset-inline-start: -6px;
  inline-size: 12px;
  block-size: 12px;
  background:
    linear-gradient(#fff, #fff) center / 2px 100% no-repeat,
    linear-gradient(#fff, #fff) center / 100% 2px no-repeat;
  filter: drop-shadow(0 0 4px rgb(140 200 255 / 0.9));
}

.ab-spark--big {
  inset-block-start: -9px;
  inset-inline-start: -9px;
  inline-size: 18px;
  block-size: 18px;
}

html[data-motion-tier='lite'] .ab-spark,
html[data-motion-tier='lite'] .ab-cursor svg {
  filter: none;
}

/* Opening: the empty dark screen the swarm arrives on. */
.ab-veil {
  position: fixed;
  inset: 0;
  z-index: 29;
  background: var(--bg);
  pointer-events: none;
}

/* Fixed editor chrome: rulers and the thin blue build line. */
.ab-chrome {
  position: fixed;
  inset: 0;
  z-index: 31;
  pointer-events: none;
}

.ab-buildline {
  position: absolute;
  inset-block-start: 3px;
  inset-inline: 0;
  block-size: 2px;
  background: #2f9bff;
  box-shadow: 0 0 8px rgb(47 155 255 / 0.8);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.25s ease-out;
}

.ab-ruler {
  position: absolute;
  background-color: rgb(14 17 23 / 0.88);
  color: rgb(160 186 220 / 0.75);
  font: 500 8px/1 ui-monospace, 'Cascadia Mono', Consolas, monospace;
}

.ab-ruler--top {
  inset-block-start: 5px;
  inset-inline: 0;
  block-size: 14px;
  border-block-end: 1px solid rgb(47 155 255 / 0.4);
  background-image:
    repeating-linear-gradient(to right, rgb(160 186 220 / 0.55) 0 1px, transparent 1px 100px),
    repeating-linear-gradient(to right, rgb(160 186 220 / 0.3) 0 1px, transparent 1px 10px);
  background-size: 100% 100%, 100% 4px;
  background-position: 0 0, 0 100%;
  background-repeat: no-repeat;
}

.ab-ruler--left {
  inset-block: 19px 0;
  inset-inline-start: 0;
  inline-size: 14px;
  border-inline-end: 1px solid rgb(47 155 255 / 0.4);
  background-image:
    repeating-linear-gradient(to bottom, rgb(160 186 220 / 0.55) 0 1px, transparent 1px 100px),
    repeating-linear-gradient(to bottom, rgb(160 186 220 / 0.3) 0 1px, transparent 1px 10px);
  background-size: 100% 100%, 4px 100%;
  background-position: 0 0, 100% 0;
  background-repeat: no-repeat;
}

.ab-ruler__n {
  position: absolute;
  inset-block-start: 2px;
}

.ab-ruler--left .ab-ruler__n {
  inset-block-start: auto;
  inset-inline-start: 2px;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}

/* ---------- Status pill ---------- */
.ab-pill {
  position: fixed;
  z-index: 96;
  inset-inline: 0;
  inset-block-end: 16px;
  margin-inline: auto;
  inline-size: max-content;
  max-inline-size: calc(100vw - 2rem);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 3px 3px 12px;
  border-radius: 999px;
  border: 1px solid rgb(255 255 255 / 0.1);
  background: rgb(20 22 28 / 0.94);
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.5);
  color: #e9edf4;
  font: 600 12px/1.2 var(--font-body);
  white-space: nowrap;
}

.ab-pill__dots {
  display: flex;
}

.ab-pill__dots i {
  inline-size: 14px;
  block-size: 14px;
  border-radius: 50%;
  background: var(--c);
  border: 2px solid rgb(20 22 28);
  margin-inline-start: -5px;
}

.ab-pill__dots i:first-child {
  margin-inline-start: 0;
}

.ab-pill__status > span {
  display: none;
}

.ab-pill[data-state='scanning'] .ab-pill__scan,
.ab-pill[data-state='building'] .ab-pill__count,
.ab-pill[data-state='complete'] .ab-pill__complete {
  display: inline;
}

.ab-pill__scan {
  color: #b9c6d8;
}

.ab-pill__count b {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.ab-pill__sep {
  display: inline-block;
  inline-size: 1px;
  block-size: 12px;
  margin-inline: 8px;
  vertical-align: -2px;
  background: rgb(255 255 255 / 0.2);
}

.ab-pill__complete {
  color: var(--accent);
}

.ab-pill__bar {
  inline-size: 56px;
  block-size: 3px;
  border-radius: 2px;
  background: rgb(255 255 255 / 0.12);
  overflow: hidden;
}

.ab-pill__bar > span {
  display: block;
  block-size: 100%;
  background: #2f9bff;
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.25s ease-out;
}

.ab-pill[data-state='complete'] .ab-pill__bar > span {
  background: var(--accent);
}

.ab-pill__btn {
  min-inline-size: 44px;
  min-block-size: 44px;
  padding-inline: 10px;
  border: 0;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.06);
  color: #e9edf4;
  font: 600 12px/1 var(--font-body);
  cursor: pointer;
}

.ab-pill__btn:hover {
  background: rgb(255 255 255 / 0.14);
}

.ab-pill__btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.ab-pill__tour[aria-pressed='true'] {
  background: rgb(47 155 255 / 0.22);
  color: #8cc8ff;
  box-shadow: inset 0 0 0 1px rgb(47 155 255 / 0.6);
}

.ab-pill__close svg {
  display: block;
  margin: auto;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
}

.ab-pill[data-state='scanning'] .ab-pill__speed {
  visibility: hidden;
}

.ab-pill[data-state='complete'] {
  padding-block: 14px;
  padding-inline-end: 16px;
}

.ab-pill[data-state='complete'] .ab-pill__btn {
  display: none;
}

@media (max-width: 767px) {
  .ab-pill {
    gap: 4px;
    padding-inline-start: 10px;
  }

  .ab-pill__bar {
    inline-size: 28px;
  }

  .ab-pill__dots i:nth-child(n + 3) {
    display: none;
  }
}

@media (max-width: 359px) {
  .ab-pill__bar,
  .ab-pill__agents-wrap {
    display: none;
  }

  .ab-pill__btn {
    padding-inline: 6px;
  }
}
