/* ============================================================
   HERO — 3 switchable variants + animated abstract visuals
   ============================================================ */

/* ---- Digro illustration ---- */
function DigroIllustration() {
  return (
    <svg viewBox="0 0 540 520" fill="none" xmlns="http://www.w3.org/2000/svg"
      aria-hidden="true" style={{ width: "100%", height: "auto", display: "block" }}>
      <defs>
        <clipPath id="dg-clip">
          <rect x="44" y="82" width="372" height="252" rx="14"/>
        </clipPath>
        <filter id="dg-shadow" x="-12%" y="-12%" width="136%" height="136%">
          <feDropShadow dx="0" dy="10" stdDeviation="18" floodColor="#1a1a1a" floodOpacity="0.28"/>
          <feDropShadow dx="0" dy="3"  stdDeviation="5"  floodColor="#1a1a1a" floodOpacity="0.18"/>
        </filter>
      </defs>
      <style>{`
        @keyframes dg-float  { 0%,100%{transform:translateY(0)}  50%{transform:translateY(-10px)} }
        @keyframes dg-floatB { 0%,100%{transform:translateY(0)}  50%{transform:translateY(-6px)} }
        @keyframes dg-blink  { 0%,49%{opacity:1} 50%,100%{opacity:0} }
        @keyframes dg-cycle  { 0%,28%{fill:#FF5C00} 33%,61%{fill:#3d3d3d} 66%,94%{fill:#F5ECD7} 100%{fill:#FF5C00} }
        @keyframes dg-grid   { 0%,100%{opacity:.05} 50%{opacity:.13} }
        @keyframes dg-glow   { 0%,100%{opacity:.18} 50%{opacity:.38} }
        @keyframes dg-notif  { 0%,100%{transform:scale(1)} 45%{transform:scale(1.22)} }
        @keyframes dg-cursor-move { 0%,25%,100%{transform:translate(0,0)} 38%{transform:translate(2px,6px)} 55%{transform:translate(0,0)} }
        @keyframes dg-ripple { 0%,30%{transform:scale(0);opacity:0} 42%{transform:scale(1);opacity:0.55} 70%{transform:scale(2.8);opacity:0} 100%{transform:scale(0);opacity:0} }
        .dg-browser { animation: dg-float 5s ease-in-out infinite; transform-origin: 230px 208px; }
        .dg-blink   { animation: dg-blink 1s step-end infinite; }
        .dg-cycle   { animation: dg-cycle 5s ease-in-out infinite; }
        .dg-grid    { animation: dg-grid  3s ease-in-out infinite; }
        .dg-glow    { animation: dg-glow  3s ease-in-out infinite; }
        .dg-fa      { animation: dg-float  4s ease-in-out infinite; }
        .dg-fb      { animation: dg-floatB 4.8s ease-in-out infinite; }
        .dg-notif   { animation: dg-notif 2.8s 1.5s ease-in-out infinite; transform-origin: 472px 106px; }
        .dg-cursor  { animation: dg-cursor-move 2.8s 0.8s ease-in-out infinite; transform-origin: 103px 232px; }
        .dg-ripple  { animation: dg-ripple 2.8s 0.8s ease-out infinite; transform-origin: 107px 253px; transform-box: fill-box; }
      `}</style>

      {/* subtle grid background */}
      <g className="dg-grid">
        {[90,150,210,270,330,390,450,510].map(x =>
          <line key={"v"+x} x1={x} y1="10" x2={x} y2="510" stroke="#3d3d3d" strokeWidth="0.6"/>)}
        {[60,120,180,240,300,360,420,480].map(y =>
          <line key={"h"+y} x1="10" y1={y} x2="530" y2={y} stroke="#3d3d3d" strokeWidth="0.6"/>)}
      </g>

      {/* glow shadow beneath browser */}
      <ellipse cx="230" cy="360" rx="170" ry="14" fill="#FF5C00" className="dg-glow"/>

      {/* ═══ BROWSER MOCKUP ═══ */}
      <g className="dg-browser" filter="url(#dg-shadow)">

        {/* chrome shell */}
        <rect x="44" y="44" width="372" height="290" rx="14" fill="#1a1a1a"/>

        {/* traffic lights */}
        <circle cx="68"  cy="63" r="6" fill="#FF5C00"/>
        <circle cx="87"  cy="63" r="6" fill="#F5ECD7" opacity="0.25"/>
        <circle cx="106" cy="63" r="6" fill="#F5ECD7" opacity="0.25"/>

        {/* URL bar */}
        <rect x="130" y="54" width="196" height="18" rx="9" fill="#F5ECD7" opacity="0.1"/>
        <rect x="142" y="59" width="80"  height="8"  rx="4" fill="#F5ECD7" opacity="0.2"/>

        {/* action icons */}
        <rect x="344" y="56" width="14" height="14" rx="3" fill="#F5ECD7" opacity="0.12"/>
        <rect x="362" y="56" width="14" height="14" rx="3" fill="#F5ECD7" opacity="0.12"/>
        <rect x="380" y="56" width="14" height="14" rx="3" fill="#F5ECD7" opacity="0.12"/>
        <rect x="398" y="54" width="9"  height="18" rx="2" fill="#F5ECD7" opacity="0.08"/>

        {/* ── WEBSITE CONTENT (clipped) ── */}
        <g clipPath="url(#dg-clip)">

          {/* page bg */}
          <rect x="44" y="82" width="372" height="252" fill="#3d3d3d"/>

          {/* ── NAVBAR ── */}
          <rect x="44" y="82" width="372" height="34" fill="#2a2a2a"/>
          {/* logo mark */}
          <rect x="60" y="93" width="28" height="11" rx="2" fill="#FF5C00"/>
          <rect x="92" y="96" width="22" height="4"  rx="2" fill="#F5ECD7" opacity="0.4"/>
          <rect x="92" y="103" width="14" height="3" rx="1.5" fill="#F5ECD7" opacity="0.2"/>
          {/* nav links */}
          <rect x="228" y="96" width="22" height="5" rx="2" fill="#F5ECD7" opacity="0.3"/>
          <rect x="258" y="96" width="18" height="5" rx="2" fill="#F5ECD7" opacity="0.3"/>
          <rect x="284" y="96" width="22" height="5" rx="2" fill="#F5ECD7" opacity="0.3"/>
          {/* CTA chip in nav */}
          <rect x="314" y="90" width="52" height="20" rx="10" fill="#FF5C00"/>
          <rect x="320" y="96" width="40" height="8" rx="3" fill="#F5ECD7" opacity="0.35"/>

          {/* ── HERO: LEFT TEXT ── */}
          {/* orange overline */}
          <rect x="60" y="132" width="64" height="5" rx="2" fill="#FF5C00" opacity="0.8"/>
          {/* headline line 1 */}
          <rect x="60" y="146" width="196" height="20" rx="3" fill="#F5ECD7"/>
          {/* headline line 2 + cursor */}
          <rect x="60" y="172" width="160" height="20" rx="3" fill="#F5ECD7"/>
          <rect x="224" y="172" width="3" height="20" rx="1" fill="#FF5C00" className="dg-blink"/>
          {/* subtext */}
          <rect x="60" y="202" width="148" height="5" rx="2" fill="#F5ECD7" opacity="0.2"/>
          <rect x="60" y="212" width="120" height="5" rx="2" fill="#F5ECD7" opacity="0.14"/>
          <rect x="60" y="222" width="136" height="5" rx="2" fill="#F5ECD7" opacity="0.1"/>
          {/* CTA buttons */}
          <rect x="60" y="240" width="94" height="26" rx="13" fill="#FF5C00"/>
          <rect x="70" y="249" width="60" height="8"  rx="3" fill="#F5ECD7" opacity="0.45"/>
          <path d="M152 253 L158 256 L152 259" stroke="#F5ECD7" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" opacity="0.5"/>
          <rect x="162" y="240" width="72" height="26" rx="13" fill="none" stroke="#F5ECD7" strokeWidth="1.2" opacity="0.25"/>
          <rect x="172" y="249" width="52" height="8"  rx="3" fill="#F5ECD7" opacity="0.15"/>

          {/* ── HERO: RIGHT VISUAL ── */}
          {/* orange block */}
          <rect x="282" y="116" width="134" height="158" rx="4" fill="#FF5C00"/>
          {/* circle on orange */}
          <circle cx="349" cy="195" r="44" fill="#F5ECD7" opacity="0.07"/>
          <circle cx="349" cy="195" r="26" fill="#F5ECD7" opacity="0.1"/>
          {/* grid dot pattern on orange */}
          {[296,316,336,356,376,396].map(x =>
            [130,150,170,190,210,230,250].map(y =>
              <circle key={`${x}-${y}`} cx={x} cy={y} r="1.3" fill="#3d3d3d" opacity="0.18"/>))}
          {/* floating card on orange */}
          <rect x="288" y="226" width="122" height="40" rx="8" fill="#3d3d3d"/>
          <rect x="298" y="236" width="52" height="7" rx="3" fill="#F5ECD7" opacity="0.25"/>
          <rect x="298" y="248" width="72" height="5" rx="2" fill="#F5ECD7" opacity="0.14"/>
          <circle cx="390" cy="246" r="11" fill="#FF5C00" opacity="0.9"/>
          <path d="M386 246 L390 242 L394 246 L390 250 Z" fill="#3d3d3d" opacity="0.5"/>

          {/* ── BOTTOM STRIP ── */}
          <rect x="44" y="290" width="372" height="44" fill="#2a2a2a"/>
          <rect x="60"  y="302" width="40" height="7" rx="3" fill="#F5ECD7" opacity="0.18"/>
          <rect x="60"  y="314" width="60" height="5" rx="2" fill="#F5ECD7" opacity="0.1"/>
          <rect x="160" y="302" width="40" height="7" rx="3" fill="#F5ECD7" opacity="0.18"/>
          <rect x="160" y="314" width="52" height="5" rx="2" fill="#F5ECD7" opacity="0.1"/>
          <rect x="260" y="302" width="40" height="7" rx="3" fill="#F5ECD7" opacity="0.18"/>
          <rect x="260" y="314" width="44" height="5" rx="2" fill="#F5ECD7" opacity="0.1"/>
          <rect x="356" y="302" width="42" height="22" rx="11" fill="#FF5C00" opacity="0.85"/>
          <rect x="362" y="309" width="30" height="8" rx="3" fill="#F5ECD7" opacity="0.4"/>
        </g>

        {/* browser frame ring */}
        <rect x="44" y="44" width="372" height="290" rx="14" fill="none" stroke="#F5ECD7" strokeWidth="0.6" opacity="0.12"/>
      </g>

      {/* ═══ FLOATING DESIGN ELEMENTS ═══ */}

      {/* Notification dot (top right of browser) */}
      <g className="dg-notif">
        <circle cx="472" cy="106" r="16" fill="#FF5C00"/>
        <text x="472" y="112" fontSize="12" fontWeight="bold" fill="#F5ECD7" textAnchor="middle" fontFamily="sans-serif">+2</text>
      </g>

      {/* Color palette card (bottom left) */}
      <g className="dg-fa" style={{ transformOrigin: "50px 388px" }}>
        <rect x="10" y="368" width="82" height="40" rx="10" fill="white" stroke="#3d3d3d" strokeWidth="1.5"/>
        <circle cx="30"  cy="388" r="11" className="dg-cycle"/>
        <circle cx="53"  cy="388" r="11" fill="#3d3d3d"/>
        <circle cx="76"  cy="388" r="11" fill="#F5ECD7" stroke="#3d3d3d" strokeWidth="1"/>
      </g>

      {/* Grid / layout card (top left) */}
      <g className="dg-fb" style={{ transformOrigin: "26px 130px", animationDelay: "0.3s" }}>
        <rect x="6" y="110" width="42" height="42" rx="8" fill="#F5ECD7" stroke="#3d3d3d" strokeWidth="1.5"/>
        {[16,27,38].map(x => [120,131,142].map(y =>
          <circle key={`${x}-${y}`} cx={x} cy={y} r="2.2" fill="#3d3d3d" opacity="0.35"/>))}
      </g>

      {/* Pen tool chip (bottom right) */}
      <g className="dg-fb" style={{ transformOrigin: "482px 408px", animationDelay: "0.8s" }}>
        <rect x="458" y="386" width="48" height="44" rx="10" fill="#FF5C00"/>
        <path d="M474 416 L482 396 L490 416 L482 411 Z" fill="#3d3d3d" opacity="0.75"/>
        <line x1="478" y1="404" x2="486" y2="404" stroke="#F5ECD7" strokeWidth="1.5" strokeLinecap="round" opacity="0.5"/>
      </g>

      {/* Cursor hovering over CTA button */}
      <g className="dg-cursor">
        <g transform="translate(96, 228) scale(0.22)">
          <path d="M0,152.12V18.68C0,2.07,20.09-6.25,31.83,5.5l90.71,90.71c11.75,11.75,3.43,31.83-13.19,31.83h-40.33c-5.92,0-11.48,2.81-15,7.57l-20.38,27.59c-10.69,14.47-33.65,6.91-33.65-11.08Z"
            fill="#F5ECD7"/>
        </g>
      </g>
    </svg>
  );
}

