/*
 * Floating actions — WhatsApp chat + back-to-top.
 *
 * Global stylesheet (deliberately not Astro-scoped) and the single source of
 * truth for both buttons: src/components/ui/WhatsAppFloat.astro intentionally
 * carries no competing <style> block, because two definitions of the same
 * classes previously fought over the box model and pushed the pulse rings off
 * centre.
 *
 * Centring contract: .wa-float is a 60px square and the button fills it, so the
 * rings and glow are centred with left/top:50% + translate(-50%,-50%), and the
 * ring/glow keyframes repeat that same translate so scaling can never drift.
 */

.float-stack {
  position: fixed;
  right: 20px;
  bottom: 24px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  /* Only the buttons themselves may capture clicks — the wrapper spans the gap
     between them and must not block page content underneath. */
  pointer-events: none;
}

/* ---------- WhatsApp ---------- */

.wa-float {
  position: relative;
  width: 60px;
  height: 60px;
  /*
   * `backwards`, not `both`: once the entrance finishes it must stop owning
   * `transform`, otherwise the finished state would outrank the :hover lift.
   */
  animation: aoslon-wa-enter 0.6s cubic-bezier(0.34, 1.5, 0.64, 1) backwards;
  transition: transform 0.25s ease;
}

/* Lift and scale the whole unit so rings + glow + icon stay concentric. */
.wa-float:hover,
.wa-float:focus-within {
  transform: translateY(-6px) scale(1.06);
}

.wa-float__ring,
.wa-float__glow {
  position: absolute;
  left: 50%;
  top: 50%;
  border-radius: 50%;
  pointer-events: none;
}

.wa-float__ring {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  border: 3px solid #25d366;
  animation: aoslon-wa-ring 2.2s ease-out infinite;
}

.wa-float__ring--a {
  border-color: #25d366;
  animation-delay: 0s;
}
.wa-float__ring--b {
  border-color: #00e5ff;
  animation-delay: 0.7s;
}
.wa-float__ring--c {
  border-color: #c6ff00;
  animation-delay: 1.4s;
}

.wa-float__glow {
  width: 118%;
  height: 118%;
  background: conic-gradient(#25d366, #00e5ff, #ffeb3b, #76ff03, #25d366);
  filter: blur(12px);
  opacity: 0.75;
  animation: aoslon-wa-spin 4s linear infinite;
}

.wa-float__btn {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  pointer-events: auto;
  background: linear-gradient(135deg, #25d366, #128c7e 50%, #00bcd4);
  background-size: 200% 200%;
  color: #fff;
  text-decoration: none;
  box-shadow: 0 4px 16px rgba(37, 211, 102, 0.5);
  animation:
    aoslon-wa-gradient 3s ease-in-out infinite,
    aoslon-wa-bob 2.5s ease-in-out infinite;
  transition: filter 0.25s ease, box-shadow 0.25s ease;
}

.wa-float:hover .wa-float__btn,
.wa-float:focus-within .wa-float__btn {
  filter: saturate(1.35) brightness(1.08);
  box-shadow:
    0 0 0 6px rgba(37, 211, 102, 0.22),
    0 0 28px rgba(37, 211, 102, 0.65),
    0 0 48px rgba(0, 188, 212, 0.35),
    0 14px 32px rgba(7, 94, 84, 0.35);
}

.wa-float__btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

.wa-float__icon {
  position: relative;
  z-index: 2;
  display: flex;
  color: #fff;
  animation: aoslon-wa-wiggle 2.6s ease-in-out infinite;
}

.wa-float:hover .wa-float__icon,
.wa-float:focus-within .wa-float__icon {
  animation: aoslon-wa-wiggle-fast 0.6s ease-in-out infinite;
}

.wa-float__tip {
  position: absolute;
  right: calc(100% + 14px);
  top: 50%;
  transform: translateY(-50%) translateX(12px);
  white-space: nowrap;
  padding: 10px 14px;
  border-radius: 8px;
  background: linear-gradient(135deg, #075e54, #25d366);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  box-shadow: 0 8px 20px rgba(7, 94, 84, 0.35);
  transition:
    opacity 0.2s ease,
    transform 0.2s ease,
    visibility 0.2s;
}

.wa-float__tip::after {
  content: '';
  position: absolute;
  right: -6px;
  top: 50%;
  margin-top: -6px;
  border: 6px solid transparent;
  border-left-color: #25d366;
}

.wa-float:hover .wa-float__tip,
.wa-float:focus-within .wa-float__tip {
  opacity: 1;
  visibility: visible;
  transform: translateY(-50%) translateX(0);
}

/* ---------- Back to top ---------- */

.to-top {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 1px solid var(--color-border, #e3e3e3);
  border-radius: 50%;
  background: #fff;
  color: var(--color-ink, #1a1a1a);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.16);
  cursor: pointer;
  pointer-events: auto;
  /*
   * Hidden but still in flow, so revealing it never shifts the WhatsApp button.
   */
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition:
    opacity 0.25s ease,
    transform 0.25s ease,
    visibility 0.25s ease,
    background 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease,
    box-shadow 0.2s ease;
}

.to-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: none;
}

.to-top:hover,
.to-top:focus-visible {
  background: var(--color-brand, #bb1517);
  border-color: var(--color-brand, #bb1517);
  color: #fff;
  box-shadow: 0 6px 18px rgba(187, 21, 23, 0.32);
}

.to-top:focus-visible {
  outline: 2px solid var(--color-brand, #bb1517);
  outline-offset: 2px;
}

/* ---------- Keyframes ---------- */

@keyframes aoslon-wa-enter {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.4);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes aoslon-wa-gradient {
  0%,
  100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

@keyframes aoslon-wa-bob {
  0%,
  100% {
    box-shadow:
      0 4px 16px rgba(37, 211, 102, 0.5),
      0 0 0 0 rgba(37, 211, 102, 0.45);
  }
  50% {
    box-shadow:
      0 8px 24px rgba(0, 229, 255, 0.4),
      0 0 0 12px rgba(37, 211, 102, 0);
  }
}

@keyframes aoslon-wa-ring {
  0% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.9;
  }
  100% {
    transform: translate(-50%, -50%) scale(2.35);
    opacity: 0;
  }
}

@keyframes aoslon-wa-spin {
  from {
    transform: translate(-50%, -50%) rotate(0deg);
  }
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

@keyframes aoslon-wa-wiggle {
  0%,
  65%,
  100% {
    transform: rotate(0);
  }
  70% {
    transform: rotate(-16deg);
  }
  78% {
    transform: rotate(14deg);
  }
  86% {
    transform: rotate(-10deg);
  }
  93% {
    transform: rotate(6deg);
  }
}

@keyframes aoslon-wa-wiggle-fast {
  0%,
  100% {
    transform: rotate(0) scale(1);
  }
  25% {
    transform: rotate(-18deg) scale(1.08);
  }
  50% {
    transform: rotate(16deg) scale(1.12);
  }
  75% {
    transform: rotate(-12deg) scale(1.06);
  }
}

@media (max-width: 560px) {
  .float-stack {
    right: 14px;
    bottom: 18px;
    gap: 10px;
  }
  .wa-float {
    width: 56px;
    height: 56px;
  }
  .to-top {
    width: 42px;
    height: 42px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .wa-float,
  .wa-float__btn,
  .wa-float__ring,
  .wa-float__glow,
  .wa-float__icon,
  .to-top {
    animation: none !important;
  }
}
