/* shared/scroll-top.css
 * Floating "back to top" button. Hairline gold border, ink fill, paper icon.
 * Fades in once the page has scrolled past 600px. Hover inverts to gold/ink.
 *
 * 2026-05-10 hardening (Sam: "sometimes appears, sometimes doesn't"):
 *   - z-index raised to 250 — above sticky topbar (z 100) AND mobile drawer
 *     (z 200) so the button is never occluded.
 *   - !important on the visibility states — cannot lose to page-local
 *     `transition: all` overrides or third-party CSS.
 *   - 48x48 minimum tap target across all viewports (WCAG 2.5.5).
 *   - position-fixed pinned with safe-area inset on iOS notch devices.
 */
.scroll-top {
  position: fixed;
  right: clamp(1rem, 3vw, 2rem);
  right: max(clamp(1rem, 3vw, 2rem), env(safe-area-inset-right, 0px));
  bottom: clamp(1rem, 3vw, 2rem);
  bottom: max(clamp(1rem, 3vw, 2rem), env(safe-area-inset-bottom, 0px));
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  border-radius: 50%;
  background: var(--ink, #0E0E0E);
  color: var(--paper, #F0EDE6);
  border: 1px solid var(--gold, #C4A35A);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  z-index: 250;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 220ms ease, transform 220ms ease, visibility 0ms linear 220ms,
              background-color 200ms ease, color 200ms ease, border-color 200ms ease, box-shadow 200ms ease;
  -webkit-tap-highlight-color: transparent;
  /* Defend against page-local resets that could blank the button. */
  font: inherit;
  margin: 0;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}

.scroll-top.is-visible {
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
  transform: translateY(0) !important;
  /* Re-declare transition so visibility ramps in immediately when shown. */
  transition: opacity 220ms ease, transform 220ms ease, visibility 0ms,
              background-color 200ms ease, color 200ms ease, border-color 200ms ease, box-shadow 200ms ease;
}

.scroll-top:hover,
.scroll-top:focus-visible {
  background: var(--gold, #C4A35A);
  color: var(--ink, #0E0E0E);
  border-color: var(--gold, #C4A35A);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
  text-decoration: none;
}

.scroll-top:focus-visible {
  outline: 2px solid var(--gold, #C4A35A);
  outline-offset: 4px;
}

.scroll-top svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: block;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .scroll-top {
    transition: opacity 0ms, visibility 0ms !important;
    transform: none !important;
  }
  .scroll-top.is-visible {
    transform: none !important;
  }
}

/* Mobile: keep 48px (WCAG min 44px) and pull slightly off the edge to clear
 * iOS home-indicator. Don't shrink — the button is the rescue from a long
 * scroll, and undersized targets fail tap-test. */
@media (max-width: 560px) {
  .scroll-top {
    width: 48px;
    height: 48px;
    right: max(0.9rem, env(safe-area-inset-right, 0px));
    bottom: max(0.9rem, env(safe-area-inset-bottom, 0px));
  }
}