/* ---- Animated radar / findability visual (variant A) ---- */
function RadarVisual() {
  return (
    <div className="radar" aria-hidden="true">
      <div className="radar__ring r1"></div>
      <div className="radar__ring r2"></div>
      <div className="radar__ring r3"></div>
      <div className="radar__ring r4"></div>
      <div className="radar__sweep"></div>
      <div className="radar__blip b1" style={{ left: "72%", top: "34%" }}></div>
      <div className="radar__blip b2" style={{ left: "30%", top: "64%" }}></div>
      <div className="radar__blip b3" style={{ left: "66%", top: "70%" }}></div>
      <div className="radar__blip b4" style={{ left: "26%", top: "30%" }}></div>
      <div className="radar__core"></div>
      <div className="radar__tag" style={{ left: "74%", top: "24%" }}><b>#1</b>&nbsp;din side</div>
      <div className="radar__tag" style={{ left: "20%", top: "78%" }}>søgeord ✓</div>
    </div>);
}

/* ---- Animated Google-style search result (variant C) ---- */
function SearchMock() {
  const phrase = "tagdækker københavn";
  const [typed, setTyped] = React.useState("");
  React.useEffect(() => {
    let i = 0; let alive = true;
    function tick() {
      if (!alive) return;
      if (i <= phrase.length) { setTyped(phrase.slice(0, i)); i++; setTimeout(tick, 110); }
      else { setTimeout(() => { i = 0; tick(); }, 2600); }
    }
    const id = setTimeout(tick, 600);
    return () => { alive = false; clearTimeout(id); };
  }, []);
  return (
    <div className="searchmock" aria-hidden="true">
      <div className="searchmock__bar"><span className="mag"></span><span>{typed}<span className="searchmock__caret"></span></span></div>
      <div className="searchmock__result top">
        <span className="searchmock__rank">★ #1 · DIN VIRKSOMHED</span>
        <div className="url">www.dinvirksomhed.dk</div>
        <div className="ttl">Tagdækker i København — gratis tilbud i dag</div>
        <div className="desc">Autoriseret tagarbejde, 5-stjernede anmeldelser og hurtig opstart. Få et uforpligtende tilbud…</div>
      </div>
      <div className="searchmock__result"><div className="url">www.konkurrent-a.dk</div><div className="ttl">Tag &amp; tagrenovering</div><div className="searchmock__ghost w2"></div><div className="searchmock__ghost w1"></div></div>
      <div className="searchmock__result"><div className="url">www.konkurrent-b.dk</div><div className="searchmock__ghost w3"></div><div className="searchmock__ghost w2"></div></div>
    </div>);
}

