/* ============================================================
   TRIPLEFOUR — WhatsApp FAB
   Floating action button, always-visible bottom-right.
   All selectors scoped to .wa-fab; tokens from tokens.css.
   ============================================================ */

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

/* Entrance: fade + scale up from slightly below */
@keyframes wa-fab-enter {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.88);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Pulse ring: expands and fades out, looping to draw attention */
@keyframes wa-fab-pulse {
  0% {
    transform: scale(1);
    opacity: 0.4;
  }
  70% {
    transform: scale(1.5);
    opacity: 0;
  }
  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}

/* ---------- Root FAB anchor ---------- */

.wa-fab {
  /* Positioning */
  position: fixed;
  bottom: clamp(1rem, 3vw, 2rem);
  right: clamp(1rem, 3vw, 2rem);
  z-index: 90; /* below --z-overlay (1000) so open mobile menu covers it */

  /* Layout: pill shape — icon + label side by side */
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);

  /* Size — minimum 56 px tap target, ~60 px height on desktop */
  min-height: 60px;
  padding: 0 var(--space-4) 0 var(--space-3);
  border-radius: var(--r-pill);

  /* Subtle dark-glass surface with a green cast — matches the site's panels
     instead of a loud solid-green fill */
  background: color-mix(in srgb, var(--wa) 12%, var(--surface));
  color: var(--text);
  border: 1px solid color-mix(in srgb, var(--wa) 30%, transparent);

  /* Soft elevation + gentle green halo (toned right down) */
  box-shadow:
    0 10px 30px rgba(0, 0, 0, 0.45),
    0 6px 22px color-mix(in srgb, var(--wa) 16%, transparent);

  /* Smooth transitions */
  transition:
    background   var(--dur-fast) var(--ease-out),
    box-shadow   var(--dur-fast) var(--ease-out),
    transform    var(--dur-fast) var(--ease-spring),
    opacity      var(--dur)      var(--ease-out),
    visibility   var(--dur)      var(--ease-out);

  /* Entrance animation: slight delay so the page settles first */
  animation: wa-fab-enter 0.55s var(--ease-spring) 0.9s both;

  /* Prevent text selection on the button */
  user-select: none;
  -webkit-user-select: none;

  will-change: transform, opacity;
}

/* ---------- Hover & focus states ---------- */

.wa-fab:hover,
.wa-fab:focus-visible {
  background: color-mix(in srgb, var(--wa) 20%, var(--surface));
  border-color: color-mix(in srgb, var(--wa) 55%, transparent);
  transform: translateY(-3px) scale(1.04);
  box-shadow:
    0 14px 38px rgba(0, 0, 0, 0.5),
    0 10px 30px color-mix(in srgb, var(--wa) 26%, transparent);
}
/* brighten the glyph slightly on hover for feedback */
.wa-fab:hover .wa-fab__icon,
.wa-fab:focus-visible .wa-fab__icon {
  color: color-mix(in srgb, var(--wa) 80%, #ffffff);
}

.wa-fab:active {
  transform: translateY(0) scale(0.97);
}

/* Focus ring — global :focus-visible sets the outline;
   adjust offset + radius so it hugs the pill shape */
.wa-fab:focus-visible {
  outline: 2px solid var(--wa);
  outline-offset: 4px;
  border-radius: var(--r-pill);
}

/* ---------- Label pill ---------- */

.wa-fab__label {
  font-family: var(--font-sans);
  font-size: var(--fs-small);
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text);
  white-space: nowrap;

  /* Smooth expand/contract on hover (desktop only — see media query below) */
  max-width: 120px;
  overflow: hidden;
  transition:
    max-width  var(--dur-fast) var(--ease-out),
    opacity    var(--dur-fast) var(--ease-out);
}

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

.wa-fab__icon {
  /* Fixed square; flex-shrink: 0 keeps it from collapsing */
  width: 28px;
  height: 28px;
  flex-shrink: 0;

  /* Green glyph carries the WhatsApp identity on the dark surface */
  color: var(--wa);
  transition: color var(--dur-fast) var(--ease-out);

  /* Override global img/svg rule that sets height: auto */
  display: block;
}

/* ---------- Pulse ring ---------- */

.wa-fab__pulse {
  /* Positioned behind the FAB, centred on it */
  position: absolute;
  inset: 0;
  border-radius: var(--r-pill);
  /* subtle expanding outline ring instead of a solid green blob */
  background: transparent;
  border: 1.5px solid var(--wa);
  opacity: 0;
  pointer-events: none;
  z-index: -1;

  /* Pulse loops every 2.8 s, starting after the entrance settles */
  animation: wa-fab-pulse 2.8s var(--ease-out) 1.8s infinite;
}

/* ---------- Hide when mobile nav is open ----------
   !important is required so this overrides the entrance animation's
   forwards-fill (which otherwise pins opacity:1) and the reduced-motion
   opacity:1 !important rule below. */
body.nav-open .wa-fab {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none;
}

/* ---------- Small screens (≤ 600 px): icon-only mode ---------- */

@media (max-width: 600px) {
  .wa-fab {
    /* Square tap target — 60 × 60 px */
    min-height: 60px;
    width: 60px;
    padding: 0;
    justify-content: center;
    gap: 0;
  }

  /* Hide the text label; leave the icon */
  .wa-fab__label {
    max-width: 0;
    opacity: 0;
    overflow: hidden;
  }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  /* Disable the looping pulse entirely */
  .wa-fab__pulse {
    animation: none !important;
  }

  /* Disable the entrance fly-in; just appear */
  .wa-fab {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }

  /* Still allow the nav-open hide (it's a visibility concern, not decoration) */
  body.nav-open .wa-fab {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none;
  }
}
