/* Path: assets/css/back-to-top.css
   Purpose: Safe-area aware, token-aligned back-to-top button */

#back-to-top {
  position: fixed;
  right: var(--space-6, 24px);
  bottom: calc(var(--space-6, 24px) + env(safe-area-inset-bottom, 0px));
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full, 9999px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  padding: 0;
  cursor: pointer;

  background: var(--color-brand-primary, #009688);
  border: none;
  box-shadow: none;

  transform-origin: center;

  will-change: transform, opacity;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  contain: layout style;

  transition:
    opacity 250ms cubic-bezier(0.4, 0, 0.2, 1),
    transform 250ms cubic-bezier(0.4, 0, 0.2, 1),
    background-color 150ms ease,
    visibility 0s linear 250ms;

  z-index: var(--fv-z-popover, 300);
  user-select: none;
}

#back-to-top:hover {
  background: var(--color-brand-hover, #00897b);
}

#back-to-top svg {
  display: block;
  pointer-events: none;
  width: 20px;
  height: 20px;
  transition: transform 150ms ease;
  color: #ffffff;
}

#back-to-top.btt-shown {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1.0);
  transition-delay: 0s;
}

#back-to-top.btt-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px) scale(0.85);
}

#back-to-top:active {
  transform: translateY(0) scale(0.92);
  transition: transform 120ms ease;
}

#back-to-top:active svg {
  transform: scale(0.95);
}

@media (max-width: 767px) {
  #back-to-top {
    right: var(--space-4, 16px);
    bottom: calc(var(--fv-nav-bottom-h, 64px) + var(--space-4, 16px) + env(safe-area-inset-bottom, 0px));
    width: 48px;
    height: 48px;
  }
  #back-to-top.btt-shown  { transform: translateY(0) scale(1.0); }
  #back-to-top.btt-hidden { transform: translateY(12px) scale(0.85); }
  #back-to-top:active     { transform: translateY(0) scale(0.92); }
}

#back-to-top:focus-visible {
  outline: 2px solid var(--color-brand-primary, #009688);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  #back-to-top, #back-to-top svg {
    transition: none;
  }
}
