/**
 * Spooky Visitor overlays - scoped under .hr-hv-root (fixed, high z-index, no pointer capture).
 */

.hr-hv-root {
  position: fixed;
  inset: 0;
  z-index: 99980;
  pointer-events: none;
  overflow: hidden;
}

.hr-hv-root *,
.hr-hv-root *::before,
.hr-hv-root *::after {
  pointer-events: none;
  box-sizing: border-box;
}

/* --- Peeking eyes (footer corners) --- */
.hr-hv-eyes {
  position: fixed;
  bottom: 0.5rem;
  width: 56px;
  height: 28px;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  opacity: 0.85;
  z-index: 99981;
}

.hr-hv-eyes--left {
  left: 1rem;
}

.hr-hv-eyes--right {
  right: 1rem;
}

.hr-hv-eye {
  width: 18px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(ellipse at 30% 30%, #ff4444, #600 70%);
  box-shadow: 0 0 12px rgba(255, 60, 60, 0.9), 0 0 24px rgba(200, 0, 0, 0.5);
  animation: hr-hv-blink 4.2s ease-in-out infinite;
}

.hr-hv-eyes--right .hr-hv-eye {
  animation-delay: 1.1s;
}

.hr-hv-eyes--right .hr-hv-eye:last-child {
  animation-delay: 2.3s;
}

@keyframes hr-hv-blink {
  0%,
  40%,
  100% {
    opacity: 1;
    transform: scaleY(1);
  }
  48% {
    opacity: 0.15;
    transform: scaleY(0.12);
  }
  55% {
    opacity: 1;
    transform: scaleY(1);
  }
}

/* --- Spider on thread --- */
.hr-hv-spider-wrap {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: 0;
  z-index: 99982;
  transition: height 0.1s linear;
}

.hr-hv-spider-thread {
  position: absolute;
  top: 0;
  left: 0;
  width: 2px;
  height: 120vh;
  max-height: 120vh;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.55), rgba(40, 40, 40, 0.35));
  transition: height 0.35s ease, max-height 0.35s ease, opacity 0.35s ease;
}

/* Thread and spider stay hidden until idle drop or during climb-up */
.hr-hv-spider-wrap:not(.hr-hv-spider--dropped):not(.hr-hv-spider--climbing) .hr-hv-spider-thread {
  height: 0;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
}

.hr-hv-spider-wrap:not(.hr-hv-spider--dropped):not(.hr-hv-spider--climbing) .hr-hv-spider {
  opacity: 0;
  visibility: hidden;
}

.hr-hv-spider {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 28px;
  height: 22px;
  margin-left: -14px;
  margin-bottom: -2px;
  background: radial-gradient(circle at 40% 35%, #1a1a1a, #0a0a0a 70%);
  border-radius: 45% 55% 40% 60%;
  box-shadow: inset -2px -2px 0 rgba(0, 0, 0, 0.5);
  transform-origin: top center;
  transition: transform 3.8s ease-in, bottom 3.8s ease-in;
}

.hr-hv-spider--dropped .hr-hv-spider {
  bottom: -35vh;
  transition: bottom 4s ease-in, transform 4s ease-in;
}

.hr-hv-spider--climbing .hr-hv-spider {
  bottom: 0;
  transition: bottom 2.4s ease-out, transform 2.4s ease-out;
}

/* --- Ghost drift --- */
.hr-hv-ghost {
  position: fixed;
  left: -12vw;
  bottom: 8vh;
  width: 72px;
  height: 88px;
  opacity: 0.35;
  z-index: 99979;
  background: radial-gradient(ellipse 50% 40% at 50% 25%, rgba(255, 255, 255, 0.5), rgba(240, 240, 255, 0.08) 55%, transparent 70%);
  border-radius: 50% 50% 45% 45%;
  filter: blur(0.5px);
  animation: hr-hv-ghost-drift 22s linear forwards;
}

@keyframes hr-hv-ghost-drift {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 0;
  }
  8% {
    opacity: 0.4;
  }
  92% {
    opacity: 0.35;
  }
  100% {
    transform: translate(115vw, -75vh) scale(1.05);
    opacity: 0;
  }
}

