/* =============================================================================
   V1 micro-interactions polish
   Desktop-enhanced; respects prefers-reduced-motion. No layout redesign.
   ============================================================================= */

/* --- Scroll progress (top bar) --------------------------------------------- */
#scrollProgress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  z-index: 200;
  pointer-events: none;
  background: linear-gradient(90deg, #2D8B4E, #F5922A, #E8751A);
  box-shadow: 0 0 12px rgba(232, 117, 26, 0.35);
  transition: width 0.05s linear;
}

/* --- Stronger scroll-reveal (builds on existing .scroll-reveal) ------------ */
@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(40px) scale(0.985);
    filter: blur(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

@supports (animation-timeline: view()) {
  .scroll-reveal {
    animation: reveal 1.15s cubic-bezier(0.22, 1, 0.36, 1) both;
    animation-timeline: view();
    animation-range: entry 5% cover 28%;
  }
}

@supports not (animation-timeline: view()) {
  .scroll-reveal {
    animation: reveal 0.95s cubic-bezier(0.22, 1, 0.36, 1) both;
  }
}

/* --- Softer donate pulse -------------------------------------------------- */
@keyframes pulse-glow {
  0%,
  100% {
    box-shadow: 0 0 14px rgba(232, 117, 26, 0.14);
  }
  50% {
    box-shadow: 0 0 22px rgba(232, 117, 26, 0.26);
  }
}

.pulse-glow {
  animation: pulse-glow 2.8s ease-in-out infinite;
}

/* Nav Donate must never pulse or drift */
#navbar .nav-donate-btn,
#navbar .pulse-glow,
#mobileMenu .nav-donate-btn {
  animation: none !important;
  transform: none !important;
}

/* --- Card hover lift (stories, animals, donate, special, reels) ----------- */
.donate-card,
#stories .group,
#animalsContainer .group,
#reelsContainer .group {
  transition:
    transform 0.35s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.35s ease,
    border-color 0.3s ease;
}

/* Donate / Special cards: green outline always (not only on hover) */
.donate-card {
  border: 2px solid rgba(45, 139, 78, 0.5) !important;
  box-shadow:
    0 4px 16px -10px rgba(0, 0, 0, 0.08),
    0 0 0 1px rgba(45, 139, 78, 0.06);
}

/* 1) Donate / Special cards: lift + stronger green glow on hover */
@media (hover: hover) and (pointer: fine) {
  .donate-card:hover {
    transform: translateY(-6px);
    border-color: rgba(45, 139, 78, 0.75) !important;
    box-shadow:
      0 18px 40px -18px rgba(0, 0, 0, 0.16),
      0 10px 28px -12px rgba(45, 139, 78, 0.32),
      0 0 0 1px rgba(45, 139, 78, 0.1);
  }

  #stories .group:hover,
  #animalsContainer .group:hover {
    transform: translateY(-6px);
    box-shadow:
      0 18px 40px -18px rgba(0, 0, 0, 0.18),
      0 8px 16px -10px rgba(232, 117, 26, 0.12);
  }

  #reelsContainer .group:hover,
  #reelsContainer a.group:hover,
  #reelsContainer .reel-card:hover {
    transform: translateY(-4px);
  }
}

/* --- Motion reels: Ken Burns on stills, soft play affordance -------------- */
@keyframes reel-kenburns {
  0%   { transform: scale(1) translate(0, 0); }
  50%  { transform: scale(1.12) translate(-2%, -1.5%); }
  100% { transform: scale(1.06) translate(1.5%, 1%); }
}

#reelsContainer .reel-kenburns {
  animation: reel-kenburns 12s ease-in-out infinite alternate;
  will-change: transform;
  transform-origin: center center;
}

#reelsContainer .reel-video {
  background: #111;
}

#reelsContainer .reel-live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 9999px;
  background: #ef4444;
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.55);
  animation: reel-live-pulse 1.6s ease-out infinite;
}

@keyframes reel-live-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.55); opacity: 1; }
  70%  { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); opacity: 0.85; }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); opacity: 1; }
}

/* When a real video is playing, dim the big play button slightly so motion shows */
#reelsContainer .reel-card[data-has-video="1"] .reel-play-btn--video {
  opacity: 0.55;
  transition: opacity 0.3s ease, transform 0.3s ease, background-color 0.2s ease;
}

#reelsContainer .reel-card[data-has-video="1"]:hover .reel-play-btn--video {
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  #reelsContainer .reel-kenburns {
    animation: none;
  }
  #reelsContainer .reel-live-dot {
    animation: none;
  }
}

/* 2) Donate / Special card buttons: tactile press */
.donate-card button {
  transition:
    transform 0.18s cubic-bezier(0.22, 1, 0.36, 1),
    background-color 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease,
    box-shadow 0.2s ease;
}

.donate-card button:active {
  transform: scale(0.97);
}

/* 3) Donation modal enter / exit */
#donateModalOverlay {
  opacity: 0;
  transition: opacity 0.28s ease;
}

.donate-modal-panel {
  opacity: 0;
  transform: scale(0.96) translateY(10px);
  transition:
    opacity 0.32s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

#donateModal.modal-open #donateModalOverlay {
  opacity: 1;
}

