/* global React, QuotanMock, ExcelMock, PdfMiniMock */
const { useState, useEffect, useRef } = React;

// ─── Logo lockup — bicolor-tail (cerchio + wordmark = var(circleColor), coda = gradiente orange)
function QuotanLogo({ height = 22, variant = 'light' }) {
  const color = variant === 'dark' ? '#FFFFFF' : '#1C1C1E';
  const id = variant === 'dark' ? 'lgd' : 'lgl';
  return (
    <svg height={height} viewBox="0 0 4031 1229" fill="none" xmlns="http://www.w3.org/2000/svg" style={{ display: 'block' }}>
      <defs>
        <linearGradient id={id} x1="338" y1="833" x2="911" y2="1094" gradientUnits="userSpaceOnUse">
          <stop offset="0%" stopColor="#F97316"/>
          <stop offset="100%" stopColor="#C2410C"/>
        </linearGradient>
      </defs>
      <path d="M374.244 321H428.105L455.964 323.662L483.824 328.1L517.255 336.087L546.971 345.85L571.116 355.612L597.118 368.037L612.905 376.912L626.835 385.787L642.622 396.437L657.48 407.975L667.695 415.962L676.982 424.837L684.411 431.05L691.84 438.15L698.34 445.25L707.627 455.012L717.842 467.437L727.128 478.975L740.129 497.612L748.487 510.925L761.488 534L771.703 556.187L780.99 580.15L788.419 603.225L793.991 626.3L798.634 652.037L801.42 679.55L802.349 700.85V712.387L800.491 743.45L796.777 770.962L792.134 794.925L785.633 818.887L775.418 848.175L765.203 871.25L751.273 897.875L738.272 918.287L724.343 937.812L721.557 941.362L717.842 940.475L703.912 928.05L693.697 920.062L681.625 909.412L671.41 901.425L657.48 889.887L647.265 882.787L649.122 878.35L663.052 856.162L673.267 836.637L682.554 814.45L689.983 792.262L695.555 769.187L699.269 747.887L701.126 728.362V691.087L698.34 665.35L694.626 644.937L687.197 618.312L678.839 596.125L666.767 571.275L655.623 552.637L646.336 539.325L635.193 525.125L624.978 513.587L614.762 502.937L601.761 490.512L591.546 482.525L580.403 473.65L561.83 461.225L542.328 450.575L515.398 438.15L492.181 430.162L468.037 423.95L448.535 420.4L422.533 417.737H382.601L362.171 419.512L336.169 423.95L312.024 430.162L293.452 436.375L270.235 446.137L252.591 455.012L230.304 468.325L213.588 480.75L201.516 490.512L190.372 500.275L180.157 510.037L171.799 519.8L162.513 530.45L149.512 548.2L141.154 561.512L131.867 577.487L121.652 599.675L114.223 619.2L106.794 645.825L103.08 666.237L100.294 692.862V725.7L103.08 753.212L107.723 777.175L113.295 797.587L118.866 813.562L126.296 831.312L137.439 853.5L147.654 870.362L156.941 883.675L165.299 894.325L173.656 904.087L182.014 912.962L192.229 923.612L206.159 936.037L216.374 944.025L231.232 954.675L245.162 963.55L267.45 975.975L288.808 985.737L314.81 994.612L338.027 1000.82L364.957 1005.26L389.102 1007.04H412.318L436.463 1005.26L463.393 1000.82L489.396 993.725L513.54 984.85L518.183 983.962L527.47 992.837L534.899 999.05L546.971 1009.7L557.187 1017.69L569.259 1027.45L585.046 1038.99L597.118 1046.97L596.19 1049.64L576.688 1060.29L554.401 1070.94L529.327 1080.7L504.254 1088.69L478.252 1094.9L451.321 1099.34L421.604 1102H382.601L358.457 1100.22L327.811 1095.79L299.952 1089.57L266.521 1078.92L247.948 1071.82L221.017 1059.4L202.444 1049.64L182.014 1037.21L167.156 1026.56L155.084 1017.69L143.011 1007.92L133.725 999.937L122.581 990.175L114.223 982.187L107.723 975.087L96.579 963.55L88.2212 953.787L74.2915 936.037L61.2905 917.4L48.2895 896.1L37.1458 875.687L26.9307 852.612L15.787 820.662L10.2151 800.25L5.57187 778.062L1.85729 754.1L0 734.575V683.1L2.78593 654.7L8.3578 623.637L14.8583 598.787L25.0734 569.5L35.2885 546.425L44.5749 527.787L57.5759 506.487L66.8624 492.287L78.0061 477.2L87.2926 465.662L97.5076 454.125L105.865 445.25L116.081 434.6L127.224 423.95L134.653 417.737L148.583 406.2L164.37 394.662L180.157 384.012L197.801 373.362L214.517 364.487L229.375 357.387L247.948 349.4L267.45 342.3L286.951 336.087L320.382 328.1L354.742 322.775L374.244 321Z" fill={color}/>
      <path d="M404.889 833.088H441.106L468.037 835.75L496.825 841.075L519.112 847.288L542.328 855.275L572.973 869.475L598.047 883.675L613.834 894.325L624.978 902.313L637.05 911.188L647.265 919.175L659.337 928.938L669.552 936.925L683.482 948.463L695.554 958.225L704.841 966.213L715.056 974.2L728.057 984.85L743.844 996.388L756.845 1006.15L773.561 1017.69L792.133 1030.11L818.136 1045.2L834.851 1054.08L849.709 1061.18L872.926 1071.83L899.856 1081.59L911 1085.14V1086.91L890.57 1090.46L864.568 1093.13L847.852 1094.01H824.636L799.563 1092.24L773.561 1088.69L751.273 1084.25L724.342 1077.15L700.198 1069.16L678.839 1060.29L663.052 1053.19L641.693 1041.65L621.263 1029.23L606.405 1018.58L593.404 1008.81L580.403 998.163L572.973 991.95L559.044 979.525L552.543 973.313L545.114 967.1L527.47 950.238L520.969 943.138L512.612 935.15L505.182 928.938L496.825 920.95L489.395 914.738L476.394 904.088L464.322 895.213L445.749 882.788L426.248 872.138L403.032 861.488L375.172 852.613L353.813 848.175L338.955 846.4V844.625L362.171 838.413L384.459 834.863L404.889 833.088Z" fill={`url(#${id})`}/>
      <path d="M1427.81 1102H1348.92L1343.12 1018.47C1325.34 1047.86 1301.36 1070.68 1271.2 1086.92C1241.03 1102.39 1205.84 1110.12 1165.63 1110.12C1120.77 1110.12 1081.71 1100.84 1048.46 1082.28C1015.2 1063.72 989.291 1035.87 970.73 998.751C952.941 961.627 944.047 914.836 944.047 858.378V521.947H1029.9V849.097C1029.9 908.649 1042.66 953.893 1068.18 984.829C1094.47 1014.99 1131.98 1030.07 1180.71 1030.07C1230.21 1030.07 1269.26 1014.22 1297.88 982.509C1327.27 950.026 1341.96 901.302 1341.96 836.336V521.947H1427.81V1102ZM1855.34 1110.12C1800.43 1110.12 1751.31 1098.13 1708 1074.16C1664.69 1050.18 1630.66 1016.15 1605.91 972.068C1581.17 927.211 1568.79 874.233 1568.79 813.134C1568.79 751.261 1581.17 697.897 1605.91 653.039C1631.44 608.182 1665.85 573.765 1709.16 549.79C1753.25 525.814 1802.75 513.826 1857.66 513.826C1912.57 513.826 1961.68 525.814 2004.99 549.79C2049.08 573.765 2083.49 608.182 2108.24 653.039C2133.76 697.123 2146.52 749.715 2146.52 810.813C2146.52 872.686 2133.76 926.051 2108.24 970.908C2082.72 1015.77 2047.91 1050.18 2003.83 1074.16C1959.75 1098.13 1910.25 1110.12 1855.34 1110.12ZM1854.18 1027.75C1888.21 1027.75 1920.3 1020.41 1950.47 1005.71C1980.63 990.243 2004.99 966.654 2023.55 934.945C2042.89 902.462 2052.56 861.471 2052.56 811.974C2052.56 761.702 2043.27 720.712 2024.71 689.002C2006.15 657.293 1981.79 634.091 1951.63 619.396C1922.24 603.928 1890.53 596.194 1856.5 596.194C1822.47 596.194 1790.76 603.928 1761.37 619.396C1731.98 634.091 1708 657.68 1689.44 690.162C1671.65 721.872 1662.76 762.476 1662.76 811.974C1662.76 862.245 1671.65 903.235 1689.44 934.945C1707.23 966.654 1730.43 990.243 1759.05 1005.71C1788.44 1020.41 1820.15 1027.75 1854.18 1027.75ZM2303.5 521.947V359.532H2390.51V521.947H2544.8V603.155H2390.51V915.223C2390.51 950.8 2397.86 976.709 2412.55 992.95C2428.02 1009.19 2447.35 1018.86 2470.56 1021.95C2494.53 1025.05 2519.28 1025.05 2544.8 1021.95V1097.36C2514.64 1104.32 2484.86 1106.25 2455.47 1103.16C2426.86 1100.07 2400.95 1091.56 2377.75 1077.64C2355.32 1062.94 2337.14 1042.45 2323.22 1016.15C2310.07 989.856 2303.5 956.213 2303.5 915.223V603.155H2216.49V521.947H2303.5ZM3037.34 1102L3030.38 997.59C3014.14 1033.17 2990.16 1061.01 2958.45 1081.12C2926.74 1100.45 2886.53 1110.12 2837.8 1110.12C2796.04 1110.12 2760.46 1103.55 2731.07 1090.4C2701.68 1077.25 2678.87 1058.69 2662.63 1034.71C2647.16 1009.96 2639.42 980.962 2639.42 947.706C2639.42 898.982 2657.6 859.151 2693.95 828.215C2730.3 796.506 2782.89 777.17 2851.72 770.21L3030.38 750.488V704.084C3030.38 671.601 3018.39 645.692 2994.42 626.357C2970.44 606.248 2937.96 596.194 2896.97 596.194C2856.75 596.194 2823.11 605.475 2796.04 624.036C2769.74 642.598 2751.57 669.281 2741.51 704.084L2662.63 676.241C2678.09 625.197 2706.32 585.366 2747.31 556.75C2789.08 528.134 2839.74 513.826 2899.29 513.826C2968.12 513.826 3021.49 531.615 3059.38 567.191C3098.05 601.994 3117.39 649.559 3117.39 709.884V1102H3037.34ZM3030.38 824.735L2850.56 845.617C2811.89 850.257 2782.5 861.085 2762.39 878.1C2742.29 894.341 2732.23 915.996 2732.23 943.066C2732.23 970.135 2741.9 991.79 2761.23 1008.03C2781.34 1024.27 2809.96 1032.39 2847.08 1032.39C2889.62 1032.39 2924.42 1023.89 2951.49 1006.87C2978.56 989.856 2998.28 967.041 3010.66 938.425C3023.81 909.036 3030.38 877.326 3030.38 843.296V824.735ZM3287.13 521.947H3367.18L3371.82 604.315C3390.38 575.699 3414.75 553.657 3444.91 538.189C3475.07 521.947 3510.26 513.826 3550.48 513.826C3594.56 513.826 3633.23 523.494 3666.49 542.829C3699.75 561.391 3725.65 589.62 3744.22 627.517C3762.78 664.64 3772.06 711.431 3772.06 767.89V1102H3685.05V778.331C3685.05 718.005 3671.9 672.374 3645.61 641.438C3620.08 609.729 3582.96 593.874 3534.24 593.874C3483.97 593.874 3444.52 610.502 3415.91 643.758C3388.06 677.015 3374.14 726.126 3374.14 791.092V1102H3287.13V521.947Z" fill={color}/>
    </svg>
  );
}

