// asset-classes.jsx — Section 5 tab visuals.
// Each mockup is a quiet, plausible product surface in monochrome + accent.

const ACT_TABS = [
{
  id: "cre",
  label: "Commercial real estate",
  image: "https://images.unsplash.com/photo-1486406146926-c627a92ad1ab?w=1400&q=80&auto=format&fit=crop",
  desc: "Acquisition diligence, portfolio risk, and capex execution across industrial, office, retail, and multifamily \u2014 with the underwriting and operating context built in."
},
{
  id: "datacenters",
  label: "Data centers",
  image: "https://images.unsplash.com/photo-1558494949-ef010cbdcc31?w=1400&q=80&auto=format&fit=crop",
  desc: "Speed-to-power assessment for hyperscale and colocation sites. Interconnection position, equipment exposure, and COD confidence in one view."
},
{
  id: "ai-power",
  label: "AI power infrastructure",
  image: "https://images.unsplash.com/photo-1473341304170-971dccb5ac1e?w=1400&q=80&auto=format&fit=crop",
  desc: "Demand-versus-supply intelligence across hyperscale pipelines. Where the gigawatts are, where the gaps are, and which projects can actually close them."
},
{
  id: "solar",
  label: "Utility-scale solar",
  image: "https://images.unsplash.com/photo-1509391366360-2e959784a276?w=1400&q=80&auto=format&fit=crop",
  desc: "Portfolio control tower for utility-scale solar. Schedule realism, equipment exposure, and tax credit eligibility tracked per project, per quarter."
},
{
  id: "wind",
  label: "Wind",
  image: "https://images.unsplash.com/photo-1532601224476-15c79f2f7a51?w=1400&q=80&auto=format&fit=crop",
  desc: "Site assessment, resource modeling, transmission proximity, and permitting risk for onshore and offshore wind development."
},
{
  id: "storage",
  label: "Battery energy storage",
  image: "https://images.unsplash.com/photo-1466611653911-95081537e5b7?w=1400&q=80&auto=format&fit=crop",
  desc: "Procurement intelligence across battery vendors, tier exposure, and lead time. Catch supply chain risk before it hits the COD."
},
{
  id: "gas",
  label: "Natural gas",
  image: "https://images.unsplash.com/photo-1581093588401-fbb62a02f120?w=1400&q=80&auto=format&fit=crop",
  desc: "Dispatchable generation siting, pipeline interconnect, air permits, and capacity market positioning for peaker and baseload assets."
},
{
  id: "nuclear",
  label: "Nuclear",
  image: "assets/asset-classes/nuclear.jpg",
  desc: "Long-cycle phase-gate tracking for SMR, restart, and large reactor projects \u2014 from site selection through NRC review and construction."
},
{
  id: "geothermal",
  label: "Geothermal",
  image: "https://images.unsplash.com/photo-1469289759076-d1484757abc3?w=1400&q=80&auto=format&fit=crop",
  desc: "Subsurface resource modeling, well design, and induced seismicity monitoring for enhanced and conventional geothermal development."
},
{
  id: "btm",
  label: "Hybrid & behind-the-meter",
  image: "https://images.unsplash.com/photo-1497435334941-8c899ee9e8e9?w=1400&q=80&auto=format&fit=crop",
  desc: "Co-located generation, storage, and load. Architecture, permits, EPC, and tax structures \u2014 modeled end-to-end before NTP."
}];


/* Mockup shell — chrome that wraps every tab's contents. */
function Mockup({ title, subtitle, badge, children }) {
  return (
    <div
      style={{
        border: "1px solid var(--border-2)",
        background: "var(--bg-2)",
        borderRadius: 6,
        overflow: "hidden"
      }}>
      
      <div
        style={{
          display: "flex", alignItems: "center", justifyContent: "space-between",
          padding: "14px 20px", borderBottom: "1px solid var(--border)"
        }}>
        
        <div style={{ display: "flex", alignItems: "center", gap: 10 }}>
          <div style={{ display: "flex", gap: 6 }}>
            <span style={{ width: 9, height: 9, borderRadius: 99, background: "var(--surface-2)" }} />
            <span style={{ width: 9, height: 9, borderRadius: 99, background: "var(--surface-2)" }} />
            <span style={{ width: 9, height: 9, borderRadius: 99, background: "var(--surface-2)" }} />
          </div>
          <div className="mono" style={{ fontSize: 11, letterSpacing: "0.06em", color: "var(--fg-3)", marginLeft: 12 }}>
            buildq · {title.toLowerCase().replace(/\s+/g, "-")}
          </div>
        </div>
        {badge &&
        <div className="mono cap" style={{ color: "var(--fg-3)" }}>{badge}</div>
        }
      </div>
      <div style={{ padding: "28px 32px 32px" }}>
        <div style={{ marginBottom: 22 }}>
          <div className="display display-4" style={{ marginBottom: 6 }}>{title}</div>
          {subtitle && <div className="muted" style={{ fontSize: 13 }}>{subtitle}</div>}
        </div>
        {children}
      </div>
    </div>);

}

/* Reusable bits */
function Gauge({ value, label, sub }) {
  // semicircular score gauge
  const r = 56;
  const cx = 70,cy = 70;
  const start = Math.PI;
  const end = 0;
  const arc = (frac) => {
    const a = start + (end - start) * frac;
    const x = cx + Math.cos(a) * r;
    const y = cy + Math.sin(a) * r;
    return `${x},${y}`;
  };
  const frac = Math.min(1, Math.max(0, value / 100));
  const sweep = ` A ${r} ${r} 0 ${frac > 0.5 ? 1 : 0} 1 `;
  const start0 = `${cx - r},${cy}`;
  return (
    <div style={{ display: "flex", flexDirection: "column", alignItems: "center", gap: 6 }}>
      <svg width="140" height="86" viewBox="0 0 140 86">
        <path d={`M ${start0} ${sweep} ${cx + r},${cy}`} fill="none" stroke="var(--border-strong)" strokeWidth="6" />
        <path
          d={`M ${start0} A ${r} ${r} 0 ${frac > 0.5 ? 1 : 0} 1 ${arc(frac)}`}
          fill="none" stroke="var(--accent)" strokeWidth="6" strokeLinecap="round" />
        
        <text x="70" y="68" textAnchor="middle" className="num-serif" fontSize="32" fill="var(--fg)">
          {value}
        </text>
      </svg>
      <div className="mono cap" style={{ color: "var(--fg-3)" }}>{label}</div>
      {sub && <div className="muted" style={{ fontSize: 11 }}>{sub}</div>}
    </div>);

}

