/* Herramientas — bosque, lenador, carrito y hoguera | Motion CSS optimizado */
/* --hr-smooth: desaceleración natural (caminar, fuego, pinos) */
/* --hr-bounce: rebote elástico (hacha, tronco, chispas) */

.herr-scene {
  --hr-smooth: cubic-bezier(0.22, 1, 0.36, 1);
  --hr-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --hr-loop: 14s;

  position: relative;
  width: 100%;
  border-radius: 1.25rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #050a0f;
  overflow: hidden;
  box-shadow: 0 0 40px rgba(16, 185, 129, 0.12);
}

.herr-scene--hero {
  max-width: none;
  margin-inline: 0;
  height: 100%;
  min-height: 100%;
}

.herr-scene__svg {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 16rem;
}

/* —— GPU —— */
.hr3-enter,
.hr3-actor,
.hr3-arm,
.hr3-axe,
.hr3-cart,
.hr3-pine-top,
.hr3-log-fly,
.hr3-log-hand,
.hr3-fire,
.hr3-pine,
.hr3-spark {
  will-change: transform;
}

.hr3-star,
.hr3-chop-dust,
.hr3-cart-log,
.hr3-fire-glow,
.hr3-fire-outer,
.hr3-fire-mid,
.hr3-fire-core {
  will-change: transform, opacity;
}

/* —— Entrada stagger —— */
.hr3-enter {
  opacity: 0;
  transform: translate3d(0, 20px, 0);
  animation: hr3EnterIn 0.9s var(--hr-smooth) forwards;
}

.hr3-enter--sky { animation-delay: 0s; }
.hr3-enter--forest { animation-delay: 0.08s; }
.hr3-enter--fire { animation-delay: 0.16s; }

@keyframes hr3EnterIn {
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

/* —— Bosque —— */
.hr3-pine {
  transform-origin: center bottom;
  transform-box: fill-box;
  animation: hr3PineSway 9s var(--hr-smooth) infinite;
}

.hr3-pine--bg2 {
  animation-delay: 1.4s;
  animation-duration: 10.5s;
}

@keyframes hr3PineSway {
  0%,
  100% {
    transform: rotate(0deg);
  }
  50% {
    transform: rotate(1deg);
  }
}

.hr3-star {
  transform-origin: center;
  animation: hr3StarTwinkle 3.6s var(--hr-smooth) infinite;
}

.hr3-star--2 { animation-delay: 0.55s; }
.hr3-star--3 { animation-delay: 1.1s; }

.hr3-moon {
  transform-origin: 1000px 48px;
  transform-box: fill-box;
  animation: hr3MoonPulse 6s var(--hr-smooth) infinite;
}

@keyframes hr3StarTwinkle {
  0%,
  100% {
    opacity: 0.25;
    transform: scale(0.85);
  }
  50% {
    opacity: 1;
    transform: scale(1.15);
  }
}

@keyframes hr3MoonPulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.9;
  }
  50% {
    transform: scale(1.05);
    opacity: 1;
  }
}

/* —— Pino: corte y caida —— */
.hr3-pine-top {
  transform-origin: 279px 198px;
  transform-box: fill-box;
  animation: hr3PineFall var(--hr-loop) var(--hr-bounce) infinite;
}

.hr3-chop-dust {
  transform-origin: 279px 210px;
  animation: hr3ChopDust var(--hr-loop) var(--hr-smooth) infinite;
}

@keyframes hr3PineFall {
  0%,
  12% {
    opacity: 1;
    transform: translate3d(0, 0, 0) rotate(0deg);
  }
  14% {
    opacity: 1;
    transform: translate3d(0, 0, 0) rotate(-2deg);
  }
  20% {
    opacity: 0.85;
    transform: translate3d(18px, 28px, 0) rotate(18deg);
  }
  26%,
  100% {
    opacity: 0;
    transform: translate3d(32px, 55px, 0) rotate(32deg);
  }
}

@keyframes hr3ChopDust {
  0%,
  11%,
  100% {
    opacity: 0;
    transform: scale(0.5);
  }
  14% {
    opacity: 0.5;
    transform: scale(1);
  }
  22% {
    opacity: 0;
    transform: scale(1.4);
  }
}