// ─── Header ─────────────────────────────────────────────────────────
function Header() {
  const [scrolled, setScrolled] = useState(false);
  const [open, setOpen] = useState(false);
  useEffect(() => {
    const onScroll = () => setScrolled(window.scrollY > 24);
    window.addEventListener('scroll', onScroll, { passive: true });
    return () => window.removeEventListener('scroll', onScroll);
  }, []);
  useEffect(() => {
    document.body.classList.toggle('no-scroll', open);
  }, [open]);

  const links = [
  ['Come funziona', '#come-funziona'],
  ['Prezzi', '#prezzi'],
  ['Blog', '#'],
  ['Domande', '#faq']];


  return (
    <header style={{
      position: 'fixed', top: 0, left: 0, right: 0, zIndex: 50,
      background: scrolled ? 'rgba(28,28,30,0.85)' : 'rgba(28,28,30,0.0)',
      backdropFilter: scrolled ? 'blur(16px) saturate(160%)' : 'none',
      WebkitBackdropFilter: scrolled ? 'blur(16px) saturate(160%)' : 'none',
      borderBottom: scrolled ? '1px solid var(--line-dark)' : '1px solid transparent',
      transition: 'background 0.3s ease, border-color 0.3s ease',
      color: 'white'
    }}>
      <div className="container" style={{
        display: 'flex', alignItems: 'center', justifyContent: 'space-between',
        height: 72
      }}>
        <a href="#top" style={{ display: 'flex', alignItems: 'center', textDecoration: 'none' }}>
          <img src="logo-white.svg" alt="Quotan" style={{ height: 20, display: 'block' }} />
        </a>
        <nav className="hide-mobile" style={{ display: 'flex', gap: 32, alignItems: 'center' }}>
          {links.map(([label, href]) =>
          <a key={label} href={href} style={{ textDecoration: 'none', color: 'rgba(255,255,255,0.78)', fontSize: 15, fontWeight: 500 }}
          onMouseOver={(e) => e.currentTarget.style.color = 'white'}
          onMouseOut={(e) => e.currentTarget.style.color = 'rgba(255,255,255,0.78)'}>
            {label}</a>
          )}
        </nav>
        <div className="hide-mobile" style={{ display: 'flex', gap: 10, alignItems: 'center' }}>
          <a href="#" style={{ color: 'rgba(255,255,255,0.78)', textDecoration: 'none', fontSize: 15, fontWeight: 500, padding: '8px 6px' }}>Accedi</a>
          <a href="#cta" className="btn btn-primary" style={{ padding: '12px 20px', fontSize: 15 }}>Provalo gratis →</a>
        </div>
        <button className="show-mobile" aria-label="Menu" onClick={() => setOpen(!open)}
        style={{
          display: 'none', background: 'transparent', border: '1px solid var(--line-dark)',
          color: 'white', padding: 10, borderRadius: 4, cursor: 'pointer'
        }}>
          <svg width="20" height="20" viewBox="0 0 20 20" fill="none">
            {open ?
            <g stroke="currentColor" strokeWidth="1.6"><path d="M4 4l12 12M16 4L4 16" /></g> :

            <g stroke="currentColor" strokeWidth="1.6"><path d="M3 6h14M3 10h14M3 14h14" /></g>
            }
          </svg>
        </button>
      </div>
      {/* mobile menu */}
      {open &&
      <div style={{
        position: 'fixed', top: 72, left: 0, right: 0, bottom: 0,
        background: 'rgba(28,28,30,0.98)', backdropFilter: 'blur(20px)',
        padding: 24, display: 'flex', flexDirection: 'column', gap: 4
      }}>
          {links.map(([label, href]) =>
        <a key={label} href={href} onClick={() => setOpen(false)}
        style={{
          padding: '20px 4px', fontSize: 24, fontWeight: 700, color: 'white',
          textDecoration: 'none', borderBottom: '1px solid var(--line-dark)',
          letterSpacing: '-0.02em'
        }}>{label}</a>
        )}
          <a href="#" onClick={() => setOpen(false)} style={{
          padding: '20px 4px', fontSize: 24, fontWeight: 700, color: 'white',
          textDecoration: 'none', borderBottom: '1px solid var(--line-dark)'
        }}>Accedi</a>
          <a href="#cta" onClick={() => setOpen(false)} className="btn btn-primary lg" style={{ marginTop: 24, alignSelf: 'flex-start' }}>Provalo gratis →</a>
        </div>
      }
      <style>{`
        @media (max-width: 880px) {
          .hide-mobile { display: none !important; }
          .show-mobile { display: inline-flex !important; align-items: center; }
        }
      `}</style>
    </header>);

}

