/* ==========================================================================
   Form 1040-BH — Barlow & Hughan LLP
   Main mount + top bar + signature/barcode footer + Tweaks panel.
   Primitives live in sections-primitives.jsx; sections in section-NN-*.jsx.
   ========================================================================== */

const { useState, useEffect } = React;

/* ---- Tweakable defaults ---- */
const TWEAK_DEFAULTS = /*EDITMODE-BEGIN*/{
  "fidelity": "balanced",
  "paper": "cream"
}/*EDITMODE-END*/;

/* ==========================================================================
   Top bar
   ========================================================================== */
function TopBar() {
  return (
    <div className="topbar">
      <div className="topbar-left">
        <span className="topbar-dept">
          Barlow &amp; Hughan LLP &middot; Certified Public Accountants &middot; {new Date().getFullYear()}
        </span>
      </div>
      <nav className="topbar-nav">
        <a href="#statistics"  data-num="I">  Numbers</a>
        <a href="#who-we-are"  data-num="II"> About</a>
        <a href="#who-we-serve" data-num="III"> Clients</a>
        <a href="#what-we-do"  data-num="IV"> Services</a>
        <a href="#how-we-work" data-num="V">  How We Work</a>
        <a href="#write-to-us" data-num="VI"> Contact</a>
      </nav>
    </div>
  );
}

/* ==========================================================================
   Golden Gate sign-off — a little San Francisco signature
   ========================================================================== */
