/* Reusable visual primitives: WasherPortal, Bubbles, Ribbons, Icons */

const GoldRibbonUnderline = ({ className = "" }) => (
  <svg className={className} viewBox="0 0 400 26" preserveAspectRatio="none" aria-hidden="true">
    <defs>
      <linearGradient id="goldGrad" x1="0" y1="0" x2="1" y2="0">
        <stop offset="0%" stopColor="#E0A911" />
        <stop offset="50%" stopColor="#FFC627" />
        <stop offset="100%" stopColor="#E0A911" />
      </linearGradient>
    </defs>
    <path
      className="ribbon-stroke"
      d="M2,18 C60,4 140,2 200,12 C260,22 340,18 398,8"
      stroke="url(#goldGrad)"
      strokeWidth="9"
      strokeLinecap="round"
      fill="none"
    />
    <path
      d="M2,18 C60,4 140,2 200,12 C260,22 340,18 398,8"
      stroke="rgba(255,255,255,0.55)"
      strokeWidth="2"
      strokeLinecap="round"
      fill="none"
      style={{ transform: 'translateY(-2px)' }}
    />
  </svg>
);

const HoursRibbonUnderline = () => (
  <svg viewBox="0 0 200 14" preserveAspectRatio="none" aria-hidden="true">
    <path d="M2,9 C40,3 100,2 150,7 C175,10 195,5 198,5"
      stroke="#FFC627" strokeWidth="5" strokeLinecap="round" fill="none" />
  </svg>
);

const CurlingLiquidRibbon = ({ className = "", style = {} }) => (
  <svg className={className} style={style} viewBox="0 0 600 400" aria-hidden="true">
    <defs>
      <linearGradient id="redLiquid" x1="0" y1="0" x2="1" y2="1">
        <stop offset="0%" stopColor="#FF5560" />
        <stop offset="100%" stopColor="#B81820" />
      </linearGradient>
    </defs>
    <path
      className="ribbon-stroke"
      d="M40,200 C100,80 220,40 320,120 C420,200 480,280 560,220"
      stroke="url(#redLiquid)"
      strokeWidth="22"
      strokeLinecap="round"
      fill="none"
      opacity="0.85"
    />
    <path
      d="M40,200 C100,80 220,40 320,120 C420,200 480,280 560,220"
      stroke="rgba(255,255,255,0.4)"
      strokeWidth="4"
      strokeLinecap="round"
      fill="none"
      style={{ transform: 'translate(0, -6px)' }}
    />
  </svg>
);

const RibbonDivider = ({ flip = false }) => (
  <svg className="ribbon-divider" viewBox="0 0 1200 30" preserveAspectRatio="none" aria-hidden="true"
    style={{ transform: flip ? 'scaleX(-1)' : 'none' }}>
    <defs>
      <linearGradient id={`rbDiv-${flip ? 'r' : 'l'}`} x1="0" y1="0" x2="1" y2="0">
        <stop offset="0%" stopColor="#E0A911" stopOpacity="0.2" />
        <stop offset="50%" stopColor="#FFC627" />
        <stop offset="100%" stopColor="#E0A911" stopOpacity="0.2" />
      </linearGradient>
    </defs>
    <path
      className="ribbon-stroke"
      d="M0,18 C200,4 400,28 600,15 C800,2 1000,26 1200,12"
      stroke={`url(#rbDiv-${flip ? 'r' : 'l'})`}
      strokeWidth="3"
      strokeLinecap="round"
      fill="none"
    />
  </svg>
);

const Sparkle = ({ size = 16, color = "#FFC627", className = "" }) => (
  <svg className={className} width={size} height={size} viewBox="0 0 24 24" aria-hidden="true">
    <path d="M12 2 L13.5 10.5 L22 12 L13.5 13.5 L12 22 L10.5 13.5 L2 12 L10.5 10.5 Z"
      fill={color} stroke="#5A2A12" strokeWidth="1.5" strokeLinejoin="round" />
  </svg>
);

const WasherPortal = ({ className = "" }) => (
  <div className={`washer-stage ${className}`}>
    <div className="washer">
      <div className="washer-glass">
        <div className="drum"></div>
      </div>
    </div>
    <div className="washer-shadow"></div>
  </div>
);