// ─── Hero ───────────────────────────────────────────────────────────
function Hero() {
  const heroRef = useRef(null);
  const [scrollProgress, setScrollProgress] = useState(0);

  useEffect(() => {
    const onScroll = () => {
      if (!heroRef.current) return;
      const h = window.innerHeight;
      const p = Math.min(Math.max(window.scrollY / h, 0), 1);
      setScrollProgress(p);
    };
    window.addEventListener('scroll', onScroll, { passive: true });
    onScroll();
    return () => window.removeEventListener('scroll', onScroll);
  }, []);

  // Parallax: mockup translates up and scales slightly as we scroll
  const mockTranslate = -80 * scrollProgress;
  const mockScale = 1 + 0.04 * scrollProgress;
  const heroFade = 1 - scrollProgress * 0.5;
  const heroBlur = scrollProgress * 4;

  return (
    <section ref={heroRef} id="top" className="hero hero-with-bg" style={{
      position: 'relative',
      width: '100vw',
      background: 'var(--ink)',
      paddingTop: 120,
      paddingBottom: 0
    }}>
      {/* Background layer — only the top viewport area is rendered; below the SVG, the section is transparent so the mockup sits flush against the next section */}
      <div aria-hidden="true" style={{
        position: 'absolute', top: 0, left: 0, right: 0,
        height: '100vh',
        overflow: 'hidden',
        zIndex: 0,
        pointerEvents: 'none'
      }}>
        <HeroBgSVG />

        {/* Readability overlay */}
        <div style={{
          position: 'absolute', inset: 0,
          background: 'radial-gradient(ellipse 60% 70% at 50% 50%, rgba(0,0,0,0.60) 0%, transparent 100%)'
        }}></div>

        {/* Soft fade at the bottom of the SVG into the section's solid ink */}
        <div style={{
          position: 'absolute', left: 0, right: 0, bottom: 0, height: 200,
          background: 'linear-gradient(180deg, rgba(28,28,30,0) 0%, rgba(28,28,30,1) 100%)'
        }}></div>
      </div>

      <div className="container" style={{
        position: 'relative', zIndex: 2,
        opacity: heroFade,
        filter: `blur(${heroBlur}px)`,
        transition: 'opacity 0.1s linear'
      }}>
        <div style={{ display: 'flex', justifyContent: 'center', marginBottom: 28, display: 'none' }}>
          <span className="mono" style={{
            display: 'inline-flex', alignItems: 'center', gap: 10,
            padding: '8px 14px',
            border: '1px solid var(--line-dark)',
            background: 'rgba(255,255,255,0.03)',
            fontSize: 12, color: 'var(--muted-on-dark)',
            letterSpacing: '0.1em', textTransform: 'uppercase',
            borderRadius: 4, fontFamily: "'Satoshi', sans-serif", fontWeight: "700"
          }}>
            <span style={{ width: 6, height: 6, borderRadius: '50%', background: 'var(--orange)', boxShadow: '0 0 12px var(--orange)' }}></span>
            Software preventivi · imprese edili
          </span>
        </div>

        <h1 style={{
          textAlign: 'center',
          fontFamily: "'Libre Baskerville', serif",
          fontSize: 'clamp(44px, 8vw, 100px)',
          fontWeight: 400,
          letterSpacing: '-0.02em',
          lineHeight: 1.05,
          color: 'white',
          maxWidth: 1100,
          margin: '0 auto'
        }}>
          Per chi <span className="accent">i lavori li fa</span>,<br />non li disegna.
        </h1>

        <p style={{
          textAlign: 'center',
          fontSize: 'clamp(17px, 1.6vw, 21px)',
          color: 'var(--muted-on-dark)',
          maxWidth: 720, margin: '32px auto 0',
          lineHeight: 1.5
        }}>
          Il preventivo coi tuoi prezzi, in meno di 10 minuti. Descrivi il lavoro a parole tue, dal cantiere. A voce o con una foto. Esce il PDF, pronto da mandare al cliente.
        </p>

        <div style={{ display: 'flex', gap: 16, justifyContent: 'center', alignItems: 'center', marginTop: 40, flexWrap: 'wrap' }}>
          <a href="#cta" className="btn btn-primary lg">Provalo gratis</a>
          <a href="#come-funziona" style={{
            color: 'white', fontWeight: 600, fontSize: 16, textDecoration: 'none',
            display: 'inline-flex', alignItems: 'center', gap: 8
          }}>Vedi come funziona <span aria-hidden>→</span></a>
        </div>

        <p style={{
          textAlign: 'center', marginTop: 28, fontSize: 14,
          color: '#9CA3AF', fontWeight: 400
        }}>
          Niente carta di credito · Niente da configurare · Cancelli quando vuoi
        </p>

        {/* Proof quote */}
        <div style={{
          display: 'flex', justifyContent: 'center', marginTop: 48,
          padding: '0 16px'
        }}>
          <div style={{
            display: 'flex', alignItems: 'center', gap: 16,
            padding: '14px 20px',
            background: 'rgba(255,255,255,0.03)',
            border: '1px solid var(--line-dark)',
            borderRadius: 4,
            maxWidth: 720
          }}>
            <div style={{
              width: 36, height: 36, borderRadius: '50%',
              background: 'var(--orange)', color: 'white',
              display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
              fontWeight: 800, fontSize: 14, flexShrink: 0
            }}>M</div>
            <div style={{ fontSize: 14, color: 'rgba(255,255,255,0.85)', lineHeight: 1.5 }}>
              <span style={{ color: 'white', fontWeight: 700 }}>«Na bomba!»</span>
              <span style={{ color: 'var(--muted-on-dark)' }}> — Mirko, titolare impresa edile, Veneto. Primo preventivo da <span style={{ color: 'var(--orange)', fontWeight: 700 }}>44.000 €</span> in <span style={{ color: 'var(--orange)', fontWeight: 700 }}>10 minuti</span>.</span>
            </div>
          </div>
        </div>
      </div>

      {/* Floating mockup emerging from bottom */}
      <div style={{
        position: 'relative', zIndex: 3,
        marginTop: 80,
        paddingBottom: 0,
        transform: `translateY(${mockTranslate}px) scale(${mockScale})`,
        transformOrigin: 'center top',
        transition: 'transform 0.05s linear'
      }}>
        <div className="container" style={{ position: 'relative' }}>
          <div style={{
            marginBottom: 0
          }}>
            <QuotanMock />
          </div>

          {/* floating PDF card top-right */}
          <div className="hide-mobile" style={{
            position: 'absolute',
            right: 60,
            top: -40,
            transform: 'rotate(4deg)'
          }}>
            <PdfMiniMock />
          </div>

          {/* floating "10 min" stat top-left */}
          <div className="hide-mobile" style={{
            position: 'absolute',
            left: 40,
            top: -10,
            background: 'var(--ink-2)',
            border: '1px solid var(--line-dark)',
            color: 'white',
            padding: '18px 22px',
            borderRadius: 4,
            transform: 'rotate(-3deg)',
            boxShadow: '0 30px 60px -20px rgba(0,0,0,0.6)'
          }}>
            <div className="mono" style={{ fontSize: 10, color: 'var(--muted-on-dark)', textTransform: 'uppercase', letterSpacing: '0.1em', marginBottom: 4 }}>tempo medio</div>
            <div style={{ fontSize: 38, fontWeight: 800, color: 'var(--orange)', letterSpacing: '-0.03em', lineHeight: 1 }}>10 min</div>
            <div style={{ fontSize: 11, color: 'var(--muted-on-dark)', marginTop: 2 }}>per preventivo</div>
          </div>
        </div>
      </div>
    </section>);

}

// ─── Ticker ─────────────────────────────────────────────────────────
function Ticker() {
  const items = [
  'Prezzario Regionale Veneto integrato',
  '10.871 voci',
  'Listino personale tuo',
  'PDF professionale',
  'Input vocale dal cantiere',
  '14 giorni gratis',
  'Niente carta di credito'];

  const doubled = [...items, ...items, ...items];
  return (
    <div className="ticker">
      <div className="ticker-track">
        {doubled.map((it, i) =>
        <span key={i}>{it} <span className="dot">●</span></span>
        )}
      </div>
    </div>);

}