function StatPill({ k, v, tone }) {
  const color = tone === "warn" ? "var(--accent)" : "var(--fg)";
  return (
    <div style={{ display: "flex", justifyContent: "space-between", padding: "10px 14px", borderBottom: "1px solid var(--border)" }}>
      <span className="muted" style={{ fontSize: 13 }}>{k}</span>
      <span className="mono" style={{ fontSize: 12, color }}>{v}</span>
    </div>);

}

/* ---- Tab contents ---- */

function MK_DataCenters() {
  return (
    <Mockup title="Speed-to-Power Assessment" subtitle="Atlas DC · 220 MW · Loudoun County, VA" badge="LIVE">
      <div style={{ display: "grid", gridTemplateColumns: "1fr 1.2fr", gap: 32 }}>
        <div>
          <div style={{ display: "flex", gap: 28, marginBottom: 24 }}>
            <Gauge value={72} label="READINESS" sub="↑ 6 wk-over-wk" />
            <Gauge value={58} label="COD CONFIDENCE" sub="P75 · Q3 '27" />
          </div>
          <div style={{ borderTop: "1px solid var(--border)" }}>
            <StatPill k="Power" v="ATTACHED · 220 MW" />
            <StatPill k="Interconnect queue" v="POS. 14 / SERIAL '23" />
            <StatPill k="Utility study" v="SIS COMPLETE" />
            <StatPill k="Equipment" v="2 GSU @ 28 wk" tone="warn" />
          </div>
        </div>
        <div>
          <div className="mono cap" style={{ color: "var(--fg-3)", marginBottom: 14 }}>Critical path · next 90 days</div>
          <div style={{ display: "flex", flexDirection: "column", gap: 10 }}>
            {[
            ["Final ISA execution", "May 27", 1.00, false],
            ["GSU delivery confirmation", "Jun 14", 0.55, true],
            ["Switchyard energization", "Aug 02", 0.18, false],
            ["Commissioning window", "Sep 09", 0.00, false]].
            map(([t, d, p, warn], i) =>
            <div key={i} style={{ display: "grid", gridTemplateColumns: "1fr 80px 200px", alignItems: "center", gap: 14, fontSize: 13 }}>
                <span>{t}</span>
                <span className="mono" style={{ color: "var(--fg-3)", fontSize: 11 }}>{d}</span>
                <div style={{ height: 4, background: "var(--surface-2)", borderRadius: 2, position: "relative" }}>
                  <div style={{
                  position: "absolute", inset: 0, width: `${p * 100}%`,
                  background: warn ? "var(--accent)" : "var(--fg-2)", borderRadius: 2
                }} />
                </div>
              </div>
            )}
          </div>
        </div>
      </div>
    </Mockup>);

}

function MK_AIPower() {
  // Power demand vs supply timeline
  return (
    <Mockup title="Hyperscale Power Demand" subtitle="14 sites · 2025–2029 · 4.6 GW pipeline" badge="FORECAST">
      <div style={{ display: "grid", gridTemplateColumns: "1fr 320px", gap: 32, alignItems: "stretch" }}>
        <div>
          <svg width="100%" viewBox="0 0 560 280" style={{ display: "block" }}>
            {[0, 1, 2, 3].map((i) =>
            <line key={i} x1="40" y1={50 + i * 60} x2="540" y2={50 + i * 60} stroke="var(--border)" strokeWidth="1" />
            )}
            {[0, 1, 2, 3, 4].map((i) =>
            <text key={i} x="32" y={232 - i * 60 + 4} textAnchor="end" fill="var(--fg-3)" fontSize="9" fontFamily="var(--font-mono)">{i}GW</text>
            )}
            {/* Supply baseline */}
            <path d="M 40 200 L 100 198 L 160 192 L 220 180 L 280 168 L 340 158 L 400 148 L 460 138 L 540 130" fill="none" stroke="var(--fg-2)" strokeWidth="1.5" />
            {/* Demand */}
            <path d="M 40 220 L 100 210 L 160 192 L 220 168 L 280 138 L 340 108 L 400 78 L 460 60 L 540 50" fill="none" stroke="var(--accent)" strokeWidth="1.5" />
            <path d="M 40 220 L 100 210 L 160 192 L 220 168 L 280 138 L 340 108 L 400 78 L 460 60 L 540 50 L 540 240 L 40 240 Z" fill="var(--accent-soft)" />
            {/* Gap */}
            <rect x="340" y="108" width="200" height="50" fill="none" stroke="var(--accent)" strokeWidth="0.5" strokeDasharray="3 3" />
            <text x="540" y="98" textAnchor="end" fill="var(--accent)" fontSize="9" fontFamily="var(--font-mono)" letterSpacing="0.6">SUPPLY GAP · 1.8 GW</text>
            {["'25", "'26", "'27", "'28", "'29"].map((y, i) =>
            <text key={i} x={60 + i * 120} y="260" textAnchor="middle" fill="var(--fg-3)" fontSize="9" fontFamily="var(--font-mono)">{y}</text>
            )}
          </svg>
        </div>
        <div>
          <div className="mono cap" style={{ color: "var(--fg-3)", marginBottom: 14 }}>Top exposures</div>
          <div>
            <StatPill k="PJM · DC corridor" v="940 MW @ RISK" tone="warn" />
            <StatPill k="ERCOT · West" v="620 MW @ Q4'27" />
            <StatPill k="MISO · Indiana" v="480 MW @ Q2'28" />
            <StatPill k="SPP · Oklahoma" v="310 MW · NTP" />
          </div>
        </div>
      </div>
    </Mockup>);

}