/* ---- Wave divider ---- */
function Wave({ flip, color = "var(--ink)", top = "var(--orange)" }) {
  return (
    <svg className="wave" viewBox="0 0 1440 180" preserveAspectRatio="none"
      style={{ transform: flip ? "scaleY(-1)" : "none", background: top, fill: "black", width: "1532px", height: "178px" }}>
      <path fill={color} d="M0,96 C240,40 420,150 720,110 C1020,70 1200,150 1440,80 L1440,180 L0,180 Z" style={{ fill: "rgb(238, 108, 45)" }} />
    </svg>);
}

/* ---- Friendly business-owner illustration — pure CSS/SVG ---- */
function IllustrationSvg() {
  return (
    <svg viewBox="0 0 320 430" xmlns="http://www.w3.org/2000/svg" style={{ width: "100%", height: "auto" }} aria-hidden="true">

      {/* Ground shadow */}
      <ellipse cx="160" cy="418" rx="68" ry="9" fill="#3d3d3d" opacity="0.07"/>

      {/* Floating figure group */}
      <g className="illus-float">

        {/* Legs */}
        <rect x="116" y="300" width="32" height="68" rx="16" fill="#2a2a2a"/>
        <rect x="172" y="300" width="32" height="68" rx="16" fill="#2a2a2a"/>
        {/* Shoes */}
        <ellipse cx="132" cy="368" rx="22" ry="10" fill="#3d3d3d"/>
        <ellipse cx="188" cy="368" rx="22" ry="10" fill="#3d3d3d"/>

        {/* Body */}
        <rect x="96" y="172" width="128" height="138" rx="24" fill="#FF5C00"/>
        {/* Apron bib */}
        <path d="M122,172 L198,172 L192,226 L128,226 Z" fill="#F5ECD7" opacity="0.65"/>
        {/* Apron neck strap */}
        <rect x="142" y="160" width="36" height="16" rx="7" fill="#F5ECD7" opacity="0.65"/>
        {/* Apron pocket */}
        <rect x="136" y="238" width="48" height="28" rx="6" fill="#F5ECD7" opacity="0.4"/>

        {/* Left arm */}
        <path d="M96,205 C56,222 50,278 82,292" stroke="#FFCFA3" strokeWidth="28" fill="none" strokeLinecap="round"/>
        {/* Right arm */}
        <path d="M224,205 C264,222 270,278 238,292" stroke="#FFCFA3" strokeWidth="28" fill="none" strokeLinecap="round"/>

        {/* Phone body */}
        <rect x="110" y="255" width="100" height="140" rx="12" fill="#3d3d3d"/>
        {/* Screen bg */}
        <rect x="119" y="264" width="82" height="122" rx="7" fill="#E8F4FD"/>
        {/* Screen glow pulse */}
        <rect className="illus-screen-glow" x="119" y="264" width="82" height="122" rx="7" fill="#FF5C00" opacity="0"/>
        {/* App bar */}
        <rect x="119" y="264" width="82" height="22" rx="7" fill="#ddeeff"/>
        <circle cx="130" cy="275" r="4" fill="#FF5C00"/>
        <rect x="138" y="272" width="40" height="6" rx="3" fill="#3d3d3d" opacity="0.2"/>
        {/* Check circle */}
        <circle cx="160" cy="335" r="24" fill="#FF5C00"/>
        <path d="M148,335 L156,344 L173,326" stroke="white" strokeWidth="3.5" fill="none" strokeLinecap="round" strokeLinejoin="round"/>
        {/* "Ny kunde!" label */}
        <rect x="126" y="300" width="68" height="18" rx="4" fill="#F5ECD7"/>
        <text x="160" y="312" textAnchor="middle" fontSize="9" fill="#FF5C00" fontFamily="system-ui,sans-serif" fontWeight="700">Ny kunde!</text>
        {/* Stars */}
        <text x="160" y="370" textAnchor="middle" fontSize="9" fill="#FF5C00" fontFamily="system-ui">★★★★★</text>

        {/* Neck */}
        <rect x="142" y="154" width="36" height="24" rx="10" fill="#FFCFA3"/>

        {/* Head */}
        <circle cx="160" cy="120" r="52" fill="#FFCFA3"/>

        {/* Hair */}
        <path d="M108,115 Q112,60 160,56 Q208,60 212,115 Q196,90 160,88 Q124,90 108,115Z" fill="#3d1f00"/>
        <path d="M108,115 Q100,145 112,168 Q114,148 116,132Z" fill="#3d1f00"/>
        <path d="M212,115 Q220,145 208,168 Q206,148 204,132Z" fill="#3d1f00"/>

        {/* Happy squinting eyes */}
        <path d="M136,115 Q145,108 154,115" stroke="#3d3d3d" strokeWidth="3" fill="none" strokeLinecap="round"/>
        <path d="M166,115 Q175,108 184,115" stroke="#3d3d3d" strokeWidth="3" fill="none" strokeLinecap="round"/>

        {/* Blush */}
        <ellipse cx="128" cy="132" rx="11" ry="7" fill="#FF5C00" opacity="0.2"/>
        <ellipse cx="192" cy="132" rx="11" ry="7" fill="#FF5C00" opacity="0.2"/>

        {/* Big smile */}
        <path d="M134,140 Q160,164 186,140" stroke="#3d3d3d" strokeWidth="3" fill="none" strokeLinecap="round"/>
        {/* Teeth */}
        <path d="M136,142 Q160,162 184,142 L182,148 Q160,167 138,148 Z" fill="white" opacity="0.55"/>
      </g>

      {/* Notification ping rings — outside float group so they appear at fixed position */}
      <circle className="illus-ping" cx="222" cy="258" r="10" fill="#FF5C00"/>
      <circle className="illus-ping illus-ping-delay" cx="222" cy="258" r="10" fill="#FF5C00"/>
      {/* Ping dot */}
      <circle cx="222" cy="258" r="7" fill="#FF5C00"/>
      <text x="222" y="261" textAnchor="middle" fontSize="7.5" fill="white" fontFamily="system-ui" fontWeight="800">+1</text>

      {/* Sparkles */}
      <g className="illus-sparkle">
        <line x1="58" y1="84" x2="58" y2="100" stroke="#FF5C00" strokeWidth="2.5" strokeLinecap="round"/>
        <line x1="50" y1="92" x2="66" y2="92" stroke="#FF5C00" strokeWidth="2.5" strokeLinecap="round"/>
        <line x1="53" y1="86" x2="63" y2="97" stroke="#FF5C00" strokeWidth="1.5" strokeLinecap="round" opacity="0.6"/>
        <line x1="63" y1="86" x2="53" y2="97" stroke="#FF5C00" strokeWidth="1.5" strokeLinecap="round" opacity="0.6"/>
      </g>
      <g className="illus-sparkle illus-sp2">
        <line x1="268" y1="60" x2="268" y2="74" stroke="#FF5C00" strokeWidth="2" strokeLinecap="round"/>
        <line x1="261" y1="67" x2="275" y2="67" stroke="#FF5C00" strokeWidth="2" strokeLinecap="round"/>
        <line x1="263" y1="62" x2="273" y2="72" stroke="#FF5C00" strokeWidth="1.3" strokeLinecap="round" opacity="0.5"/>
      </g>
      <g className="illus-sparkle illus-sp3">
        <line x1="285" y1="210" x2="285" y2="222" stroke="#FF5C00" strokeWidth="2" strokeLinecap="round"/>
        <line x1="279" y1="216" x2="291" y2="216" stroke="#FF5C00" strokeWidth="2" strokeLinecap="round"/>
      </g>
    </svg>
  );
}