// ─── Reveal helper ──────────────────────────────────────────────────
function Reveal({ children, delay = 0, style = {}, ...rest }) {
  const ref = useRef(null);
  const [shown, setShown] = useState(false);
  useEffect(() => {
    if (!ref.current) return;
    const io = new IntersectionObserver(([e]) => {
      if (e.isIntersecting) {
        setTimeout(() => setShown(true), delay);
        io.disconnect();
      }
    }, { threshold: 0.15 });
    io.observe(ref.current);
    return () => io.disconnect();
  }, [delay]);
  return (
    <div ref={ref} className={'reveal' + (shown ? ' in' : '')} style={style} {...rest}>{children}</div>);

}

// ─── Section: Come funziona ─────────────────────────────────────────
function ComeFunziona() {
  const steps = [
  {
    n: '01',
    title: 'Descrivi il lavoro.',
    body: 'A parole tue, dal cantiere. A voce o con una foto del posto.',
    visual: 'upload'
  },
  {
    n: '02',
    title: 'Quotan compila i prezzi.',
    body: 'Il sistema scompone il lavoro in voci e inserisce i tuoi prezzi dal listino e dal Prezzario Regionale Veneto. 10.871 voci già dentro.',
    visual: 'compile'
  },
  {
    n: '03',
    title: 'Scegli il margine. Scarichi il PDF.',
    body: 'Tre opzioni di prezzo: competitivo, standard, premium. Scegli, scarichi, mandi al cliente.',
    visual: 'pdf'
  }];


  return (
    <section id="come-funziona" className="band-light" style={{ padding: '96px 0' }}>
      <div className="container">
        <Reveal>
          <span className="eyebrow" style={{ color: 'var(--orange)' }}>Come funziona</span>
          <h2 className="h2" style={{ marginTop: 16, maxWidth: 900 }}>
            Tre passaggi.<br /><span className="accent">Punto.</span>
          </h2>
        </Reveal>

        <div style={{
          display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 1,
          marginTop: 80,
          background: 'var(--line-light)',
          border: '1px solid var(--line-light)'
        }} className="cf-grid">
          {steps.map((s, i) =>
          <Reveal key={s.n} delay={i * 100} style={{ background: 'white', padding: '40px 32px', display: 'flex', flexDirection: 'column' }}>
              <div style={{
              display: 'inline-block', fontSize: 13, color: 'var(--orange)', fontWeight: 500,
              letterSpacing: '-0.005em', marginBottom: 24
            }}>Step {s.n}</div>
              <StepVisual kind={s.visual} />
              <h3 style={{ fontSize: 26, fontWeight: 800, letterSpacing: '-0.025em', marginTop: 32, marginBottom: 12 }}>
                {s.title}
              </h3>
              <p style={{ fontSize: 16, color: 'var(--muted-on-light)', lineHeight: 1.6 }}>
                {s.body}
              </p>
            </Reveal>
          )}
        </div>

        <Reveal style={{ marginTop: 56 }}>
          <a href="#" className="link-arrow" style={{ color: 'var(--ink)' }}>Vedi come funziona in dettaglio →</a>
        </Reveal>
      </div>

      <style>{`
        @media (max-width: 880px) {
          .cf-grid { grid-template-columns: 1fr !important; }
        }
      `}</style>
    </section>);

}

function StepVisual({ kind }) {
  if (kind === 'upload') {
    return (
      <div style={{
        height: 180, background: 'var(--surface)', borderRadius: 4,
        display: 'flex', alignItems: 'center', justifyContent: 'center',
        border: '1px dashed rgba(28,28,30,0.2)', position: 'relative', overflow: 'hidden'
      }}>
        <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 14 }}>
          <div style={{ display: 'flex', gap: 8 }}>
            <FileBadge label="📄 Computo" color="#E14B3D" />
            <FileBadge label="✍ Descrizione" color="#1F6E43" />
            <FileBadge label="🎙 Voce" mono color="#1C1C1E" />
          </div>
          <div className="mono" style={{ fontSize: 11, color: 'var(--muted-on-light)' }}>trascina o registra</div>
        </div>
      </div>);

  }
  if (kind === 'compile') {
    return (
      <div style={{
        height: 180, background: 'var(--ink)', color: 'white', padding: 16, borderRadius: 4,
        position: 'relative', overflow: 'hidden'
      }}>
        {[
        ['Demolizione tramezze', '450,80'],
        ['Massetto autolivellante', '1.245,32'],
        ['Pavimento gres 60×60', '2.998,70'],
        ['Tinteggiatura', '1.599,36']].
        map((r, i) =>
        <div key={i} style={{
          display: 'flex', justifyContent: 'space-between',
          padding: '8px 0', fontSize: 12,
          borderBottom: '1px solid var(--line-dark)',
          opacity: 0, animation: `fillIn 0.5s ease ${i * 0.12}s forwards`
        }}>
            <span style={{ color: 'rgba(255,255,255,0.85)' }}>{r[0]}</span>
            <span className="mono" style={{ color: 'var(--orange)', fontWeight: 600 }}>€ {r[1]}</span>
          </div>
        )}
        <style>{`@keyframes fillIn { to { opacity: 1; } }`}</style>
      </div>);

  }
  // pdf
  return (
    <div style={{
      height: 180, background: 'var(--surface)', borderRadius: 4,
      display: 'flex', alignItems: 'center', justifyContent: 'center', position: 'relative'
    }}>
      <div style={{ display: 'flex', gap: 14 }}>
        {[
        ['Competitivo', '€ 38.900', false],
        ['Standard', '€ 44.218', true],
        ['Premium', '€ 49.600', false]].
        map(([label, price, active]) =>
        <div key={label} style={{
          background: 'white',
          border: active ? '2px solid var(--orange)' : '1px solid var(--line-light)',
          padding: '12px 14px',
          borderRadius: 4,
          minWidth: 110
        }}>
            <div className="mono" style={{ fontSize: 9, textTransform: 'uppercase', color: active ? 'var(--orange)' : 'var(--muted-on-light)', letterSpacing: '0.1em', marginBottom: 6 }}>{label}</div>
            <div style={{ fontWeight: 800, fontSize: 16, letterSpacing: '-0.02em' }}>{price}</div>
          </div>
        )}
      </div>
    </div>);

}

function FileBadge({ label, color, mono }) {
  return (
    <div style={{
      padding: '8px 12px', background: 'white', border: '1px solid var(--line-light)',
      borderRadius: 4, fontSize: 12, fontWeight: 600,
      display: 'inline-flex', alignItems: 'center', gap: 8,
      fontFamily: mono ? 'JetBrains Mono, monospace' : 'inherit'
    }}>
      <span style={{ width: 6, height: 6, background: color, borderRadius: 1 }}></span>
      {label}
    </div>);

}