function MK_BTM() {
  return (
    <Mockup title="Behind-the-Meter Flow" subtitle="Co-located 180 MW gas + 60 MWh storage" badge="ARCHITECTURE">
      <div style={{ display: "grid", gridTemplateColumns: "1fr 280px", gap: 32 }}>
        <svg viewBox="0 0 560 280" width="100%" style={{ display: "block" }}>
          {/* Boxes: Generation, BESS, Load, Grid */}
          {[
          ["GAS · 180 MW", 30, 110, "var(--fg-2)"],
          ["BESS · 60 MWh", 230, 30, "var(--fg-2)"],
          ["DATA HALL · 200 MW", 230, 200, "var(--accent)"],
          ["GRID · 50 MW", 430, 110, "var(--fg-2)"]].
          map(([t, x, y, col], i) =>
          <g key={i}>
              <rect x={x} y={y} width="140" height="60" fill="var(--surface-2)" stroke={col} strokeWidth={col === "var(--accent)" ? 1.5 : 1} />
              <text x={x + 70} y={y + 28} textAnchor="middle" fill={col} fontSize="10" fontFamily="var(--font-mono)" letterSpacing="0.5">{t}</text>
              <text x={x + 70} y={y + 44} textAnchor="middle" fill="var(--fg-3)" fontSize="8" fontFamily="var(--font-mono)">{i === 0 ? "Primary" : i === 1 ? "Peak shaving" : i === 2 ? "Load" : "Backup"}</text>
            </g>
          )}
          {/* Lines */}
          <g fill="none" stroke="var(--fg-2)" strokeWidth="1">
            <path d="M 170 140 L 230 230" />
            <path d="M 170 140 L 230 60" />
            <path d="M 370 60 L 430 140" />
            <path d="M 370 230 L 430 140" />
            <path d="M 370 230 L 230 230" stroke="var(--accent)" strokeWidth="1.5" />
          </g>
          {/* Flow labels */}
          <text x="280" y="250" fill="var(--accent)" fontSize="9" fontFamily="var(--font-mono)">140 MW</text>
          <text x="195" y="90" fill="var(--fg-3)" fontSize="9" fontFamily="var(--font-mono)">40 MW</text>
        </svg>
        <div>
          <div className="mono cap" style={{ color: "var(--fg-3)", marginBottom: 14 }}>Readiness checks</div>
          <StatPill k="Air permit" v="ISSUED · APR" />
          <StatPill k="Gas LDC capacity" v="CONFIRMED" />
          <StatPill k="EPC contract" v="LNTP · 3 WK" tone="warn" />
          <StatPill k="ITC structure" v="UNDER REVIEW" />
          <StatPill k="LCOE est." v="$58/MWh" />
        </div>
      </div>
    </Mockup>);

}

function MK_Solar() {
  return (
    <Mockup title="COD Control Tower" subtitle="6 utility-scale solar projects · 1.4 GW combined" badge="PORTFOLIO">
      <div className="mono cap" style={{ color: "var(--fg-3)", marginBottom: 14, display: "grid", gridTemplateColumns: "180px 60px 1fr 80px", gap: 16 }}>
        <span>PROJECT</span><span>MW</span><span>SCHEDULE</span><span style={{ textAlign: "right" }}>COD P75</span>
      </div>
      <div>
        {[
        ["Mojave Ridge", 300, [["IA", 1], ["EPC", 1], ["Equip", 0.85], ["Energize", 0.4]], "Q1 '27"],
        ["Sandhill Flats", 220, [["IA", 1], ["EPC", 0.9], ["Equip", 0.6], ["Energize", 0.25]], "Q3 '27"],
        ["Pleasant Valley", 180, [["IA", 1], ["EPC", 0.7], ["Equip", 0.4], ["Energize", 0.1]], "Q4 '27", true],
        ["Big Springs", 260, [["IA", 1], ["EPC", 1], ["Equip", 1], ["Energize", 0.75]], "Q3 '26"],
        ["Tularosa II", 240, [["IA", 0.8], ["EPC", 0.4], ["Equip", 0.2], ["Energize", 0]], "Q2 '28", true],
        ["Cedar Creek", 200, [["IA", 1], ["EPC", 0.95], ["Equip", 0.9], ["Energize", 0.5]], "Q4 '26"]].
        map(([name, mw, phases, cod, warn], i) =>
        <div key={i} style={{
          display: "grid", gridTemplateColumns: "180px 60px 1fr 80px", gap: 16, alignItems: "center",
          padding: "12px 0", borderBottom: "1px solid var(--border)", fontSize: 13
        }}>
            <span>{name}</span>
            <span className="mono" style={{ color: "var(--fg-3)", fontSize: 12 }}>{mw}</span>
            <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr 1fr 1fr", gap: 6 }}>
              {phases.map(([label, p], j) =>
            <div key={j}>
                  <div style={{ height: 6, background: "var(--surface-2)", borderRadius: 2, position: "relative" }}>
                    <div style={{
                  position: "absolute", left: 0, top: 0, height: "100%",
                  width: `${p * 100}%`,
                  background: warn && p < 0.6 ? "var(--accent)" : "var(--fg-2)",
                  borderRadius: 2
                }} />
                  </div>
                  <div className="mono" style={{ fontSize: 9, color: "var(--fg-3)", marginTop: 4, letterSpacing: 0.5 }}>{label}</div>
                </div>
            )}
            </div>
            <span className="mono" style={{ fontSize: 12, color: warn ? "var(--accent)" : "var(--fg)", textAlign: "right" }}>{cod}</span>
          </div>
        )}
      </div>
    </Mockup>);

}