/* ---- "online?" draw-on SVG ---- */
function OnlineSvg({ style }) {
  const svgRef = React.useRef(null);
  const started = React.useRef(false);

  React.useEffect(() => {
    if (!svgRef.current || started.current) return;
    started.current = true;
    const paths = svgRef.current.querySelectorAll("path");
    const delays    = [0.3, 1.9, 2.1, 2.15, 2.35];
    const durations = [1.6, 0.28, 0.45, 0.28, 0.45];
    paths.forEach((p, i) => {
      const len = p.getTotalLength();
      p.style.strokeDasharray  = len;
      p.style.strokeDashoffset = len;
      p.style.animation = `drawPath ${durations[i]}s ease forwards ${delays[i]}s`;
    });
  }, []);

  return (
    <svg ref={svgRef} className="online-svg" viewBox="0 0 1387.55 561.92"
      xmlns="http://www.w3.org/2000/svg" aria-label="online?" role="img" style={style}>
      <path strokeWidth="55" strokeLinecap="round" d="M163.78,261.95c-30.32-25.66-76.35-39.24-106.64,16.14s-18.44,87.96-5.38,111.04,40.64,40.32,68.97,31.8c24.79-7.46,38.53-35.98,45.49-54.79s6.05-69.16,3.42-91.47-30.82-22.01-30.82-22.01c0,0-20.44,28-.49,57.23s85.95,42.66,112.51,20.54,43.07-123.37,27.88-86.09-26.63,158.79-13.21,176.59,78.63-225.05,132.56-171.69c4.08,4.66-45.07,129.74-11.25,166.8s94.04-36.81,116.3-57.89,123.97-197.51,128.98-273.54c4.08-61.85-43.83-76.07-79.77-29.76s-60.95,242.23-43.81,306.84,95.48,76.02,134.1,15.83,51.33-154.89,40.72-135.25-98.46,206.91-26.16,178.66,121.64-113.36,123.8-166.49c4.34-70.48-17.29,192.03-7.29,166.49s130.86-223.76,117.32-168.02c-7.62,31.36-10.85,86.21-8.13,138.2,12.48,73.67,145.44-24.25,177.92-52.89,69.01-54.13,21.28-122.37-37.9-86.93-42.59,25.51-52.24,82.38-25.08,146.45,27.26,64.3,115.06,4.36,128.79-19.92"/>
      <path strokeWidth="39" d="M699.09,157.77c10.43-19.83,37.03,1.98,29.49,17.16-8.71,17.54-41.76,6.16-29.49-17.16Z"/>
      <path strokeWidth="55" strokeLinecap="round" d="M1241.08,319.8c28.41-86.72,97.79-113.48,114.97-168.19,21.7-89.97-51.67-85.9-57.49-85.9s-83.12-2.57-83.12,74.15"/>
      <path strokeWidth="39" d="M1207.09,395.17c1.05-22.38,34.39-13.89,33.98,3.05-.47,19.58-35.22,23.27-33.98-3.05Z"/>
      <path strokeWidth="55" strokeLinecap="round" d="M27.5,527.93c470.66,15.49,918.85,4.56,1332.55-46.93"/>
    </svg>
  );
}