/* Floating bubble field around hero */
const BubbleField = () => {
  const bubbles = [
    { size: 88, top: '4%', left: '8%', delay: 0, dur: 11 },
    { size: 56, top: '12%', right: '12%', delay: 1, dur: 9 },
    { size: 36, top: '32%', left: '2%', delay: 2, dur: 13 },
    { size: 70, bottom: '8%', right: '4%', delay: 0.5, dur: 12 },
    { size: 28, bottom: '24%', left: '14%', delay: 3, dur: 8 },
    { size: 44, top: '52%', right: '0%', delay: 1.5, dur: 10 },
    { size: 24, top: '68%', left: '8%', delay: 2.5, dur: 7 },
    { size: 52, top: '78%', right: '22%', delay: 0.8, dur: 14 },
    { size: 32, top: '24%', right: '34%', delay: 1.8, dur: 9.5 },
    { size: 40, bottom: '40%', left: '22%', delay: 2.2, dur: 11.5 },
  ];
  return (
    <>
      {bubbles.map((b, i) => (
        <div
          key={i}
          className="bubble"
          style={{
            width: b.size, height: b.size,
            top: b.top, left: b.left, right: b.right, bottom: b.bottom,
            animation: `bubble-float-${i % 3} ${b.dur}s ease-in-out ${b.delay}s infinite`,
          }}
        />
      ))}
      <style>{`
        @keyframes bubble-float-0 {
          0%, 100% { transform: translate(0, 0); }
          25% { transform: translate(6px, -10px); }
          50% { transform: translate(-4px, -18px); }
          75% { transform: translate(8px, -8px); }
        }
        @keyframes bubble-float-1 {
          0%, 100% { transform: translate(0, 0); }
          33% { transform: translate(-8px, -12px); }
          66% { transform: translate(6px, -20px); }
        }
        @keyframes bubble-float-2 {
          0%, 100% { transform: translate(0, 0); }
          50% { transform: translate(10px, -16px); }
        }
      `}</style>
    </>
  );
};

/* Coin icons as SVG */
const IconCalendar = () => (
  <svg width="44" height="44" viewBox="0 0 48 48" aria-hidden="true">
    <rect x="6" y="10" width="36" height="32" rx="4" fill="#E5232B" stroke="#5A2A12" strokeWidth="2.5" />
    <rect x="6" y="10" width="36" height="10" fill="#B81820" stroke="#5A2A12" strokeWidth="2.5" />
    <rect x="13" y="6" width="4" height="10" rx="1.5" fill="#5A2A12" />
    <rect x="31" y="6" width="4" height="10" rx="1.5" fill="#5A2A12" />
    <circle cx="16" cy="28" r="2.5" fill="#FFC627" />
    <circle cx="24" cy="28" r="2.5" fill="#FFC627" />
    <circle cx="32" cy="28" r="2.5" fill="#FFC627" />
    <circle cx="16" cy="36" r="2.5" fill="#FFC627" />
    <circle cx="24" cy="36" r="2.5" fill="#FFF7EC" />
  </svg>
);
const IconChat = () => (
  <svg width="44" height="44" viewBox="0 0 48 48" aria-hidden="true">
    <path d="M8 14 Q8 8 14 8 H34 Q40 8 40 14 V28 Q40 34 34 34 H22 L14 40 V34 Q8 34 8 28 Z"
      fill="#FFC627" stroke="#5A2A12" strokeWidth="2.5" strokeLinejoin="round" />
    <text x="24" y="26" fontFamily="Futura PT, sans-serif" fontWeight="800" fontSize="11" textAnchor="middle" fill="#5A2A12">EN/ES</text>
  </svg>
);
const IconHeart = () => (
  <svg width="44" height="44" viewBox="0 0 48 48" aria-hidden="true">
    <path d="M24 40 C8 30 4 18 12 12 C18 8 22 12 24 16 C26 12 30 8 36 12 C44 18 40 30 24 40 Z"
      fill="#E5232B" stroke="#5A2A12" strokeWidth="2.5" strokeLinejoin="round" />
    <circle cx="18" cy="20" r="3" fill="#FFC627" />
    <circle cx="30" cy="20" r="3" fill="#FFC627" />
  </svg>
);
const IconBundle = () => (
  <svg width="44" height="44" viewBox="0 0 48 48" aria-hidden="true">
    <ellipse cx="24" cy="32" rx="18" ry="10" fill="#FFC627" stroke="#5A2A12" strokeWidth="2.5" />
    <path d="M8 28 Q8 14 24 14 Q40 14 40 28" fill="#FFF7EC" stroke="#5A2A12" strokeWidth="2.5" />
    <rect x="22" y="16" width="4" height="22" fill="#E5232B" />
    <rect x="14" y="24" width="20" height="4" fill="#E5232B" />
  </svg>
);

/* Star sparkle for stickers */
const StickerStar = ({ className = "", size = 22 }) => (
  <svg className={`star ${className}`} width={size} height={size} viewBox="0 0 24 24" aria-hidden="true">
    <path d="M12 2 L14 10 L22 12 L14 14 L12 22 L10 14 L2 12 L10 10 Z"
      fill="#5A2A12" />
  </svg>
);

Object.assign(window, {
  GoldRibbonUnderline, HoursRibbonUnderline, CurlingLiquidRibbon,
  RibbonDivider, Sparkle, WasherPortal, BubbleField,
  IconCalendar, IconChat, IconHeart, IconBundle, StickerStar,
});
