/*
 * Back-to-top button of the long pages (markup: cf-shared/ui/scroll-top).
 *
 * Reads the design tokens of the including page (--primary, --bg-card, --text-main, ...),
 * so the button is violet on lucee@schüri and green on hosting@schüri without any page
 * rebuilding it. Every token has a fallback. The argument accentColor overrides the accent
 * through --cf-scroll-top-accent.
 *
 * --cf-scroll-top-offset is set by scroll-top.js: the height of whatever is fixed to the
 * bottom edge (admin control bar), so the button sits above it instead of on it.
 */
.cf-scroll-top {
  --cf-scroll-top-accent: var(--primary, #8b5cf6);

  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: calc(var(--cf-scroll-top-offset, 0px) + max(16px, env(safe-area-inset-bottom)));
  /* Above the sticky headers (100) and the skip link (101), below cookie banner and control
     bar (2147483000), whose menus open upwards across this corner. */
  z-index: 1000;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--cf-scroll-top-accent) 45%, transparent);
  border-radius: 50%;
  background: var(--bg-card, rgba(15, 22, 38, 0.55));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text-main, #f3f4f6);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  cursor: pointer;

  /* Hidden until scroll-top.js adds .is-visible. visibility (not only opacity) also takes the
     button out of the tab order and the accessibility tree. */
  visibility: hidden;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s linear 0.2s,
    background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.cf-scroll-top.is-visible {
  visibility: visible;
  opacity: 1;
  transform: none;
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s,
    background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.cf-scroll-top:hover {
  background: var(--cf-scroll-top-accent);
  border-color: var(--cf-scroll-top-accent);
  color: #ffffff;
}

.cf-scroll-top:focus-visible {
  outline: 2px solid var(--cf-scroll-top-accent);
  outline-offset: 3px;
}

.cf-scroll-top svg {
  display: block;
  flex: 0 0 auto;
}

/* scroll-top.js parks the focus on the body after the jump (temporary tabindex="-1"). That
   is a starting point for the next Tab, not something to highlight with a frame around the
   whole page. */
body[tabindex="-1"]:focus {
  outline: none;
}

@media (prefers-reduced-motion: reduce) {
  .cf-scroll-top,
  .cf-scroll-top.is-visible {
    transform: none;
    transition: none;
  }
}

@media print {
  .cf-scroll-top {
    display: none;
  }
}
