// Reusable hooks + animated SVG scenes for Homli

const { useState, useEffect, useRef, useMemo, useCallback } = React;

// ---------------- Hook: in-view ----------------
function useInView(options = {}) {
  const ref = useRef(null);
  const [inView, setInView] = useState(false);
  useEffect(() => {
    if (!ref.current) return;
    const io = new IntersectionObserver(([e]) => {
      if (e.isIntersecting) setInView(true);
    }, { threshold: 0.2, ...options });
    io.observe(ref.current);
    return () => io.disconnect();
  }, []);
  return [ref, inView];
}

// ---------------- Hook: mouse parallax ----------------
function useMouseParallax(strength = 12) {
  const [pos, setPos] = useState({ x: 0, y: 0 });
  useEffect(() => {
    // En táctil / pantallas pequeñas no se aplica: un tap genera un mousemove
    // sintético que dejaría los elementos corridos sin posibilidad de reset.
    if (window.matchMedia('(hover: none), (pointer: coarse), (max-width: 720px)').matches) return;
    const handler = (e) => {
      const x = (e.clientX / window.innerWidth - 0.5) * strength;
      const y = (e.clientY / window.innerHeight - 0.5) * strength;
      setPos({ x, y });
    };
    window.addEventListener('mousemove', handler);
    return () => window.removeEventListener('mousemove', handler);
  }, [strength]);
  return pos;
}

// Detección de dispositivo táctil (sin hover real): para no aplicar efectos
// hover que un mousemove sintético dejaría "pegados" al tocar.
const IS_TOUCH = typeof window !== 'undefined' &&
  window.matchMedia('(hover: none), (pointer: coarse)').matches;

// ---------------- Hook: global scroll progress (0..1 across whole page) ----------------
function usePageScroll() {
  const [progress, setProgress] = useState(0);
  const [scrollY, setScrollY] = useState(0);
  useEffect(() => {
    let raf = null;
    const update = () => {
      const max = document.documentElement.scrollHeight - window.innerHeight;
      const y = window.scrollY;
      setScrollY(y);
      setProgress(max > 0 ? Math.min(1, Math.max(0, y / max)) : 0);
      raf = null;
    };
    const handler = () => { if (raf == null) raf = requestAnimationFrame(update); };
    update();
    window.addEventListener('scroll', handler, { passive: true });
    window.addEventListener('resize', handler);
    return () => {
      window.removeEventListener('scroll', handler);
      window.removeEventListener('resize', handler);
      if (raf) cancelAnimationFrame(raf);
    };
  }, []);
  return { progress, scrollY };
}

// ---------------- Hook: per-element scroll progress ----------------
// Returns 0 when element top hits viewport bottom, 1 when element bottom hits viewport top.
// Useful for scroll-driven animations tied to a specific section.
function useScrollProgress(opts = {}) {
  const ref = useRef(null);
  const [p, setP] = useState(0);
  useEffect(() => {
    if (!ref.current) return;
    let raf = null;
    const compute = () => {
      const el = ref.current;
      if (!el) return;
      const rect = el.getBoundingClientRect();
      const vh = window.innerHeight;
      const total = rect.height + vh;
      const scrolled = vh - rect.top;
      const next = Math.min(1, Math.max(0, scrolled / total));
      setP(next);
      raf = null;
    };
    const handler = () => { if (raf == null) raf = requestAnimationFrame(compute); };
    compute();
    window.addEventListener('scroll', handler, { passive: true });
    window.addEventListener('resize', handler);
    return () => {
      window.removeEventListener('scroll', handler);
      window.removeEventListener('resize', handler);
      if (raf) cancelAnimationFrame(raf);
    };
  }, []);
  return [ref, p];
}

// Map a value from one range to another, clamped
function lerp(a, b, t) { return a + (b - a) * Math.min(1, Math.max(0, t)); }
function mapRange(t, inMin, inMax, outMin, outMax) {
  const k = (t - inMin) / (inMax - inMin);
  return lerp(outMin, outMax, k);
}

// ---------------- Homli mark (real isotipo) ----------------
function HomliMark({ color = 'var(--coral)', size = 28 }) {
  return (
    <svg viewBox="0 0 1000 1000" width={size} height={size} style={{ display: 'block' }} aria-hidden="true">
      <path d="M254.13,905.43V94.58c0-2.92,3.15-4.76,5.69-3.32l484.12,273.36c1.2.68,1.94,1.94,1.94,3.32v537.49c0,2.11-1.71,3.81-3.81,3.81h-50.42c-2.11,0-3.82-1.71-3.81-3.82l.61-505.91c0-1.38-.74-2.65-1.94-3.33l-369.08-207.85c-2.54-1.43-5.68.41-5.68,3.32v713.77c0,2.11-1.71,3.81-3.81,3.81h-49.98c-2.11,0-3.81-1.71-3.81-3.81Z" fill={color}/>
      <path d="M401.09,905.44V348.25c0-2.92,3.16-4.75,5.69-3.3l50.36,28.89c1.18.68,1.91,1.94,1.91,3.3v528.3c0,2.1-1.7,3.8-3.8,3.8h-50.36c-2.1,0-3.8-1.7-3.8-3.8Z" fill={color}/>
      <path d="M545.33,906.06v-465.64c0-2.44,3.16-3.97,5.69-2.76l50.36,24.14c1.18.57,1.91,1.62,1.91,2.76v441.5c0,1.76-1.7,3.18-3.8,3.18h-50.36c-2.1,0-3.8-1.42-3.8-3.18Z" fill={color}/>
    </svg>
  );
}

