/* ======================================================
   Earn Health — Animations & Visual Effects
   ====================================================== */

/* ── Keyframes ── */

@keyframes shimmer {
  0%   { background-position: -200% center; }
  100% { background-position:  200% center; }
}

@keyframes glow-pulse-gold {
  0%, 100% {
    text-shadow: 0 0 8px rgba(212,161,46,.45), 0 0 20px rgba(212,161,46,.2);
  }
  50% {
    text-shadow: 0 0 22px rgba(212,161,46,.9), 0 0 45px rgba(212,161,46,.45), 0 0 70px rgba(212,161,46,.2);
  }
}

@keyframes glow-pulse-indigo {
  0%, 100% {
    box-shadow: 0 0 6px rgba(99,102,241,.35), 0 0 0 0 rgba(99,102,241,.2);
  }
  50% {
    box-shadow: 0 0 20px rgba(99,102,241,.75), 0 0 35px rgba(99,102,241,.35);
  }
}

@keyframes float-gentle {
  0%, 100% { transform: translateY(0px); }
  50%       { transform: translateY(-9px); }
}

@keyframes float-subtle {
  0%, 100% { transform: translateY(0px) rotate(0deg); }
  33%       { transform: translateY(-5px) rotate(1deg); }
  66%       { transform: translateY(-3px) rotate(-1deg); }
}

