/* ══════════════════════════════════════════════════════════════
   Back-to-top floating button — bottom-LEFT (alert notifier owns
   bottom-right). Hidden until the user scrolls past ~1 viewport.
   ══════════════════════════════════════════════════════════════ */
.mvsd-back-to-top {
  position: fixed;
  /* env() keeps the button clear of the iOS home-indicator on notched devices. */
  bottom: calc(var(--space-5, 1.25rem) + env(safe-area-inset-bottom));
  left: calc(var(--space-5, 1.25rem) + env(safe-area-inset-left));
  /* Above page content but below modals/dialogs (Drupal off-canvas ~1260,
     alert notifier 9000). Was 9000 originally — that competed with overlays. */
  z-index: 100;

  /* Tap target: 48px circular button (above the 44px WCAG minimum). */
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 0;
  padding: 0;

  background: var(--color-primary, #01491f);
  color: #fff;
  cursor: pointer;
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.25),
    0 1px 3px rgba(0, 0, 0, 0.15);

  display: flex;
  align-items: center;
  justify-content: center;

  /* Hidden by default — shown via .is-visible */
  opacity: 0;
  transform: translateY(0.5rem);
  pointer-events: none;
  transition: opacity 200ms ease, transform 200ms ease, background 150ms ease;
}

.mvsd-back-to-top.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.mvsd-back-to-top:hover {
  background: var(--color-primary-mid, #0b8545);
}

.mvsd-back-to-top:focus-visible {
  outline: 3px solid var(--color-accent, #f5a623);
  outline-offset: 2px;
}

.mvsd-back-to-top svg {
  width: 22px;
  height: 22px;
  display: block;
}

/* Shrink slightly on very narrow viewports so it doesn't crowd content. */
@media (max-width: 480px) {
  .mvsd-back-to-top {
    bottom: calc(0.85rem + env(safe-area-inset-bottom));
    left: calc(0.85rem + env(safe-area-inset-left));
    width: 44px;
    height: 44px;
  }
  .mvsd-back-to-top svg {
    width: 20px;
    height: 20px;
  }
}

/* Respect reduced-motion preference — kill the show/hide transition. */
@media (prefers-reduced-motion: reduce) {
  .mvsd-back-to-top {
    transition: opacity 0s, transform 0s;
    transform: none;
  }
}

/* Print: hide. */
@media print {
  .mvsd-back-to-top { display: none !important; }
}

/* Windows high-contrast mode — keep the button visually present. The default
   button rendering loses its background/box-shadow under forced colors, so
   the chevron would float on the page background. */
@media (forced-colors: active) {
  .mvsd-back-to-top {
    border: 2px solid ButtonText;
    background: ButtonFace;
    color: ButtonText;
    box-shadow: none;
  }
  .mvsd-back-to-top:hover,
  .mvsd-back-to-top:focus-visible {
    border-color: Highlight;
    color: Highlight;
  }
}
