/* =============================================================
   TransRisk v3 — animations.css
   Supplement to style.css: enhanced interactions, counter,
   back-to-top, NEW badge pulse, prefers-reduced-motion.
   Loaded on every page after style.css.
============================================================= */

/* ─────────────────────────────────────────────────────────────
   CTA BUTTON — scale hover (supplements style.css hover)
───────────────────────────────────────────────────────────── */
.btn-primary:hover,
.btn-primary:focus-visible {
  transform: scale(1.02);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-secondary:hover,
.btn-secondary:focus-visible {
  transform: scale(1.03);
}

.btn-ghost-white:hover,
.btn-ghost-white:focus-visible {
  transform: scale(1.03);
}


/* ─────────────────────────────────────────────────────────────
   CARD HOVER — universal lift (supplements page-specific CSS)
   Pages define their own hover but this is a safe fallback.
───────────────────────────────────────────────────────────── */
.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 36px rgba(15, 31, 46, 0.12);
  transition: transform 200ms ease, box-shadow 200ms ease;
}


/* ─────────────────────────────────────────────────────────────
   NEW BADGE — subtle pulse to draw attention
───────────────────────────────────────────────────────────── */
@keyframes newBadgePulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(45, 122, 58, 0.0);
  }
  50% {
    box-shadow: 0 0 0 3px rgba(45, 122, 58, 0.18);
  }
}

.nav-badge-new,
.badge-new,
.badge.badge-green {
  animation: newBadgePulse 2s ease-in-out infinite;
}


/* ─────────────────────────────────────────────────────────────
   COUNTER ANIMATION — numbers count up on scroll
───────────────────────────────────────────────────────────── */
.counter-val {
  display: inline-block;
  /* JS writes the number; no CSS needed beyond display */
}

/* Metrics strip — fade-in when section enters viewport */
.metrics-strip.in-view .metric-number {
  animation: scrollRevealUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}


/* ─────────────────────────────────────────────────────────────
   BACK TO TOP BUTTON
───────────────────────────────────────────────────────────── */
.back-to-top {
  position: fixed;
  bottom: 32px;
  right: 28px;
  z-index: 800;
  width: 44px;
  height: 44px;
  background: var(--color-green);
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(45, 122, 58, 0.35);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease, background 0.15s ease;
  /* Focus ring */
  outline-offset: 3px;
}

.back-to-top:focus-visible {
  outline: 2px solid var(--color-green);
  outline-offset: 3px;
}

.back-to-top.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.back-to-top:hover {
  background: var(--color-green-dark);
  transform: translateY(-2px);
}

.back-to-top svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}


/* ─────────────────────────────────────────────────────────────
   SKIP TO MAIN CONTENT LINK (accessibility)
───────────────────────────────────────────────────────────── */
.skip-to-main {
  position: absolute;
  top: -100px;
  left: 16px;
  z-index: 9999;
  background: var(--color-green);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: top 0.15s ease;
  white-space: nowrap;
}

.skip-to-main:focus {
  top: 12px;
}


/* ─────────────────────────────────────────────────────────────
   FOCUS RING — override browser default with styled ring
───────────────────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--color-green);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Remove focus ring for mouse users */
:focus:not(:focus-visible) {
  outline: none;
}


/* ─────────────────────────────────────────────────────────────
   COMPARISON TABLE — row hover highlight
───────────────────────────────────────────────────────────── */
.comparison-row:hover,
.compare-row:hover {
  background: rgba(45, 122, 58, 0.04);
  transition: background 150ms ease;
}


/* ─────────────────────────────────────────────────────────────
   FORM FEEDBACK — inline error/valid states
───────────────────────────────────────────────────────────── */
.form-input.is-invalid,
.form-select.is-invalid,
.form-textarea.is-invalid {
  border-color: #dc2626;
  background: rgba(220, 38, 38, 0.03);
}

.form-input.is-valid,
.form-select.is-valid,
.form-textarea.is-valid {
  border-color: var(--color-green);
}

.form-error-msg {
  display: none;
  align-items: center;
  gap: 5px;
  margin-top: 5px;
  font-size: 12.5px;
  color: #dc2626;
  font-weight: 500;
}

.form-error-msg.is-visible {
  display: flex;
}

.form-error-msg svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* Submit button loading state */
.form-submit-btn.is-loading {
  pointer-events: none;
  opacity: 0.7;
}

.form-submit-btn .btn-spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  flex-shrink: 0;
}

.form-submit-btn.is-loading .btn-spinner {
  display: block;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}


/* ─────────────────────────────────────────────────────────────
   PREFERS-REDUCED-MOTION — disable ALL animations
───────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {

  /* Buttons */
  .btn-primary:hover,
  .btn-secondary:hover,
  .btn-ghost-white:hover {
    transform: none;
  }

  /* Cards */
  .card:hover {
    transform: none;
  }

  /* NEW badge pulse */
  .nav-badge-new,
  .badge-new,
  .badge.badge-green {
    animation: none;
  }

  /* Map dots */
  .map-dot {
    animation: none;
    opacity: 0.8;
  }

  /* Back-to-top */
  .back-to-top {
    transition: none;
  }

  /* Spinner */
  .form-submit-btn .btn-spinner {
    animation: none;
  }

  /* Any other transitions */
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