// ---------------- Homli full logo (isotipo + wordmark con tipografía de marca) ----------------
function HomliLogo({ height = 28, isoColor = 'var(--coral)', wordColor = 'var(--ink)' }) {
  return (
    <svg viewBox="220 100 1780 580" height={height} style={{ display: 'block', width: 'auto' }} aria-label="Homli">
      <g fill={isoColor}>
        <path d="M238.51,639.96V128.62c0-1.84,1.98-3,3.59-2.09l305.3,172.39c.76.43,1.22,1.23,1.22,2.09v338.95c0,1.33-1.08,2.4-2.4,2.4h-31.8c-1.33,0-2.41-1.08-2.4-2.41l.38-319.04c0-.87-.47-1.67-1.22-2.1l-232.75-131.07c-1.6-.9-3.58.26-3.58,2.09v450.12c0,1.33-1.08,2.4-2.4,2.4h-31.52c-1.33,0-2.4-1.08-2.4-2.4Z"/>
        <path d="M331.19,639.97v-351.37c0-1.84,1.99-3,3.59-2.08l31.76,18.22c.75.43,1.2,1.22,1.2,2.08v333.16c0,1.32-1.07,2.4-2.4,2.4h-31.76c-1.32,0-2.4-1.07-2.4-2.4Z"/>
        <path d="M422.15,640.36v-293.65c0-1.54,1.99-2.5,3.59-1.74l31.76,15.23c.75.36,1.2,1.02,1.2,1.74v278.42c0,1.11-1.07,2-2.4,2h-31.76c-1.32,0-2.4-.9-2.4-2Z"/>
      </g>
      <g fill={wordColor}>
        <path d="M664.67,642.37v-360.51h51.5v360.51h-51.5ZM707.42,479.62v-42.23h197.76v42.23h-197.76ZM893.85,642.37v-360.51h51.5v360.51h-51.5Z"/>
        <path d="M1136.42,648.54c-24.38,0-46.27-5.67-65.66-17-19.4-11.33-34.68-27.21-45.84-47.64-11.16-20.42-16.74-44.03-16.74-70.81s5.67-51.41,17-71.84c11.33-20.42,26.78-36.31,46.35-47.64,19.57-11.33,41.54-17,65.92-17s46.69,5.67,65.92,17c19.22,11.33,34.42,27.13,45.58,47.38,11.15,20.26,16.74,44.12,16.74,71.59s-5.58,51.33-16.74,71.59c-11.16,20.26-26.52,36.05-46.09,47.38-19.57,11.33-41.72,17-66.44,17ZM1136.42,604.25c14.07,0,26.86-3.43,38.37-10.3,11.5-6.86,20.77-17.08,27.81-30.64,7.03-13.56,10.56-30.46,10.56-50.73s-3.44-37.16-10.3-50.73c-6.87-13.56-16.05-23.77-27.55-30.64-11.51-6.86-24.12-10.3-37.85-10.3s-26.44,3.44-38.11,10.3c-11.68,6.87-21.04,17.08-28.07,30.64-7.04,13.57-10.56,30.47-10.56,50.73s3.52,37.17,10.56,50.73c7.03,13.57,16.3,23.78,27.81,30.64,11.5,6.87,23.95,10.3,37.34,10.3Z"/>
        <path d="M1326.46,642.37v-259.56h46.35l3.61,36.57c8.24-13.39,19.22-23.86,32.96-31.42,13.73-7.55,29.18-11.33,46.35-11.33,13.05,0,24.89,1.8,35.54,5.41,10.64,3.6,20.09,9.01,28.33,16.22,8.24,7.21,14.93,16.14,20.09,26.78,9.27-15.1,21.71-26.95,37.34-35.53,15.62-8.58,32.19-12.88,49.7-12.88,20.94,0,38.96,4.21,54.08,12.62,15.1,8.42,26.6,20.95,34.51,37.6,7.9,16.66,11.84,37.34,11.84,62.06v153.47h-50.98v-148.32c0-24.03-4.89-42.23-14.68-54.59-9.78-12.36-24.12-18.54-43-18.54-12.7,0-24.04,3.27-33.99,9.78-9.96,6.53-17.77,15.97-23.43,28.33-5.67,12.36-8.5,27.47-8.5,45.32v138.02h-51.5v-148.32c0-24.03-4.89-42.23-14.68-54.59-9.78-12.36-24.12-18.54-43-18.54-12.02,0-23.01,3.27-32.96,9.78-9.96,6.53-17.86,15.97-23.69,28.33-5.84,12.36-8.76,27.47-8.76,45.32v138.02h-51.5Z"/>
        <path d="M1793.57,642.37v-370.81h51.5v370.81h-51.5Z"/>
        <path d="M1945.49,333.87c-9.96,0-18.11-3.09-24.46-9.27-6.36-6.18-9.53-14.08-9.53-23.69s3.17-16.91,9.53-22.92c6.35-6,14.5-9.01,24.46-9.01s17.68,3.01,24.2,9.01c6.52,6.01,9.79,13.65,9.79,22.92s-3.27,17.51-9.79,23.69c-6.53,6.18-14.6,9.27-24.2,9.27ZM1919.23,642.37v-259.56h51.5v259.56h-51.5Z"/>
      </g>
    </svg>
  );
}

// ---------------- Common reduced-motion CSS injected once ----------------
const REDUCED_MOTION_CSS = `@media (prefers-reduced-motion: reduce) { .scene-anim, .scene-anim * { animation: none !important; transition: none !important; } }`;

// ============================================================
// SCENES
// ============================================================

// ---- BroomScene (Limpieza regular) ----
function BroomScene({ animate = true }) {
  // Build a fan of bristles with center-aligned spread
  const bristles = Array.from({ length: 13 }).map((_, i) => {
    const t = (i - 6) / 6; // -1 to 1
    const baseX = 60 + t * 16; // base spans x=44 to x=76
    const tipX = 60 + t * 22; // tips spread wider for fan effect
    const tipY = 104 + Math.cos(t * Math.PI / 2) * 4 - 4; // outer bristles slightly shorter (curved fan)
    return { baseX, tipX, tipY };
  });
  return (
    <svg viewBox="0 0 120 120" width="100%" height="100%" aria-hidden="true" className="scene-anim">
      <defs>
        <linearGradient id="broom-handle-grad" x1="0" x2="0" y1="0" y2="1">
          <stop offset="0" stopColor="#D8A37A"/>
          <stop offset="1" stopColor="#9E6B43"/>
        </linearGradient>
        <linearGradient id="broom-binding-grad" x1="0" x2="0" y1="0" y2="1">
          <stop offset="0" stopColor="#5C4633"/>
          <stop offset="1" stopColor="#3A2A1E"/>
        </linearGradient>
      </defs>
      <ellipse cx="60" cy="106" rx="34" ry="2.5" fill="rgba(0,0,0,0.08)"/>
      <g style={{ transformOrigin: '60px 102px' }} className={animate ? 'broom-sweep' : ''}>
        {/* Handle: thicker, rounded ends, subtle tilt */}
        <rect x="57.5" y="12" width="5" height="70" rx="2.5" fill="url(#broom-handle-grad)" stroke="rgba(26,20,16,0.18)" strokeWidth="0.4"/>
        {/* Hanging hole at top */}
        <circle cx="60" cy="17" r="1.2" fill="rgba(26,20,16,0.35)"/>
        {/* Binding cord (decorative) */}
        <rect x="50" y="78" width="20" height="6" rx="1.5" fill="url(#broom-binding-grad)"/>
        <line x1="50" y1="80" x2="70" y2="80" stroke="rgba(255,255,255,0.15)" strokeWidth="0.4"/>
        <line x1="50" y1="83" x2="70" y2="83" stroke="rgba(255,255,255,0.15)" strokeWidth="0.4"/>
        {/* Fanned bristles: 13 individual strands forming a natural spread */}
        {bristles.map((b, i) => (
          <line key={i}
            x1={b.baseX} y1={84}
            x2={b.tipX} y2={b.tipY}
            stroke={i % 2 === 0 ? '#E8B080' : '#D89A6A'}
            strokeWidth={i === 6 || i === 5 || i === 7 ? 2.2 : 1.8}
            strokeLinecap="round" opacity="0.95"/>
        ))}
        {/* Slight darker accent on outer bristles for depth */}
        {[0, 12].map(i => (
          <line key={`o${i}`}
            x1={bristles[i].baseX} y1={84}
            x2={bristles[i].tipX} y2={bristles[i].tipY}
            stroke="#9E6B43" strokeWidth="1.6" strokeLinecap="round" opacity="0.6"/>
        ))}
      </g>
      {animate && (
        <g className="broom-dust">
          <circle cx="32" cy="104" r="1.6" fill="var(--coral-soft)" opacity="0.85"/>
          <circle cx="40" cy="106" r="1.1" fill="var(--coral-soft)" opacity="0.7"/>
          <circle cx="28" cy="107" r="0.9" fill="var(--coral-soft)" opacity="0.55"/>
          <circle cx="84" cy="106" r="1.4" fill="var(--coral-soft)" opacity="0.7"/>
          <circle cx="90" cy="104" r="1" fill="var(--coral-soft)" opacity="0.55"/>
        </g>
      )}
      <style>{`
        @keyframes broomSweep { 0%,100% { transform: rotate(-7deg);} 50% { transform: rotate(7deg);} }
        .broom-sweep { animation: broomSweep 2.6s ease-in-out infinite; }
        @keyframes broomDust { 0%,15% { opacity: 0; transform: translate(0,0);} 30% { opacity: 1;} 100% { opacity: 0; transform: translate(-6px, -10px);} }
        @keyframes broomDustR { 0%,15% { opacity: 0; transform: translate(0,0);} 30% { opacity: 1;} 100% { opacity: 0; transform: translate(6px, -10px);} }
        .broom-dust circle:nth-child(-n+3) { animation: broomDust 2.6s ease-out infinite; }
        .broom-dust circle:nth-child(2) { animation-delay: 0.3s;}
        .broom-dust circle:nth-child(3) { animation-delay: 0.6s;}
        .broom-dust circle:nth-child(4), .broom-dust circle:nth-child(5) { animation: broomDustR 2.6s ease-out infinite 1.3s;}
        .broom-dust circle:nth-child(5) { animation-delay: 1.6s;}
        ${REDUCED_MOTION_CSS}
      `}</style>
    </svg>
  );
}