// ─── Section: Problema ──────────────────────────────────────────────
function Problema() {
  return (
    <section className="band-dark" style={{ padding: '96px 0', position: 'relative', overflow: 'hidden' }}>
      <ProblemaBg />
      <div className="container" style={{ position: 'relative', zIndex: 1 }}>
        <div style={{ display: 'grid', gridTemplateColumns: '1.1fr 0.9fr', gap: 80, alignItems: 'center' }} className="prob-grid">
          <div>
            <Reveal>
              <span className="eyebrow">Il problema</span>
              <h2 className="h2" style={{ marginTop: 16, color: 'white' }}>
                Le sere a fare preventivi.<br /><span className="accent">Sai cosa significa.</span>
              </h2>
            </Reveal>

            <Reveal delay={120}>
              <blockquote style={{
                marginTop: 40,
                paddingLeft: 24,
                borderLeft: '3px solid var(--orange)',
                fontSize: 20, fontStyle: 'italic',
                color: 'white', lineHeight: 1.5,
                fontWeight: 500
              }}>
                «Lunedì sono rimasto fino alle 9 e mezza di sera a fare un preventivo.»
                <footer style={{
                  marginTop: 12, fontSize: 13, fontStyle: 'normal',
                  color: 'var(--muted-on-dark)', fontWeight: 500
                }}>— Vincenzo, artigiano, Veneto</footer>
              </blockquote>
            </Reveal>

            <Reveal delay={200}>
              <div style={{ marginTop: 36, color: 'var(--muted-on-dark)', fontSize: 17, lineHeight: 1.65, maxWidth: 540 }}>
                <p>Cinquanta voci, prezzi a memoria, la calcolatrice del telefono. Tre ore se va bene. E intanto il cliente aspetta. Il preventivo che gli mandi è scritto in "ediliziese" che lui non capisce. Poi ti chiama, contesta, vuole sconti.</p>
                <p style={{ marginTop: 18, color: 'white' }}>
                  Lo facevi anche te. Lo facevano anche i tuoi colleghi.<br /><span style={{ color: 'var(--orange)', fontWeight: 700 }}>Per questo c'è Quotan.</span>
                </p>
              </div>
            </Reveal>
          </div>

          <Reveal delay={300} style={{ position: 'relative' }}>
            <ExcelMock />
            {/* sticky note */}
            <div style={{
              position: 'absolute', bottom: -30, right: -30,
              background: '#FFE066', padding: '14px 18px',
              fontFamily: '"Caveat", "Comic Sans MS", cursive',
              fontSize: 18, color: '#1C1C1E', fontWeight: 600,
              transform: 'rotate(6deg)', maxWidth: 200,
              boxShadow: '0 16px 40px -12px rgba(0,0,0,0.6)',
              lineHeight: 1.2
            }}>
              chiamare bianchi<br />x prezzo cemento!!
            </div>
          </Reveal>
        </div>
      </div>
      <style>{`
        @media (max-width: 880px) {
          .prob-grid { grid-template-columns: 1fr !important; gap: 60px !important; }
        }
      `}</style>
    </section>);

}

// ─── Section: Stats Bad ─────────────────────────────────────────────
function StatsBad() {
  const stats = [
  ['5–10', 'ore', 'a settimana che un titolare passa a fare preventivi a mano'],
  ['70%', '', 'delle dispute con i clienti nasce da preventivi poco chiari'],
  ['22,2%', '', 'delle aziende in liquidazione giudiziaria nel 2025 sono nell\'edilizia']];


  const sectionRef = React.useRef(null);
  const titleRef = React.useRef(null);
  const footerRef = React.useRef(null);

  React.useEffect(() => {
    const section = sectionRef.current;
    if (!section) return;
    const observer = new IntersectionObserver((entries) => {
      entries.forEach((entry) => {
        if (entry.isIntersecting) {
          // Title first
          if (titleRef.current) {
            titleRef.current.style.opacity = '1';
            titleRef.current.style.transform = 'translateY(0)';
          }
          // Then 3 stats with 400ms stagger
          const items = entry.target.querySelectorAll('.stat-item');
          items.forEach((item, i) => {
            setTimeout(() => {
              item.style.opacity = '1';
              item.style.transform = 'translateY(0)';
            }, i * 700);
          });
          // Footer 200ms after last stat
          setTimeout(() => {
            if (footerRef.current) {
              footerRef.current.style.opacity = '1';
              footerRef.current.style.transform = 'translateY(0)';
            }
          }, (items.length - 1) * 700 + 200);
          observer.unobserve(entry.target);
        }
      });
    }, { threshold: 0.2 });
    observer.observe(section);
    return () => observer.disconnect();
  }, []);

  return (
    <section ref={sectionRef} className="band-surface stats-section" style={{ padding: '96px 0' }}>
      <div className="container">
        <div ref={titleRef} className="stats-title" style={{ opacity: 0, transform: 'translateY(40px)', transition: 'opacity 0.9s ease-out, transform 0.9s ease-out' }}>
          <span className="eyebrow">IL COSTO NASCOSTO</span>
          <h2 className="h2" style={{ marginTop: 16, maxWidth: 900 }}>
            Quanto costa veramente un<br />preventivo <span className="accent">a mano.</span>
          </h2>
          <p style={{ marginTop: 20, fontSize: 18, color: 'var(--muted-on-light)' }}>I numeri che non vedi.</p>
        </div>

        <div style={{
          display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 24,
          marginTop: 80
        }} className="stats-grid-3">
          {stats.map((s, i) =>
          <div key={i} className="stat-item">
              <div style={{
              borderTop: '2px solid var(--ink)',
              paddingTop: 24
            }}>
                <div style={{
                display: 'flex', alignItems: 'baseline', gap: 8,
                fontSize: 'clamp(64px, 9vw, 120px)',
                fontWeight: 800, color: 'var(--orange)',
                letterSpacing: '-0.05em', lineHeight: 0.95
              }}>
                  <span>{s[0]}</span>
                  {s[1] && <span style={{ fontSize: 'clamp(20px, 2vw, 28px)', color: 'var(--ink)', letterSpacing: '-0.02em' }}>{s[1]}</span>}
                </div>
                <p style={{ marginTop: 18, fontSize: 16, color: 'var(--ink)', lineHeight: 1.5, maxWidth: 320 }}>
                  {s[2]}
                </p>
              </div>
            </div>
          )}
        </div>

        <div ref={footerRef} className="stats-footer" style={{ opacity: 0, transform: 'translateY(40px)', transition: 'opacity 0.9s ease-out, transform 0.9s ease-out' }}>
          <div style={{ marginTop: 60, paddingTop: 32, borderTop: '1px solid var(--line-light)', display: 'flex', justifyContent: 'space-between', alignItems: 'flex-end', flexWrap: 'wrap', gap: 16 }}>
            <p style={{ fontSize: 'clamp(20px, 2.4vw, 28px)', fontWeight: 700, letterSpacing: '-0.025em', maxWidth: 700 }}>
              Margini al 5–10%. <span style={{ color: 'var(--muted-on-light)', fontWeight: 500 }}>Zero spazio per gli errori di calcolo.</span>
            </p>
            <p className="mono" style={{ fontSize: 11, color: 'var(--muted-on-light)', textTransform: 'uppercase', letterSpacing: '0.08em' }}>

            </p>
          </div>
        </div>
      </div>
      <style>{`
        .stats-section .stat-item {
          opacity: 0;
          transform: translateY(40px);
          transition: opacity 0.9s ease-out, transform 0.9s ease-out;
        }
        @media (max-width: 880px) {
          .stats-grid-3 { grid-template-columns: 1fr !important; gap: 48px !important; }
        }
      `}</style>
    </section>);

}