/* —— Hombre: recorrido completo —— */
.hr3-actor {
  transform: translate3d(279px, 232px, 0);
  animation: hr3ActorJourney var(--hr-loop) var(--hr-smooth) infinite;
}

@keyframes hr3ActorJourney {
  0%,
  10% {
    transform: translate3d(279px, 232px, 0);
  }
  20% {
    transform: translate3d(460px, 232px, 0);
  }
  28%,
  34% {
    transform: translate3d(460px, 232px, 0);
  }
  38% {
    transform: translate3d(500px, 232px, 0);
  }
  62% {
    transform: translate3d(800px, 232px, 0);
  }
  68%,
  74% {
    transform: translate3d(800px, 232px, 0);
  }
  88%,
  100% {
    transform: translate3d(279px, 232px, 0);
  }
}

.hr3-arm {
  transform-origin: 10px -6px;
  transform-box: fill-box;
  animation: hr3ArmChop var(--hr-loop) var(--hr-bounce) infinite;
}

@keyframes hr3ArmChop {
  0%,
  8% {
    transform: rotate(-48deg);
  }
  4% {
    transform: rotate(32deg);
  }
  6% {
    transform: rotate(-38deg);
  }
  10% {
    transform: rotate(28deg);
  }
  12%,
  100% {
    transform: rotate(-12deg);
  }
}

.hr3-log-hand {
  animation: hr3LogHand var(--hr-loop) var(--hr-smooth) infinite;
}

@keyframes hr3LogHand {
  0%,
  18%,
  100% {
    opacity: 0;
  }
  22%,
  32% {
    opacity: 1;
  }
  36% {
    opacity: 0;
  }
}

/* —— Carrito —— */
.hr3-cart {
  transform: translate3d(468px, 240px, 0);
  animation: hr3CartMove var(--hr-loop) var(--hr-smooth) infinite;
}

@keyframes hr3CartMove {
  0%,
  36% {
    transform: translate3d(468px, 240px, 0);
  }
  62% {
    transform: translate3d(800px, 240px, 0);
  }
  88%,
  100% {
    transform: translate3d(468px, 240px, 0);
  }
}

.hr3-cart-log--1 {
  animation: hr3CartLog1 var(--hr-loop) var(--hr-smooth) infinite;
}

.hr3-cart-log--2 {
  animation: hr3CartLog2 var(--hr-loop) var(--hr-smooth) infinite;
}

.hr3-cart-log--3 {
  animation: hr3CartLog3 var(--hr-loop) var(--hr-smooth) infinite;
}

