// Refined SF Golden Gate motif — single thin-line drawing.
// Replaces the previous busy illustrated bridge + starry sky.
// Uses currentColor so it tints with the theme.

const BridgeBackdrop = () => {
  // Vertical suspender lines following catenary between towers
  const T1 = 380;   // left tower x
  const T2 = 1060;  // right tower x
  const TOP = 130;  // tower top y
  const ROAD = 290; // roadway y
  const SAG = 250;  // bottom of cable sag (between towers)

  // y on a parabola: y = a*(x-mid)^2 + minY, with cable peaking at TOP at towers and reaching SAG at midpoint
  const mid = (T1 + T2) / 2;
  const a = (TOP - SAG) / Math.pow(T1 - mid, 2);
  const cableY = (x) => a * Math.pow(x - mid, 2) + SAG;

  const suspenders = [];
  const N = 30;
  for (let i = 1; i < N; i++) {
    const x = T1 + (i * (T2 - T1)) / N;
    suspenders.push(
      <line key={"s" + i} x1={x} y1={cableY(x)} x2={x} y2={ROAD} opacity="0.18" />
    );
  }

  // Side cables (tower to anchorage on shore)
  const sideCableLeft = `M 0 250 Q 200 200 ${T1} ${TOP}`;
  const sideCableRight = `M ${T2} ${TOP} Q 1240 200 1440 250`;
  // Center span cable
  const centerCable = `M ${T1} ${TOP} Q ${mid} ${SAG + 30} ${T2} ${TOP}`;

  return (
    <svg
      className="bridge-backdrop"
      viewBox="0 0 1440 480"
      fill="none"
      stroke="currentColor"
      strokeWidth="0.7"
      preserveAspectRatio="xMidYMax slice"
      aria-hidden="true"
    >
      {/* Far horizon line */}
      <line x1="0" y1="340" x2="1440" y2="340" opacity="0.18" />

      {/* Faint water ripples */}
      <line x1="0" y1="380" x2="1440" y2="380" opacity="0.06" />
      <line x1="0" y1="412" x2="1440" y2="412" opacity="0.05" />
      <line x1="0" y1="444" x2="1440" y2="444" opacity="0.04" />

      {/* Hills behind */}
      <path d="M 0 340 L 80 322 L 160 332 L 240 318 L 320 328 L 380 340" opacity="0.22" />
      <path d="M 1060 340 L 1140 324 L 1220 334 L 1300 320 L 1380 330 L 1440 322" opacity="0.22" />

      {/* Towers */}
      <line x1={T1} y1={ROAD} x2={T1} y2={TOP} opacity="0.55" />
      <line x1={T1 + 14} y1={ROAD} x2={T1 + 14} y2={TOP} opacity="0.55" />
      <line x1={T1} y1={TOP + 18} x2={T1 + 14} y2={TOP + 18} opacity="0.5" />
      <line x1={T1} y1={TOP + 60} x2={T1 + 14} y2={TOP + 60} opacity="0.5" />
      <line x1={T1} y1={TOP + 110} x2={T1 + 14} y2={TOP + 110} opacity="0.5" />

      <line x1={T2} y1={ROAD} x2={T2} y2={TOP} opacity="0.55" />
      <line x1={T2 + 14} y1={ROAD} x2={T2 + 14} y2={TOP} opacity="0.55" />
      <line x1={T2} y1={TOP + 18} x2={T2 + 14} y2={TOP + 18} opacity="0.5" />
      <line x1={T2} y1={TOP + 60} x2={T2 + 14} y2={TOP + 60} opacity="0.5" />
      <line x1={T2} y1={TOP + 110} x2={T2 + 14} y2={TOP + 110} opacity="0.5" />

      {/* Cables */}
      <path d={sideCableLeft} opacity="0.5" />
      <path d={centerCable} opacity="0.5" />
      <path d={sideCableRight} opacity="0.5" />

      {/* Suspenders */}
      {suspenders}

      {/* Roadway — double line */}
      <line x1="0" y1={ROAD} x2="1440" y2={ROAD} opacity="0.4" />
      <line x1="0" y1={ROAD + 5} x2="1440" y2={ROAD + 5} opacity="0.22" />

      {/* A small sailboat — single, quiet */}
      <g opacity="0.4" transform="translate(220, 380)">
        <line x1="0" y1="0" x2="0" y2="-16" />
        <path d="M 0 -16 L 11 -2 L 0 -2 Z" fill="currentColor" stroke="none" />
        <path d="M -9 0 L 9 0 L 7 4 L -7 4 Z" />
      </g>
    </svg>
  );
};

window.BridgeBackdrop = BridgeBackdrop;