// ─── Section: Excel vs Quotan ───────────────────────────────────────
function VsTable() {
  const rows = [
  ['3 ore a preventivo', 'Meno di 10 minuti'],
  ['Prezzi a memoria', 'I tuoi prezzi dal listino'],
  ['Errori di calcolo nascosti', 'Numeri sempre coerenti'],
  ['Voci scritte in "ediliziese"', 'Voci chiare dal Prezzario Regionale Veneto'],
  ['Si chiude senza salvare', 'Tutto online, sempre tuo'],
  ['Niente migliora', 'Più lo usi, più impara come lavori']];

  return (
    <section className="band-dark" style={{ padding: '96px 0', position: 'relative', overflow: 'hidden' }}>
      <ConfrontoBg />
      <div className="container" style={{ position: 'relative', zIndex: 1 }}>
        <Reveal>
          <span className="eyebrow">Il confronto</span>
          <h2 className="h2" style={{ marginTop: 16, color: 'white', maxWidth: 1100 }}>
            Excel sa cosa scrivi.<br />Quotan <span className="accent">sa cosa costa.</span>
          </h2>
        </Reveal>

        <Reveal delay={150} style={{ marginTop: 80 }}>
          <div style={{
            display: 'grid', gridTemplateColumns: '1fr 1fr',
            border: '1px solid var(--line-dark)'
          }} className="vs-head">
            <div style={{
              padding: '20px 28px', borderRight: '1px solid var(--line-dark)',
              background: 'rgba(255,255,255,0.02)'
            }}>
              <div className="mono" style={{ fontSize: 11, letterSpacing: '0.12em', textTransform: 'uppercase', color: 'var(--muted-on-dark)', marginBottom: 6 }}>Prima</div>
              <div style={{ fontSize: 22, fontWeight: 700, color: 'rgba(255,255,255,0.55)', textDecoration: 'line-through', textDecorationColor: 'rgba(255,255,255,0.25)' }}>Excel + memoria</div>
            </div>
            <div style={{
              padding: '20px 28px',
              background: 'linear-gradient(180deg, rgba(249,115,22,0.10), rgba(249,115,22,0.04))',
              borderLeft: '2px solid var(--orange)'
            }}>
              <div className="mono" style={{ fontSize: 11, letterSpacing: '0.12em', textTransform: 'uppercase', color: 'var(--orange)', marginBottom: 6 }}>Adesso</div>
              <div style={{ fontSize: 22, fontWeight: 800, color: 'white' }}>Quotan</div>
            </div>
          </div>

          <div style={{ border: '1px solid var(--line-dark)', borderTop: 'none' }} className="vs-rows">
            {rows.map((r, i) =>
            <div key={i} style={{
              display: 'grid', gridTemplateColumns: '1fr 1fr',
              borderBottom: i < rows.length - 1 ? '1px solid var(--line-dark)' : 'none'
            }} className="vs-row">
                <div style={{
                padding: '24px 28px', borderRight: '1px solid var(--line-dark)',
                display: 'flex', alignItems: 'center', gap: 14,
                color: 'rgba(255,255,255,0.50)', fontSize: 17
              }}>
                  <span style={{ width: 20, height: 20, border: '1px solid rgba(255,255,255,0.3)', borderRadius: 2, display: 'inline-flex', alignItems: 'center', justifyContent: 'center', flexShrink: 0 }}>
                    <svg width="10" height="10" viewBox="0 0 10 10" fill="none"><path d="M2 2L8 8M8 2L2 8" stroke="rgba(255,255,255,0.5)" strokeWidth="1.5" /></svg>
                  </span>
                  {r[0]}
                </div>
                <div style={{
                padding: '24px 28px',
                display: 'flex', alignItems: 'center', gap: 14,
                color: 'white', fontSize: 17, fontWeight: 600,
                background: 'rgba(249,115,22,0.04)',
                borderLeft: '2px solid var(--orange)'
              }}>
                  <span style={{ width: 20, height: 20, background: 'var(--orange)', borderRadius: 2, display: 'inline-flex', alignItems: 'center', justifyContent: 'center', flexShrink: 0 }}>
                    <svg width="10" height="10" viewBox="0 0 10 10" fill="none"><path d="M2 5L4 7L8 3" stroke="white" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" /></svg>
                  </span>
                  {r[1]}
                </div>
              </div>
            )}
          </div>
        </Reveal>
      </div>
      <style>{`
        @media (max-width: 720px) {
          .vs-head { grid-template-columns: 1fr !important; }
          .vs-head > div:first-child { border-right: none !important; border-bottom: 1px solid var(--line-dark); }
          .vs-row { grid-template-columns: 1fr !important; }
          .vs-row > div:first-child { border-right: none !important; border-bottom: 1px solid var(--line-dark); }
        }
      `}</style>
    </section>);

}

// ─── Section: Testimonial ───────────────────────────────────────────
function Testimonial() {
  return (
    <section className="band-light" style={{ padding: '96px 0' }}>
      <div className="container">
        <Reveal>
          <span className="eyebrow">Testimonial</span>
          <h2 className="h2" style={{ marginTop: 16, maxWidth: 900 }}>
            Non lo dice <span className="accent">solo Mirko.</span>
          </h2>
        </Reveal>

        <div style={{ display: 'grid', gridTemplateColumns: '1.2fr 0.8fr', gap: 80, marginTop: 80 }} className="t-grid">
          <Reveal delay={120}>
            <div style={{
              fontSize: 'clamp(28px, 3vw, 40px)',
              fontWeight: 700, lineHeight: 1.2, letterSpacing: '-0.025em',
              maxWidth: 720,
              textWrap: 'balance'
            }}>
              <span style={{ color: 'var(--orange)', fontFamily: 'Georgia, serif', fontSize: '1.4em', lineHeight: 0, verticalAlign: '-0.3em', marginRight: 4 }}>«</span>
              Un muratore che si fa i preventivi la sera dopo che ha fatto la giornata in cantiere... quello che stai cercando di creare è <span style={{ color: 'var(--orange)' }}>oro.</span>
              <span style={{ color: 'var(--orange)', fontFamily: 'Georgia, serif', fontSize: '1.4em', lineHeight: 0, verticalAlign: '-0.3em', marginLeft: 4 }}>»</span>
            </div>
            <div style={{ marginTop: 32, display: 'flex', alignItems: 'center', gap: 16 }}>
              <div style={{
                width: 56, height: 56, borderRadius: '50%',
                background: 'var(--ink)', color: 'white',
                display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
                fontWeight: 800, fontSize: 22
              }}>A</div>
              <div>
                <div style={{ fontWeight: 700, fontSize: 16 }}>Andrea</div>
                <div style={{ fontSize: 14, color: 'var(--muted-on-light)' }}>Titolare impresa edile · 12 dipendenti · Veneto</div>
              </div>
            </div>
          </Reveal>

          <Reveal delay={250}>
            <div style={{ fontSize: 16, lineHeight: 1.7, color: 'var(--ink)' }}>
              <p>Andrea ha un'azienda strutturata, un ufficio preventivi, conosce il BIM. Ha visto Quotan e ha detto questa frase. Non perché ne abbia bisogno per la sua impresa — perché sa cosa significa, per il muratore con 4 dipendenti, riprendersi le sere.</p>
              <p style={{ marginTop: 18 }}>E il muratore con 4 dipendenti l'ha già provato. Si chiama <strong>Mirko</strong>, gestisce un'impresa edile in Veneto da quindici anni. Il suo primo preventivo con Quotan, da <span className="accent" style={{ fontWeight: 700 }}>44.000 euro</span>, è uscito in <span className="accent" style={{ fontWeight: 700 }}>10 minuti</span> — voci abbinate, prezzi al posto giusto, PDF pronto. Quando l'ha visto compilarsi sotto i suoi occhi, ha solo detto: <em>«Na bomba!»</em></p>
              <p style={{ marginTop: 18, fontWeight: 600 }}>Da allora i suoi preventivi escono prima del caffè.</p>

              <div style={{ marginTop: 28, display: 'flex', alignItems: 'center', gap: 12 }}>
                <div style={{
                  width: 40, height: 40, borderRadius: '50%',
                  background: 'var(--orange)', color: 'white',
                  display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
                  fontWeight: 800, fontSize: 16
                }}>M</div>
                <div style={{ fontSize: 13, color: 'var(--muted-on-light)' }}>
                  <strong style={{ color: 'var(--ink)' }}>Mirko</strong> · titolare impresa edile · Veneto
                </div>
              </div>
            </div>
          </Reveal>
        </div>
      </div>
      <style>{`
        @media (max-width: 880px) {
          .t-grid { grid-template-columns: 1fr !important; gap: 48px !important; }
        }
      `}</style>
    </section>);

}

// ─── Section: Numbers ───────────────────────────────────────────────
function CountUp({ end, duration = 1400, format = (v) => v }) {
  const ref = useRef(null);
  const [val, setVal] = useState(0);
  useEffect(() => {
    if (!ref.current) return;
    const io = new IntersectionObserver(([e]) => {
      if (e.isIntersecting) {
        const start = performance.now();
        const tick = (t) => {
          const p = Math.min((t - start) / duration, 1);
          const eased = 1 - Math.pow(1 - p, 3);
          setVal(Math.round(end * eased));
          if (p < 1) requestAnimationFrame(tick);
        };
        requestAnimationFrame(tick);
        io.disconnect();
      }
    }, { threshold: 0.4 });
    io.observe(ref.current);
    return () => io.disconnect();
  }, [end, duration]);
  return <span ref={ref}>{format(val)}</span>;
}

