/* Floating quick nav (#scrollRouteNav): one clean pass that sits last and overrides the older layers.
   Motion uses transform and opacity only, enters with a short ease-out, leaves faster than it enters,
   and falls back to a plain fade when the visitor asks for reduced motion. */

html body .scroll-route-nav,
body.app-mode .scroll-route-nav {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  bottom: auto;
  z-index: 90;
  display: flex !important;
  align-items: center;
  gap: 2px;
  width: max-content;
  max-width: calc(100vw - 24px);
  min-height: 0;
  height: auto;
  margin: 0;
  padding: 5px;
  box-sizing: border-box;
  border: 1px solid var(--sc-border) !important;
  border-radius: 999px !important;
  background: var(--sc-surface) !important;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow: 0 10px 28px rgb(0 0 0 / 0.16) !important;
  transform: translate(-50%, -10px) scale(0.985) !important;
  opacity: 0 !important;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 160ms ease-in,
    transform 160ms ease-in,
    visibility 0s linear 160ms !important;
}

html body .scroll-route-nav.is-visible,
body.app-mode .scroll-route-nav.is-visible {
  transform: translate(-50%, 0) scale(1) !important;
  opacity: 1 !important;
  visibility: visible;
  pointer-events: auto;
  transition:
    opacity 260ms cubic-bezier(0.22, 1, 0.36, 1),
    transform 320ms cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0s !important;
}

html body .scroll-route-nav[hidden],
body.app-mode .scroll-route-nav[hidden] {
  display: none !important;
}

/* Links and the wallet button: one height, no wrapping, no shrinking. */
html body .scroll-route-nav a,
html body .scroll-route-nav .scroll-wallet-button,
body.app-mode .scroll-route-nav a,
body.app-mode .scroll-route-nav .scroll-wallet-button {
  flex: none !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: auto !important;
  height: 38px;
  min-height: 38px;
  min-width: 0 !important;
  max-width: none !important;
  margin: 0;
  padding: 0 12px !important;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--sc-muted);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  opacity: 0;
  transform: translateY(6px);
  transition:
    background-color 160ms ease,
    color 160ms ease,
    opacity 200ms ease,
    transform 280ms cubic-bezier(0.22, 1, 0.36, 1);
}

html body .scroll-route-nav.is-visible a,
html body .scroll-route-nav.is-visible .scroll-wallet-button,
body.app-mode .scroll-route-nav.is-visible a,
body.app-mode .scroll-route-nav.is-visible .scroll-wallet-button {
  opacity: 1;
  transform: none;
}

/* Stagger the entrance, top to bottom, 30ms apart. */
html body .scroll-route-nav.is-visible > :nth-child(1) { transition-delay: 0ms; }
html body .scroll-route-nav.is-visible > :nth-child(2) { transition-delay: 30ms; }
html body .scroll-route-nav.is-visible > :nth-child(3) { transition-delay: 60ms; }
html body .scroll-route-nav.is-visible > :nth-child(4) { transition-delay: 90ms; }
html body .scroll-route-nav.is-visible > :nth-child(5) { transition-delay: 120ms; }
html body .scroll-route-nav.is-visible > :nth-child(6) { transition-delay: 150ms; }

html body .scroll-route-nav .scroll-route-brand {
  width: 38px;
  padding: 0;
}

html body .scroll-route-nav .scroll-route-brand img {
  display: block;
  width: 25px;
  height: 25px;
  object-fit: contain;
}

html body .scroll-route-nav a svg {
  flex: none;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

html body .scroll-route-nav a:hover,
html body .scroll-route-nav .scroll-wallet-button:hover {
  color: var(--sc-text);
  background: var(--sc-raised);
}

html body .scroll-route-nav a[aria-current="page"] {
  color: var(--sc-text);
  background: var(--sc-raised);
}

html body .scroll-route-nav .scroll-wallet-label {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Narrow screens: keep the icons and the wallet, drop the text of the secondary links. */
@media (max-width: 720px) {
  html body .scroll-route-nav a span {
    display: none;
  }
  html body .scroll-route-nav a {
    width: 38px !important;
    padding: 0 !important;
  }
  html body .scroll-route-nav .scroll-wallet-label {
    max-width: 110px;
  }
}

/* Reduced motion: a short fade only, no travel, no stagger. */
@media (prefers-reduced-motion: reduce) {
  html body .scroll-route-nav,
  html body .scroll-route-nav a,
  html body .scroll-route-nav .scroll-wallet-button {
    transform: none !important;
    transition: opacity 120ms linear, visibility 0s linear 120ms !important;
    transition-delay: 0s !important;
  }
  html body .scroll-route-nav.is-visible,
  html body .scroll-route-nav.is-visible a,
  html body .scroll-route-nav.is-visible .scroll-wallet-button {
    transition: opacity 120ms linear, visibility 0s !important;
    transition-delay: 0s !important;
  }
}
