/* Shared "back to top" button - used on both the marketing/storefront layout and the app shell
   (_Layout.cshtml, covering Workspace + onboarding). Plain inline SVG rather than a Keenicon/Tabler
   glyph so one partial works unmodified in both icon-set contexts. */

.lvxd-back-to-top {
  /* Each surface paints its own accent. --lvxd-accent is defined in lvxd-onboarding.css, which
     only the app shell loads; _MarketingLayout doesn't, so on the storefront it is undefined and
     this used to land on the hardcoded fallback - the Hub's teal, on a blue marketing page.
     Chaining through --lvxd-sf-accent picks up the storefront's own blue there, and the literal
     is now a genuine last resort rather than the storefront's effective value. */
  --lvxd-btt-accent: var(--lvxd-accent, var(--lvxd-sf-accent, #0b7ea3));
  --lvxd-btt-accent-hover: var(--lvxd-accent-hover, var(--lvxd-sf-primary-grad-end, #096987));

  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 60;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--lvxd-btt-accent);
  /* White ink is right on both surfaces: the Hub's teal and the storefront's blue are both
     dark enough. Only the Hub's dark/dim themes override it, via --lvxd-on-accent. */
  color: var(--lvxd-on-accent, #fff);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .18);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity .2s ease, transform .2s ease, background .15s ease, visibility .2s, box-shadow .3s ease;
}

.lvxd-back-to-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.lvxd-back-to-top:hover {
  background: var(--lvxd-btt-accent-hover);
}

.lvxd-back-to-top-arrow { position: relative; transition: transform .2s ease; }

/* fun bits: the arrow hops on hover, and once you've scrolled to the very bottom the ring gets a
   playful pulsing glow to invite the click ("fully charged - ready to launch") */
.lvxd-back-to-top:hover .lvxd-back-to-top-arrow { animation: lvxd-btt-hop .5s ease infinite; }

/* radial core glow, centred behind the arrow - starts small/hidden and blooms outward to meet
   the outer box-shadow ring, so the whole effect reads as radiating out from the icon rather
   than just appearing at the button's edge. */
.lvxd-back-to-top::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  transform: scale(.3);
  background: radial-gradient(circle, rgba(255, 255, 255, .9) 0%, rgba(255, 255, 255, 0) 72%);
}

/* two gentle pulses to catch the eye, then settle into a steady soft glow rather than
   pulsing forever - a constant loop read as nagging rather than inviting */
.lvxd-back-to-top.is-maxed {
  box-shadow: 0 6px 18px rgba(0, 0, 0, .18), 0 0 8px 2px color-mix(in oklch, var(--lvxd-btt-accent) 22%, transparent);
  animation: lvxd-btt-charged 2.6s ease-in-out 2;
}
.lvxd-back-to-top.is-maxed::before {
  animation: lvxd-btt-charged-core 2.6s ease-in-out 2;
}

.lvxd-back-to-top.is-launching { animation: lvxd-btt-launch .5s cubic-bezier(.34, 1.56, .64, 1); }

@keyframes lvxd-btt-hop {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}
/* eases up from nothing (rather than popping straight to full glow the instant .is-maxed is
   added), lingers on white for a beat, then softens into the accent blue and settles there -
   matching .is-maxed's own box-shadow at 100% so there's no jump once the two pulses finish
   and the animation hands off to the static resting state */
@keyframes lvxd-btt-charged {
  0% {
    box-shadow: 0 6px 18px rgba(0, 0, 0, .18), 0 0 0 0 rgba(255, 255, 255, 0);
    animation-timing-function: ease-out;
  }
  22% {
    box-shadow: 0 6px 18px rgba(0, 0, 0, .18), 0 0 9px 3px rgba(255, 255, 255, .48);
    animation-timing-function: ease-in-out;
  }
  38% {
    box-shadow: 0 6px 18px rgba(0, 0, 0, .18), 0 0 9px 3px rgba(255, 255, 255, .4);
    animation-timing-function: ease-in-out;
  }
  70% {
    box-shadow: 0 6px 18px rgba(0, 0, 0, .18), 0 0 10px 6px color-mix(in oklch, var(--lvxd-btt-accent) 30%, transparent);
    animation-timing-function: ease-in-out;
  }
  100% {
    box-shadow: 0 6px 18px rgba(0, 0, 0, .18), 0 0 8px 2px color-mix(in oklch, var(--lvxd-btt-accent) 22%, transparent);
  }
}
/* mirrors lvxd-btt-charged's white-to-blue colour story and timing, but as a radial bloom
   from the centre (behind the arrow) instead of an edge glow - the two together read as one
   pulse radiating outward from the icon. */
@keyframes lvxd-btt-charged-core {
  0% {
    opacity: 0;
    transform: scale(.3);
    background: radial-gradient(circle, rgba(255, 255, 255, .9) 0%, rgba(255, 255, 255, 0) 72%);
    animation-timing-function: ease-out;
  }
  22% {
    opacity: .85;
    transform: scale(.85);
    background: radial-gradient(circle, rgba(255, 255, 255, .9) 0%, rgba(255, 255, 255, 0) 72%);
    animation-timing-function: ease-in-out;
  }
  38% {
    opacity: .7;
    transform: scale(1);
    background: radial-gradient(circle, rgba(255, 255, 255, .75) 0%, rgba(255, 255, 255, 0) 72%);
    animation-timing-function: ease-in-out;
  }
  70% {
    opacity: .4;
    transform: scale(1.35);
    background: radial-gradient(circle, color-mix(in oklch, var(--lvxd-btt-accent) 70%, white) 0%, transparent 72%);
    animation-timing-function: ease-in-out;
  }
  100% {
    opacity: 0;
    transform: scale(1.5);
    background: radial-gradient(circle, color-mix(in oklch, var(--lvxd-btt-accent) 70%, white) 0%, transparent 72%);
  }
}
@keyframes lvxd-btt-launch {
  0% { transform: translateY(0) scale(1); }
  35% { transform: translateY(6px) scale(.92); }
  70% { transform: translateY(-14px) scale(1.06); }
  100% { transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .lvxd-back-to-top:hover .lvxd-back-to-top-arrow,
  .lvxd-back-to-top.is-maxed,
  .lvxd-back-to-top.is-launching {
    animation: none !important;
  }
  .lvxd-back-to-top.is-maxed::before {
    animation: none !important;
    opacity: 0 !important;
  }
}

@media (max-width: 640px) {
  .lvxd-back-to-top {
    right: 16px;
    bottom: 16px;
    width: 40px;
    height: 40px;
  }
}