/* ============================================================
   HERO VARIANTS
   ============================================================ */
function Hero({ variant, copy }) {
  if (variant === "type")   return <HeroType copy={copy} />;
  if (variant === "search") return <HeroSearch copy={copy} />;
  return <HeroRadar copy={copy} />;
}

/* Variant A — radar / split */
function HeroRadar({ copy }) {
  return (
    <header className="hero grain" id="top">
      <div className="blinds"></div>
      <div className="wrap" style={{ position: "relative", zIndex: 2 }}>
        <div className="hero__grid">
          <div>
            <p className="eyebrow reveal in">Hjemmesider · SEO · Synlighed</p>
            <h1 className="display hero__title reveal in d1" style={{ marginTop: 22 }}>
              Kan man <span className="hl">finde</span> dig online?
            </h1>
            <p className="lead hero__sub reveal in d2">{copy.sub}</p>
            <div className="hero__actions reveal in d3">
              <a href="#kontakt" className="btn">Kontakt os <span className="arrow">→</span></a>
              <a href="#ydelser" className="btn btn--ghost">Se hvad vi laver</a>
            </div>
            <div className="hero__meta reveal in d4">
              <div className="mi"><span className="n">100%</span><span className="l">Bygget til SEO</span></div>
              <div className="mi"><span className="n">Top 3</span><span className="l">Mål på Google</span></div>
              <div className="mi"><span className="n">14 dage</span><span className="l">Til live site</span></div>
            </div>
          </div>
          <div className="hero__visual-wrap reveal in d2"><RadarVisual /></div>
        </div>
      </div>
    </header>);
}