function GoldenGateSignoff() {
  // SVG illustration of the Golden Gate Bridge seen from the water, with
  // the Marin headlands on the left, San Francisco on the right, fog
  // rolling under the deck, a pelican overhead, and a small sailboat.
  // International Orange line-art over cream.
  const W = 900;
  const H = 380;

  const orange = "#C2410C"; // International Orange tuned to cream paper
  const ink = "var(--ink-soft)";

  // Bridge geometry — proportions closer to the real thing.
  // Real GGB: towers 227m, center span 1280m → roughly 1 : 5.6.
  const leftAnchor = 90;
  const rightAnchor = W - 90;
  const leftTowerX = 260;
  const rightTowerX = W - 260;
  const towerTopY = 70;
  const deckY = 220;
  const midX = W / 2;
  // Cable anchor height — well below the deck so the side-span "legs" sweep
  // visibly down from each tower top, past the deck, to a shore anchorage.
  const anchorY = deckY + 40;
  // Control-point Y for the side-span Bezier — close to deck level so the
  // cable plunges sharply near the anchor and rises fast to the tower top.
  const sideCtrlY = deckY - 10;
  // Main-span catenary: real GGB cable low-point sits ~17m above the deck
  // (deck-to-tower = 152m, sag = 135m). So cable low-point visually sits
  // ~10% of the way from deck to tower top — nearly touching the roadway.
  const cableSagLowY = deckY - 8; // visual low-point of the main cable
  // Q control-Y that makes the quadratic Bezier bottom out at cableSagLowY
  // (Bezier midpoint y = 0.5*(startY + endY)/2... see derivation in comment).
  // For symmetric Q curve with endpoints at towerTopY+6 and desired midpoint
  // at cableSagLowY: ctrlY = 2*midY - endY.
  const cableCtrlY = 2 * cableSagLowY - (towerTopY + 6);
  // Water, shore, and fog levels — pushed down to give clear vertical
  // space between the deck/anchor and the water.
  const waterTopY = deckY + 90;
  const fogTopY = deckY + 55;

  // Tower renderer — slim tapered Art Deco tower that rises from the water
  // surface, through the deck, all the way up to the Art Deco cap. Real GGB
  // towers taper inward going up, and flare slightly outward at the base
  // where they rest on concrete foundations in the water.
  const tower = (cx) => {
    const baseHalfW = 9;      // outer half-width at deck
    const topHalfW = 6;       // outer half-width at tower top (narrowest)
    const waterHalfW = 11;    // outer half-width at water base (slight flare)
    const baseInnerHalf = 3;
    const topInnerHalf = 2;
    const waterInnerHalf = 4;
    const topY = towerTopY + 6; // where the legs begin (just under the caps)
    const taperOuter = (t) => topHalfW + (baseHalfW - topHalfW) * t;
    return (
      <g stroke={orange} strokeWidth="1.3" fill="none" strokeLinejoin="miter">
        {/* Upper tower: tower top → deck, tapered inward */}
        <line x1={cx - topHalfW} y1={topY} x2={cx - baseHalfW} y2={deckY} />
        <line x1={cx + topHalfW} y1={topY} x2={cx + baseHalfW} y2={deckY} />
        <line x1={cx - topInnerHalf} y1={topY} x2={cx - baseInnerHalf} y2={deckY} />
        <line x1={cx + topInnerHalf} y1={topY} x2={cx + baseInnerHalf} y2={deckY} />
        {/* Upper horizontal struts */}
        {[0.15, 0.35, 0.60, 0.82].map((t, i) => {
          const y = topY + (deckY - topY) * t;
          const hw = taperOuter(t);
          return <line key={`up${i}`} x1={cx - hw} y1={y} x2={cx + hw} y2={y} />;
        })}
        {/* Deck-level strut — wider shoulder, this is the roadway crossbeam */}
        <line x1={cx - baseHalfW - 3} y1={deckY - 2} x2={cx + baseHalfW + 3} y2={deckY - 2} strokeWidth="1.8" />
        {/* Lower tower: deck → water, flared outward */}
        <line x1={cx - baseHalfW} y1={deckY + 2} x2={cx - waterHalfW} y2={waterTopY} />
        <line x1={cx + baseHalfW} y1={deckY + 2} x2={cx + waterHalfW} y2={waterTopY} />
        <line x1={cx - baseInnerHalf} y1={deckY + 2} x2={cx - waterInnerHalf} y2={waterTopY} />
        <line x1={cx + baseInnerHalf} y1={deckY + 2} x2={cx + waterInnerHalf} y2={waterTopY} />
        {/* Lower horizontal struts — 2 struts below the deck */}
        {[0.35, 0.70].map((t, i) => {
          const y = deckY + (waterTopY - deckY) * t;
          const hw = baseHalfW + (waterHalfW - baseHalfW) * t;
          return <line key={`lo${i}`} x1={cx - hw} y1={y} x2={cx + hw} y2={y} />;
        })}
        {/* Foundation base at water surface — broad horizontal cap */}
        <line x1={cx - waterHalfW - 3} y1={waterTopY} x2={cx + waterHalfW + 3} y2={waterTopY} strokeWidth="1.8" />
        {/* Stepped Art Deco cap */}
        <rect x={cx - topHalfW} y={towerTopY + 2} width={topHalfW * 2} height="4" />
        <rect x={cx - topHalfW + 2} y={towerTopY - 2} width={(topHalfW - 2) * 2} height="4" />
        <rect x={cx - topHalfW + 4} y={towerTopY - 6} width={(topHalfW - 4) * 2} height="4" />
        {/* Spire */}
        <line x1={cx} y1={towerTopY - 6} x2={cx} y2={towerTopY - 14} />
      </g>
    );
  };

  // Suspenders between towers — vertical ropes dropping from the cable to
  // the deck. Use the actual quadratic Bezier so suspenders perfectly
  // match the visible cable curve.
  const mainSuspenders = [];
  const span = rightTowerX - leftTowerX;
  const towerTopPlus = towerTopY + 6;
  const n = 38;
  for (let i = 1; i < n; i++) {
    const t = i / n;
    // Quadratic Bezier y: (1-t)^2 * y0 + 2(1-t)t * yc + t^2 * y2
    const cableY = (1 - t) * (1 - t) * towerTopPlus + 2 * (1 - t) * t * cableCtrlY + t * t * towerTopPlus;
    const x = leftTowerX + span * t;
    // Only draw if cable is above deck (near midpoint it can nearly touch)
    if (cableY < deckY - 2) {
      mainSuspenders.push(
        <line key={`m${i}`} x1={x} y1={cableY} x2={x} y2={deckY - 2} stroke={orange} strokeWidth="0.5" opacity="0.85" />
      );
    }
  }

  // Suspenders on the side spans — use the EXACT same Bezier as the main
  // cable path so the suspender tops land precisely on the visible cable.
  // Cable goes from (anchorX_cable, anchorY) via control (midpoint X,
  // sideCtrlY) to (towerX_cable, towerTopY+6). Since the control X is the
  // midpoint of the two endpoints, x(t) is linear in t, so we can invert
  // x → t trivially. (towerTopPlus declared above for mainSuspenders.)
  const sideSuspenders = (anchorX_cable, towerX_cable) => {
    const arr = [];
    const nn = 18;
    const dir = towerX_cable > anchorX_cable ? 1 : -1;
    // Inset the suspenders slightly so they don't touch the anchor or tower
    const xStart = anchorX_cable + 8 * dir;
    const xEnd = towerX_cable - 12 * dir;
    for (let i = 0; i < nn; i++) {
      const tPlace = i / (nn - 1);
      const x = xStart + (xEnd - xStart) * tPlace;
      // Invert x → t on the cable Bezier (linear since control X = midpoint)
      const t = (x - anchorX_cable) / (towerX_cable - anchorX_cable);
      // Bezier y at that t — identical formula to the main cable path
      const y = (1 - t) * (1 - t) * anchorY + 2 * (1 - t) * t * sideCtrlY + t * t * towerTopPlus;
      // Only draw where cable is above deck; below deck the cable is plunging
      // to the shore anchor and there's no roadway to suspend from
      if (y < deckY - 4) {
        arr.push(<line key={`s${anchorX_cable}-${i}`} x1={x} y1={y} x2={x} y2={deckY - 2} stroke={orange} strokeWidth="0.45" opacity="0.75" />);
      }
    }
    return arr;
  };

  // Deck camber — slight arch
  const deckPath = `M ${leftAnchor - 20} ${deckY}
                    Q ${midX} ${deckY - 8} ${rightAnchor + 20} ${deckY}`;

  return (
    <section style={{
      marginTop: 48,
      paddingTop: 36,
      paddingBottom: 20,
      borderTop: "1px solid var(--rule-thin)",
      textAlign: "center",
    }}>
      <svg
        viewBox={`0 0 ${W} ${H}`}
        width="100%"
        style={{ maxWidth: 880, display: "block", margin: "0 auto" }}
        aria-label="The Golden Gate Bridge, from our window in San Francisco"
      >
        {/* Sun */}
        <g stroke={orange} strokeWidth="0.8" fill="none" opacity="0.55">
          <circle cx="120" cy="58" r="16" />
          {[0, 1, 2, 3, 4, 5, 6, 7].map(i => {
            const a = (i / 8) * Math.PI * 2;
            const x1 = 120 + Math.cos(a) * 22;
            const y1 = 58 + Math.sin(a) * 22;
            const x2 = 120 + Math.cos(a) * 28;
            const y2 = 58 + Math.sin(a) * 28;
            return <line key={i} x1={x1} y1={y1} x2={x2} y2={y2} />;
          })}
        </g>

        {/* Pelican in flight */}
        <g stroke={orange} strokeWidth="1.1" fill="none" opacity="0.8">
          <path d="M 460 48 q 8 -10 16 0 q 8 -10 16 0" />
          <path d="M 470 52 l 3 3" />
        </g>
        {/* Second gull, smaller */}
        <g stroke={orange} strokeWidth="0.8" fill="none" opacity="0.55">
          <path d="M 620 38 q 5 -6 10 0 q 5 -6 10 0" />
        </g>

        {/* Marin headlands (left) — rolling hills silhouette behind the anchor,
            with a shoreline that drops past the deck down to the anchor level */}
        <g fill="none" stroke={orange} strokeWidth="1" opacity="0.85">
          <path d={`M 0 ${anchorY + 14}
                    L 0 ${deckY - 28}
                    Q 30 ${deckY - 58} 55 ${deckY - 40}
                    Q 75 ${deckY - 30} 90 ${deckY - 48}
                    Q 110 ${deckY - 70} 135 ${deckY - 44}
                    L ${leftAnchor + 22} ${deckY}
                    L ${leftAnchor + 18} ${deckY + 14}
                    L ${leftAnchor - 22} ${anchorY + 8}
                    Z`} />
          {/* Texture: a few tick marks for grass */}
          <line x1="20" y1={deckY - 10} x2="20" y2={deckY - 6} />
          <line x1="45" y1={deckY - 18} x2="45" y2={deckY - 14} />
          <line x1="72" y1={deckY - 24} x2="72" y2={deckY - 20} />
          <line x1="98" y1={deckY - 34} x2="98" y2={deckY - 30} />
        </g>

        {/* San Francisco side (right) — hills + a minimal skyline tease,
            with a shoreline dropping past the deck to the anchor level */}
        <g fill="none" stroke={orange} strokeWidth="1" opacity="0.85">
          <path d={`M ${rightAnchor - 22} ${anchorY + 8}
                    L ${rightAnchor - 18} ${deckY + 14}
                    L ${rightAnchor - 22} ${deckY}
                    Q ${W - 130} ${deckY - 50} ${W - 105} ${deckY - 30}
                    Q ${W - 75} ${deckY - 70} ${W - 50} ${deckY - 42}
                    Q ${W - 25} ${deckY - 30} ${W} ${deckY - 32}
                    L ${W} ${anchorY + 14} Z`} />
          {/* Tiny skyline: a couple of tower hints */}
          <rect x={W - 70} y={deckY - 65} width="6" height="32" />
          <rect x={W - 58} y={deckY - 72} width="4" height="38" />
          <polygon points={`${W-48},${deckY-80} ${W-44},${deckY-95} ${W-40},${deckY-80}`} />
          <rect x={W - 30} y={deckY - 58} width="5" height="26" />
        </g>

        {/* Main cable — shore anchor (well below deck) → tower top → center
            catenary that sags nearly to the deck → tower top → shore anchor.
            The side-span legs sweep dramatically past the deck to the shore. */}
        <path
          d={`M ${leftAnchor} ${anchorY}
              Q ${(leftAnchor + leftTowerX) / 2} ${sideCtrlY}
                ${leftTowerX} ${towerTopY + 6}
              Q ${midX} ${cableCtrlY}
                ${rightTowerX} ${towerTopY + 6}
              Q ${(rightTowerX + rightAnchor) / 2} ${sideCtrlY}
                ${rightAnchor} ${anchorY}`}
          fill="none"
          stroke={orange}
          strokeWidth="1.8"
          strokeLinecap="round"
        />

        {/* Suspenders */}
        {mainSuspenders}
        {sideSuspenders(leftAnchor, leftTowerX)}
        {sideSuspenders(rightAnchor, rightTowerX)}

        {/* Towers */}
        {tower(leftTowerX)}
        {tower(rightTowerX)}

        {/* Deck / roadway — thick truss girder with roadway line above */}
        {/* Road surface */}
        <path d={deckPath} fill="none" stroke={orange} strokeWidth="1.8" />
        {/* Truss underside — forms the characteristic orange beam visible in
            every photo of the bridge */}
        <path d={`M ${leftAnchor - 20} ${deckY + 6} Q ${midX} ${deckY - 2} ${rightAnchor + 20} ${deckY + 6}`} fill="none" stroke={orange} strokeWidth="1.4" />
        {/* Vertical tick marks along the truss suggesting diagonal bracing */}
        <g stroke={orange} strokeWidth="0.5" opacity="0.55">
          {Array.from({ length: 36 }).map((_, i) => {
            const t = i / 36;
            const x = leftAnchor - 10 + (rightAnchor - leftAnchor + 20) * t;
            // Follow deck camber — slight arch
            const yTop = deckY + 1 + Math.sin(t * Math.PI) * -2;
            const yBot = deckY + 6 + Math.sin(t * Math.PI) * -2;
            return <line key={`tk${i}`} x1={x} y1={yTop} x2={x} y2={yBot} />;
          })}
        </g>

        {/* Anchorages — trapezoidal blocks at each end where the cable
            terminates. Positioned below the deck where the cable actually
            meets the shore. */}
        <g stroke={orange} strokeWidth="1" fill="none">
          <path d={`M ${leftAnchor - 20} ${anchorY + 10} L ${leftAnchor - 8} ${anchorY - 4} L ${leftAnchor + 8} ${anchorY - 4} L ${leftAnchor + 20} ${anchorY + 10} Z`} />
          <path d={`M ${rightAnchor - 20} ${anchorY + 10} L ${rightAnchor - 8} ${anchorY - 4} L ${rightAnchor + 8} ${anchorY - 4} L ${rightAnchor + 20} ${anchorY + 10} Z`} />
        </g>

        {/* Fog rolling between the bridge and the water (classic SF) */}
        <g stroke={orange} strokeWidth="0.7" fill="none" opacity="0.35">
          <path d={`M 80 ${fogTopY} q 20 -6 40 0 t 40 0 t 40 0 t 40 0 t 40 0 t 40 0 t 40 0 t 40 0 t 40 0 t 40 0 t 40 0 t 40 0 t 40 0 t 40 0 t 40 0 t 40 0 t 40 0 t 40 0 t 40 0`} />
          <path d={`M 40 ${fogTopY + 16} q 30 -8 60 0 t 60 0 t 60 0 t 60 0 t 60 0 t 60 0 t 60 0 t 60 0 t 60 0 t 60 0 t 60 0 t 60 0 t 60 0 t 60 0`} />
        </g>

        {/* Water — ripple lines at the bay surface */}
        <g stroke={orange} strokeWidth="0.6" fill="none" opacity="0.4">
          <path d={`M 20 ${waterTopY} q 14 -4 28 0 t 28 0 t 28 0 t 28 0 t 28 0 t 28 0 t 28 0 t 28 0 t 28 0 t 28 0 t 28 0 t 28 0 t 28 0 t 28 0 t 28 0 t 28 0 t 28 0 t 28 0 t 28 0 t 28 0 t 28 0 t 28 0 t 28 0 t 28 0 t 28 0 t 28 0 t 28 0 t 28 0 t 28 0 t 28 0`} />
          <path d={`M 0 ${waterTopY + 16} q 18 -4 36 0 t 36 0 t 36 0 t 36 0 t 36 0 t 36 0 t 36 0 t 36 0 t 36 0 t 36 0 t 36 0 t 36 0 t 36 0 t 36 0 t 36 0 t 36 0 t 36 0 t 36 0 t 36 0 t 36 0 t 36 0 t 36 0 t 36 0 t 36 0 t 36 0`} />
        </g>

        {/* Sailboat — a small ketch drifting on the bay, sized relative to water line */}
        <g stroke={orange} strokeWidth="1" fill="none" opacity="0.85">
          {/* hull */}
          <path d={`M ${midX - 22} ${waterTopY - 6}
                    l 4 8
                    l 36 0
                    l 4 -8 Z`} />
          {/* mast */}
          <line x1={midX + 2} y1={waterTopY - 34} x2={midX + 2} y2={waterTopY - 6} />
          {/* mainsail */}
          <path d={`M ${midX + 2} ${waterTopY - 34}
                    L ${midX + 18} ${waterTopY - 8}
                    L ${midX + 2} ${waterTopY - 8} Z`} />
          {/* jib */}
          <path d={`M ${midX + 2} ${waterTopY - 28}
                    L ${midX - 12} ${waterTopY - 8}
                    L ${midX + 2} ${waterTopY - 8} Z`} />
          {/* reflection */}
          <line x1={midX - 18} y1={waterTopY + 6} x2={midX + 18} y2={waterTopY + 6} strokeWidth="0.5" opacity="0.5" />
        </g>

        {/* Compass rose — tiny, decorative */}
        <g transform={`translate(${W - 50}, ${H - 40})`} stroke={orange} strokeWidth="0.7" fill="none" opacity="0.6">
          <circle r="12" />
          <polygon points="0,-12 3,0 0,12 -3,0" />
          <polygon points="-12,0 0,3 12,0 0,-3" />
          <text x="0" y="-16" textAnchor="middle" fontFamily="var(--mono)" fontSize="8" fill={orange} stroke="none" letterSpacing="0.08em">N</text>
        </g>
      </svg>

      {/* Handwritten sign-off */}
      <div style={{
        marginTop: 18,
        fontFamily: '"Caveat", "Dancing Script", cursive',
        fontSize: "var(--t-num)",
        color: "var(--ink)",
        lineHeight: 1.1,
      }}>
        From our window, with care.
      </div>
      <div style={{
        marginTop: 6,
        fontFamily: "var(--mono)",
        fontSize: "var(--t-cap)",
        color: "var(--ink-muted)",
        letterSpacing: "0.18em",
        textTransform: "uppercase",
      }}>
        ▲ Fig. — The Golden Gate, from our office window
      </div>
    </section>
  );
}

