/* Busy feedback: the top progress bar for HTMX swaps, and the overlay for full
   page navigations. Both are chrome that must sit above everything, so this
   loads last in base.html and its z-indexes are above the highest in the app
   (1200, analysis.css).

   Two separate mechanisms because the two cases are genuinely different. An
   HTMX swap replaces part of a page that stays usable, so the feedback is a
   bar plus dimming the region being replaced. A full navigation throws the
   document away and the browser keeps painting the old one until the server
   answers — there is nothing to dim and nothing to keep using, so it gets a
   blocking overlay instead. */

/* ── HTMX progress bar ─────────────────────────────────────────────────────── */

#ags-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 2010;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s ease;
}

#ags-progress.is-on { opacity: 1; }

/* Indeterminate, because the duration is genuinely unknown — a fake progress
   percentage that stalls at 90% is worse than an honest one that keeps moving. */
#ags-progress::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 35%;
  background: linear-gradient(90deg, rgba(45,108,223,0), #2d6cdf, rgba(45,108,223,0));
  animation: ags-progress-slide 1.05s ease-in-out infinite;
}

@keyframes ags-progress-slide {
  from { transform: translateX(-100%); }
  to   { transform: translateX(340%); }
}

/* The region being replaced. pointer-events is the important half: it stops a
   second click landing on stale content that is about to be swapped out, which
   is how a slow recompute turns into two slow recomputes. */
.ags-busy {
  opacity: .45;
  pointer-events: none;
  transition: opacity .12s ease;
}

/* ── Full-navigation overlay ───────────────────────────────────────────────── */

#ags-nav-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: none;
  place-items: center;
  background: rgba(247, 249, 252, .78);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

#ags-nav-overlay.is-on { display: grid; }

.ags-nav-box {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 22px 30px;
  min-width: 220px;
  max-width: min(420px, 80vw);
  background: #fff;
  border: 1px solid #d5dbe3;
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(10, 22, 40, .14);
  text-align: center;
}

.ags-nav-spinner {
  width: 26px;
  height: 26px;
  border: 3px solid #e6eaf0;
  border-top-color: #2d6cdf;
  border-radius: 50%;
  animation: ags-spin .7s linear infinite;
}

@keyframes ags-spin {
  to { transform: rotate(360deg); }
}

.ags-nav-label {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: #0a1628;
  /* An address can be long and there is no room to wrap indefinitely. */
  overflow-wrap: anywhere;
}

.ags-nav-label strong { font-weight: 600; }

.ags-nav-sub {
  margin: 0;
  font-size: 11px;
  color: #6b7686;
}

/* ── Reduced motion ────────────────────────────────────────────────────────── */

/* Both indicators stay visible — they are the whole point — but stop moving.
   The bar becomes a static full-width rule rather than a travelling one. */
@media (prefers-reduced-motion: reduce) {
  #ags-progress::before {
    animation: none;
    width: 100%;
    background: #2d6cdf;
    opacity: .8;
  }
  .ags-nav-spinner {
    animation: none;
    border-top-color: #2d6cdf;
    border-right-color: #2d6cdf;
  }
  .ags-busy,
  #ags-progress { transition: none; }
}
