/* ────────────────────────────────────────────────────────────
   Section 2 - The Problem
   "Beyond 5km, the economics collapse. That's exactly where
    geothermal begins."
   3 proof points + a closing line about US geothermal potential.
   Visual: large headline, three numbered proof points laid out
   as a 3-column band of typographic specimens.
   ──────────────────────────────────────────────────────────── */

function SectionProblem() {
  // Parallax: U.S. drilling-costs background drifts slower than the
  // foreground as the user descends - gives the impression of moving
  // down through rock. Speed 0.5 per motion brief §11 (anchored /
  // monumental). The bg layer is sized 140% tall so the offset never
  // reveals empty edges, as the brief requires.
  const bgRef = React.useRef(null);
  const sectionRef = React.useRef(null);
  // Parallax speed RISES on mobile to dial the effect down. The
  // hook's convention is: maxOffset = sectionHeight * (1 - speed),
  // so a HIGHER speed value means LESS drift. On a phone the
  // section occupies most of the viewport, so a desktop-tuned 0.5
  // produces a much larger pixel-distance drift than intended —
  // raising to 0.8 keeps a hint of depth without the heave.
  const isMobile =
    typeof window !== "undefined" &&
    window.matchMedia &&
    window.matchMedia("(max-width: 768px)").matches;
  useParallax(bgRef, { speed: isMobile ? 0.8 : 0.5, container: sectionRef });

  const points = [
  {
    n: "01",
    stat: "~60%",
    label: "OF TOTAL PROJECT COST",
    body: "Drilling consumes ~60% of total project cost - before a single watt is produced."
  },
  {
    n: "02",
    stat: "5 km",
    label: "WHERE CONVENTIONAL DRILLING FAILS",
    body: "Beyond 5 km, conventional drilling fails - where 90%+ of the viable resource begins."
  },
  {
    n: "03",
    stat: "10×",
    label: "OUTPUT VS. CONVENTIONAL",
    body: "Superhot rock, capable of 10× the output of a conventional well, has never been commercially reached."
  }];


  return (
    <div ref={sectionRef} style={{ position: "relative", overflow: "hidden", isolation: "isolate" }}>
      {/* Full-bleed Geothermal Drilling Costs background. Replaces the
          earlier strata graphic. Same parallax slack (140% tall).
          ImageSettle wraps the parallax layer so the entrance
          transform (1.06→1.00 + y +40→0) lives on the wrapper while
          the inner div keeps owning the per-scroll parallax shift. */}
      <ImageSettle aria-hidden="true" style={{
        position: "absolute",
        top: "-20%",
        left: 0,
        width: "100%",
        height: "140%",
        pointerEvents: "none",
        zIndex: 0,
        WebkitMaskImage: "linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0.35) 14%, rgba(0,0,0,0.85) 32%, rgba(0,0,0,1) 55%, rgba(0,0,0,0.85) 85%, rgba(0,0,0,0.2) 100%)",
        maskImage: "linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0.35) 14%, rgba(0,0,0,0.85) 32%, rgba(0,0,0,1) 55%, rgba(0,0,0,0.85) 85%, rgba(0,0,0,0.2) 100%)"
      }}>
        <div
          ref={bgRef}
          style={{
            position: "absolute", inset: 0,
            backgroundImage: "url(assets/imagery/section-2-drilling-costs.png)",
            backgroundSize: "cover",
            backgroundPosition: "center center",
            backgroundRepeat: "no-repeat",
            opacity: 0.85,
            willChange: "transform"
          }} />
      </ImageSettle>

      {/* Framer-style gradient overlay - same shape as the hero. Heavier
          at top + bottom, lighter in the middle, fully graphite at the
          bottom so the section seam blends into Section 3. */}
      <div aria-hidden="true" style={{
        position: "absolute", inset: 0,
        background: "linear-gradient(180deg, rgba(1,0,4,0.50) 0%, rgba(1,0,4,0.20) 25%, rgba(1,0,4,0.20) 50%, rgba(1,0,4,0.50) 75%, #15171A 100%)",
        pointerEvents: "none",
        zIndex: 0
      }} />
      

      <SectionFrame index="02" plate="II." dispatch="The cost wall · § 02" bg="transparent">
        <SectionEyebrow index="02" label="The cost wall" />

      {/* Headline treatment per spec: both sentences 30px,
          -0.01em letter-spacing, 1.25 line-height. Rendered as a
          single <h2> via SectionHeading-style atom but with custom
          sizing. */}
      <h2 style={{
        fontFamily: '"GT America", system-ui, sans-serif',
        fontWeight: 600,
        fontSize: "var(--fs-fluid-h3)",
        lineHeight: 1.25,
        letterSpacing: "-0.01em",
        color: "#EDEAE2",
        margin: 0,
        textWrap: "balance",
        maxWidth: 1100
      }}>
        Beyond 5 km, the economics collapse. That's exactly where geothermal begins.{" "}
        <span style={{ color: "rgba(237,234,226,0.45)" }}>
          The United States sits on 5,500 GW of geothermal potential. The constraint isn't the resource. It's the cost of reaching it.
        </span>
      </h2>

      {/* Proof points - three column band, separated by hairlines.
                         A faint dark backing keeps mono numbers crisp against the strata. */}
      <div className="ax-problem-points" style={{
          position: "relative",
          marginTop: "var(--sp-fluid-xl)",
          display: "grid",
          gridTemplateColumns: "repeat(3, 1fr)",
          borderTop: "1px solid rgba(237,234,226,0.18)",
          borderBottom: "1px solid rgba(237,234,226,0.10)",
          background: "linear-gradient(180deg, rgba(15,15,16,0.55) 0%, rgba(15,15,16,0.78) 100%)",
          backdropFilter: "blur(2px)",
          WebkitBackdropFilter: "blur(2px)"
        }}>
        {points.map((p, i) =>
          <div key={p.n} style={{
            padding: "var(--sp-fluid-loose) var(--sp-fluid-base)",
            borderRight: i < 2 ? "1px solid rgba(237,234,226,0.10)" : "none",
            display: "flex",
            flexDirection: "column",
            gap: 20
          }}>
            <div style={{
              display: "flex",
              alignItems: "center",
              gap: 10,
              fontFamily: "var(--font-mono)",
              fontSize: 11,
              color: "#D4A24C",
              letterSpacing: "0.20em",
              textTransform: "uppercase"
            }}>
              <span>§ {p.n}</span>
              <span style={{ width: 24, height: 1, background: "rgba(212,162,76,0.6)" }} />
            </div>
            <div style={{
              fontFamily: "var(--font-display)",
              fontSize: "var(--fs-fluid-display)",
              fontWeight: 700,
              lineHeight: 0.95,
              letterSpacing: "-0.025em",
              color: "#EDEAE2",
              whiteSpace: "nowrap"
            }}>
              <CountUp value={p.stat} />
            </div>
            <div style={{
              fontFamily: "var(--font-mono)",
              fontSize: 11,
              color: "#6F7178",
              letterSpacing: "0.18em",
              textTransform: "uppercase",
              marginTop: -8
            }}>
              {p.label}
            </div>
            <div style={{
              fontFamily: "var(--font-body)",
              fontSize: 15,
              lineHeight: 1.55,
              color: "#A8A8A2",
              maxWidth: 360,
              marginTop: 4
            }}>
              {p.body}
            </div>
          </div>
          )}
      </div>
      <style>{`
        @media (max-width: 768px) {
          .ax-problem-points { grid-template-columns: 1fr !important; }
          .ax-problem-points > div { border-right: none !important; border-bottom: 1px solid rgba(237,234,226,0.10) !important; }
          .ax-problem-points > div:last-child { border-bottom: none !important; }
        }
      `}</style>
      </SectionFrame>
    </div>);

}

window.SectionProblem = SectionProblem;