/* global React */
const { useState: useStateB, useEffect: useEffectB, useRef: useRefB } = React;
// ============= §03 · FIGHT NIGHT FORMAT (merged) =====================
// Single section that consolidates everything a builder needs to know about
// the actual competition: bot limits + bout format (6-card grid), the arena
// (top-down SVG + spec callouts), the bracket (10 teams · 4 rounds), and a
// recommended-reading link to Bristol Bot Builders for community guides.
// Replaces the old CpDeal (spec table) + CpRules (rules list + arena) split.

function CpArenaSvg() {
  // SVG coord system: 600×600. Arena occupies (50,50)→(550,550) — i.e.
  // 500×500 representing 3000×3000mm (1mm ≈ 0.1667px).  Centre pit is
  // 167×167px (~1m).  House bots sit at the exact NW (50,50) and SE
  // (550,550) corners with a 200px (~1200mm) quarter-circle aggression
  // radius extending into the arena.
  return (
    <svg className="cp-arena-svg" viewBox="0 0 600 600" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Arena top-down blueprint, 3m by 3m with a centre 1m by 1m pit and two corner house bots">
      <defs>
        {/* fine 100mm grid */}
        <pattern id="cp-arena-grid-fine" width="16.667" height="16.667" patternUnits="userSpaceOnUse">
          <path d="M 16.667 0 L 0 0 0 16.667" stroke="#FF6A1A" strokeWidth="0.4" fill="none" opacity="0.07" />
        </pattern>
        {/* bold 1m grid */}
        <pattern id="cp-arena-grid-bold" width="166.667" height="166.667" patternUnits="userSpaceOnUse">
          <path d="M 166.667 0 L 0 0 0 166.667" stroke="#FF6A1A" strokeWidth="0.8" fill="none" opacity="0.20" />
        </pattern>
        {/* hazard stripes for the pit */}
        <pattern id="cp-arena-hazard" width="14" height="14" patternUnits="userSpaceOnUse" patternTransform="rotate(45)">
          <line x1="0" y1="0" x2="0" y2="14" stroke="#FF6A1A" strokeWidth="3" opacity="0.45" />
        </pattern>
      </defs>

      {/* base */}
      <rect width="600" height="600" fill="#06050a" />

      {/* grid layers, clipped to arena bounds */}
      <rect x="50" y="50" width="500" height="500" fill="url(#cp-arena-grid-fine)" />
      <rect x="50" y="50" width="500" height="500" fill="url(#cp-arena-grid-bold)" />

      {/* 3×3 grid of 1m × 1m cells — center cell is the pit (removed) */}
      <g stroke="#FF6A1A" strokeWidth="1" strokeDasharray="6 6" opacity="0.45">
        <line x1="217" y1="50"  x2="217" y2="217" />
        <line x1="217" y1="383" x2="217" y2="550" />
        <line x1="383" y1="50"  x2="383" y2="217" />
        <line x1="383" y1="383" x2="383" y2="550" />
        <line x1="50"  y1="217" x2="217" y2="217" />
        <line x1="383" y1="217" x2="550" y2="217" />
        <line x1="50"  y1="383" x2="217" y2="383" />
        <line x1="383" y1="383" x2="550" y2="383" />
      </g>

      {/* aggression zones — convex quarter circles at NW (50,50) and SE (550,550) */}
      <path d="M 50 250 A 200 200 0 0 0 250 50 L 50 50 Z" fill="rgba(255, 106, 26, 0.18)" />
      <path d="M 50 250 A 200 200 0 0 0 250 50" fill="none" stroke="#FF6A1A" strokeWidth="1.5" strokeDasharray="4 4" opacity="0.85" />
      <path d="M 550 350 A 200 200 0 0 0 350 550 L 550 550 Z" fill="rgba(255, 106, 26, 0.18)" />
      <path d="M 550 350 A 200 200 0 0 0 350 550" fill="none" stroke="#FF6A1A" strokeWidth="1.5" strokeDasharray="4 4" opacity="0.85" />

      {/* aggression radius callouts — inside the danger zone, off the bot */}
      <g fill="#FF6A1A" fontFamily="JetBrains Mono, ui-monospace, monospace" fontSize="9" letterSpacing="2" opacity="0.9">
        <text x="62" y="170">⟡ R 1200</text>
        <text x="430" y="540" textAnchor="end">⟡ R 1200</text>
      </g>

      {/* centre pit */}
      <g>
        <rect x="217" y="217" width="166" height="166" fill="#000" />
        <rect x="217" y="217" width="166" height="166" fill="url(#cp-arena-hazard)" />
        <rect className="cp-arena-pit-border" x="217" y="217" width="166" height="166" fill="none" stroke="#FF6A1A" strokeWidth="2.4" strokeDasharray="10 5" />
        <text x="300" y="293" fill="#FF6A1A" fontFamily="JetBrains Mono, ui-monospace, monospace" fontSize="20" textAnchor="middle" letterSpacing="6" fontWeight="700">PIT</text>
        <text x="300" y="313" fill="#ffb01a" fontFamily="JetBrains Mono, ui-monospace, monospace" fontSize="9" textAnchor="middle" letterSpacing="3" opacity="0.7">1000 × 1000</text>
        <text x="300" y="328" fill="#ff2d14" fontFamily="JetBrains Mono, ui-monospace, monospace" fontSize="8" textAnchor="middle" letterSpacing="3" opacity="0.9">FALL = OUT</text>
      </g>

      {/* arena boundary */}
      <rect x="50" y="50" width="500" height="500" fill="none" stroke="#FF6A1A" strokeWidth="3" />
      <rect x="56" y="56" width="488" height="488" fill="none" stroke="#FF6A1A" strokeWidth="0.5" opacity="0.45" />

      {/* corner registration marks at arena corners */}
      <g stroke="#FF6A1A" strokeWidth="1.2" fill="none">
        <line x1="40" y1="50"  x2="60" y2="50" />
        <line x1="50" y1="40"  x2="50" y2="60" />
        <line x1="540" y1="50" x2="560" y2="50" />
        <line x1="550" y1="40" x2="550" y2="60" />
        <line x1="40" y1="550" x2="60" y2="550" />
        <line x1="50" y1="540" x2="50" y2="560" />
        <line x1="540" y1="550" x2="560" y2="550" />
        <line x1="550" y1="540" x2="550" y2="560" />
      </g>

      {/* scan line — sweeps across the arena */}
      <g className="cp-arena-scan">
        <line x1="50" y1="50" x2="50" y2="550" stroke="#FF6A1A" strokeWidth="2" opacity="0.7" />
        <line x1="51" y1="50" x2="51" y2="550" stroke="#ffb01a" strokeWidth="0.6" opacity="0.4" />
      </g>

      {/* house bots — diagonal rectangles facing each other across the arena */}
      <g transform="translate(82 82) rotate(45)">
        <rect x="-25" y="-12" width="50" height="24" fill="#06050a" stroke="#FF6A1A" strokeWidth="2" />
        <rect x="15" y="-7" width="8" height="14" fill="#FF6A1A" opacity="0.85" />
      </g>
      <g transform="translate(518 518) rotate(225)">
        <rect x="-25" y="-12" width="50" height="24" fill="#06050a" stroke="#FF6A1A" strokeWidth="2" />
        <rect x="15" y="-7" width="8" height="14" fill="#FF6A1A" opacity="0.85" />
      </g>

      {/* dimension callouts — top + right */}
      <g stroke="#ffb01a" strokeWidth="0.8" opacity="0.65">
        <line x1="50" y1="32" x2="244" y2="32" />
        <line x1="356" y1="32" x2="550" y2="32" />
        <line x1="50" y1="28" x2="50" y2="36" />
        <line x1="550" y1="28" x2="550" y2="36" />
      </g>
      <text x="300" y="36" fill="#ffb01a" fontFamily="JetBrains Mono, ui-monospace, monospace" fontSize="11" textAnchor="middle" letterSpacing="3">3000 mm</text>

      <g stroke="#ffb01a" strokeWidth="0.8" opacity="0.65">
        <line x1="568" y1="50" x2="568" y2="244" />
        <line x1="568" y1="356" x2="568" y2="550" />
        <line x1="564" y1="50" x2="572" y2="50" />
        <line x1="564" y1="550" x2="572" y2="550" />
      </g>
      <text x="568" y="304" fill="#ffb01a" fontFamily="JetBrains Mono, ui-monospace, monospace" fontSize="11" textAnchor="middle" letterSpacing="3" transform="rotate(-90 568 300)">3000 mm</text>

      {/* compass — top right */}
      <g transform="translate(586 22)">
        <circle cx="0" cy="0" r="9" fill="none" stroke="#FF6A1A" strokeWidth="1" />
        <path d="M 0 -6 L 4 5 L 0 1 L -4 5 Z" fill="#FF6A1A" />
        <text x="0" y="-12" fill="#FF6A1A" fontFamily="JetBrains Mono, ui-monospace, monospace" fontSize="8" textAnchor="middle">N</text>
      </g>

      {/* title block — bottom left */}
      <g>
        <text x="32" y="577" fill="#FF6A1A" fontFamily="JetBrains Mono, ui-monospace, monospace" fontSize="9" letterSpacing="3" fontWeight="700">FIG. 04 · ARENA · TOP-DOWN</text>
        <text x="32" y="588" fill="#ffb01a" fontFamily="JetBrains Mono, ui-monospace, monospace" fontSize="8" letterSpacing="2" opacity="0.7">FN26.ENG.0042 · REV-A</text>
      </g>
    </svg>
  );
}

