/* ==========================================================================
   Back-to-top control. Visibility toggled via .is-visible by scripts/site.js
   on scroll. Note: dark mode keeps the box-shadow that other surfaces drop
   (--back-to-top-shadow is constant across both themes) and uses a distinct
   teal icon color rather than the standard accent green — both preserved
   from the live site rather than normalized, since they're deliberate
   enough to look intentional rather than accidental.
   Requires tokens.css + base.css.
   ========================================================================== */

.back-to-top {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 999;
  width: 52px;
  height: 52px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--surface-bg);
  color: var(--heading-color);
  box-shadow: 0 16px 36px var(--back-to-top-shadow);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  font-weight: 800;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity 180ms ease, transform 180ms ease, visibility 180ms ease,
    background 180ms ease, color 180ms ease;
}

.back-to-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top:hover {
  background: var(--cta-gold);
  color: var(--heading-color);
  transform: translateY(-2px);
}

.back-to-top:focus-visible {
  outline: 3px solid rgba(31, 163, 153, 0.45);
  outline-offset: 3px;
}

body.dark-theme .back-to-top {
  color: rgb(47, 208, 191);
}

/* body.dark-theme .back-to-top (0,2,1) otherwise beats .back-to-top:hover
   (0,2,0) on specificity alone, so the intended hover color never applied
   in dark mode - the :hover pseudo-class here raises this rule to (0,3,1),
   which wins without needing !important or touching either rule above. */
body.dark-theme .back-to-top:hover {
  color: var(--heading-color);
}

@media (max-width: 640px) {
  .back-to-top {
    right: 16px;
    bottom: 16px;
    width: 46px;
    height: 46px;
  }
}