// ---- SparkleScene (Limpieza profunda): sponge with sparkles ----
function SparkleScene({ animate = true }) {
  return (
    <svg viewBox="0 0 120 120" width="100%" height="100%" aria-hidden="true" className="scene-anim">
      <defs>
        <linearGradient id="sponge-foam-grad" x1="0" x2="0" y1="0" y2="1">
          <stop offset="0" stopColor="#FFE4A8"/>
          <stop offset="1" stopColor="#E8B868"/>
        </linearGradient>
      </defs>
      <ellipse cx="60" cy="100" rx="34" ry="2.5" fill="rgba(0,0,0,0.10)"/>
      {/* Sponge body (yellow foam only) */}
      <g style={{ transformOrigin: '60px 76px' }} className={animate ? 'sponge-motion' : ''}>
        <rect x="26" y="50" width="68" height="42" rx="4" fill="url(#sponge-foam-grad)" stroke="rgba(26,20,16,0.2)" strokeWidth="0.7"/>
        {/* Top highlight */}
        <rect x="30" y="52" width="60" height="2" rx="1" fill="rgba(255,255,255,0.3)"/>
        {/* Foam pores */}
        <circle cx="36" cy="60" r="1.4" fill="rgba(26,20,16,0.16)"/>
        <circle cx="46" cy="64" r="1.0" fill="rgba(26,20,16,0.16)"/>
        <circle cx="56" cy="60" r="1.6" fill="rgba(26,20,16,0.16)"/>
        <circle cx="66" cy="66" r="1.2" fill="rgba(26,20,16,0.16)"/>
        <circle cx="76" cy="60" r="1.4" fill="rgba(26,20,16,0.16)"/>
        <circle cx="84" cy="66" r="1.0" fill="rgba(26,20,16,0.16)"/>
        <circle cx="40" cy="72" r="1.1" fill="rgba(26,20,16,0.16)"/>
        <circle cx="52" cy="76" r="1.3" fill="rgba(26,20,16,0.16)"/>
        <circle cx="64" cy="72" r="1.5" fill="rgba(26,20,16,0.16)"/>
        <circle cx="74" cy="76" r="1.1" fill="rgba(26,20,16,0.16)"/>
        <circle cx="32" cy="80" r="0.9" fill="rgba(26,20,16,0.16)"/>
        <circle cx="44" cy="84" r="1.2" fill="rgba(26,20,16,0.16)"/>
        <circle cx="58" cy="86" r="1.4" fill="rgba(26,20,16,0.16)"/>
        <circle cx="70" cy="84" r="1.0" fill="rgba(26,20,16,0.16)"/>
        <circle cx="82" cy="80" r="1.3" fill="rgba(26,20,16,0.16)"/>
        <circle cx="88" cy="74" r="0.9" fill="rgba(26,20,16,0.16)"/>
      </g>
      {/* Sparkles twinkling around the sponge */}
      {animate && (
        <g>
          <path className="sparkle sparkle-1" d="M 20 38 L 21.3 41.7 L 25 43 L 21.3 44.3 L 20 48 L 18.7 44.3 L 15 43 L 18.7 41.7 Z" fill="var(--sun)"/>
          <path className="sparkle sparkle-2" d="M 100 32 L 101.5 36.5 L 106 38 L 101.5 39.5 L 100 44 L 98.5 39.5 L 94 38 L 98.5 36.5 Z" fill="var(--coral)"/>
          <path className="sparkle sparkle-3" d="M 104 72 L 105 75.5 L 108 77 L 105 78.5 L 104 82 L 103 78.5 L 100 77 L 103 75.5 Z" fill="var(--sun)"/>
          <path className="sparkle sparkle-4" d="M 16 72 L 17 75.5 L 20 77 L 17 78.5 L 16 82 L 15 78.5 L 12 77 L 15 75.5 Z" fill="var(--coral)"/>
          <path className="sparkle sparkle-5" d="M 60 24 L 61.5 28.5 L 66 30 L 61.5 31.5 L 60 36 L 58.5 31.5 L 54 30 L 58.5 28.5 Z" fill="var(--sun)"/>
        </g>
      )}
      <style>{`
        @keyframes spongeMotion {
          0%,100% { transform: translateX(-5px) rotate(-2deg);}
          50% { transform: translateX(5px) rotate(2deg);}
        }
        .sponge-motion { animation: spongeMotion 1.8s ease-in-out infinite; }
        @keyframes sparkleTwinkle {
          0%, 100% { opacity: 0; transform: scale(0.4) rotate(0deg);}
          50% { opacity: 1; transform: scale(1) rotate(180deg);}
        }
        .sparkle { animation: sparkleTwinkle 2.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
        .sparkle-1 { animation-delay: 0s;}
        .sparkle-2 { animation-delay: 0.4s;}
        .sparkle-3 { animation-delay: 0.9s;}
        .sparkle-4 { animation-delay: 1.3s;}
        .sparkle-5 { animation-delay: 1.7s;}
        ${REDUCED_MOTION_CSS}
      `}</style>
    </svg>
  );
}