function MK_Wind() {
  return (
    <Mockup title="Site Wind Assessment" subtitle="Crow Butte · 320 MW · NE" badge="SITING">
      <div style={{ display: "grid", gridTemplateColumns: "1.3fr 1fr", gap: 28 }}>
        <svg viewBox="0 0 460 300" width="100%" style={{ display: "block", border: "1px solid var(--border)", borderRadius: 4 }}>
          {/* contour-style topo */}
          {Array.from({ length: 10 }).map((_, i) =>
          <ellipse key={i} cx={230 + i * 3} cy={150 + i * 2} rx={200 - i * 15} ry={110 - i * 8} fill="none" stroke="var(--border-2)" strokeWidth="0.5" />
          )}
          {/* turbines */}
          {[
          [120, 80], [180, 100], [240, 90], [300, 110], [360, 95],
          [140, 160], [200, 180], [260, 170], [320, 190], [380, 175],
          [160, 230], [220, 240], [280, 235], [340, 245]].
          map(([x, y], i) =>
          <g key={i}>
              <circle cx={x} cy={y} r="3" fill="var(--accent)" />
            </g>
          )}
          {/* wind direction arrows */}
          <g fill="none" stroke="var(--fg-3)" strokeWidth="0.6">
            <path d="M 40 50 L 60 50 M 55 46 L 60 50 L 55 54" />
            <path d="M 40 90 L 60 90 M 55 86 L 60 90 L 55 94" />
          </g>
          <text x="32" y="42" fill="var(--fg-3)" fontSize="8" fontFamily="var(--font-mono)">W</text>
          {/* boundary */}
          <rect x="80" y="40" width="340" height="230" fill="none" stroke="var(--fg-2)" strokeWidth="0.5" strokeDasharray="3 3" />
          <text x="86" y="32" fill="var(--fg-3)" fontSize="9" fontFamily="var(--font-mono)" letterSpacing="0.5">PROJECT BOUNDARY · 8,400 ac</text>
        </svg>
        <div>
          <div className="mono cap" style={{ color: "var(--fg-3)", marginBottom: 14 }}>Resource & risk</div>
          <StatPill k="Mean wind speed (80m)" v="8.2 m/s" />
          <StatPill k="Capacity factor (P50)" v="44.6%" />
          <StatPill k="Setback compliance" v="14/14" />
          <StatPill k="Avian risk" v="LOW-MOD" />
          <StatPill k="Transmission distance" v="6.4 mi" />
          <StatPill k="LCOE est." v="$32/MWh" />
        </div>
      </div>
    </Mockup>);

}

function MK_Storage() {
  return (
    <Mockup title="Equipment Radar" subtitle="Battery storage supply chain · 5 projects · 1.1 GWh" badge="PROCUREMENT">
      <div className="mono cap" style={{ color: "var(--fg-3)", marginBottom: 14, display: "grid", gridTemplateColumns: "200px 100px 1fr 100px 100px", gap: 12 }}>
        <span>VENDOR / TIER</span><span>SKU</span><span>LEAD TIME</span><span>EXPOSURE</span><span style={{ textAlign: "right" }}>STATUS</span>
      </div>
      {[
      ["CATL · T1", "EnerC 5MWh", 38, 0.42, "ORDERED", false],
      ["BYD · T1", "MC-1.0", 44, 0.28, "PO ISSUED", false],
      ["Fluence · T1", "Gridstack", 52, 0.18, "RFQ", true],
      ["Powin · T2", "Pod 1500", 46, 0.08, "BACKUP", false],
      ["LG ES · T1", "TR1300", 58, 0.04, "DEFERRED", true]].
      map(([v, sku, weeks, expo, status, warn], i) =>
      <div key={i} style={{
        display: "grid", gridTemplateColumns: "200px 100px 1fr 100px 100px", gap: 12, alignItems: "center",
        padding: "14px 0", borderBottom: "1px solid var(--border)", fontSize: 13
      }}>
          <span>{v}</span>
          <span className="mono" style={{ color: "var(--fg-3)", fontSize: 12 }}>{sku}</span>
          <div style={{ display: "flex", alignItems: "center", gap: 12 }}>
            <div style={{ flex: 1, height: 4, background: "var(--surface-2)", position: "relative", borderRadius: 2 }}>
              <div style={{
              position: "absolute", inset: 0, width: `${weeks / 60 * 100}%`,
              background: warn ? "var(--accent)" : "var(--fg-2)", borderRadius: 2
            }} />
            </div>
            <span className="mono" style={{ fontSize: 11, color: "var(--fg-3)", minWidth: 36, textAlign: "right" }}>{weeks}w</span>
          </div>
          <span className="mono" style={{ fontSize: 12, color: "var(--fg-3)" }}>{(expo * 100).toFixed(0)}% · port.</span>
          <span className="mono" style={{ fontSize: 11, color: warn ? "var(--accent)" : "var(--fg)", textAlign: "right", letterSpacing: 0.5 }}>{status}</span>
        </div>
      )}
    </Mockup>);

}

function MK_Nuclear() {
  return (
    <Mockup title="Phase-Gate Tracker" subtitle="SMR · 300 MW · Site selection → COL" badge="LONG-CYCLE">
      <svg viewBox="0 0 720 280" width="100%" style={{ display: "block" }}>
        {/* Phases */}
        {[
        ["Site selection", 0, 80, 1],
        ["ESP", 80, 140, 0.85],
        ["COL submittal", 220, 130, 0.45],
        ["NRC review", 350, 160, 0.15],
        ["Construction", 510, 150, 0],
        ["Commissioning", 660, 60, 0]].
        map(([name, x, w, p], i) =>
        <g key={i}>
            <rect x={x + 30} y="90" width={w} height="36" fill="var(--surface-2)" stroke="var(--border-strong)" />
            <rect x={x + 30} y="90" width={w * p} height="36" fill={p === 1 ? "var(--fg-2)" : i === 1 ? "var(--fg-2)" : "var(--accent)"} opacity={p === 1 ? 0.5 : 0.9} />
            <text x={x + 30 + w / 2} y="148" textAnchor="middle" fill="var(--fg-2)" fontSize="10" fontFamily="var(--font-mono)" letterSpacing="0.4">{name}</text>
            <text x={x + 30 + w / 2} y="162" textAnchor="middle" fill="var(--fg-3)" fontSize="8" fontFamily="var(--font-mono)">{(p * 100).toFixed(0)}%</text>
          </g>
        )}
        {/* Years */}
        <line x1="30" y1="200" x2="690" y2="200" stroke="var(--border-2)" />
        {["2024", "2025", "2026", "2027", "2028", "2029", "2030"].map((y, i) =>
        <g key={i}>
            <line x1={30 + i * 110} y1="196" x2={30 + i * 110} y2="206" stroke="var(--fg-3)" strokeWidth="0.5" />
            <text x={30 + i * 110} y="222" textAnchor="middle" fill="var(--fg-3)" fontSize="9" fontFamily="var(--font-mono)">{y}</text>
          </g>
        )}
        {/* Today marker */}
        <line x1="270" y1="70" x2="270" y2="200" stroke="var(--accent)" strokeWidth="1" strokeDasharray="2 3" />
        <text x="270" y="62" textAnchor="middle" fill="var(--accent)" fontSize="9" fontFamily="var(--font-mono)" letterSpacing="0.5">TODAY</text>
        {/* Risks */}
        <g fontFamily="var(--font-mono)" fontSize="9" fill="var(--accent)" letterSpacing="0.5">
          <circle cx="380" cy="78" r="3" fill="var(--accent)" />
          <text x="388" y="82">Spent fuel pathway · open</text>
        </g>
      </svg>
    </Mockup>);

}