@keyframes slide-up-fade {
  from { opacity: 0; transform: translateY(28px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slide-in-right {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes slide-in-left {
  from { opacity: 0; transform: translateX(-40px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes bounce-in {
  0%   { opacity: 0; transform: scale(0.4) translateY(-30px); }
  55%  { opacity: 1; transform: scale(1.06) translateY(6px); }
  75%  { transform: scale(0.96); }
  100% { transform: scale(1) translateY(0); }
}

@keyframes gradient-shift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes badge-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,.55); }
  50%       { box-shadow: 0 0 0 7px rgba(239,68,68,0); }
}

@keyframes neon-glow-indigo {
  0%, 100% { filter: drop-shadow(0 0 4px rgba(99,102,241,.45)); }
  50%       { filter: drop-shadow(0 0 14px rgba(99,102,241,.9)) drop-shadow(0 0 28px rgba(99,102,241,.4)); }
}

@keyframes gold-logo-glow {
  0%, 100% { filter: drop-shadow(0 0 4px rgba(212,161,46,.4)); }
  50%       { filter: drop-shadow(0 0 14px rgba(212,161,46,.85)) drop-shadow(0 0 28px rgba(212,161,46,.35)); }
}

@keyframes ring-pulse {
  0%   { transform: scale(1); opacity: .7; }
  100% { transform: scale(2.4); opacity: 0; }
}

@keyframes ring-pulse-slow {
  0%   { transform: scale(1); opacity: .45; }
  100% { transform: scale(2.8); opacity: 0; }
}

@keyframes number-pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.22); }
  100% { transform: scale(1); }
}

@keyframes ripple-effect {
  to { transform: scale(4); opacity: 0; }
}

@keyframes sparkle-burst {
  0%   { transform: rotate(0deg) scale(1); opacity: 1; }
  100% { transform: rotate(720deg) scale(0); opacity: 0; }
}

@keyframes confetti-fall {
  0%   { transform: translateY(-10px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

@keyframes success-flash {
  0%   { background-color: transparent; }
  25%  { background-color: rgba(16,185,129,.13); }
  100% { background-color: transparent; }
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes hero-bg-pan {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes scan-line {
  0%   { transform: translateY(0); opacity: .6; }
  50%  { opacity: 1; }
  100% { transform: translateY(60px); opacity: .6; }
}

@keyframes shimmer-sweep {
  0%   { left: -70%; }
  100% { left: 130%; }
}

@keyframes rotate-slow {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@keyframes wobble {
  0%, 100% { transform: rotate(0deg); }
  15%       { transform: rotate(-6deg); }
  30%       { transform: rotate(4deg); }
  45%       { transform: rotate(-3deg); }
  60%       { transform: rotate(2deg); }
  75%       { transform: rotate(-1deg); }
}

/* ── Utility Animation Classes ── */

.animate-slide-up    { animation: slide-up-fade .5s ease both; }
.animate-slide-right { animation: slide-in-right .45s ease both; }
.animate-slide-left  { animation: slide-in-left .45s ease both; }
.animate-bounce-in   { animation: bounce-in .55s cubic-bezier(.36,.07,.19,.97) both; }
.animate-fade-in     { animation: fade-in .4s ease both; }
.animate-float       { animation: float-gentle 4s ease-in-out infinite; }
.animate-float-sub   { animation: float-subtle 5s ease-in-out infinite; }
.animate-wobble      { animation: wobble .7s ease-in-out; }

/* Stagger delays */
.delay-1  { animation-delay: .1s; }
.delay-2  { animation-delay: .2s; }
.delay-3  { animation-delay: .3s; }
.delay-4  { animation-delay: .4s; }
.delay-5  { animation-delay: .5s; }
.delay-6  { animation-delay: .65s; }
.delay-7  { animation-delay: .8s; }

/* ── Scroll Reveal ── */
.scroll-animate {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity .6s ease, transform .6s ease;
}
.scroll-animate.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ── Balance Hero Glow ── */
.hw-balance {
  animation: glow-pulse-gold 3.5s ease-in-out infinite;
}

/* ── Animated gradient hero backgrounds ── */
.hw-hero,
.portal-dash-hero {
  background-size: 250% 250% !important;
  animation: gradient-shift 10s ease infinite;
}

/* ── Portal dashboard hero ── */
.portal-dash-hero {
  background: linear-gradient(135deg, #1a1f2e 0%, #1e2a4a 35%, #2d1f4a 65%, #1a2a3a 100%);
  background-size: 300% 300%;
  animation: gradient-shift 12s ease infinite;
  border-radius: 14px;
  padding: 1.75rem 2rem;
  margin-bottom: 1.5rem;
  color: white;
  position: relative;
  overflow: hidden;
}
.portal-dash-hero::before {
  content: '';
  position: absolute;
  top: -50px; right: -50px;
  width: 200px; height: 200px;
  border-radius: 50%;
  border: 2px solid rgba(99,102,241,.25);
  animation: ring-pulse 3.5s ease-out infinite;
  pointer-events: none;
}
.portal-dash-hero::after {
  content: '';
  position: absolute;
  bottom: -30px; left: -30px;
  width: 150px; height: 150px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(212,161,46,.15) 0%, transparent 70%);
  pointer-events: none;
}
.portal-dash-hero h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.55rem;
  font-weight: 800;
  margin: 0 0 .35rem;
}
.portal-dash-hero p { opacity: .72; font-size: .88rem; margin: 0; }

/* ── Hero inner rings ── */
.hw-hero {
  position: relative;
}
.hw-hero::before {
  content: '';
  position: absolute;
  right: -70px; top: -70px;
  width: 220px; height: 220px;
  border-radius: 50%;
  border: 2px solid rgba(212,161,46,.2);
  animation: ring-pulse-slow 4s ease-out infinite;
  pointer-events: none;
}

/* ── Shimmer Button ── */
.hw-btn-primary,
.btn-primary,
.btn-success,
.btn-amber {
  position: relative;
  overflow: hidden;
}
.hw-btn-primary::after,
.btn-primary::after,
.btn-success::after,
.btn-amber::after {
  content: '';
  position: absolute;
  top: 0; left: -70%;
  width: 50%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.28), transparent);
  transform: skewX(-20deg);
  pointer-events: none;
}
.hw-btn-primary:hover::after,
.btn-primary:hover::after,
.btn-success:hover::after,
.btn-amber:hover::after {
  animation: shimmer-sweep .6s ease-in-out forwards;
}

/* ── Card Lift & Hover ── */
.stat-card,
.card,
.hw-feat-tile,
.milestone-mini-item {
  transition: transform .25s cubic-bezier(.4,0,.2,1),
              box-shadow .25s cubic-bezier(.4,0,.2,1),
              border-color .25s ease;
}

.stat-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 14px 36px rgba(99,102,241,.18), 0 4px 12px rgba(0,0,0,.08);
}

.hw-feat-tile:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 28px rgba(27,77,142,.14), 0 4px 10px rgba(0,0,0,.07);
  border-color: #a5b4fc !important;
}

.card:hover {
  box-shadow: 0 8px 26px rgba(0,0,0,.09);
}

.milestone-mini-item:hover {
  transform: translateX(4px);
  background: #f0f5ff !important;
}

/* ── Stat icon glow on card hover ── */
.stat-card:hover .stat-icon.indigo { box-shadow: 0 0 0 5px rgba(99,102,241,.2); transition: box-shadow .25s; }
.stat-card:hover .stat-icon.green  { box-shadow: 0 0 0 5px rgba(16,185,129,.2); transition: box-shadow .25s; }
.stat-card:hover .stat-icon.amber  { box-shadow: 0 0 0 5px rgba(245,158,11,.2); transition: box-shadow .25s; }
.stat-card:hover .stat-icon.red    { box-shadow: 0 0 0 5px rgba(239,68,68,.2);  transition: box-shadow .25s; }
.stat-card:hover .stat-icon.blue   { box-shadow: 0 0 0 5px rgba(59,130,246,.2); transition: box-shadow .25s; }
.stat-icon { transition: box-shadow .25s; }

/* ── Notification badge pulse ── */
.badge-count {
  animation: badge-pulse 2s ease-in-out infinite;
}

/* ── Pulsing live dot ── */
.live-dot {
  display: inline-block;
  width: 8px; height: 8px;
  background: #10b981;
  border-radius: 50%;
  animation: badge-pulse 2.2s ease-in-out infinite;
  vertical-align: middle;
  margin-right: .3rem;
  box-shadow: 0 0 0 0 rgba(16,185,129,.5);
}
@keyframes badge-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,.55); }
  50%       { box-shadow: 0 0 0 7px rgba(239,68,68,0); }
}
.live-dot {
  animation: live-dot-pulse 2.2s ease-in-out infinite;
}
@keyframes live-dot-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16,185,129,.55); }
  50%       { box-shadow: 0 0 0 5px rgba(16,185,129,0); }
}