// ---- CurtainScene (Lavado de cortinas) ----
function CurtainScene({ animate = true }) {
  return (
    <svg viewBox="0 0 120 120" width="100%" height="100%" aria-hidden="true" className="scene-anim">
      <defs>
        <linearGradient id="curtain-grad" x1="0" x2="0" y1="0" y2="1">
          <stop offset="0" stopColor="#A8C6DA"/>
          <stop offset="1" stopColor="#5C87A8"/>
        </linearGradient>
        <linearGradient id="curtain-rod-grad" x1="0" x2="0" y1="0" y2="1">
          <stop offset="0" stopColor="#F0BC68"/>
          <stop offset="1" stopColor="#C68A2E"/>
        </linearGradient>
      </defs>
      <ellipse cx="60" cy="105" rx="34" ry="3" fill="rgba(0,0,0,0.08)"/>
      {/* Rod */}
      <rect x="14" y="20" width="92" height="5" rx="2.5" fill="url(#curtain-rod-grad)"/>
      <circle cx="16" cy="22" r="4" fill="url(#curtain-rod-grad)"/>
      <circle cx="104" cy="22" r="4" fill="url(#curtain-rod-grad)"/>
      {/* Curtain folds (animated) */}
      <g className={animate ? 'curtain-wave' : ''}>
        <path d="M 22 25 Q 24 60 22 100 L 30 100 Q 28 60 30 25 Z" fill="url(#curtain-grad)"/>
        <path d="M 32 25 Q 34 62 32 100 L 40 100 Q 38 62 40 25 Z" fill="url(#curtain-grad)" opacity="0.92"/>
        <path d="M 42 25 Q 44 60 42 100 L 50 100 Q 48 60 50 25 Z" fill="url(#curtain-grad)"/>
        <path d="M 52 25 Q 54 62 52 100 L 60 100 Q 58 62 60 25 Z" fill="url(#curtain-grad)" opacity="0.92"/>
        <path d="M 62 25 Q 64 60 62 100 L 70 100 Q 68 60 70 25 Z" fill="url(#curtain-grad)"/>
        <path d="M 72 25 Q 74 62 72 100 L 80 100 Q 78 62 80 25 Z" fill="url(#curtain-grad)" opacity="0.92"/>
        <path d="M 82 25 Q 84 60 82 100 L 90 100 Q 88 60 90 25 Z" fill="url(#curtain-grad)"/>
        <path d="M 92 25 Q 94 62 92 100 L 100 100 Q 98 62 100 25 Z" fill="url(#curtain-grad)" opacity="0.92"/>
      </g>
      {/* Plant in corner */}
      <g className={animate ? 'plant-sway' : ''} style={{ transformOrigin: '14px 100px' }}>
        <path d="M 10 100 Q 6 88 10 80 Q 14 88 14 100 Z" fill="var(--sage)"/>
        <path d="M 14 100 Q 18 90 22 86 Q 18 96 18 100 Z" fill="var(--sage)" opacity="0.85"/>
      </g>
      <style>{`
        @keyframes curtainWave { 0%,100% { transform: translateX(0);} 50% { transform: translateX(2px);} }
        .curtain-wave { animation: curtainWave 3s ease-in-out infinite; }
        .curtain-wave path:nth-child(2n) { animation: curtainWave 3s ease-in-out infinite 0.4s; }
        @keyframes plantSway { 0%,100% { transform: rotate(-3deg);} 50% { transform: rotate(3deg);} }
        .plant-sway { animation: plantSway 3s ease-in-out infinite; }
        ${REDUCED_MOTION_CSS}
      `}</style>
    </svg>
  );
}

// ---- TapScene (Fontanería) ----
function TapScene({ animate = true }) {
  return (
    <svg viewBox="0 0 120 120" width="100%" height="100%" aria-hidden="true" className="scene-anim">
      <defs>
        <linearGradient id="tap-grad" x1="0" x2="0" y1="0" y2="1">
          <stop offset="0" stopColor="#E4ECF2"/>
          <stop offset="0.45" stopColor="#AEBCC8"/>
          <stop offset="1" stopColor="#5C6B7A"/>
        </linearGradient>
        <linearGradient id="drop-grad" x1="0" x2="0" y1="0" y2="1">
          <stop offset="0" stopColor="#BCE0F4"/>
          <stop offset="1" stopColor="#5C87A8"/>
        </linearGradient>
      </defs>
      <ellipse cx="60" cy="105" rx="30" ry="3" fill="rgba(0,0,0,0.08)"/>
      {/* Wall flange (entrance from wall) */}
      <rect x="8" y="34" width="6" height="20" rx="1" fill="url(#tap-grad)" stroke="rgba(26,20,16,0.3)" strokeWidth="0.5"/>
      {/* Horizontal pipe from wall to body */}
      <rect x="14" y="38" width="34" height="12" rx="2" fill="url(#tap-grad)" stroke="rgba(26,20,16,0.3)" strokeWidth="0.6"/>
      {/* Body (where handle attaches) */}
      <rect x="42" y="32" width="16" height="22" rx="2" fill="url(#tap-grad)" stroke="rgba(26,20,16,0.3)" strokeWidth="0.6"/>
      {/* Spout: horizontal extending right from body, then bending down */}
      <path
        d="M 58 38 L 76 38 Q 86 38 86 48 L 86 70 L 74 70 L 74 50 Q 74 46 70 46 L 58 46 Z"
        fill="url(#tap-grad)" stroke="rgba(26,20,16,0.3)" strokeWidth="0.6"/>
      {/* Aerator (rim at spout tip) */}
      <rect x="72" y="69" width="16" height="4" rx="1" fill="url(#tap-grad)" stroke="rgba(26,20,16,0.3)" strokeWidth="0.5"/>
      {/* Spout opening (dark hole at bottom of aerator) */}
      <ellipse cx="80" cy="72.6" rx="6" ry="0.9" fill="rgba(0,0,0,0.45)"/>
      {/* Cross handle on top of body */}
      <rect x="48" y="20" width="4" height="14" rx="1" fill="url(#tap-grad)" stroke="rgba(26,20,16,0.3)" strokeWidth="0.5"/>
      <rect x="38" y="18" width="24" height="5" rx="2.5" fill="url(#tap-grad)" stroke="rgba(26,20,16,0.3)" strokeWidth="0.5"/>
      <rect x="48" y="12" width="4" height="9" rx="1" fill="url(#tap-grad)" stroke="rgba(26,20,16,0.3)" strokeWidth="0.5"/>
      <circle cx="40" cy="20.5" r="2.4" fill="url(#tap-grad)" stroke="rgba(26,20,16,0.3)" strokeWidth="0.5"/>
      <circle cx="60" cy="20.5" r="2.4" fill="url(#tap-grad)" stroke="rgba(26,20,16,0.3)" strokeWidth="0.5"/>
      <circle cx="50" cy="12" r="2.4" fill="url(#tap-grad)" stroke="rgba(26,20,16,0.3)" strokeWidth="0.5"/>
      <circle cx="50" cy="20.5" r="2" fill="rgba(0,0,0,0.4)"/>
      {/* Chrome highlights */}
      <rect x="16" y="40" width="30" height="1.6" rx="0.8" fill="rgba(255,255,255,0.45)"/>
      <rect x="44" y="34" width="1.8" height="18" rx="0.9" fill="rgba(255,255,255,0.4)"/>
      <path d="M 60 40 L 76 40 Q 84 40 84 48 L 84 68" fill="none" stroke="rgba(255,255,255,0.35)" strokeWidth="1.2" strokeLinecap="round"/>
      {/* Drops falling from spout opening (cx=80, cy=72.6) */}
      {animate && (
        <>
          <path className="drop-fall drop-1" d="M 80 74 Q 76 80 80 84 Q 84 80 80 74 Z" fill="url(#drop-grad)" stroke="rgba(92,135,168,0.45)" strokeWidth="0.3"/>
          <path className="drop-fall drop-2" d="M 80 74 Q 76 80 80 84 Q 84 80 80 74 Z" fill="url(#drop-grad)" stroke="rgba(92,135,168,0.45)" strokeWidth="0.3"/>
          <ellipse className="drop-splash" cx="80" cy="100" rx="6" ry="1.4" fill="var(--sky)" opacity="0.6"/>
        </>
      )}
      <style>{`
        @keyframes dropFall {
          0% { opacity: 0; transform: translateY(0) scale(0.3);}
          15% { opacity: 1; transform: translateY(0) scale(1);}
          70% { opacity: 1; transform: translateY(22px) scale(0.92);}
          85% { opacity: 1; transform: translateY(26px) scale(0.6);}
          100% { opacity: 0; transform: translateY(28px) scale(0.3);}
        }
        .drop-1 { animation: dropFall 2.4s cubic-bezier(0.5, 0, 0.85, 0.4) infinite; }
        .drop-2 { animation: dropFall 2.4s cubic-bezier(0.5, 0, 0.85, 0.4) infinite; animation-delay: 1.2s; }
        @keyframes dropSplash {
          0%, 70% { opacity: 0; transform: scaleX(0.3);}
          78% { opacity: 0.8; transform: scaleX(1);}
          92% { opacity: 0; transform: scaleX(1.4);}
          100% { opacity: 0; }
        }
        .drop-splash { animation: dropSplash 2.4s ease-out infinite; transform-origin: 80px 100px; }
        ${REDUCED_MOTION_CSS}
      `}</style>
    </svg>
  );
}