/* ==========================================================================
   Barcode footer — barcode + QR both link to barlowandhughan.com
   ========================================================================== */
function BarcodeFooter() {
  const url = "https://www.barlowandhughan.com";
  const cap = {
    fontFamily: "var(--mono)",
    fontSize: "var(--t-cap)",
    color: "var(--ink-muted)",
    letterSpacing: "0.14em",
    textTransform: "uppercase",
    marginTop: 6,
    textAlign: "center",
    display: "block",
  };
  return (
    <footer className="barcode-footer" style={{
      display: "grid",
      gridTemplateColumns: "auto 1fr auto",
      alignItems: "end",
      gap: 28,
      marginTop: 0,
    }}>
      {/* QR */}
      <a href={url} target="_blank" rel="noopener noreferrer" style={{ textDecoration: "none", color: "inherit" }}>
        <QR />
      </a>

      {/* Filing line */}
      <div style={{
        alignSelf: "center",
        display: "flex",
        justifyContent: "space-between",
        fontFamily: "var(--mono)",
        fontSize: "var(--t-cap)",
        color: "var(--ink-muted)",
        letterSpacing: "0.12em",
        textTransform: "uppercase",
        borderTop: "1px solid var(--rule-thin)",
        borderBottom: "1px solid var(--rule-thin)",
        padding: "10px 14px",
      }}>
        <span>Form 1040-BH &middot; {new Date().getFullYear()}</span>
        <span>© Barlow &amp; Hughan LLP &middot; Est. 1946 &middot; San Francisco, CA</span>
        <span>Rev. {String(new Date().getMonth() + 1).padStart(2, "0")}-{new Date().getFullYear()}</span>
      </div>

      {/* Revision / URL stub */}
      <div style={{
        textAlign: "right",
        fontFamily: "var(--mono)",
        fontSize: "var(--t-cap)",
        color: "var(--ink-muted)",
        letterSpacing: "0.1em",
        textTransform: "uppercase",
      }}>
        <a href={url} target="_blank" rel="noopener noreferrer"
           style={{ display: "inline-block", color: "var(--ink)", borderBottom: "1px solid var(--ink)" }}>
          barlowandhughan.com
        </a>
      </div>
    </footer>
  );
}