function MK_Geothermal() {
  return (
    <Mockup title="Resource Profile" subtitle="Black Rock · enhanced geothermal · 80 MW" badge="SUBSURFACE">
      <div style={{ display: "grid", gridTemplateColumns: "1fr 280px", gap: 28 }}>
        <svg viewBox="0 0 480 320" width="100%" style={{ display: "block", border: "1px solid var(--border)", borderRadius: 4 }}>
          {/* depth gradient layers */}
          {Array.from({ length: 6 }).map((_, i) =>
          <rect key={i} x="0" y={i * 50} width="480" height="50"
          fill={`rgba(229, 162, 105, ${0.02 + i * 0.04})`} />
          )}
          {/* well bores */}
          {[120, 200, 280, 360].map((x, i) =>
          <g key={i}>
              <line x1={x} y1="0" x2={x} y2={i === 1 ? 280 : 250} stroke="var(--fg-2)" strokeWidth="1" />
              <line x1={x} y1={i === 1 ? 280 : 250} x2={x + (i === 1 ? 80 : 60)} y2={i === 1 ? 290 : 270} stroke={i === 1 ? "var(--accent)" : "var(--fg-2)"} strokeWidth="1.5" />
              <text x={x} y="-2" textAnchor="middle" fill="var(--fg-3)" fontSize="8" fontFamily="var(--font-mono)">W{i + 1}</text>
            </g>
          )}
          {/* depth labels */}
          {[1, 2, 3, 4, 5].map((d, i) =>
          <text key={i} x="8" y={50 * (i + 1) + 4} fill="var(--fg-3)" fontSize="8" fontFamily="var(--font-mono)">{d}km</text>
          )}
          {/* temperature contours */}
          <text x="450" y="160" textAnchor="end" fill="var(--fg-3)" fontSize="8" fontFamily="var(--font-mono)">180°C</text>
          <text x="450" y="260" textAnchor="end" fill="var(--accent)" fontSize="8" fontFamily="var(--font-mono)">240°C · target</text>
        </svg>
        <div>
          <div className="mono cap" style={{ color: "var(--fg-3)", marginBottom: 14 }}>Resource & dev</div>
          <StatPill k="Reservoir depth" v="3.8 km" />
          <StatPill k="Target temp" v="240°C" />
          <StatPill k="Flow rate (per well)" v="78 kg/s" />
          <StatPill k="Wells planned" v="4 + 1 injector" />
          <StatPill k="Induced seismicity" v="MONITORED" tone="warn" />
          <StatPill k="LCOE est." v="$71/MWh" />
        </div>
      </div>
    </Mockup>);

}

function MK_CRE() {
  return (
    <Mockup title="CRE Diligence" subtitle="Industrial portfolio · 12 assets · $840M" badge="ACQUISITION">
      <div style={{ display: "grid", gridTemplateColumns: "1fr 320px", gap: 32 }}>
        <div>
          <div className="mono cap" style={{ color: "var(--fg-3)", marginBottom: 14 }}>Asset-by-asset readiness</div>
          <div>
            {[
            ["Greenfield Logistics", "Industrial", "Phoenix, AZ", 0.92, "CLEAR"],
            ["Midtown 8", "Office", "Atlanta, GA", 0.61, "REVIEW", true],
            ["Stonebridge Center", "Mixed-use", "Denver, CO", 0.78, "CLEAR"],
            ["Harbor Point", "Multifamily", "Tampa, FL", 0.48, "FLAG", true],
            ["Westline Park", "Retail", "Dallas, TX", 0.85, "CLEAR"],
            ["North Loop II", "Industrial", "Columbus, OH", 0.70, "REVIEW"]].
            map(([name, kind, loc, score, status, warn], i) =>
            <div key={i} style={{
              display: "grid", gridTemplateColumns: "180px 100px 1fr 80px 80px", gap: 14, alignItems: "center",
              padding: "12px 0", borderBottom: "1px solid var(--border)", fontSize: 13
            }}>
                <span>{name}</span>
                <span className="mono" style={{ color: "var(--fg-3)", fontSize: 11 }}>{kind}</span>
                <span className="mono" style={{ color: "var(--fg-3)", fontSize: 11 }}>{loc}</span>
                <div style={{ height: 4, background: "var(--surface-2)", borderRadius: 2, position: "relative" }}>
                  <div style={{ position: "absolute", inset: 0, width: `${score * 100}%`, background: warn ? "var(--accent)" : "var(--fg-2)", borderRadius: 2 }} />
                </div>
                <span className="mono" style={{ fontSize: 11, color: warn ? "var(--accent)" : "var(--fg)", textAlign: "right", letterSpacing: 0.5 }}>{status}</span>
              </div>
            )}
          </div>
        </div>
        <div>
          <div className="mono cap" style={{ color: "var(--fg-3)", marginBottom: 14 }}>Diligence surface</div>
          <StatPill k="Title & survey" v="COMPLETE" />
          <StatPill k="Lease abstracts" v="112 / 118" />
          <StatPill k="Entitlement risk" v="2 OPEN" tone="warn" />
          <StatPill k="Environmental (P1)" v="CLEAR" />
          <StatPill k="Zoning intelligence" v="VALIDATED" />
          <StatPill k="Capex plan" v="$62M / 3Y" />
        </div>
      </div>
    </Mockup>);

}