function Numbers() {
  const stats = [
  {
    display: <CountUp end={10871} format={(v) => v.toLocaleString('it-IT').replace(/,/g, '.')} />,
    label: 'voci del Prezzario Regionale Veneto già integrate'
  },
  {
    display: <span><CountUp end={16} /> <span style={{ color: 'rgba(255,255,255,0.4)', fontSize: '0.5em', fontWeight: 600 }}>su</span> <CountUp end={16} /></span>,
    label: 'voci abbinate correttamente nel primo test reale'
  },
  {
    display: <span><CountUp end={10} /> <span style={{ fontSize: '0.5em', color: 'white', fontWeight: 600, letterSpacing: '-0.02em' }}>min</span></span>,
    label: 'preventivo da 44.000 euro fatto da Mirko'
  },
  {
    display: <span><CountUp end={150} /> <span style={{ fontSize: '0.5em', color: 'white', fontWeight: 600 }}>€/mese</span></span>,
    label: 'meno del primo preventivo che salvi'
  }];


  return (
    <section className="grid-bg-dark" style={{ padding: '96px 0', position: 'relative' }}>
      <div className="container">
        <Reveal>
          <span className="eyebrow">I numeri</span>
          <h2 className="h2" style={{ marginTop: 16, color: 'white', maxWidth: 900 }}>
            I numeri dentro <span className="accent">Quotan.</span>
          </h2>
        </Reveal>

        <div style={{
          display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', gap: 0,
          marginTop: 80,
          border: '1px solid var(--line-dark)'
        }} className="num-grid">
          {stats.map((s, i) =>
          <Reveal key={i} delay={i * 100}
          style={{
            padding: '40px 28px',
            borderRight: i < stats.length - 1 ? '1px solid var(--line-dark)' : 'none',
            display: 'flex', flexDirection: 'column', justifyContent: 'space-between',
            minHeight: 280
          }}
          className="num-cell">
            
              <div style={{
              fontSize: 'clamp(48px, 6vw, 84px)', fontWeight: 800,
              color: 'var(--orange)', letterSpacing: '-0.045em', lineHeight: 1
            }}>
                {s.display}
              </div>
              <p style={{ marginTop: 20, fontSize: 14, color: 'var(--muted-on-dark)', lineHeight: 1.5 }}>{s.label}</p>
            </Reveal>
          )}
        </div>

        <Reveal delay={400}>
          <p className="mono" style={{ marginTop: 40, fontSize: 13, color: 'var(--muted-on-dark)', fontFamily: "'Satoshi', sans-serif" }}>
            <span style={{ color: 'white' }}>«In 5 minuti si tira giù un preventivo.»</span> — Diego, capo cantiere, Veneto · test 16 aprile 2026
          </p>
          <p className="mono" style={{ marginTop: 8, fontSize: 11, color: 'rgba(255,255,255,0.25)', letterSpacing: '0.06em', textTransform: 'uppercase', fontFamily: "'Satoshi', sans-serif" }}>
            Ricerca settoriale Quotan, ANCE/CRESME 2025
          </p>
        </Reveal>
      </div>
      <style>{`
        @media (max-width: 980px) {
          .num-grid { grid-template-columns: repeat(2, 1fr) !important; }
          .num-cell:nth-child(1), .num-cell:nth-child(2) { border-bottom: 1px solid var(--line-dark); }
          .num-cell:nth-child(2) { border-right: none !important; }
          .num-cell:nth-child(3) { border-right: 1px solid var(--line-dark) !important; }
        }
        @media (max-width: 600px) {
          .num-grid { grid-template-columns: 1fr !important; }
          .num-cell { border-right: none !important; border-bottom: 1px solid var(--line-dark); }
          .num-cell:last-child { border-bottom: none; }
        }
      `}</style>
    </section>);

}

// ─── Section: Prezzi ────────────────────────────────────────────────
function Prezzi() {
  const features = [
  'Preventivi illimitati',
  'Prezzario Regionale Veneto (10.871 voci)',
  'Listino personale tuo',
  'PDF professionale',
  'Input vocale dal cantiere'];

  return (
    <section id="prezzi" className="band-light" style={{ padding: '96px 0' }}>
      <div className="container" style={{ maxWidth: 760, textAlign: 'center' }}>
        <Reveal>
          <span className="eyebrow" style={{ textAlign: "center" }}>Prezzi</span>
          <h2 className="h2" style={{ marginTop: 16 }}>
            Un piano. <span className="accent">Tutto incluso.</span>
          </h2>
        </Reveal>

        <Reveal delay={150} style={{ marginTop: 60 }}>
          <div style={{
            position: 'relative',
            background: 'white',
            border: '2px solid var(--orange)',
            padding: '48px 40px',
            borderRadius: 4,
            textAlign: 'left',
            boxShadow: '0 30px 80px -20px rgba(249,115,22,0.25)'
          }}>
            <div style={{
              position: 'absolute', top: -14, left: 32,
              background: 'var(--orange)', color: 'white',
              padding: '6px 14px', fontSize: 12, fontWeight: 700,
              letterSpacing: '0.05em',
              fontFamily: "'IBM Plex Mono', monospace",
              textTransform: 'uppercase'
            }}>UN PIANO SOLO</div>

            <div style={{ display: 'flex', alignItems: 'baseline', gap: 12, flexWrap: 'wrap' }}>
              <span style={{ fontSize: 'clamp(72px, 10vw, 120px)', fontWeight: 800, letterSpacing: '-0.05em', color: 'var(--ink)', lineHeight: 1 }}>
                150 €
              </span>
              <span style={{ fontSize: 22, color: 'var(--muted-on-light)', fontWeight: 600 }}>al mese</span>
            </div>

            <ul style={{ listStyle: 'none', marginTop: 36, display: 'grid', gap: 12 }}>
              {features.map((f) =>
              <li key={f} style={{ display: 'flex', alignItems: 'center', gap: 14, fontSize: 16 }}>
                  <span style={{
                  width: 22, height: 22, background: 'var(--orange)',
                  display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
                  flexShrink: 0
                }}>
                    <svg width="12" height="12" viewBox="0 0 12 12" fill="none"><path d="M2 6L5 9L10 3" stroke="white" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" /></svg>
                  </span>
                  {f}
                </li>
              )}
            </ul>

            <a href="#cta" className="btn btn-primary lg" style={{ marginTop: 36, width: '100%' }}>Provalo gratis 14 giorni</a>

            <p className="mono" style={{ marginTop: 20, fontSize: 12, color: 'var(--muted-on-light)', textTransform: 'uppercase', letterSpacing: '0.06em', textAlign: 'center', fontFamily: "'Satoshi', sans-serif", fontWeight: "700" }}>
              14 giorni gratis · Niente carta di credito · Cancelli quando vuoi
            </p>
          </div>
        </Reveal>

        <Reveal delay={300} style={{ marginTop: 32 }}>
          <a href="#" className="link-arrow">Vedi i prezzi in dettaglio →</a>
        </Reveal>
      </div>
    </section>);

}