/* ==========================================================================
   Tweaks panel
   ========================================================================== */
function Tweaks({ open, fidelity, paper, onChange }) {
  return (
    <div className={`tweaks ${open ? "visible" : ""}`}>
      <div className="tweaks-title">Tweaks &middot; Form 1040-BH</div>

      <div className="tweaks-row">
        <div className="tweaks-label">Form fidelity</div>
        <div className="tweaks-options">
          {["subtle", "balanced", "maximal"].map(v => (
            <button key={v} className={fidelity === v ? "active" : ""} onClick={() => onChange("fidelity", v)}>
              {v}
            </button>
          ))}
        </div>
      </div>

      <div className="tweaks-row">
        <div className="tweaks-label">Paper</div>
        <div className="tweaks-options">
          {["cream", "white"].map(v => (
            <button key={v} className={paper === v ? "active" : ""} onClick={() => onChange("paper", v)}>
              {v}
            </button>
          ))}
        </div>
      </div>

      <div style={{
        fontFamily: "var(--mono)",
        fontSize: "var(--t-cap)",
        color: "var(--ink-muted)",
        letterSpacing: "0.08em",
        borderTop: "1px solid var(--rule-thin)",
        paddingTop: 10,
        marginTop: 4,
      }}>
        Toggle via toolbar &middot; changes persist
      </div>
    </div>
  );
}