function MK_Gas() {
  return (
    <Mockup title="Generation Siting" subtitle="Peaker plant \u00b7 220 MW \u00b7 Pipeline interconnect" badge="DISPATCHABLE">
      <div style={{ display: "grid", gridTemplateColumns: "1fr 280px", gap: 32 }}>
        <div>
          <div className="mono cap" style={{ color: "var(--fg-3)", marginBottom: 14 }}>Dispatch economics · next 7 days</div>
          <svg viewBox="0 0 560 220" width="100%" style={{ display: "block" }}>
            {[0, 1, 2, 3].map((i) =>
            <line key={i} x1="40" y1={30 + i * 50} x2="540" y2={30 + i * 50} stroke="var(--border)" strokeWidth="1" />
            )}
            {/* Locational marginal price line */}
            <path d="M 40 130 L 110 90 L 180 110 L 250 60 L 320 80 L 390 50 L 460 95 L 540 70" fill="none" stroke="var(--accent)" strokeWidth="1.5" />
            {/* Dispatch bars */}
            {[
            [50, 60], [120, 85], [190, 35], [260, 95], [330, 50], [400, 100], [470, 45]].
            map(([x, h], i) =>
            <rect key={i} x={x} y={180 - h} width="36" height={h} fill="var(--fg-2)" opacity="0.6" />
            )}
            <line x1="40" y1="180" x2="540" y2="180" stroke="var(--border-2)" />
            {["M", "T", "W", "T", "F", "S", "S"].map((d, i) =>
            <text key={i} x={68 + i * 70} y="200" textAnchor="middle" fill="var(--fg-3)" fontSize="9" fontFamily="var(--font-mono)">{d}</text>
            )}
            <text x="540" y="22" textAnchor="end" fill="var(--accent)" fontSize="9" fontFamily="var(--font-mono)" letterSpacing="0.6">LMP · $/MWh</text>
          </svg>
        </div>
        <div>
          <div className="mono cap" style={{ color: "var(--fg-3)", marginBottom: 14 }}>Siting & permits</div>
          <StatPill k="Pipeline interconnect" v="4.2 mi" />
          <StatPill k="Air permit" v="DRAFT · 60d" tone="warn" />
          <StatPill k="Capacity market" v="PJM RPM · IN" />
          <StatPill k="Heat rate" v="9,400 Btu/kWh" />
          <StatPill k="Capacity factor" v="18% (peaker)" />
          <StatPill k="LCOE est." v="$74/MWh" />
        </div>
      </div>
    </Mockup>);

}

const MOCKUPS = {
  "cre": MK_CRE,
  "datacenters": MK_DataCenters,
  "ai-power": MK_AIPower,
  "btm": MK_BTM,
  "solar": MK_Solar,
  "wind": MK_Wind,
  "storage": MK_Storage,
  "gas": MK_Gas,
  "nuclear": MK_Nuclear,
  "geothermal": MK_Geothermal
};

function ImageCard({ tab, idx, total, active }) {
  return (
    <div
      style={{
        height: "100%",
        border: `1px solid ${active ? "var(--border-strong)" : "var(--border-2)"}`,
        borderRadius: 6,
        background: "var(--bg-2)",
        position: "relative",
        overflow: "hidden",
        transition: "border-color .3s ease",
        display: "flex",
        flexDirection: "column"
      }}>
      
      {/* Image */}
      <div style={{
        position: "relative",
        flex: "1 1 auto",
        minHeight: 0,
        overflow: "hidden",
        background: "linear-gradient(180deg, var(--surface) 0%, var(--bg) 100%)"
      }}>
        <img
          src={(window.__resources && window.__resources[`img-${tab.id}`]) || tab.image}
          alt={tab.label}
          loading="lazy"
          onError={(e) => {
            // Fallback to a guaranteed-working seeded placeholder if Unsplash 404s.
            if (!e.currentTarget.dataset.fallback) {
              e.currentTarget.dataset.fallback = "1";
              e.currentTarget.src = `https://picsum.photos/seed/buildq-${tab.id}/1400/900`;
            }
          }}
          style={{
            width: "100%",
            height: "100%",
            objectFit: "cover",
            display: "block",
            filter: active ? "none" : "grayscale(0.6) brightness(0.85)",
            transition: "filter .5s ease, transform .8s ease",
            transform: active ? "scale(1.0)" : "scale(1.02)"
          }} />
        
        {/* Top dark scrim for the meta row */}
        <div
          aria-hidden
          style={{
            position: "absolute", inset: 0,
            background:
              "linear-gradient(180deg, rgba(10,14,24,0.55) 0%, rgba(10,14,24,0) 35%, rgba(10,14,24,0) 60%, rgba(10,14,24,0.88) 100%)"
          }} />
        
        {/* Meta row */}
        <div style={{
          position: "absolute", top: 18, left: 22, right: 22,
          display: "flex", justifyContent: "space-between", alignItems: "flex-start",
          color: "rgba(237,231,218,0.86)"
        }}>
          <div className="mono cap" style={{ fontSize: 10.5, letterSpacing: "0.16em" }}>
            {String(idx + 1).padStart(2, "0")} / {String(total).padStart(2, "0")}
          </div>
          <div className="mono cap" style={{ fontSize: 10.5, letterSpacing: "0.16em" }}>
            Asset class
          </div>
        </div>

        {/* Title overlaid at bottom of image */}
        <div style={{
          position: "absolute", left: 22, right: 22, bottom: 20,
          color: "#EDE7DA"
        }}>
          <div
            className="display"
            style={{
              fontSize: "clamp(22px, 2vw, 30px)",
              letterSpacing: "-0.015em",
              lineHeight: 1.1,
              textWrap: "balance"
            }}>
            {tab.label}
          </div>
        </div>
      </div>

      {/* Description block */}
      <div style={{
        flex: "0 0 auto",
        padding: "20px 22px 22px",
        borderTop: "1px solid var(--border)",
        background: "var(--bg-2)",
        display: "flex",
        gap: 14,
        alignItems: "flex-start"
      }}>
        <span
          aria-hidden
          style={{
            display: "inline-block",
            width: 6, height: 6, borderRadius: 999,
            background: "var(--accent)",
            marginTop: 8, flex: "0 0 auto"
          }} />
        <p style={{
          margin: 0,
          fontSize: 13.5,
          lineHeight: 1.55,
          color: "var(--fg-2)"
        }}>
          {tab.desc}
        </p>
      </div>
    </div>);

}