// ---- KeyScene (Cerrajería) ----
function KeyScene({ animate = true }) {
  return (
    <svg viewBox="0 0 120 120" width="100%" height="100%" aria-hidden="true" className="scene-anim">
      <defs>
        <linearGradient id="key-grad" x1="0" x2="1" y1="0" y2="1">
          <stop offset="0" stopColor="#F08566"/>
          <stop offset="1" stopColor="#C84727"/>
        </linearGradient>
        <linearGradient id="lock-plate-grad" x1="0" x2="0" y1="0" y2="1">
          <stop offset="0" stopColor="#C8B59A"/>
          <stop offset="1" stopColor="#8E7A5E"/>
        </linearGradient>
        <linearGradient id="cylinder-grad" x1="0" x2="0" y1="0" y2="1">
          <stop offset="0" stopColor="#5A4F44"/>
          <stop offset="1" stopColor="#2A211A"/>
        </linearGradient>
        <radialGradient id="keyhole-grad" cx="0.5" cy="0.4" r="0.6">
          <stop offset="0" stopColor="#0A0604"/>
          <stop offset="1" stopColor="#1A1410"/>
        </radialGradient>
      </defs>
      <ellipse cx="60" cy="105" rx="30" ry="3" fill="rgba(0,0,0,0.08)"/>
      {/* Door panel hint */}
      <rect x="18" y="22" width="84" height="76" rx="3" fill="#EFE6D8" stroke="rgba(26,20,16,0.12)" strokeWidth="0.6"/>
      <rect x="24" y="28" width="72" height="64" rx="2" fill="none" stroke="rgba(26,20,16,0.08)" strokeWidth="0.6"/>
      {/* Lock escutcheon plate (vertical, oval) */}
      <rect x="48" y="38" width="24" height="56" rx="12" fill="url(#lock-plate-grad)" stroke="rgba(26,20,16,0.25)" strokeWidth="0.8"/>
      {/* Plate screws */}
      <circle cx="60" cy="44" r="1.2" fill="rgba(26,20,16,0.4)"/>
      <circle cx="60" cy="88" r="1.2" fill="rgba(26,20,16,0.4)"/>
      {/* Cylinder (circular, matte black) */}
      <circle cx="60" cy="58" r="9" fill="url(#cylinder-grad)" stroke="rgba(0,0,0,0.4)" strokeWidth="0.6"/>
      <circle cx="60" cy="58" r="9" fill="none" stroke="rgba(255,255,255,0.08)" strokeWidth="0.4"/>
      {/* Click flash */}
      {animate && <circle className="key-flash" cx="60" cy="58" r="11" fill="var(--cream)" opacity="0"/>}
      {/* Keyhole: classic shape with round top, slot below */}
      <g className={animate ? 'key-turn' : ''} style={{ transformOrigin: '60px 58px' }}>
        <circle cx="60" cy="56" r="2.6" fill="url(#keyhole-grad)"/>
        <path d="M 58.6 56 L 58 64 L 62 64 L 61.4 56 Z" fill="url(#keyhole-grad)"/>
      </g>
      {/* Doorknob below */}
      <circle cx="60" cy="78" r="6" fill="url(#cylinder-grad)" stroke="rgba(0,0,0,0.3)" strokeWidth="0.5"/>
      <circle cx="58" cy="76" r="1.6" fill="rgba(255,255,255,0.15)"/>
      {/* Key being inserted from the right */}
      <g className={animate ? 'key-insert' : ''} style={{ transformOrigin: '60px 60px' }}>
        {/* Key bow */}
        <circle cx="100" cy="60" r="6.5" fill="url(#key-grad)" stroke="rgba(26,20,16,0.2)" strokeWidth="0.5"/>
        <circle cx="100" cy="60" r="2.5" fill="var(--cream)"/>
        {/* Key shaft */}
        <rect x="68" y="58.5" width="26" height="3" rx="0.5" fill="url(#key-grad)"/>
        {/* Key teeth */}
        <path d="M 68 61.5 L 70 64 L 72 61.5 L 74 64 L 76 61.5 L 78 63.5 L 80 61.5 Z" fill="url(#key-grad)"/>
      </g>
      <style>{`
        @keyframes keyInsert {
          0% { transform: translateX(20px); opacity: 0; }
          15%, 35% { transform: translateX(0px); opacity: 1; }
          45%, 65% { transform: translateX(0px) rotate(0deg); opacity: 1; }
          75%, 95% { transform: translateX(0px) rotate(0deg); opacity: 1; }
          100% { transform: translateX(20px); opacity: 0; }
        }
        .key-insert { animation: keyInsert 4s ease-in-out infinite; transform-origin: 60px 60px; transform-box: fill-box; }
        @keyframes keyTurn { 0%, 40% { transform: rotate(0deg);} 55%, 80% { transform: rotate(90deg);} 95%,100% { transform: rotate(0deg);} }
        .key-turn { animation: keyTurn 4s ease-in-out infinite; }
        @keyframes keyFlash { 0%,55% { opacity: 0; transform: scale(0.6);} 60% { opacity: 0.8; transform: scale(1);} 75%,100% { opacity: 0; transform: scale(1.4);} }
        .key-flash { animation: keyFlash 4s ease-out infinite; transform-origin: 60px 58px; }
        ${REDUCED_MOTION_CSS}
      `}</style>
    </svg>
  );
}