#donateModal.modal-open .donate-modal-panel {
  opacity: 1;
  transform: scale(1) translateY(0);
}

#donateModal.modal-closing #donateModalOverlay {
  opacity: 0;
  transition-duration: 0.2s;
}

#donateModal.modal-closing .donate-modal-panel {
  opacity: 0;
  transform: scale(0.97) translateY(6px);
  transition-duration: 0.2s;
  transition-timing-function: ease-in;
}

/* --- Custom cursor (desktop only, enabled via body class) ----------------- */
@media (hover: hover) and (pointer: fine) {
  body.polish-cursor {
    cursor: none;
  }

  body.polish-cursor a,
  body.polish-cursor button,
  body.polish-cursor [role='button'],
  body.polish-cursor label,
  body.polish-cursor .donate-card,
  body.polish-cursor .story-btn,
  body.polish-cursor .animal-story-btn {
    cursor: none;
  }

  /* Forms keep a normal caret/cursor for usability */
  body.polish-cursor input,
  body.polish-cursor textarea,
  body.polish-cursor select {
    cursor: text;
  }

  body.polish-cursor select {
    cursor: pointer;
  }
}

#cursorDot,
#cursorRing {
  position: fixed;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 9999;
  border-radius: 9999px;
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 0.25s ease;
}

body.polish-cursor-active #cursorDot,
body.polish-cursor-active #cursorRing {
  opacity: 1;
}

#cursorDot {
  width: 6px;
  height: 6px;
  background: #e8751a;
  box-shadow: 0 0 10px rgba(232, 117, 26, 0.55);
  mix-blend-mode: normal;
}

#cursorRing {
  width: 28px;
  height: 28px;
  border: 1.5px solid rgba(232, 117, 26, 0.55);
  background: rgba(232, 117, 26, 0.06);
  box-shadow: 0 0 18px rgba(232, 117, 26, 0.18);
  transition:
    width 0.22s ease,
    height 0.22s ease,
    background 0.22s ease,
    border-color 0.22s ease,
    box-shadow 0.22s ease;
}

/* Hover morph on interactive targets */
body.polish-cursor-hover #cursorRing {
  width: 44px;
  height: 44px;
  border-color: rgba(45, 139, 78, 0.5);
  background: rgba(45, 139, 78, 0.08);
  box-shadow: 0 0 22px rgba(45, 139, 78, 0.2);
}

body.polish-cursor-cta #cursorRing {
  width: 52px;
  height: 52px;
  border-color: rgba(232, 117, 26, 0.75);
  background: rgba(232, 117, 26, 0.12);
  box-shadow: 0 0 28px rgba(232, 117, 26, 0.28);
}

/* Click spark container */
#cursorSparks {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9998;
  overflow: hidden;
}

.cursor-spark {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: #e8751a;
  box-shadow: 0 0 8px rgba(232, 117, 26, 0.7);
  pointer-events: none;
  animation: spark-fly 0.55s ease-out forwards;
}

.cursor-spark.alt {
  background: #2d8b4e;
  box-shadow: 0 0 8px rgba(45, 139, 78, 0.65);
}

@keyframes spark-fly {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(var(--sx), var(--sy)) scale(0.2);
  }
}

/* --- Hero dust particles (canvas) ----------------------------------------- */
#heroDust {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
  opacity: 0.55;
}

#hero > .relative.max-w-7xl {
  z-index: 3;
}

/* --- Special Days cursor-reactive gradient -------------------------------- */
#special {
  position: relative;
  isolation: isolate;
}

#specialGradient {
  position: absolute;
  inset: -20% -10%;
  pointer-events: none;
  z-index: 0;
  opacity: 0.55;
  background:
    radial-gradient(
      520px circle at var(--sgx, 50%) var(--sgy, 40%),
      rgba(232, 117, 26, 0.16),
      rgba(245, 146, 42, 0.08) 28%,
      rgba(45, 139, 78, 0.06) 48%,
      transparent 70%
    );
  transition: opacity 0.4s ease;
}

#special > .relative,
#special > .max-w-7xl {
  position: relative;
  z-index: 1;
}

/* Magnetic CTAs subtle transition */
.magnetic-cta {
  will-change: transform;
  transition: transform 0.2s ease-out;
}

/* Reduced motion: kill extras */
@media (prefers-reduced-motion: reduce) {
  #scrollProgress {
    display: none;
  }

  .scroll-reveal {
    animation: none !important;
    opacity: 1 !important;
    filter: none !important;
    transform: none !important;
  }

  .pulse-glow,
  .float-anim,
  .heartbeat {
    animation: none !important;
  }

  body.polish-cursor,
  body.polish-cursor a,
  body.polish-cursor button {
    cursor: auto !important;
  }

  #cursorDot,
  #cursorRing,
  #cursorSparks,
  #heroDust,
  #specialGradient {
    display: none !important;
  }

  .donate-card:hover,
  #stories .group:hover,
  #animalsContainer .group:hover {
    transform: none !important;
  }

  .donate-card button:active {
    transform: none !important;
  }

  #donateModalOverlay,
  .donate-modal-panel {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
}
