/* Back to top: a dark disc bottom right; its 3px ring fills with the
   scroll and carries a dot for each section.
   Lifted up above the bottom app bar on all inner pages. */
.totop {
  position: fixed;
  right: calc(var(--space-3) + env(safe-area-inset-right, 0px));
  bottom: calc(var(--space-3) + env(safe-area-inset-bottom, 0px));
  z-index: 1001;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background-color: var(--color-night-a85);
  color: var(--color-gold);
  box-shadow: 0 12px 32px -8px var(--color-shadow-a60);
  opacity: 0;
  visibility: hidden;
  transform: translate3d(0, var(--space-2), 0);
  transition:
    bottom 0.25s var(--ease-out),
    opacity var(--duration-ui) var(--ease-out),
    transform var(--duration-ui) var(--ease-out),
    visibility 0s var(--duration-ui);
}

/* Lift Back-to-Top button on other pages (above the bottom app bar) */
body.kebab-inner-page .totop,
body:not(.kebab-front-page):not(.home) .totop {
  bottom: calc(80px + env(safe-area-inset-bottom, 0px));
}

.totop.is-visible {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition:
    bottom 0.25s var(--ease-out),
    opacity var(--duration-ui) var(--ease-out),
    transform var(--duration-ui) var(--ease-out),
    visibility 0s;
}

.totop__ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  transform: rotate(-90deg);
}

.totop__track,
.totop__fill {
  fill: none;
  stroke-width: 3;
}

.totop__track {
  stroke: var(--color-cream-a12);
}

.totop__fill {
  stroke: var(--color-gold);
  stroke-linecap: round;
  stroke-dasharray: 0 100;
}

.totop__mark {
  fill: var(--color-cream-a45);
  stroke: var(--color-night);
  stroke-width: 1.5;
  transform-box: fill-box;
  transform-origin: center;
  transition: fill var(--duration-ui) var(--ease-out);
}

.totop__mark.is-passed {
  fill: var(--color-gold);
}

.totop__mark.is-blink {
  animation: mark-blink 1s var(--ease-out);
}

@keyframes mark-blink {
  0%,
  40%,
  80% {
    fill: var(--color-ivory);
    transform: scale(1.8);
  }

  20%,
  60%,
  100% {
    fill: var(--color-gold);
    transform: scale(1);
  }
}

.totop__arrow {
  width: 22px;
  height: 22px;
  overflow: visible;
}

.totop__chevron {
  opacity: 0.55;
}

.totop:is(:hover, :focus-visible) .totop__chevron {
  animation: chevron-light 1.1s var(--ease-out) infinite;
}

.totop:is(:hover, :focus-visible) .totop__chevron--high {
  animation-delay: 0.22s;
}

@keyframes chevron-light {
  0%,
  70%,
  100% {
    opacity: 0.35;
  }

  30% {
    opacity: 1;
    stroke: var(--color-ivory);
  }
}