// ---- BoltScene (Electricidad, bombilla) ----
function BoltScene({ animate = true }) {
  return (
    <svg viewBox="0 0 120 120" width="100%" height="100%" aria-hidden="true" className="scene-anim">
      <defs>
        <linearGradient id="bulb-grad" x1="0" x2="0" y1="0" y2="1">
          <stop offset="0" stopColor="#FFD98A"/>
          <stop offset="1" stopColor="#E8A13D"/>
        </linearGradient>
      </defs>
      <ellipse cx="60" cy="105" rx="22" ry="3" fill="rgba(0,0,0,0.08)"/>
      {/* Cable */}
      <g className={animate ? 'bulb-swing' : ''} style={{ transformOrigin: '60px 8px' }}>
        <line x1="60" y1="8" x2="60" y2="40" stroke="#1A1410" strokeWidth="1.5"/>
        {/* Socket */}
        <rect x="52" y="40" width="16" height="10" rx="1" fill="#3A2F28"/>
        <rect x="50" y="48" width="20" height="4" fill="#1A1410"/>
        {/* Bulb glow when on */}
        {animate && <circle className="bulb-glow" cx="60" cy="72" r="28" fill="var(--sun)" opacity="0"/>}
        {/* Bulb */}
        <path d="M 46 56 Q 46 80 54 86 L 66 86 Q 74 80 74 56 Q 74 50 60 50 Q 46 50 46 56 Z" fill="url(#bulb-grad)" stroke="rgba(26,20,16,0.2)" strokeWidth="0.8"/>
        {/* Filament */}
        <path d="M 54 64 Q 56 70 58 64 Q 60 58 62 64 Q 64 70 66 64" fill="none" stroke="#C84727" strokeWidth="1.2" strokeLinecap="round" className={animate ? 'filament-glow' : ''}/>
      </g>
      {/* Light rays */}
      {animate && (
        <g className="bulb-rays">
          <line x1="32" y1="72" x2="22" y2="72" stroke="var(--sun)" strokeWidth="2" strokeLinecap="round"/>
          <line x1="88" y1="72" x2="98" y2="72" stroke="var(--sun)" strokeWidth="2" strokeLinecap="round"/>
          <line x1="40" y1="50" x2="32" y2="42" stroke="var(--sun)" strokeWidth="2" strokeLinecap="round"/>
          <line x1="80" y1="50" x2="88" y2="42" stroke="var(--sun)" strokeWidth="2" strokeLinecap="round"/>
        </g>
      )}
      <style>{`
        @keyframes bulbSwing { 0%,100% { transform: rotate(-2deg);} 50% { transform: rotate(2deg);} }
        .bulb-swing { animation: bulbSwing 4s ease-in-out infinite; }
        @keyframes bulbGlow { 0%,40% { opacity: 0;} 50%,80% { opacity: 0.5;} 100% { opacity: 0;} }
        .bulb-glow { animation: bulbGlow 3s ease-in-out infinite; filter: blur(8px); }
        @keyframes filamentGlow { 0%,40% { stroke: #6B5E56; opacity: 0.5;} 50%,80% { stroke: #FFE39A; opacity: 1;} 100% { stroke: #6B5E56; opacity: 0.5;} }
        .filament-glow { animation: filamentGlow 3s ease-in-out infinite; }
        @keyframes raysBurst { 0%,40% { opacity: 0; transform: scale(0.6);} 55%,75% { opacity: 1; transform: scale(1);} 100% { opacity: 0; transform: scale(1.2);} }
        .bulb-rays { animation: raysBurst 3s ease-out infinite; transform-origin: 60px 72px; }
        ${REDUCED_MOTION_CSS}
      `}</style>
    </svg>
  );
}

// ---- HammerScene (Carpintería) ----
// Based on the svgrepo "hammer-tool" path. Splits the original single-color path
// into two sub-paths (handle + head) so we can apply brand gradients. Outer
// transform scales the 64-unit source into the shared 120 viewBox and centers it
// so the hammer matches the visual weight of the other service icons.
function HammerScene({ animate = true }) {
  return (
    <svg viewBox="0 0 120 120" width="100%" height="100%" aria-hidden="true" className="scene-anim">
      <defs>
        <linearGradient id="hammer-head-grad" x1="0" x2="0" y1="0" y2="1">
          <stop offset="0" stopColor="#B8C0CC"/>
          <stop offset="0.5" stopColor="#7A828E"/>
          <stop offset="1" stopColor="#3E454F"/>
        </linearGradient>
        <linearGradient id="hammer-handle-grad" x1="0" x2="1" y1="0" y2="1">
          <stop offset="0" stopColor="#E0A878"/>
          <stop offset="0.5" stopColor="#A87648"/>
          <stop offset="1" stopColor="#6A4628"/>
        </linearGradient>
      </defs>
      <ellipse cx="60" cy="106" rx="22" ry="2.5" fill="rgba(0,0,0,0.10)"/>
      <g transform="translate(12 12) scale(1.5)">
        <g style={{ transformOrigin: 'center', transformBox: 'fill-box' }} className={animate ? 'hammer-wobble' : ''}>
          {/* Handle (diagonal wood) */}
          <path
            d="M30.651,23.538l25.24,24.346l-6.577,6.577l-23.969,-25.617l5.306,-5.306Z"
            fill="url(#hammer-handle-grad)"
            stroke="rgba(26,20,16,0.45)"
            strokeWidth="0.4"
            strokeLinejoin="round"
            vectorEffect="non-scaling-stroke"/>
          {/* Head (with strike face + claw) */}
          <path
            d="M23.443,26.941l5.306,-5.305c0,0 -2.695,-2.056 -2.447,-3.34c0.248,-1.285 0.809,-3.1 4.711,-4.711c3.903,-1.611 7.543,-1.757 7.543,-1.757l0.131,-1.758c0,0 -8.969,-1.356 -13.707,0.327c-4.738,1.684 -10.097,8.02 -10.097,8.02c0,0 0.935,3.064 -0.667,4.666c-1.601,1.601 -3.754,-0.245 -3.754,-0.245l-2.456,3.118l6.197,6.197l3.112,-2.461c0,0 -1.472,-2.207 -0.017,-3.528c3.132,-2.842 6.145,0.777 6.145,0.777Z"
            fill="url(#hammer-head-grad)"
            stroke="rgba(26,20,16,0.45)"
            strokeWidth="0.4"
            strokeLinejoin="round"
            vectorEffect="non-scaling-stroke"/>
        </g>
      </g>
      <style>{`
        @keyframes hammerWobble {
          0%, 100% { transform: rotate(-3deg);}
          50% { transform: rotate(3deg);}
        }
        .hammer-wobble { animation: hammerWobble 3.2s ease-in-out infinite; }
        ${REDUCED_MOTION_CSS}
      `}</style>
    </svg>
  );
}