@keyframes hr3CartLog1 {
  0%,
  32%,
  100% {
    opacity: 0;
    transform: translate3d(0, 10px, 0);
  }
  36%,
  88% {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

@keyframes hr3CartLog2 {
  0%,
  34%,
  100% {
    opacity: 0;
    transform: translate3d(0, 10px, 0);
  }
  38%,
  88% {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

@keyframes hr3CartLog3 {
  0%,
  36%,
  100% {
    opacity: 0;
    transform: translate3d(0, 10px, 0);
  }
  40%,
  88% {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

/* —— Tronco volando a la hoguera —— */
.hr3-log-fly {
  transform: translate3d(800px, 232px, 0);
  animation: hr3LogThrow var(--hr-loop) var(--hr-bounce) infinite;
}

@keyframes hr3LogThrow {
  0%,
  60%,
  100% {
    opacity: 0;
    transform: translate3d(800px, 232px, 0) rotate(0deg);
  }
  61% {
    opacity: 1;
    transform: translate3d(800px, 228px, 0) rotate(-6deg);
  }
  63% {
    opacity: 0;
    transform: translate3d(940px, 258px, 0) rotate(18deg);
  }
  64% {
    opacity: 1;
    transform: translate3d(800px, 228px, 0) rotate(-6deg);
  }
  66% {
    opacity: 0;
    transform: translate3d(960px, 260px, 0) rotate(20deg);
  }
  67% {
    opacity: 1;
    transform: translate3d(800px, 228px, 0) rotate(-6deg);
  }
  69% {
    opacity: 0;
    transform: translate3d(978px, 262px, 0) rotate(10deg);
  }
}

/* —— Hoguera: crece con cada tiro —— */
.hr3-fire {
  transform: translate3d(980px, 268px, 0) scale(1);
  transform-origin: 0 0;
  animation: hr3FireGrow var(--hr-loop) var(--hr-smooth) infinite;
}

@keyframes hr3FireGrow {
  0%,
  60% {
    transform: translate3d(980px, 268px, 0) scale(1);
  }
  62% {
    transform: translate3d(980px, 267px, 0) scale(1.12);
  }
  64% {
    transform: translate3d(980px, 266px, 0) scale(1.22);
  }
  66% {
    transform: translate3d(980px, 265px, 0) scale(1.32);
  }
  68% {
    transform: translate3d(980px, 263px, 0) scale(1.42);
  }
  72%,
  88% {
    transform: translate3d(980px, 262px, 0) scale(1.48);
  }
  100% {
    transform: translate3d(980px, 268px, 0) scale(1);
  }
}

.hr3-fire-core,
.hr3-fire-mid,
.hr3-fire-outer {
  transform-origin: 0 -20px;
  animation: hr3FireFlicker 1.8s var(--hr-smooth) infinite;
}

.hr3-fire-mid { animation-delay: 0.2s; }
.hr3-fire-outer { animation-delay: 0.4s; }

@keyframes hr3FireFlicker {
  0%,
  100% {
    opacity: 0.88;
    transform: scaleY(1) scaleX(1);
  }
  45% {
    opacity: 1;
    transform: scaleY(1.08) scaleX(1.04);
  }
  70% {
    opacity: 0.92;
    transform: scaleY(0.96) scaleX(0.98);
  }
}

.hr3-spark {
  transform-origin: center;
  animation: hr3SparkPop 1.4s var(--hr-bounce) infinite;
}

.hr3-spark--2 { animation-delay: 0.35s; }
.hr3-spark--3 { animation-delay: 0.7s; }

@keyframes hr3SparkPop {
  0%,
  100% {
    opacity: 0;
    transform: translate3d(0, 0, 0) scale(0.4);
  }
  50% {
    opacity: 1;
    transform: translate3d(0, -10px, 0) scale(1.2);
  }
}

/* —— Glows HTML —— */
.herr-scene__glow {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(40px);
  will-change: transform, opacity;
}

.herr-scene__glow--left {
  width: 30%;
  height: 65%;
  left: 0;
  top: 20%;
  background: radial-gradient(circle, rgba(52, 211, 153, 0.18), transparent 70%);
  animation: hr3GlowPulse 5s var(--hr-smooth) infinite;
}

.herr-scene__glow--center {
  width: 22%;
  height: 50%;
  left: 38%;
  top: 35%;
  background: radial-gradient(circle, rgba(254, 243, 199, 0.12), transparent 70%);
  animation: hr3GlowPulse 4s var(--hr-smooth) infinite;
  animation-delay: 0.5s;
}

.herr-scene__glow--right {
  width: 28%;
  height: 55%;
  right: 4%;
  bottom: 8%;
  background: radial-gradient(circle, rgba(251, 146, 60, 0.28), transparent 70%);
  animation: hr3GlowFire 3.2s var(--hr-smooth) infinite;
}

@keyframes hr3GlowPulse {
  0%,
  100% {
    opacity: 0.4;
    transform: scale(1);
  }
  50% {
    opacity: 0.75;
    transform: scale(1.06);
  }
}

@keyframes hr3GlowFire {
  0%,
  100% {
    opacity: 0.45;
    transform: scale(1);
  }
  50% {
    opacity: 0.9;
    transform: scale(1.12);
  }
}

@media (prefers-reduced-motion: reduce) {
  .herr-scene *,
  .herr-scene__glow {
    animation: none !important;
    will-change: auto;
  }

  .hr3-enter {
    opacity: 1;
    transform: none;
  }

  .hr3-actor {
    transform: translate3d(500px, 232px, 0);
  }

  .hr3-cart {
    transform: translate3d(468px, 240px, 0);
  }

  .hr3-fire {
    transform: translate3d(980px, 268px, 0) scale(1.15);
  }

  .hr3-cart-log--1,
  .hr3-cart-log--2 {
    opacity: 1;
  }
}