// ─── Section: FAQ ───────────────────────────────────────────────────
function FAQ() {
  const items = [
  ['Posso provarlo gratis?', 'Sì. 14 giorni, niente carta di credito. Se non ti convince, non paghi niente.'],
  ['Quanto ci vuole per partire?', 'Mezza giornata. Carichi i tuoi listini o i vecchi preventivi, e Quotan impara come lavori. Da quel momento i preventivi escono coi tuoi prezzi.'],
  ['E se sbaglia i prezzi?', 'I prezzi non li inventa il sistema. Vengono dal tuo listino e dal Prezzario Regionale Veneto. Tu controlli e correggi sempre tutto.'],
  ['Devo essere bravo col computer?', 'No. Se sai mandare un messaggio su WhatsApp, sai usare Quotan. Niente form complicati, niente menu da imparare.'],
  ['Funziona solo in Veneto?', 'Quotan ha il Prezzario Regionale Veneto già dentro. In più puoi caricare il tuo listino personale, e funziona ovunque tu lavori.'],
  ['Se smetto di pagare, perdo i miei dati?', 'No. I tuoi dati restano al sicuro per 30 giorni dopo la cancellazione. Se cambi idea, li ritrovi.'],
  ['Per quanti dipendenti va bene?', 'È pensato per imprese da 2 a 10 dipendenti. Se sei un artigiano da solo, va bene lo stesso. Se sei più grande, scrivici a supporto@quotan.it.']];

  const [open, setOpen] = useState(0);
  return (
    <section id="faq" className="band-surface" style={{ padding: '96px 0' }}>
      <div className="container">
        <div style={{ display: 'grid', gridTemplateColumns: '0.8fr 1.2fr', gap: 80 }} className="faq-grid">
          <Reveal>
            <span className="eyebrow">FAQ</span>
            <h2 className="h2" style={{ marginTop: 16 }}>
              Domande che<br />ci fanno <span className="accent">tutti.</span>
            </h2>
            <p style={{ marginTop: 24, color: 'var(--muted-on-light)', fontSize: 16, maxWidth: 320 }}>
              Non trovi la risposta? Scrivici a <a href="mailto:supporto@quotan.it" style={{ color: 'var(--orange)', fontWeight: 600 }}>supporto@quotan.it</a>
            </p>
          </Reveal>

          <Reveal delay={150}>
            <div style={{ borderTop: '1px solid rgba(28,28,30,0.18)' }}>
              {items.map(([q, a], i) => {
                const isOpen = open === i;
                return (
                  <div key={i} style={{ borderBottom: '1px solid rgba(28,28,30,0.18)' }}>
                    <button
                      onClick={() => setOpen(isOpen ? -1 : i)}
                      style={{
                        width: '100%', textAlign: 'left',
                        background: 'transparent', border: 'none', cursor: 'pointer',
                        padding: '24px 0',
                        display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start',
                        gap: 24,
                        fontFamily: 'inherit'
                      }}>
                      
                      <span style={{
                        fontSize: 'clamp(18px, 1.6vw, 22px)', fontWeight: 700,
                        letterSpacing: '-0.02em', color: 'var(--ink)'
                      }}>{q}</span>
                      <span style={{
                        flexShrink: 0, width: 32, height: 32,
                        background: isOpen ? 'var(--orange)' : 'transparent',
                        border: isOpen ? 'none' : '1px solid rgba(28,28,30,0.25)',
                        color: isOpen ? 'white' : 'var(--ink)',
                        display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
                        transition: 'all 0.2s ease'
                      }}>
                        <svg width="14" height="14" viewBox="0 0 14 14" fill="none">
                          <path d="M7 2v10M2 7h10" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round"
                          style={{ transition: 'transform 0.2s ease', transformOrigin: 'center', transform: isOpen ? 'rotate(45deg)' : 'rotate(0deg)' }} />
                          
                        </svg>
                      </span>
                    </button>
                    <div style={{
                      maxHeight: isOpen ? 300 : 0, overflow: 'hidden',
                      transition: 'max-height 0.3s ease'
                    }}>
                      <p style={{ paddingBottom: 24, paddingRight: 56, fontSize: 16, color: 'var(--muted-on-light)', lineHeight: 1.6 }}>{a}</p>
                    </div>
                  </div>);

              })}
            </div>
          </Reveal>
        </div>
      </div>
      <style>{`
        @media (max-width: 880px) {
          .faq-grid { grid-template-columns: 1fr !important; gap: 48px !important; }
        }
      `}</style>
    </section>);

}

// ─── Section: CTA finale ────────────────────────────────────────────
function FinalCTA() {
  return (
    <section id="cta" className="grid-bg-dark" style={{ padding: '160px 0', position: 'relative', overflow: 'hidden' }}>
      <div style={{
        position: 'absolute', inset: 0,
        background: 'radial-gradient(ellipse 60% 50% at 50% 50%, rgba(255,255,255,0.04), transparent 60%)',
        pointerEvents: 'none'
      }}></div>
      <div className="container" style={{ position: 'relative', zIndex: 2, textAlign: 'center' }}>
        <Reveal>
          <h2 style={{
            fontFamily: "'Libre Baskerville', serif",
            fontSize: 'clamp(44px, 7vw, 96px)',
            fontWeight: 400, letterSpacing: '-0.018em', lineHeight: 1.05,
            color: 'white', maxWidth: 1100, margin: '0 auto'
          }}>
            Le sere a fare<br />preventivi sono <span className="accent">finite.</span>
          </h2>
        </Reveal>

        <Reveal delay={150}>
          <p className="mono" style={{
            marginTop: 32, fontSize: 14, color: 'var(--muted-on-dark)',
            textTransform: 'uppercase', letterSpacing: '0.1em', fontFamily: "'Satoshi', sans-serif", fontWeight: "700"
          }}>
            14 giorni gratis · Niente carta · Cancelli quando vuoi
          </p>
        </Reveal>

        <Reveal delay={250}>
          <a href="#" className="btn btn-primary xl" style={{ marginTop: 40, fontSize: 22, padding: '28px 44px' }}>
            Inizia gratis, zero impegno →
          </a>
        </Reveal>

        <Reveal delay={350}>
          <p style={{ marginTop: 32, fontSize: 14, color: 'var(--muted-on-dark)' }}>
            Hai una domanda? Scrivici a <a href="mailto:supporto@quotan.it" style={{ color: 'var(--orange)', fontWeight: 600 }}>supporto@quotan.it</a>
          </p>
        </Reveal>
      </div>
    </section>);

}

// ─── Footer ─────────────────────────────────────────────────────────
function Footer() {
  const cols = [
  ['Prodotto', ['Come funziona', 'Prezzi', 'Domande']],
  ['Azienda', ['Chi siamo', 'Contatti', 'Blog']],
  ['Legale', ['Privacy', 'Termini', 'Cookie']]];

  return (
    <footer className="band-dark" style={{ paddingTop: 80, paddingBottom: 40, borderTop: '1px solid var(--line-dark)' }}>
      <div className="container" style={{ fontFamily: "'Satoshi', sans-serif" }}>
        <div style={{ display: 'grid', gridTemplateColumns: '1.4fr repeat(3, 1fr)', gap: 48 }} className="footer-grid">
          <div>
            <div>
              <img src="logo-white.svg" alt="Quotan" style={{ height: 22, display: 'block' }} />
            </div>
            <p style={{ marginTop: 20, fontSize: 18, fontWeight: 700, color: 'white', letterSpacing: '-0.02em', maxWidth: 320, lineHeight: 1.3 }}>
              Per chi i lavori li fa,<br />non li disegna.
            </p>
            <p className="mono" style={{ marginTop: 28, fontSize: 12, color: 'var(--muted-on-dark)' }}>
              © 2026 Quotan S.r.l.<br />P.IVA [da inserire]
            </p>
          </div>
          {cols.map(([title, items]) =>
          <div key={title}>
              <h4 className="mono" style={{ fontSize: 11, fontWeight: 600, color: 'var(--orange)', textTransform: 'uppercase', letterSpacing: '0.12em', marginBottom: 18 }}>{title}</h4>
              <ul style={{ listStyle: 'none', display: 'grid', gap: 12 }}>
                {items.map((it) =>
              <li key={it}>
                    <a href="#" style={{ color: 'rgba(255,255,255,0.78)', textDecoration: 'none', fontSize: 15 }}>{it}</a>
                  </li>
              )}
              </ul>
            </div>
          )}
        </div>
        <div style={{
          marginTop: 64, paddingTop: 28,
          borderTop: '1px solid var(--line-dark)',
          display: 'flex', justifyContent: 'space-between', alignItems: 'center', flexWrap: 'wrap', gap: 12
        }}>
          <p className="mono" style={{ fontSize: 12, color: 'var(--muted-on-dark)', fontFamily: "'Satoshi', sans-serif", fontWeight: "500" }}>
            Made in Veneto · Per chi sta in cantiere
          </p>
          <p className="mono" style={{ fontSize: 12, color: 'var(--muted-on-dark)' }}>
            <a href="mailto:supporto@quotan.it" style={{ color: 'inherit', textDecoration: 'none' }}>supporto@quotan.it</a>
          </p>
        </div>
      </div>
      <style>{`
        @media (max-width: 880px) {
          .footer-grid { grid-template-columns: 1fr 1fr !important; gap: 36px !important; }
        }
        @media (max-width: 540px) {
          .footer-grid { grid-template-columns: 1fr !important; }
        }
      `}</style>
    </footer>);

}

Object.assign(window, {
  Header, Hero, Ticker, ComeFunziona, Problema, StatsBad, VsTable,
  Testimonial, Numbers, Prezzi, FAQ, FinalCTA, Footer, Reveal
});