// ---- TrowelScene (Obra civil, ladrillos) ----
function TrowelScene({ animate = true }) {
  return (
    <svg viewBox="0 0 120 120" width="100%" height="100%" aria-hidden="true" className="scene-anim">
      <defs>
        <linearGradient id="brick-grad" x1="0" x2="0" y1="0" y2="1">
          <stop offset="0" stopColor="#D65438"/>
          <stop offset="1" stopColor="#9E3A22"/>
        </linearGradient>
        <linearGradient id="brick-fall-grad" x1="0" x2="0" y1="0" y2="1">
          <stop offset="0" stopColor="#EC6A4D"/>
          <stop offset="1" stopColor="#B53E22"/>
        </linearGradient>
      </defs>
      <ellipse cx="60" cy="105" rx="42" ry="3" fill="rgba(0,0,0,0.08)"/>
      {/* Existing bricks row */}
      <g>
        <rect x="18" y="80" width="28" height="14" rx="1" fill="url(#brick-grad)" stroke="rgba(255,255,255,0.5)" strokeWidth="0.8"/>
        <rect x="48" y="80" width="28" height="14" rx="1" fill="url(#brick-grad)" stroke="rgba(255,255,255,0.5)" strokeWidth="0.8"/>
        <rect x="78" y="80" width="28" height="14" rx="1" fill="url(#brick-grad)" stroke="rgba(255,255,255,0.5)" strokeWidth="0.8"/>
      </g>
      {/* Dust cloud at impact */}
      {animate && (
        <g className="brick-dust">
          <circle cx="56" cy="78" r="3" fill="#C9BDAE" opacity="0.5"/>
          <circle cx="62" cy="74" r="2.4" fill="#C9BDAE" opacity="0.4"/>
          <circle cx="68" cy="78" r="2.6" fill="#C9BDAE" opacity="0.45"/>
          <circle cx="58" cy="72" r="1.8" fill="#C9BDAE" opacity="0.4"/>
          <circle cx="66" cy="70" r="2" fill="#C9BDAE" opacity="0.4"/>
        </g>
      )}
      {/* Falling brick */}
      <rect className={animate ? 'brick-fall' : ''}
        x="48" y="64" width="24" height="14" rx="1"
        fill="url(#brick-fall-grad)" stroke="rgba(255,255,255,0.5)" strokeWidth="0.8"/>
      <style>{`
        @keyframes brickFall {
          0% { transform: translateY(-90px); opacity: 0;}
          15% { opacity: 1;}
          50% { transform: translateY(0); }
          55% { transform: translate(0, 2px) scaleY(0.95);}
          60%, 80% { transform: translateY(0);}
          90% { opacity: 1;}
          100% { transform: translateY(-90px); opacity: 0;}
        }
        .brick-fall { animation: brickFall 3s ease-in infinite; transform-origin: 60px 78px; }
        @keyframes brickDust {
          0%, 45% { opacity: 0; transform: translateY(4px) scale(0.6);}
          55% { opacity: 0.6; transform: translateY(0) scale(1);}
          80%, 100% { opacity: 0; transform: translateY(-12px) scale(1.4);}
        }
        .brick-dust { animation: brickDust 3s ease-out infinite; transform-origin: 60px 76px; }
        ${REDUCED_MOTION_CSS}
      `}</style>
    </svg>
  );
}

// ---- FogScene (Fumigación) ----
function FogScene({ animate = true }) {
  return (
    <svg viewBox="0 0 120 120" width="100%" height="100%" aria-hidden="true" className="scene-anim">
      <defs>
        <linearGradient id="spray-body-grad" x1="0" x2="1" y1="0" y2="0">
          <stop offset="0" stopColor="#E8DDC8"/>
          <stop offset="0.5" stopColor="#C9B894"/>
          <stop offset="1" stopColor="#8E7A5A"/>
        </linearGradient>
        <linearGradient id="spray-trigger-grad" x1="0" x2="0" y1="0" y2="1">
          <stop offset="0" stopColor="#EC6A4D"/>
          <stop offset="1" stopColor="#B53E22"/>
        </linearGradient>
      </defs>
      <ellipse cx="60" cy="105" rx="32" ry="2.5" fill="rgba(0,0,0,0.10)"/>
      {/* Body */}
      <rect x="42" y="48" width="28" height="50" rx="3" fill="url(#spray-body-grad)" stroke="rgba(26,20,16,0.25)" strokeWidth="0.7"/>
      <rect x="46" y="50" width="2" height="44" rx="1" fill="rgba(255,255,255,0.4)"/>
      {/* Label */}
      <rect x="44" y="64" width="24" height="20" rx="1" fill="rgba(255,255,255,0.55)" stroke="rgba(26,20,16,0.15)" strokeWidth="0.3"/>
      <line x1="48" y1="70" x2="64" y2="70" stroke="rgba(26,20,16,0.4)" strokeWidth="1.2" strokeLinecap="round"/>
      <line x1="48" y1="74" x2="60" y2="74" stroke="rgba(26,20,16,0.25)" strokeWidth="0.8" strokeLinecap="round"/>
      <line x1="48" y1="78" x2="62" y2="78" stroke="rgba(26,20,16,0.25)" strokeWidth="0.8" strokeLinecap="round"/>
      {/* Neck */}
      <rect x="48" y="42" width="16" height="8" rx="1" fill="url(#spray-body-grad)" stroke="rgba(26,20,16,0.25)" strokeWidth="0.6"/>
      {/* Trigger head */}
      <path d="M 36 32 L 64 32 Q 68 32 68 36 L 68 44 L 48 44 L 48 42 L 36 42 Z"
        fill="url(#spray-trigger-grad)" stroke="rgba(26,20,16,0.3)" strokeWidth="0.6"/>
      {/* Trigger handle */}
      <path d="M 50 44 L 50 56 Q 50 60 46 60 L 42 60"
        fill="none" stroke="url(#spray-trigger-grad)" strokeWidth="5" strokeLinecap="round"/>
      {/* Nozzle */}
      <rect x="26" y="34" width="14" height="4" rx="1" fill="#5A4F44" stroke="rgba(26,20,16,0.3)" strokeWidth="0.4"/>
      <circle cx="26" cy="36" r="1.6" fill="rgba(0,0,0,0.5)"/>
      {/* Mist */}
      {animate && (
        <g className="mist">
          <circle cx="18" cy="36" r="2" fill="rgba(140,170,200,0.5)"/>
          <circle cx="14" cy="32" r="1.6" fill="rgba(140,170,200,0.45)"/>
          <circle cx="12" cy="40" r="1.8" fill="rgba(140,170,200,0.4)"/>
          <circle cx="8" cy="36" r="1.4" fill="rgba(140,170,200,0.4)"/>
          <circle cx="16" cy="44" r="1.2" fill="rgba(140,170,200,0.35)"/>
          <circle cx="6" cy="30" r="1.0" fill="rgba(140,170,200,0.3)"/>
          <circle cx="10" cy="48" r="1.4" fill="rgba(140,170,200,0.3)"/>
        </g>
      )}
      <style>{`
        @keyframes mistDrift {
          0% { opacity: 0; transform: translateX(0) scale(0.6);}
          20% { opacity: 0.8; transform: translateX(-3px) scale(1);}
          80% { opacity: 0.5; transform: translateX(-12px) scale(1.3);}
          100% { opacity: 0; transform: translateX(-18px) scale(1.5);}
        }
        .mist circle { animation: mistDrift 2.4s ease-out infinite; transform-origin: center; transform-box: fill-box; }
        .mist circle:nth-child(1) { animation-delay: 0s;}
        .mist circle:nth-child(2) { animation-delay: 0.3s;}
        .mist circle:nth-child(3) { animation-delay: 0.5s;}
        .mist circle:nth-child(4) { animation-delay: 0.8s;}
        .mist circle:nth-child(5) { animation-delay: 1.1s;}
        .mist circle:nth-child(6) { animation-delay: 1.4s;}
        .mist circle:nth-child(7) { animation-delay: 1.7s;}
        ${REDUCED_MOTION_CSS}
      `}</style>
    </svg>
  );
}

