/* ==========================================================================
   bottom-to-top.css  -  3D FLOATING "BOTTOM TO TOP" BUTTON
   The visitor scrolls to the bottom of the page and uses this button to
   jump to the top again. The look is copied from the old version of the site.
   Colours are written directly (not variables) so they stay the same
   when the palette in base.css is changed.
   ========================================================================== */

/* Fixed box that keeps the button in the bottom-right corner.
   "perspective" gives the tilt effect its 3D depth. */
.bottom-to-top-wrap {
  position: fixed;
  right: clamp(16px, 3vw, 32px);
  bottom: clamp(18px, 3vw, 32px);
  z-index: 45;
  perspective: 800px;
  pointer-events: none;
}

/* The button itself. --rx / --ry = tilt angles, --mx / --my = light position.
   bottom-to-top.js updates these four values on mouse move. */
.bottom-to-top {
  --rx: 0deg;
  --ry: 0deg;
  --mx: 50%;
  --my: 50%;
  position: relative;
  width: 58px;
  height: 58px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 14px;
  background: linear-gradient(145deg, #1E293B 0%, #0F172A 100%);
  color: #FFFFFF;
  cursor: pointer;
  pointer-events: auto;
  transform-style: preserve-3d;
  /* Hidden at first; the .show class is added by JS after the visitor scrolls down. */
  opacity: 0;
  visibility: hidden;
  transform: translateY(28px) rotateX(-35deg) scale(0.82);
  /* Two solid blue lines make the 3D edge, the last shadow is the soft drop shadow. */
  box-shadow:
    0 5px 0 #0266D6,
    0 6px 0 #024AA0,
    0 16px 28px rgba(15, 23, 42, 0.34);
  transition:
    opacity 0.35s ease,
    visibility 0.35s ease,
    transform 0.35s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.2s ease;
}

/* Visible state: the button slides up and follows the mouse tilt. */
.bottom-to-top.show {
  opacity: 1;
  visibility: visible;
  transform: rotateX(var(--rx)) rotateY(var(--ry)) translateY(0) scale(1);
}

/* Hover: the 3D edge grows taller and the shadow turns blue. */
.bottom-to-top.show:hover {
  box-shadow:
    0 7px 0 #0266D6,
    0 8px 0 #024AA0,
    0 22px 36px rgba(2, 102, 214, 0.38);
}

/* Pressed: the button sinks down like a real key. */
.bottom-to-top.show:active {
  transform: rotateX(var(--rx)) rotateY(var(--ry)) translateY(4px) scale(0.97);
  box-shadow:
    0 1px 0 #0266D6,
    0 2px 0 #024AA0,
    0 6px 12px rgba(15, 23, 42, 0.28);
  transition-duration: 0.08s;
}


/* Live scroll-progress border: a light blue line draws around the button
   while the visitor scrolls (bottom-to-top.js sets stroke-dashoffset). */
.bottom-to-top-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  transform: translateZ(4px);
}
.bottom-to-top-ring rect {
  fill: none;
  stroke: #38BDF8;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  transition: stroke-dashoffset 0.12s linear;
}

/* The arrow and the "Top" label float above the button face (translateZ = depth). */
.bottom-to-top-inner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: 100%;
  transform: translateZ(14px);
  pointer-events: none;
}
.bottom-to-top-inner svg {
  width: 16px;
  height: 16px;
  stroke: #FFFFFF;
  stroke-width: 2.2;
  fill: none;
  transition: transform 0.25s ease;
}
/* On hover the arrow moves up a little. */
.bottom-to-top:hover .bottom-to-top-inner svg { transform: translateY(-2px); }
.bottom-to-top-inner span {
  font: 500 9.5px/1 var(--font-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #CBD5E1;
}

/* Slightly smaller button on phones. */
@media (max-width: 600px) {
  .bottom-to-top { width: 52px; height: 52px; border-radius: 12px; }
  .bottom-to-top-glare { border-radius: 11px; }
}

/* Accessibility: visitors who prefer less motion get no tilt. */
@media (prefers-reduced-motion: reduce) {
  .bottom-to-top, .bottom-to-top-inner { transform: none !important; }
}