// Six rules — bot limits + bout format. Reuses the cp-spec-card visual
// (proven 3-col grid w/ corner brackets, big orange value, mono sub-note).
const FIGHT_RULES = [
  {
    n: "01", k: "WEIGHT",
    v: "2", unit: "kg max",
    sub: "TOTAL — FULLY ARMED & CHARGED",
  },
  {
    n: "02", k: "VOLTAGE",
    v: "6–24", unit: "V",
    sub: "6S LIPO, FULLY CHARGED",
  },
  {
    n: "03", k: "WEAPONS",
    v: "OPEN", unit: "all classes",
    sub: "SPINNERS · LIFTERS · HAMMERS · CRUSHERS",
  },
  {
    n: "04", k: "BOUT",
    v: "3", unit: "min",
    sub: "SINGLE ROUND, FULL CLOCK",
  },
  {
    n: "05", k: "MATCH",
    v: "BO3", unit: "best of three",
    sub: "ADVANCE THE BRACKET ON TWO WINS",
  },
  {
    n: "06", k: "TEAMS",
    v: "8–10", unit: "teams",
    sub: "SINGLE ELIMINATION · FOUR ROUNDS TO TROPHY",
  },
];

const FIGHT_ROUNDS = [
  { name: "ROUND 1",        matches: 2, from: 10, to: 8 },
  { name: "QUARTER FINALS", matches: 4, from: 8,  to: 4 },
  { name: "SEMI FINALS",    matches: 2, from: 4,  to: 2 },
  { name: "FINAL",          matches: 1, from: 2,  to: 1, isFinal: true },
];