/* Variant B — type-forward, cream bg + illustration */
function HeroType({ copy }) {
  const heroRef = React.useRef(null);

  React.useEffect(() => {
    if (!window.gsap) return;
    const ctx = gsap.context(() => {
      gsap.registerPlugin(ScrollTrigger);
      const tl = gsap.timeline({ defaults: { ease: "power3.out" } });
      tl.fromTo(".hero-line",   { y: 55, opacity: 0 }, { y: 0, opacity: 1, duration: 0.85, stagger: 0.15 })
        .fromTo(".hero-illus",  { x: 50, opacity: 0 }, { x: 0, opacity: 1, duration: 0.95, ease: "power2.out" }, "-=0.55")
        .fromTo(".hero-cta a",  { y: 18, opacity: 0 }, { y: 0, opacity: 1, duration: 0.55, stagger: 0.1 }, "-=0.35");

      /* Scroll parallax on illustration */
      gsap.to(".hero-illus", {
        y: -55,
        ease: "none",
        scrollTrigger: {
          trigger: heroRef.current,
          start: "top top",
          end: "bottom top",
          scrub: 1.4
        }
      });
    }, heroRef);
    return () => ctx.revert();
  }, []);

  return (
    <header ref={heroRef} className="hero" id="top"
      style={{ background: "#F5ECD7", color: "#3d3d3d", position: "relative", overflow: "hidden", minHeight: "100vh", display: "flex", alignItems: "center" }}>
      <div className="wrap" style={{ position: "relative", zIndex: 2, paddingTop: 96, paddingBottom: 64, width: "100%", display: "flex", alignItems: "center", gap: 48 }}>

        {/* Left — headline + CTA */}
        <div style={{ flex: "1 1 48%", minWidth: 0 }}>
          <h1 className="display" style={{ margin: 0, fontSize: "clamp(2.8rem, 7vw, 6.8rem)", color: "#3d3d3d" }}>
            <span className="hero-line" style={{ display: "block", lineHeight: 1.05, opacity: 0, whiteSpace: "nowrap" }}>Findes din</span>
            <span className="hero-line" style={{ display: "block", lineHeight: 1.05, opacity: 0 }}>virksomhed</span>
            <span className="hero-line" style={{ display: "block", opacity: 0, marginTop: "-0.55em" }}>
              <OnlineSvg style={{ display: "block", width: "62%", height: "auto" }} />
            </span>
          </h1>
          <div className="hero-cta" style={{ marginTop: 40, display: "flex", gap: 14, flexWrap: "wrap" }}>
            <a href="/kontakt" className="btn">Kontakt os <span className="arrow">→</span></a>
            <a href="/ydelser" className="btn btn--ghost-orange">Ydelser</a>
          </div>
        </div>

        {/* Right — illustration */}
        <div className="hero-illus" style={{ flex: "1 1 52%", maxWidth: "clamp(320px, 52vw, 620px)", alignSelf: "center", opacity: 0,
          borderRadius: 24, overflow: "hidden" }}>
          <DigroIllustration />
        </div>
      </div>
    </header>);
}

/* Variant C — literal search result */
function HeroSearch({ copy }) {
  return (
    <header className="hero grain" id="top">
      <div className="blinds" style={{ opacity: 0.6 }}></div>
      <div className="wrap" style={{ position: "relative", zIndex: 2 }}>
        <div className="hero__grid">
          <div>
            <p className="eyebrow reveal in">Bliv fundet · ikke overset</p>
            <h1 className="display hero__title reveal in d1" style={{ marginTop: 22 }}>
              Vær <span className="hl">det første</span> de finder.
            </h1>
            <p className="lead hero__sub reveal in d2">{copy.sub}</p>
            <div className="hero__actions reveal in d3">
              <a href="#kontakt" className="btn">Kontakt os <span className="arrow">→</span></a>
              <a href="#cases" className="btn btn--ghost">Se resultater</a>
            </div>
          </div>
          <div className="hero__visual-wrap reveal in d2"><SearchMock /></div>
        </div>
      </div>
    </header>);
}

Object.assign(window, { Hero, RadarVisual, SearchMock, Wave });