function InactiveCard({ tab, idx, total }) {
  return (
    <div
      style={{
        height: "100%",
        border: "1px solid var(--border-2)",
        borderRadius: 6,
        background: "linear-gradient(180deg, var(--bg-2) 0%, var(--surface) 100%)",
        position: "relative",
        display: "flex",
        flexDirection: "column",
        justifyContent: "space-between",
        padding: "32px",
        overflow: "hidden",
        transition: "border-color .3s ease, transform .5s ease"
      }}>
      
      {/* Decorative geometric accent — quietly hints at the asset class */}
      <svg
        aria-hidden
        viewBox="0 0 480 480"
        style={{
          position: "absolute",
          right: -120,
          top: -60,
          width: 540,
          height: 540,
          opacity: 0.18,
          pointerEvents: "none"
        }}>
        
        <g fill="none" stroke="var(--fg-2)" strokeWidth="0.5">
          {Array.from({ length: 12 }).map((_, i) =>
          <circle key={i} cx="240" cy="240" r={20 + i * 18} />
          )}
        </g>
        <circle cx="240" cy="240" r="3" fill="var(--accent)" opacity="0.6" />
      </svg>

      <div style={{ display: "flex", justifyContent: "space-between", alignItems: "flex-start" }}>
        <div className="mono cap" style={{ color: "var(--fg-3)" }}>
          {String(idx + 1).padStart(2, "0")} / {String(total).padStart(2, "0")}
        </div>
        <div className="mono cap" style={{ color: "var(--fg-3)" }}>
          Asset class
        </div>
      </div>

      <div style={{ maxWidth: 380 }}>
        <div
          className="display display-3"
          style={{
            color: "var(--fg-2)",
            letterSpacing: "-0.015em",
            lineHeight: 1.04
          }}>
          
          {tab.label}
        </div>
      </div>

      <div className="mono cap" style={{ color: "var(--fg-3)", display: "flex", alignItems: "center", gap: 10 }}>
        <span>View</span>
        <span aria-hidden style={{ color: "var(--accent)" }}>→</span>
      </div>
    </div>);

}

function CarouselDots({ total, active, onChange, progressKey, playing, durationMs, label }) {
  return (
    <div
      style={{
        display: "flex",
        alignItems: "center",
        gap: 24,
        flex: 1,
        minWidth: 0,
      }}>
      <span
        className="mono"
        style={{
          fontSize: 10.5,
          letterSpacing: "0.16em",
          textTransform: "uppercase",
          color: "var(--fg-3)",
          whiteSpace: "nowrap",
          flexShrink: 0,
        }}>
        {String(active + 1).padStart(2, "0")} / {String(total).padStart(2, "0")}
      </span>

      {/* Hairline progress track — N segments, accent fills the active
          segment over durationMs, done segments are filled neutral. */}
      <div
        role="tablist"
        style={{
          display: "grid",
          gridTemplateColumns: `repeat(${total}, 1fr)`,
          gap: 4,
          flex: 1,
          minWidth: 0,
        }}>
        {Array.from({ length: total }).map((_, i) => {
          const isActive = i === active;
          const isDone = i < active;
          return (
            <button
              key={i}
              role="tab"
              aria-selected={isActive}
              aria-label={`Go to slide ${i + 1}`}
              onClick={() => onChange(i)}
              style={{
                position: "relative",
                height: 2,
                background: "var(--border)",
                border: 0,
                padding: 0,
                cursor: "pointer",
                overflow: "hidden",
              }}>
              {isDone &&
                <span aria-hidden style={{
                  position: "absolute", inset: 0,
                  background: "var(--fg-3)",
                }} />
              }
              {isActive &&
                <span
                  key={progressKey}
                  aria-hidden
                  style={{
                    position: "absolute", inset: 0,
                    background: "var(--accent)",
                    transformOrigin: "left center",
                    transform: "scaleX(0)",
                    animation: playing ?
                      `carouselProgress ${durationMs}ms linear forwards` :
                      "none",
                  }} />
              }
            </button>);
        })}
      </div>

      {label &&
        <span
          className="display"
          style={{
            fontSize: 18,
            letterSpacing: "-0.005em",
            color: "var(--fg)",
            whiteSpace: "nowrap",
            flexShrink: 0,
            minWidth: 160,
            textAlign: "right",
          }}>
          {label}
        </span>
      }
    </div>);

}

function CarouselArrow({ dir, onClick, disabled }) {
  return (
    <button
      onClick={onClick}
      disabled={disabled}
      aria-label={dir === "prev" ? "Previous" : "Next"}
      style={{
        width: 44, height: 44, borderRadius: 999,
        border: "1px solid var(--border-2)",
        background: "var(--bg-2)",
        display: "inline-flex", alignItems: "center", justifyContent: "center",
        color: "var(--fg)",
        opacity: disabled ? 0.35 : 1,
        cursor: disabled ? "default" : "pointer",
        transition: "background .2s, border-color .2s"
      }}>
      
      <svg width="14" height="14" viewBox="0 0 14 14" fill="none" style={{ transform: dir === "prev" ? "rotate(180deg)" : "none" }}>
        <path d="M2 7 H11 M8 4 L11 7 L8 10" stroke="currentColor" strokeWidth="1.25" strokeLinecap="round" strokeLinejoin="round" />
      </svg>
    </button>);

}