const ARENA_FACTS = [
  "3 M × 3 M ENCLOSED",
  "1 M × 1 M PIT (FALL = OUT)",
  "2 HOUSE-BOT CORNERS · NW + SE",
  "POLYCARB WALLS · CO₂ READY",
];

function CpFight() {
  const ref = useRefB(null);
  const [inView, setInView] = useStateB(false);
  useEffectB(() => {
    if (!ref.current) return;
    const obs = new IntersectionObserver((entries) => {
      entries.forEach((e) => {
        if (e.isIntersecting) {
          setInView(true);
          obs.disconnect();
        }
      });
    }, { threshold: 0.18 });
    obs.observe(ref.current);
    return () => obs.disconnect();
  }, []);

  return (
    <section className="cp-section cp-fight-section" data-cp-id="03b" data-screen-label="03b Compete · Fight Night Format">
      <div className="cp-fight-head">
        <div className="cp-fight-head-l">
          <span className="cp-fight-eyebrow">▸ §03 · FIGHT NIGHT FORMAT</span>
          <h2 className="cp-sec-title">
            FIGHT<br />
            <span className="accent">NIGHT.</span>
          </h2>
        </div>
        <p className="cp-fight-lede">
          September 5th, only one team can come out on top. Below are some of
          our rules, almost entirely inspired from the{" "}
          <strong>Beetleweight rules from Bristol Bot Builders</strong>. Rules
          are in spirit, not iron-clad — if you have something unique you want
          to try, talk to the committee first.
        </p>
      </div>

      <div className="cp-fight-spec-block">
        <div className="cp-fight-spec-eyebrow">▸ THE RULES // 6 THINGS TO KNOW</div>
        <div ref={ref} className={`cp-spec-card-grid${inView ? " is-in" : ""}`}>
          {FIGHT_RULES.map((c) => (
            <div key={c.n} className="cp-spec-card">
              <span className="cp-spec-card-corner tl" aria-hidden="true"></span>
              <span className="cp-spec-card-corner br" aria-hidden="true"></span>
              <div className="cp-spec-card-head">
                <span className="num">▸ {c.n}</span>
                <span className="sep">//</span>
                <span className="lbl">{c.k}</span>
                {c.flag && <span className="flag">{c.flag}</span>}
              </div>
              <div className="cp-spec-card-value-row">
                <span className="cp-spec-card-value">{c.v}</span>
                {c.unit && <span className="cp-spec-card-unit">{c.unit}</span>}
              </div>
              <div className="cp-spec-card-sub">{c.sub}</div>
            </div>
          ))}
        </div>
      </div>

      <div className="cp-fight-arena-block">
        <div className="cp-fight-spec-eyebrow">▸ THE ARENA + THE BRACKET</div>
        <div className="cp-fight-arena-grid">
          <div className="cp-arena-pane">
            <div className="cp-arena-bar">
              <span className="dots">
                <span className="dot"></span>
                <span className="dot"></span>
                <span className="dot"></span>
              </span>
              <span>ARENA · TOP-DOWN · 1:50</span>
              <span className="live"><span className="dot"></span>BLUEPRINT</span>
            </div>
            <div className="cp-arena-frame">
              <span className="cp-arena-corner tl" aria-hidden="true"></span>
              <span className="cp-arena-corner tr" aria-hidden="true"></span>
              <span className="cp-arena-corner bl" aria-hidden="true"></span>
              <span className="cp-arena-corner br" aria-hidden="true"></span>
              <CpArenaSvg />
            </div>
            <div className="cp-arena-foot">
              {ARENA_FACTS.map((f) => <span key={f}>{f}</span>)}
            </div>
          </div>

          <div className="cp-fight-tournament">
            <div className="cp-fight-tournament-bar">
              <span className="dots">
                <span className="dot live"></span>
                <span className="dot"></span>
                <span className="dot"></span>
              </span>
              <span>BRACKET.SH · FN-26</span>
              <span className="strict">▣ 10 SEEDS</span>
            </div>
            <div className="cp-fight-tournament-body">
              <div className="cp-fight-tournament-head">
                <div>
                  <span className="k">▸ FORMAT</span>
                  <span className="v">SINGLE ELIMINATION</span>
                </div>
                <div>
                  <span className="k">▸ ENTRIES</span>
                  <span className="v">10 TEAMS</span>
                </div>
              </div>
              <CpBracketTree />
              <div className="cp-fight-tournament-foot">
                last team standing takes the trophy.
              </div>
            </div>
          </div>
        </div>
      </div>

      <a
        className="cp-fight-bristol"
        href="https://bristolbotbuilders.com/guides/#beetle_guides"
        target="_blank"
        rel="noopener noreferrer"
      >
        <div className="cp-fight-bristol-l">
          <span className="cp-fight-bristol-eyebrow">▸ RECOMMENDED READING</span>
          <span className="cp-fight-bristol-title">BRISTOL BOT BUILDERS</span>
          <p className="cp-fight-bristol-body">
            New to combat robotics? Our ruleset is based off of the
            Bristol Bot Builders Beetleweight class. They have excellent
            resources and guides.
          </p>
        </div>
        <div className="cp-fight-bristol-r">
          <span className="cp-fight-bristol-host">bristolbotbuilders.com</span>
          <span className="cp-fight-bristol-arrow" aria-hidden="true">→</span>
        </div>
      </a>
    </section>
  );
}

