/* ========================================
   Scroll to Top Button with Rocket Animation
   ======================================== */

.scroll-to-top-btn {
  position: fixed;
  bottom: 30px;
  left: 30px;
  width: 50px;
  height: 50px;
  background: linear-gradient(135deg, var(--site-accent-dark, #5b9bd5), var(--site-accent, #5b9bd5));
  border: none;
  border-radius: 50%;
  color: #ffffff;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px var(--site-accent-glow, rgba(91, 155, 213, 0.3));
  z-index: 999;
  overflow: hidden;
}

.scroll-to-top-btn.visible {
  opacity: 1;
  visibility: visible;
}

.scroll-to-top-btn:hover {
  transform: translateY(-5px);
  box-shadow: 0 6px 25px var(--site-accent-glow, rgba(91, 155, 213, 0.3));
}

/* Button Content Container */
.scroll-to-top-btn .btn-content {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Arrow Icon */
.scroll-to-top-btn .icon-arrow {
  transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  opacity: 1;
  transform: translateY(0);
}

.scroll-to-top-btn:hover .icon-arrow {
  transform: translateY(-3px);
}

/* Rocket Container (hidden by default) */
.scroll-to-top-btn .rocket-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
  pointer-events: none;
}

.scroll-to-top-btn .icon-rocket {
  font-size: 1.4rem;
  display: block;
  transition: transform 0.3s ease;
}

/* Rocket Flames */
.scroll-to-top-btn .rocket-flames {
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.scroll-to-top-btn .flame {
  width: 4px;
  height: 10px;
  background: linear-gradient(to bottom, #ff6b35, #ffc107, #fff);
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  animation: flameFlicker 0.15s infinite alternate;
}

.scroll-to-top-btn .flame-1 {
  animation-delay: 0s;
  height: 8px;
}

.scroll-to-top-btn .flame-2 {
  animation-delay: 0.05s;
  height: 12px;
}

.scroll-to-top-btn .flame-3 {
  animation-delay: 0.1s;
  height: 8px;
}

@keyframes flameFlicker {
  0% {
    transform: scaleY(0.8) scaleX(1);
    opacity: 0.8;
  }
  100% {
    transform: scaleY(1.2) scaleX(0.9);
    opacity: 1;
  }
}

/* ========================================
   Launching State (button clicked)
   ======================================== */

.scroll-to-top-btn.launching {
  pointer-events: none;
}

.scroll-to-top-btn.launching .icon-arrow {
  opacity: 0;
  transform: translateY(-20px) scale(0.5);
}

.scroll-to-top-btn.launching .rocket-container {
  opacity: 1;
  animation: rocketShake 0.1s infinite alternate;
}

.scroll-to-top-btn.launching .rocket-flames {
  opacity: 1;
}

@keyframes rocketShake {
  0% {
    transform: translate(-50%, -50%) translateX(-1px);
  }
  100% {
    transform: translate(-50%, -50%) translateX(1px);
  }
}

/* ========================================
   Reset State (after scroll completes)
   ======================================== */

.scroll-to-top-btn.resetting .icon-arrow {
  opacity: 1;
  transform: translateY(0);
  transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.scroll-to-top-btn.resetting .rocket-container {
  opacity: 0;
  transform: translate(-50%, -50%) translateY(-20px);
  transition: all 0.3s ease;
}

.scroll-to-top-btn.resetting .rocket-flames {
  opacity: 0;
}

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 768px) {
  .scroll-to-top-btn {
    width: 45px;
    height: 45px;
    bottom: 20px;
    left: 20px;
    font-size: 1.25rem;
  }

  .scroll-to-top-btn .icon-rocket {
    font-size: 1.2rem;
  }
}

/* White border when overlapping footer */
.scroll-to-top-btn.near-footer {
  border: 2px solid #ffffff;
}

/* Adjust floating chat position to avoid overlap */
.floating-chat {
  bottom: 30px;
  right: 30px;
}

@media (max-width: 768px) {
  .floating-chat {
    bottom: 20px;
    right: 20px;
  }
}