/* ── Portal brand icon glow ── */
.portal-brand-icon {
  animation: neon-glow-indigo 4.5s ease-in-out infinite;
}

/* ── Logo mark glow ── */
.logo-mark,
.logo-mark-light {
  animation: gold-logo-glow 4.5s ease-in-out infinite;
}

/* ── Sidebar nav active state glow ── */
.portal-nav a.active {
  box-shadow: inset 3px 0 12px rgba(99,102,241,.12);
}

/* ── Table row hover ── */
tbody tr {
  transition: background .18s ease;
}
tbody tr:hover td {
  background: #f5f8ff;
}

/* ── Number counter pop ── */
.pop-number {
  animation: number-pop .45s cubic-bezier(.36,.07,.19,.97);
}

/* ── Ripple effect ── */
.ripple-container { position: relative; overflow: hidden; }
.ripple-circle {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,.32);
  transform: scale(0);
  animation: ripple-effect .65s linear;
  pointer-events: none;
}

/* ── Sparkle star ── */
.sparkle-star {
  position: absolute;
  background: #D4A12E;
  clip-path: polygon(50% 0%,61% 35%,98% 35%,68% 57%,79% 91%,50% 70%,21% 91%,32% 57%,2% 35%,39% 35%);
  animation: sparkle-burst 1.4s ease-out forwards;
  pointer-events: none;
  z-index: 10;
}

/* ── Glowing focus ring ── */
.form-control:focus,
input:focus,
select:focus,
textarea:focus {
  box-shadow: 0 0 0 3px rgba(99,102,241,.22) !important;
  border-color: #6366f1 !important;
  outline: none;
}

/* ── Toast / message slide-in ── */
.messages-list li {
  animation: slide-in-right .4s cubic-bezier(.36,.07,.19,.97) both;
}

/* ── Approval success flash ── */
.approve-flash {
  animation: success-flash .9s ease;
}

/* ── Glow button variants ── */
.btn-glow-gold {
  box-shadow: 0 0 0 0 rgba(212,161,46,0);
  transition: box-shadow .3s ease, transform .2s ease;
}
.btn-glow-gold:hover {
  box-shadow: 0 0 22px rgba(212,161,46,.55), 0 5px 14px rgba(212,161,46,.3);
  transform: translateY(-2px);
}

.btn-glow-indigo {
  box-shadow: 0 0 0 0 rgba(99,102,241,0);
  transition: box-shadow .3s ease, transform .2s ease;
}
.btn-glow-indigo:hover {
  box-shadow: 0 0 22px rgba(99,102,241,.55), 0 5px 14px rgba(99,102,241,.3);
  transform: translateY(-2px);
}

.btn-glow-green {
  box-shadow: 0 0 0 0 rgba(16,185,129,0);
  transition: box-shadow .3s ease, transform .2s ease;
}
.btn-glow-green:hover {
  box-shadow: 0 0 20px rgba(16,185,129,.55), 0 5px 12px rgba(16,185,129,.3);
  transform: translateY(-2px);
}

/* ── Glow card border accents ── */
.glow-border-indigo { box-shadow: 0 0 0 1.5px rgba(99,102,241,.45), 0 0 18px rgba(99,102,241,.12); }
.glow-border-gold   { box-shadow: 0 0 0 1.5px rgba(212,161,46,.45),  0 0 18px rgba(212,161,46,.12); }
.glow-border-green  { box-shadow: 0 0 0 1.5px rgba(16,185,129,.45),  0 0 18px rgba(16,185,129,.12); }

/* ── Confetti pieces ── */
.confetti-piece {
  position: fixed;
  border-radius: 2px;
  animation: confetti-fall linear forwards;
  pointer-events: none;
  z-index: 9999;
}