// ============= BRACKET TREE GRAPHIC =====================================
// 10-team single-elimination bracket as an SVG tree with a cyber-styled
// "W" glowing in the centre. Vertical layout on desktop, horizontal on
// mobile — same geometry, just transposed. Entry dots are abstract (no
// individual seed labels) so the bracket reads as a structure rather than
// a fixtures list.
function CpBracketTree() {
  return (
    <div className="cp-bracket-tree" aria-label="Tournament bracket — 10 teams, 4 rounds, single elimination">
      <svg
        className="cp-bracket-svg cp-bracket-svg-v"
        viewBox="0 0 480 720"
        xmlns="http://www.w3.org/2000/svg"
        role="img"
        aria-hidden="true"
      >
        <defs>
          <filter id="cp-brk-glow-v" x="-100%" y="-100%" width="300%" height="300%">
            <feGaussianBlur stdDeviation="2.5" result="blur" />
            <feMerge>
              <feMergeNode in="blur" />
              <feMergeNode in="SourceGraphic" />
            </feMerge>
          </filter>
          <radialGradient id="cp-brk-bg-v" cx="50%" cy="50%" r="50%">
            <stop offset="0%" stopColor="#FF6A1A" stopOpacity="0.32" />
            <stop offset="60%" stopColor="#FF6A1A" stopOpacity="0.08" />
            <stop offset="100%" stopColor="#FF6A1A" stopOpacity="0" />
          </radialGradient>
        </defs>

        {/* round labels (right rail) */}
        <g fill="#FF6A1A" fontSize="8" fontFamily="JetBrains Mono, ui-monospace, monospace" letterSpacing="2" opacity="0.55">
          <text x="456" y="93">R1</text>
          <text x="456" y="143">QF</text>
          <text x="456" y="203">SF</text>
          <text x="456" y="362" dominantBaseline="central">F</text>
          <text x="456" y="523">SF</text>
          <text x="456" y="583">QF</text>
          <text x="456" y="633">R1</text>
        </g>

        {/* top half entry dots */}
        <g fill="#FF6A1A">
          {[20, 80, 180, 305, 425].map((x, i) => (
            <g key={`tv-${i}`}>
              <circle cx={x} cy={40} r={3.5} />
              <circle cx={x} cy={40} r={7} fill="none" stroke="#FF6A1A" strokeWidth="0.8" opacity="0.4" />
            </g>
          ))}
        </g>

        {/* top half bracket lines */}
        <g stroke="#FF6A1A" strokeWidth="1.4" fill="none" opacity="0.78" strokeLinejoin="miter">
          <path d="M 20 40 V 90 H 80 V 40" />
          <path d="M 50 90 V 140 H 180 V 40" />
          <path d="M 305 40 V 140 H 425 V 40" />
          <path d="M 115 140 V 200 H 365 V 140" />
          <path d="M 240 200 V 304" />
        </g>

        {/* W in centre with cyber glow */}
        <g transform="translate(240, 360)">
          <circle r="92" fill="url(#cp-brk-bg-v)" />
          <circle r="56" fill="none" stroke="#FF6A1A" strokeWidth="1" strokeDasharray="2 4" opacity="0.55" className="cp-bracket-w-ring" />
          <circle r="44" fill="rgba(6,5,10,0.94)" stroke="#FF6A1A" strokeWidth="1.6" filter="url(#cp-brk-glow-v)" />
          <g stroke="#FF6A1A" strokeWidth="1.4" opacity="0.85">
            <line x1="-58" y1="0" x2="-48" y2="0" />
            <line x1="58" y1="0" x2="48" y2="0" />
            <line x1="0" y1="-58" x2="0" y2="-48" />
            <line x1="0" y1="58" x2="0" y2="48" />
          </g>
          <g stroke="#FF6A1A" strokeWidth="0.8" opacity="0.55">
            <line x1="-42" y1="-42" x2="-34" y2="-34" />
            <line x1="42" y1="-42" x2="34" y2="-34" />
            <line x1="-42" y1="42" x2="-34" y2="34" />
            <line x1="42" y1="42" x2="34" y2="34" />
          </g>
          <text
            textAnchor="middle"
            dominantBaseline="central"
            fontSize="42"
            fontWeight="900"
            fill="#FF6A1A"
            fontFamily="JetBrains Mono, ui-monospace, monospace"
            filter="url(#cp-brk-glow-v)"
            className="cp-bracket-w-letter"
          >W</text>
        </g>

        {/* bottom half bracket lines */}
        <g stroke="#FF6A1A" strokeWidth="1.4" fill="none" opacity="0.78" strokeLinejoin="miter">
          <path d="M 240 416 V 520" />
          <path d="M 115 580 V 520 H 365 V 580" />
          <path d="M 50 630 V 580 H 180 V 680" />
          <path d="M 305 680 V 580 H 425 V 680" />
          <path d="M 20 680 V 630 H 80 V 680" />
        </g>

        {/* bottom half entry dots */}
        <g fill="#FF6A1A">
          {[20, 80, 180, 305, 425].map((x, i) => (
            <g key={`bv-${i}`}>
              <circle cx={x} cy={680} r={3.5} />
              <circle cx={x} cy={680} r={7} fill="none" stroke="#FF6A1A" strokeWidth="0.8" opacity="0.4" />
            </g>
          ))}
        </g>
      </svg>

      <svg
        className="cp-bracket-svg cp-bracket-svg-h"
        viewBox="0 0 720 480"
        xmlns="http://www.w3.org/2000/svg"
        role="img"
        aria-hidden="true"
      >
        <defs>
          <filter id="cp-brk-glow-h" x="-100%" y="-100%" width="300%" height="300%">
            <feGaussianBlur stdDeviation="2.5" result="blur" />
            <feMerge>
              <feMergeNode in="blur" />
              <feMergeNode in="SourceGraphic" />
            </feMerge>
          </filter>
          <radialGradient id="cp-brk-bg-h" cx="50%" cy="50%" r="50%">
            <stop offset="0%" stopColor="#FF6A1A" stopOpacity="0.32" />
            <stop offset="60%" stopColor="#FF6A1A" stopOpacity="0.08" />
            <stop offset="100%" stopColor="#FF6A1A" stopOpacity="0" />
          </radialGradient>
        </defs>

        {/* round labels (top rail) */}
        <g fill="#FF6A1A" fontSize="8" fontFamily="JetBrains Mono, ui-monospace, monospace" letterSpacing="2" opacity="0.55">
          <text x="93" y="14">R1</text>
          <text x="143" y="14">QF</text>
          <text x="203" y="14">SF</text>
          <text x="360" y="14" textAnchor="middle">F</text>
          <text x="523" y="14">SF</text>
          <text x="583" y="14">QF</text>
          <text x="633" y="14">R1</text>
        </g>

        {/* left side entry dots */}
        <g fill="#FF6A1A">
          {[20, 80, 180, 305, 425].map((y, i) => (
            <g key={`lh-${i}`}>
              <circle cx={40} cy={y} r={3.5} />
              <circle cx={40} cy={y} r={7} fill="none" stroke="#FF6A1A" strokeWidth="0.8" opacity="0.4" />
            </g>
          ))}
        </g>

        {/* left side bracket lines */}
        <g stroke="#FF6A1A" strokeWidth="1.4" fill="none" opacity="0.78" strokeLinejoin="miter">
          <path d="M 40 20 H 90 V 80 H 40" />
          <path d="M 90 50 H 140 V 180 H 40" />
          <path d="M 40 305 H 140 V 425 H 40" />
          <path d="M 140 115 H 200 V 365 H 140" />
          <path d="M 200 240 H 304" />
        </g>

        {/* W in centre */}
        <g transform="translate(360, 240)">
          <circle r="92" fill="url(#cp-brk-bg-h)" />
          <circle r="56" fill="none" stroke="#FF6A1A" strokeWidth="1" strokeDasharray="2 4" opacity="0.55" className="cp-bracket-w-ring" />
          <circle r="44" fill="rgba(6,5,10,0.94)" stroke="#FF6A1A" strokeWidth="1.6" filter="url(#cp-brk-glow-h)" />
          <g stroke="#FF6A1A" strokeWidth="1.4" opacity="0.85">
            <line x1="-58" y1="0" x2="-48" y2="0" />
            <line x1="58" y1="0" x2="48" y2="0" />
            <line x1="0" y1="-58" x2="0" y2="-48" />
            <line x1="0" y1="58" x2="0" y2="48" />
          </g>
          <g stroke="#FF6A1A" strokeWidth="0.8" opacity="0.55">
            <line x1="-42" y1="-42" x2="-34" y2="-34" />
            <line x1="42" y1="-42" x2="34" y2="-34" />
            <line x1="-42" y1="42" x2="-34" y2="34" />
            <line x1="42" y1="42" x2="34" y2="34" />
          </g>
          <text
            textAnchor="middle"
            dominantBaseline="central"
            fontSize="42"
            fontWeight="900"
            fill="#FF6A1A"
            fontFamily="JetBrains Mono, ui-monospace, monospace"
            filter="url(#cp-brk-glow-h)"
            className="cp-bracket-w-letter"
          >W</text>
        </g>

        {/* right side bracket lines */}
        <g stroke="#FF6A1A" strokeWidth="1.4" fill="none" opacity="0.78" strokeLinejoin="miter">
          <path d="M 416 240 H 520" />
          <path d="M 580 115 H 520 V 365 H 580" />
          <path d="M 630 50 H 580 V 180 H 680" />
          <path d="M 680 305 H 580 V 425 H 680" />
          <path d="M 680 20 H 630 V 80 H 680" />
        </g>

        {/* right side entry dots */}
        <g fill="#FF6A1A">
          {[20, 80, 180, 305, 425].map((y, i) => (
            <g key={`rh-${i}`}>
              <circle cx={680} cy={y} r={3.5} />
              <circle cx={680} cy={y} r={7} fill="none" stroke="#FF6A1A" strokeWidth="0.8" opacity="0.4" />
            </g>
          ))}
        </g>
      </svg>
    </div>
  );
}

Object.assign(window, { CpFight, CpBracketTree });
