html {
  scroll-behavior: smooth;
}

/* Each frame is positioned by navigation.js during explicit anchor navigation. */
html.is-scrolling {
  scroll-behavior: auto !important;
}

.back-to-top {
  position: fixed;
  right: max(24px, env(safe-area-inset-right));
  bottom: max(24px, env(safe-area-inset-bottom));
  z-index: 1000;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: var(--brand-primary);
  color: var(--brand-white);
  box-shadow: 0 6px 18px #08766533;
  transition: transform 0.2s, box-shadow 0.2s;
}

.back-to-top[hidden] {
  display: none;
}

.back-to-top:hover {
  color: var(--brand-white);
  transform: translateY(-3px);
  box-shadow: 0 8px 22px #08766544, inset 0 0 0 2px var(--brand-accent);
}

.back-to-top:focus-visible {
  outline: 3px solid var(--brand-accent);
  outline-offset: 4px;
}

@media (max-width: 700px) {
  .back-to-top {
    right: max(16px, env(safe-area-inset-right));
    bottom: max(16px, env(safe-area-inset-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .back-to-top {
    transition: none;
  }

  .back-to-top:hover {
    transform: none;
  }
}