/* ==========================================================================
   App
   ========================================================================== */
function App() {
  const [fidelity, setFidelity] = useState(TWEAK_DEFAULTS.fidelity);
  const [paper, setPaper] = useState(TWEAK_DEFAULTS.paper);
  const [tweaksOpen, setTweaksOpen] = useState(false);

  useEffect(() => {
    document.documentElement.setAttribute("data-fidelity", fidelity);
    document.documentElement.setAttribute("data-paper", paper);
  }, [fidelity, paper]);

  useEffect(() => {
    const onMsg = (e) => {
      if (!e.data || typeof e.data !== "object") return;
      if (e.data.type === "__activate_edit_mode") setTweaksOpen(true);
      if (e.data.type === "__deactivate_edit_mode") setTweaksOpen(false);
    };
    window.addEventListener("message", onMsg);
    window.parent.postMessage({ type: "__edit_mode_available" }, "*");
    return () => window.removeEventListener("message", onMsg);
  }, []);

  const updateTweak = (key, val) => {
    if (key === "fidelity") setFidelity(val);
    if (key === "paper") setPaper(val);
    window.parent.postMessage(
      { type: "__edit_mode_set_keys", edits: { [key]: val } },
      "*"
    );
  };

  return (
    <>
      <TopBar />
      <main className="page">
        <FirmHeader />
        <Statistics />
        <WhoWeAre />
        <WhoWeServe />
        <WhatWeDo />
        <HowWeWork />
        <WriteToUs />
        <GoldenGateSignoff />
        <BarcodeFooter />
      </main>
      <Tweaks
        open={tweaksOpen}
        fidelity={fidelity}
        paper={paper}
        onChange={updateTweak}
      />
    </>
  );
}

ReactDOM.createRoot(document.getElementById("root")).render(<App />);
