/* ============================================================
   FORM POLISH — shared enhancement layer
   ------------------------------------------------------------
   Drop-in CSS that adds smooth, modern, "addictive to fill"
   micro-interactions to any lead form on the page.

   - Theme-agnostic: only targets [data-fp] attributes added by
     form-polish.js, so it can't conflict with existing styles
   - Respects prefers-reduced-motion
   - Pure CSS, no fonts/icons/dependencies
   ============================================================ */

/* Progress bar at the top of the page */
.fp-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, currentColor, currentColor);
  z-index: 9999;
  transition: width 350ms cubic-bezier(.22, 1, .36, 1), opacity 250ms;
  pointer-events: none;
  opacity: 0;
}
.fp-progress.fp-active { opacity: 1; }

/* Validity ring around inputs */
[data-fp="field"] {
  position: relative;
  transition: transform 200ms cubic-bezier(.22, 1, .36, 1);
}

[data-fp-state="valid"] input,
[data-fp-state="valid"] select,
[data-fp-state="valid"] textarea {
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.35), 0 1px 2px rgba(0,0,0,0.04);
  transition: box-shadow 220ms ease;
}

[data-fp-state="invalid"] input,
[data-fp-state="invalid"] select,
[data-fp-state="invalid"] textarea {
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.45), 0 1px 2px rgba(0,0,0,0.04);
  transition: box-shadow 220ms ease;
}

/* Subtle green checkmark that fades in on valid */
.fp-check {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%) scale(0.6);
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.12);
  color: rgb(22, 163, 74);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease, transform 220ms cubic-bezier(.22, 1, .36, 1);
  z-index: 5;
}
.fp-check::before {
  content: "";
  width: 6px;
  height: 11px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translate(-1px, -1px);
}
[data-fp-state="valid"] .fp-check {
  opacity: 1;
  transform: translateY(-50%) scale(1);
}
[data-fp-type="select"] .fp-check,
[data-fp-type="textarea"] .fp-check {
  display: none; /* selects/textareas have native arrows; checkmark would clash */
}

/* Shake on validation error */
@keyframes fp-shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-3px); }
  40%, 60% { transform: translateX(3px); }
}
.fp-shake {
  animation: fp-shake 380ms cubic-bezier(.36, .07, .19, .97) both;
}

/* Submit button "wakes up" when form is complete */
button[data-fp="submit"] {
  transition: transform 220ms cubic-bezier(.22, 1, .36, 1),
              box-shadow 220ms ease,
              filter 220ms ease,
              opacity 220ms ease;
  position: relative;
  overflow: hidden;
}
button[data-fp="submit"][data-fp-ready="false"] {
  filter: grayscale(0.4);
  opacity: 0.85;
}
button[data-fp="submit"][data-fp-ready="true"] {
  filter: none;
  opacity: 1;
  box-shadow: 0 12px 32px -8px rgba(0,0,0,0.18), 0 4px 12px -4px rgba(0,0,0,0.12);
  transform: translateY(-1px);
}
button[data-fp="submit"][data-fp-ready="true"]:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 40px -10px rgba(0,0,0,0.25), 0 6px 14px -4px rgba(0,0,0,0.15);
}

/* Soft shimmer sweep across submit button when ready */
button[data-fp="submit"][data-fp-ready="true"]::after {
  content: "";
  position: absolute;
  top: 0; left: -100%;
  width: 50%;
  height: 100%;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(255,255,255,0.18) 50%,
    transparent 100%);
  animation: fp-shimmer 2.6s ease-in-out infinite;
  pointer-events: none;
}
@keyframes fp-shimmer {
  0%   { left: -100%; }
  60%  { left: 130%; }
  100% { left: 130%; }
}

/* Focus glow */
[data-fp="field"] input:focus,
[data-fp="field"] select:focus,
[data-fp="field"] textarea:focus {
  outline: none !important;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18), 0 1px 2px rgba(0,0,0,0.04) !important;
  transition: box-shadow 180ms ease;
}

/* Reduced motion — strip animations */
@media (prefers-reduced-motion: reduce) {
  .fp-progress,
  [data-fp="field"],
  .fp-check,
  button[data-fp="submit"],
  button[data-fp="submit"]::after {
    transition: none !important;
    animation: none !important;
  }
}