function AssetClassesSection() {
  const [active, setActive] = React.useState(0);
  const [viewportW, setViewportW] = React.useState(typeof window !== "undefined" ? window.innerWidth : 1440);
  const [paused, setPaused] = React.useState(false);

  React.useEffect(() => {
    const onR = () => setViewportW(window.innerWidth);
    window.addEventListener("resize", onR);
    return () => window.removeEventListener("resize", onR);
  }, []);

  // Card width adapts down for narrower viewports. Image cards look better narrower.
  const cardWidth = Math.min(640, Math.max(440, viewportW - 480));
  const gap = 20;
  const trackOffset = -active * (cardWidth + gap) + (viewportW - cardWidth) / 2;
  const total = ACT_TABS.length;

  const ActiveMockup = MOCKUPS[ACT_TABS[active].id];

  // Keyboard support
  React.useEffect(() => {
    const onKey = (e) => {
      if (e.key === "ArrowRight") {setActive((a) => (a + 1) % total);setPaused(true);}
      if (e.key === "ArrowLeft") {setActive((a) => (a - 1 + total) % total);setPaused(true);}
    };
    window.addEventListener("keydown", onKey);
    return () => window.removeEventListener("keydown", onKey);
  }, [total]);

  // Autoplay: advance every 6s, looping, pause on hover/interaction
  const AUTOPLAY_MS = 6000;
  const [tick, setTick] = React.useState(0); // re-key the progress fill on each step
  React.useEffect(() => {
    if (paused) return;
    const id = setTimeout(() => {
      setActive((a) => (a + 1) % total);
      setTick((t) => t + 1);
    }, AUTOPLAY_MS);
    return () => clearTimeout(id);
  }, [active, paused, total]);

  // Manual navigation pauses autoplay; clicking the same active card resumes
  const manualGo = (i) => {
    setActive(i);
    setPaused(true);
  };

  // ───────── Drag-to-swipe ─────────
  // Pointer-down anywhere on the track starts a drag. We translate the track
  // by the live delta, then snap to the nearest card on release. Threshold
  // is ~25% of one card-width — beyond that, we advance/retreat by N steps.
  const [drag, setDrag] = React.useState({ active: false, startX: 0, dx: 0, pointerId: null });
  const trackRef = React.useRef(null);

  const onPointerDown = (e) => {
    // Only left mouse / touch / pen
    if (e.button !== undefined && e.button !== 0) return;
    setPaused(true);
    setDrag({ active: true, startX: e.clientX, dx: 0, pointerId: e.pointerId });
    try { e.currentTarget.setPointerCapture(e.pointerId); } catch (_) {}
  };
  const onPointerMove = (e) => {
    if (!drag.active) return;
    setDrag((d) => ({ ...d, dx: e.clientX - d.startX }));
  };
  const endDrag = (e) => {
    if (!drag.active) return;
    const step = cardWidth + gap;
    const steps = Math.round(-drag.dx / step);
    if (steps !== 0) {
      setActive((a) => {
        let next = a + steps;
        // Clamp instead of wrap to feel natural with drag.
        next = Math.max(0, Math.min(total - 1, next));
        return next;
      });
    }
    setDrag({ active: false, startX: 0, dx: 0, pointerId: null });
    try { e.currentTarget.releasePointerCapture(e.pointerId); } catch (_) {}
  };

  // ───────── Wheel / trackpad horizontal scroll ─────────
  // Trackpads send deltaX continuously; we accumulate and step the carousel
  // once a threshold is crossed, then add a short cooldown so a single swipe
  // doesn't fly through three slides.
  const wheelAccum = React.useRef(0);
  const wheelCooldown = React.useRef(0);
  const onWheel = (e) => {
    // Only respond to horizontal intent — vertical scroll keeps scrolling the page.
    const dx = Math.abs(e.deltaX);
    const dy = Math.abs(e.deltaY);
    if (dx < dy) return;
    e.preventDefault();
    setPaused(true);
    const now = performance.now();
    if (now < wheelCooldown.current) return;
    wheelAccum.current += e.deltaX;
    const THRESH = 90;
    if (Math.abs(wheelAccum.current) >= THRESH) {
      const dir = wheelAccum.current > 0 ? 1 : -1;
      setActive((a) => Math.max(0, Math.min(total - 1, a + dir)));
      wheelAccum.current = 0;
      wheelCooldown.current = now + 360;
    }
  };

  return (
    <section
      data-screen-label="05 Asset classes"
      style={{ overflow: "hidden" }}>
      
      <div className="wrap" style={{ marginBottom: 56 }}>
        <div style={{ marginBottom: 40, maxWidth: 760 }}>
          <h2 className="display display-2" style={{ marginBottom: 22 }}>Every project.
Every asset class.
          </h2>
          <p className="lede">BuildQ supports complex infrastructure projects end-to-end — from site origination to last-mile execution across every capital-intensive asset class.</p>
        </div>

        {/* Controls row */}
        <div style={{ display: "flex", alignItems: "center", justifyContent: "space-between", gap: 24 }}>
          <CarouselArrow dir="prev" onClick={() => manualGo((active - 1 + total) % total)} />
          <CarouselDots
            total={total}
            active={active}
            onChange={manualGo}
            progressKey={tick}
            playing={!paused}
            durationMs={AUTOPLAY_MS}
            label={ACT_TABS[active].label} />
          
          <CarouselArrow dir="next" onClick={() => manualGo((active + 1) % total)} />
        </div>
      </div>

      {/* Carousel track — full-bleed. Pause-on-hover is scoped to the track,
            not the whole section, so the section header doesn't trap the timer.
            Pointer + wheel handlers wire up drag-to-swipe and trackpad scroll. */}
      <div
        style={{ position: "relative", width: "100%", touchAction: "pan-y" }}
        onMouseEnter={() => setPaused(true)}
        onMouseLeave={() => setPaused(false)}
        onPointerDown={onPointerDown}
        onPointerMove={onPointerMove}
        onPointerUp={endDrag}
        onPointerCancel={endDrag}
        onWheel={onWheel}>
        
        <div
          ref={trackRef}
          style={{
            display: "flex",
            gap,
            height: 540,
            transform: `translate3d(${trackOffset + drag.dx}px, 0, 0)`,
            transition: drag.active ? "none" : "transform 600ms cubic-bezier(0.625, 0.05, 0, 1)",
            willChange: "transform",
            userSelect: drag.active ? "none" : "auto",
            cursor: drag.active ? "grabbing" : "grab"
          }}>
          
          {ACT_TABS.map((tab, i) => {
            const isActive = i === active;
            return (
              <div
                key={tab.id}
                onClick={() => !isActive && setActive(i)}
                style={{
                  flex: `0 0 ${cardWidth}px`,
                  width: cardWidth,
                  height: "100%",
                  cursor: isActive ? "default" : "pointer",
                  opacity: isActive ? 1 : 0.72,
                  transform: isActive ? "scale(1)" : "scale(0.95)",
                  transition: "opacity .5s ease, transform .5s ease",
                  overflow: "hidden",
                  borderRadius: 6
                }}>
                
                <ImageCard tab={tab} idx={i} total={total} active={isActive} />
              </div>);

          })}
        </div>
      </div>

    </section>);

}

window.AssetClassesSection = AssetClassesSection;