/* --- Bat (one-shot animation class on element) --- */
.hr-hv-bat {
  position: fixed;
  width: 36px;
  height: 20px;
  z-index: 99983;
  background: #0a0a0a;
  border-radius: 40% 60% 50% 50%;
  box-shadow: inset 0 -2px 0 #222;
  animation: hr-hv-bat-jagged 2.6s linear forwards;
}

.hr-hv-bat::before,
.hr-hv-bat::after {
  content: '';
  position: absolute;
  top: -6px;
  width: 18px;
  height: 10px;
  background: #0a0a0a;
  border-radius: 50% 50% 0 0;
}

.hr-hv-bat::before {
  left: 2px;
  transform: rotate(-25deg);
}

.hr-hv-bat::after {
  right: 2px;
  transform: rotate(25deg);
}

@keyframes hr-hv-bat-jagged {
  0% {
    transform: translate(-8vw, 70vh) rotate(12deg);
    opacity: 1;
  }
  18% {
    transform: translate(22vw, 42vh) rotate(-18deg);
  }
  38% {
    transform: translate(48vw, 58vh) rotate(22deg);
  }
  58% {
    transform: translate(62vw, 28vh) rotate(-14deg);
  }
  78% {
    transform: translate(85vw, 48vh) rotate(16deg);
  }
  100% {
    transform: translate(108vw, -5vh) rotate(-8deg);
    opacity: 0;
  }
}

/* --- Fog --- */
.hr-hv-fog {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 22vh;
  z-index: 99978;
  opacity: 0;
  background: repeating-linear-gradient(
    90deg,
    rgba(180, 180, 200, 0.07) 0 80px,
    rgba(120, 120, 140, 0.04) 80px 200px
  );
  pointer-events: none;
}

.hr-hv-fog--roll {
  animation: hr-hv-fog-roll 14s linear forwards;
}

@keyframes hr-hv-fog-roll {
  0% {
    opacity: 0;
    transform: translateX(-30%);
  }
  12% {
    opacity: 0.55;
  }
  88% {
    opacity: 0.5;
  }
  100% {
    opacity: 0;
    transform: translateX(30%);
  }
}

/* --- Scratch overlay --- */
.hr-hv-scratch {
  position: fixed;
  inset: 0;
  z-index: 99984;
  opacity: 0;
  background: repeating-linear-gradient(
    125deg,
    transparent 0 40px,
    rgba(255, 255, 255, 0.04) 40px 41px,
    transparent 41px 120px
  );
  animation: hr-hv-scratch-fade 2.2s ease-out forwards;
}

@keyframes hr-hv-scratch-fade {
  0% {
    opacity: 0;
  }
  15% {
    opacity: 0.45;
  }
  70% {
    opacity: 0.25;
  }
  100% {
    opacity: 0;
  }
}

/* --- Cursor ectoplasm dot --- */
.hr-hv-trail-dot {
  position: fixed;
  width: 5px;
  height: 5px;
  margin: -2px 0 0 -2px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  z-index: 99977;
  animation: hr-hv-trail-fade 0.55s ease-out forwards;
}

@keyframes hr-hv-trail-fade {
  to {
    opacity: 0;
    transform: scale(0.3);
  }
}

/* --- Peeker --- */
.hr-hv-peeker {
  position: fixed;
  left: 0;
  top: 38%;
  width: 48px;
  height: 56px;
  z-index: 99981;
  transform: translateX(-100%);
  transition: transform 1.4s ease-out;
  background: radial-gradient(circle at 60% 35%, #3a2020, #120808 65%);
  border-radius: 0 50% 50% 0;
  box-shadow: 4px 0 12px rgba(0, 0, 0, 0.4);
}

.hr-hv-peeker--out {
  transform: translateX(0);
}

.hr-hv-peeker--retreat {
  transform: translateX(-100%);
  transition: transform 0.5s ease-in;
}

@media (prefers-reduced-motion: reduce) {
  .hr-hv-root .hr-hv-ghost,
  .hr-hv-root .hr-hv-bat,
  .hr-hv-root .hr-hv-fog--roll,
  .hr-hv-root .hr-hv-scratch {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }

  .hr-hv-spider,
  .hr-hv-spider--dropped .hr-hv-spider,
  .hr-hv-spider--climbing .hr-hv-spider {
    transition-duration: 0.01ms !important;
  }
}