// ---- PlantScene (Jardinería) ----
function PlantScene({ animate = true }) {
  return (
    <svg viewBox="0 0 120 120" width="100%" height="100%" aria-hidden="true" className="scene-anim">
      <defs>
        <linearGradient id="pot-grad" x1="0" x2="0" y1="0" y2="1">
          <stop offset="0" stopColor="#D87555"/>
          <stop offset="1" stopColor="#A14228"/>
        </linearGradient>
        <linearGradient id="leaf-grad" x1="0" x2="0" y1="0" y2="1">
          <stop offset="0" stopColor="#8DAB7F"/>
          <stop offset="1" stopColor="#5A7D52"/>
        </linearGradient>
        <linearGradient id="leaf-grad-light" x1="0" x2="0" y1="0" y2="1">
          <stop offset="0" stopColor="#A8C29A"/>
          <stop offset="1" stopColor="#6E9264"/>
        </linearGradient>
      </defs>
      <ellipse cx="60" cy="105" rx="32" ry="2.5" fill="rgba(0,0,0,0.10)"/>
      {/* Pot */}
      <path d="M 38 70 L 82 70 L 78 100 L 42 100 Z" fill="url(#pot-grad)" stroke="rgba(26,20,16,0.3)" strokeWidth="0.7"/>
      <rect x="34" y="68" width="52" height="6" rx="1" fill="url(#pot-grad)" stroke="rgba(26,20,16,0.3)" strokeWidth="0.7"/>
      <line x1="42" y1="74" x2="46" y2="96" stroke="rgba(255,255,255,0.18)" strokeWidth="1.6" strokeLinecap="round"/>
      {/* Soil */}
      <ellipse cx="60" cy="71" rx="22" ry="2.5" fill="#4A3528"/>
      {/* Stem */}
      <path d="M 60 70 Q 58 56 60 42 Q 62 28 60 20" fill="none" stroke="#5A7D52" strokeWidth="2.2" strokeLinecap="round"/>
      {/* Leaves */}
      <g className={animate ? 'plant-sway' : ''} style={{ transformOrigin: '60px 70px' }}>
        <path d="M 60 56 Q 48 50 38 54 Q 44 60 60 58 Z" fill="url(#leaf-grad)" stroke="rgba(26,20,16,0.2)" strokeWidth="0.4"/>
        <path d="M 60 60 Q 72 56 82 60 Q 76 66 60 62 Z" fill="url(#leaf-grad-light)" stroke="rgba(26,20,16,0.2)" strokeWidth="0.4"/>
        <path d="M 60 42 Q 50 36 42 38 Q 48 46 60 44 Z" fill="url(#leaf-grad-light)" stroke="rgba(26,20,16,0.2)" strokeWidth="0.4"/>
        <path d="M 60 38 Q 70 32 80 36 Q 74 44 60 42 Z" fill="url(#leaf-grad)" stroke="rgba(26,20,16,0.2)" strokeWidth="0.4"/>
        <path d="M 60 22 Q 52 16 48 22 Q 54 28 60 26 Q 66 28 72 22 Q 68 16 60 22 Z" fill="url(#leaf-grad)" stroke="rgba(26,20,16,0.2)" strokeWidth="0.4"/>
        {/* Leaf veins */}
        <line x1="58" y1="56" x2="42" y2="55" stroke="rgba(26,20,16,0.22)" strokeWidth="0.4"/>
        <line x1="62" y1="60" x2="78" y2="60" stroke="rgba(26,20,16,0.22)" strokeWidth="0.4"/>
        <line x1="58" y1="42" x2="44" y2="40" stroke="rgba(26,20,16,0.22)" strokeWidth="0.4"/>
        <line x1="62" y1="38" x2="76" y2="38" stroke="rgba(26,20,16,0.22)" strokeWidth="0.4"/>
      </g>
      {/* Flower accent */}
      {animate && (
        <circle className="bloom" cx="60" cy="20" r="3" fill="var(--coral)" stroke="rgba(26,20,16,0.25)" strokeWidth="0.3"/>
      )}
      <style>{`
        @keyframes plantSway {
          0%, 100% { transform: rotate(-2deg);}
          50% { transform: rotate(2deg);}
        }
        .plant-sway { animation: plantSway 3.6s ease-in-out infinite; }
        @keyframes bloomPulse {
          0%, 100% { transform: scale(1);}
          50% { transform: scale(1.15);}
        }
        .bloom { animation: bloomPulse 2.4s ease-in-out infinite; transform-origin: 60px 20px; transform-box: fill-box; }
        ${REDUCED_MOTION_CSS}
      `}</style>
    </svg>
  );
}

// ---------------- Export ----------------
Object.assign(window, {
  IS_TOUCH,
  useInView, useMouseParallax, usePageScroll, useScrollProgress,
  lerp, mapRange,
  HomliMark, HomliLogo,
  BroomScene, KeyScene, TapScene, CurtainScene,
  HammerScene, SparkleScene, TrowelScene, BoltScene,
  FogScene, PlantScene,
});