/* ── Score/points "pop" on change ── */
@keyframes pts-pop {
  0%   { transform: scale(1); color: inherit; }
  50%  { transform: scale(1.35); color: #D4A12E; }
  100% { transform: scale(1); color: inherit; }
}
.pts-pop { animation: pts-pop .5s ease; }

/* ── Wallet hero balance shimmer overlay ── */
.hw-hero-balance-wrap {
  position: relative;
  display: inline-block;
}
.hw-hero-balance-wrap::after {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.18), transparent);
  transform: skewX(-15deg);
  animation: shimmer-sweep 3s ease-in-out infinite;
  pointer-events: none;
}

/* ── Animated gradient text ── */
.text-gradient-gold {
  background: linear-gradient(90deg, #D4A12E, #f0c95e, #D4A12E);
  background-size: 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer 3s linear infinite;
}

.text-gradient-indigo {
  background: linear-gradient(90deg, #6366f1, #a78bfa, #6366f1);
  background-size: 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer 3s linear infinite;
}

/* ── Pending milestone count badge extra pulse ── */
.milestone-pending-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ef4444;
  color: #fff;
  border-radius: 999px;
  font-size: .68rem;
  font-weight: 700;
  min-width: 20px;
  padding: .15rem .45rem;
  animation: badge-pulse 2s ease-in-out infinite;
  margin-left: auto;
}

/* ── Flow steps shimmer ── */
.hw-flow-step {
  position: relative;
  overflow: hidden;
}
.hw-flow-step::after {
  content: '';
  position: absolute;
  top: 0; left: -60%;
  width: 40%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.15), transparent);
  animation: shimmer-sweep 4s ease-in-out infinite;
  pointer-events: none;
}

/* ── QR scan animation ── */
.qr-scan-line {
  animation: scan-line 1.8s ease-in-out infinite alternate;
}

/* ── Spinning loader ── */
.spin { animation: rotate-slow .8s linear infinite; }

/* ── Page-level fade on load ── */
body {
  animation: fade-in .35s ease both;
}

/* ── Portal sidebar nav hover slide ── */
.portal-nav a {
  position: relative;
  overflow: hidden;
}
.portal-nav a::before {
  content: '';
  position: absolute;
  left: 0; top: 0;
  width: 0; height: 100%;
  background: rgba(99,102,241,.1);
  border-radius: 8px;
  transition: width .22s ease;
  z-index: -1;
}
.portal-nav a:hover::before {
  width: 100%;
}

/* ── Wallet sidebar nav hover ── */
.admin-nav-item {
  position: relative;
  overflow: hidden;
}
.admin-nav-item::before {
  content: '';
  position: absolute;
  left: 0; top: 0;
  width: 0; height: 100%;
  background: rgba(255,255,255,.1);
  border-radius: 6px;
  transition: width .22s ease;
  z-index: -1;
}
.admin-nav-item:hover::before {
  width: 100%;
}

/* ── Section header accent line ── */
.section-accent-bar {
  display: inline-block;
  width: 36px; height: 4px;
  background: linear-gradient(90deg, #D4A12E, #6366f1);
  border-radius: 2px;
  margin-bottom: .6rem;
  animation: shimmer 3s linear infinite;
  background-size: 200%;
}

/* ── Avatar initial glow ── */
.portal-user-avatar {
  transition: box-shadow .25s ease;
}
.portal-user-avatar:hover {
  box-shadow: 0 0 0 3px rgba(212,161,46,.5);
}

/* ── Input field shake on error ── */
@keyframes input-shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-5px); }
  40%       { transform: translateX(5px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(4px); }
}
.input-error {
  animation: input-shake .45s ease;
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 3px rgba(239,68,68,.18) !important;
}

/* ── Particle dots background ── */
.particle-bg {
  position: absolute; inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.particle-dot {
  position: absolute;
  border-radius: 50%;
  background: rgba(212,161,46,.35);
  animation: float-gentle var(--dur, 6s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}

/* ── Hover scale for feature icons ── */
.hw-feat-icon {
  transition: transform .2s ease, box-shadow .2s ease;
}
.hw-feat-tile:hover .hw-feat-icon {
  transform: scale(1.15) rotate(-4deg);
  box-shadow: 0 4px 12px rgba(27,77,142,.2);
}

/* ── Store item card shine ── */
.store-item-card,
.store-card {
  position: relative;
  overflow: hidden;
}
.store-item-card::before,
.store-card::before {
  content: '';
  position: absolute;
  top: -100%; left: -100%;
  width: 60%;
  height: 300%;
  background: linear-gradient(135deg, transparent, rgba(255,255,255,.12), transparent);
  transform: rotate(30deg);
  transition: left .5s ease, top .5s ease;
  pointer-events: none;
}
.store-item-card:hover::before,
.store-card:hover::before {
  left: 130%;
  top: -100%;
}

/* ── Responsive: reduce motion for accessibility ── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
