// src/sections-v2.jsx — Brand guide sections for Mighty Orbit v0.2

// ── Configuration ─────────────────────────────────────────────────────
const ACCENTS = {
  magenta: { id:"magenta", name:"Electric Magenta", hex:"#E724FF", ink:"#FFFFFF", desc:"Primary action and signal color. Use for CTA fills, active states, and rare type emphasis." },
};

const TYPE_SYSTEM = {
  display: { name:"DM Sans", family:`"DM Sans", sans-serif`, weight:600, desc:"Display, section headlines, stat numerals, and big conversion copy." },
  body: { name:"Geist", family:`"Geist", sans-serif`, weight:400, desc:"Body copy, UI labels, captions, navigation, forms, and dense explanations." },
};

const HEADLINES = [
  "We build gravity for brands that need it.",
  "The right prospects don't get found. They fall in.",
  "Marketing as gravitational pull, not megaphone blast.",
  "Past a certain point, the decision is already made.",
];

const PRINCIPLES = [
  ["01","Gravity, not chase","Design the field. Let leads fall in."],
  ["02","Event horizon clarity","Past the line, the decision is already made."],
  ["03","Orbit over capture","Long retention beats short conversion."],
  ["04","Dot matrix over slop","Built from primitives. Renders anywhere."],
];

// ── Section: Hero (cover) ─────────────────────────────────────────────
function SecHero({ t, setTweak }){
  const accent = ACCENTS.magenta;
  const headline = t.headline ?? HEADLINES[0];

  return (
    <div className="hero" style={{"--accent":accent.hex, "--accent-ink":accent.ink}}>
      {/* Orbit blueprint rings */}
      <OrbitRings color="rgba(224,246,255,.10)" count={7}/>

      {/* Event horizon dot field */}
      <DotCanvas
        density={t.density}
        color="#FFFFFF"
        highlight={accent.hex}
        highlightR={0.16}
        ringR={0.14}
        centerVoid={0.05}
        pullStrength={0.10}
        swirl={0.75}
        baseSize={1.3}
      />

      {/* Sticky nav overlay */}
      <div className="sticky-nav">
        <div className="wrap">
          <div className="nav-top nav-dark">
            <img src="assets/mightyorbit-signature.png" alt="Mighty Orbit" style={{height:24, filter:"brightness(0) invert(1)"}}/>
            <nav className="nav-links">
              <a href="#">Work</a>
              <a href="#">Method</a>
              <a href="#">Proof</a>
              <a href="#">About</a>
            </nav>
            <div style={{display:"flex",gap:8}}>
              <button className="btn btn-primary btn-sm">Book a call</button>
            </div>
          </div>
        </div>
      </div>

      <div className="hero-content">
        <h1 className="display">
          {headline}
        </h1>
        <p className="lead">
          A digital marketing agency that designs the gravitational pull around your brand —
          so the right prospects fall in, and stay in orbit.
        </p>
        <div style={{display:"flex",gap:12,justifyContent:"center",flexWrap:"wrap"}}>
          <button className="btn btn-primary btn-lg">Book a call →</button>
          <button className="btn btn-ghost-dark btn-lg">See the method</button>
        </div>
      </div>
    </div>
  );
}

// ── Section helper ────────────────────────────────────────────────────
function SecHead({ num, title, right }){
  return (
    <div className="sec-head">
      <div>
        <div className="sec-num">{num}</div>
        <h2 style={{marginTop:8}}>{title}</h2>
      </div>
      {right && <div className="caption" style={{textAlign:"right"}}>{right}</div>}
    </div>
  );
}

// ── Section: Foundations ──────────────────────────────────────────────
function SecFoundations(){
  return (
    <section className="sec">
      <div className="wrap">
        <SecHead num="01" title="Foundations" right="Positioning · Principles"/>

        <div className="grid grid-2" style={{alignItems:"start", marginBottom:64}}>
          <p className="display" style={{fontSize:40, lineHeight:1.05, margin:0, maxWidth:"24ch"}}>
            Mighty Orbit designs the gravitational pull around your brand. Prospects don't get found. They fall in.
          </p>
          <div>
            <div className="eyebrow">Principles</div>
            <ul style={{listStyle:"none", padding:0, margin:"16px 0 0", display:"flex", flexDirection:"column", gap:16}}>
              {PRINCIPLES.map(([n,h,s])=>(
                <li key={n} style={{display:"grid", gridTemplateColumns:"32px 1fr", gap:14}}>
                  <span className="caption" style={{color:"var(--ash-medium)"}}>{n}</span>
                  <div>
                    <div style={{fontWeight:500}}>{h}</div>
                    <div className="caption" style={{marginTop:4, lineHeight:1.4}}>{s}</div>
                  </div>
                </li>
              ))}
            </ul>
          </div>
        </div>

        <div className="eyebrow" style={{marginBottom:16}}>Language rules</div>
        <div className="grid grid-3">
          {[
            ["Operator clear","Write like a growth operator explaining the lever, not a brand poet explaining the metaphor."],
            ["Pipeline specific","Tie the gravity idea back to qualified meetings, sales opportunity, cost per meeting, and handoff quality."],
            ["Motion restrained","Use orbit language as a system, not a pun bank. One image per section is enough."],
          ].map(([h,b])=>(
            <div key={h} className="spec-card">
              <div className="eyebrow">{h}</div>
              <p className="lead" style={{fontSize:16,lineHeight:1.55,margin:"14px 0 0"}}>{b}</p>
            </div>
          ))}
        </div>
      </div>
    </section>
  );
}

// ── Section: Logo ─────────────────────────────────────────────────────
function SecLogo(){
  return (
    <section className="sec">
      <div className="wrap">
        <SecHead num="02" title="Logo" right="Existing wordmark · placement & clearspace"/>

        <div className="grid grid-2" style={{marginBottom:24}}>
          {/* Horizontal signature on light */}
          <div className="card" style={{display:"flex",alignItems:"center",justifyContent:"center",minHeight:200,padding:48}}>
            <img src="assets/mightyorbit-signature.png" alt="Mighty Orbit signature" style={{height:36}}/>
          </div>
          {/* Stacked on light */}
          <div className="card" style={{display:"flex",alignItems:"center",justifyContent:"center",minHeight:200,padding:32}}>
            <img src="assets/mightyorbit-stacked.png" alt="Mighty Orbit stacked" style={{height:140}}/>
          </div>
        </div>

        <div className="grid grid-2" style={{marginBottom:24}}>
          {/* Horizontal — dark */}
          <div style={{background:"#001033",borderRadius:20,padding:48,display:"flex",alignItems:"center",justifyContent:"center",minHeight:200}}>
            <img src="assets/mightyorbit-signature.png" alt="Mighty Orbit signature on dark" style={{height:36, filter:"brightness(0) invert(1)"}}/>
          </div>
          {/* Stacked — dark */}
          <div style={{background:"#001033",borderRadius:20,padding:32,display:"flex",alignItems:"center",justifyContent:"center",minHeight:200,position:"relative",overflow:"hidden"}}>
            <DotHalftone color="#5fbdf7" opacity={0.18} size={12} dot={1.2}/>
            <img src="assets/mightyorbit-stacked.png" alt="Mighty Orbit stacked on dark" style={{height:140, position:"relative", zIndex:1, filter:"drop-shadow(0 0 24px rgba(95,189,247,.3))"}}/>
          </div>
        </div>

        <div className="grid grid-3">
          <div className="card-recessed">
            <div className="eyebrow">Primary lockup</div>
            <p style={{marginTop:8,color:"var(--storm-gray)",fontSize:14,lineHeight:1.5}}>
              Horizontal signature for nav, headers, email sign-offs. The icon and wordmark are inseparable at this lockup.
            </p>
          </div>
          <div className="card-recessed">
            <div className="eyebrow">Stacked lockup</div>
            <p style={{marginTop:8,color:"var(--storm-gray)",fontSize:14,lineHeight:1.5}}>
              Hero moments, keynote covers, social profile avatars. Use when the mark needs room to breathe.
            </p>
          </div>
          <div className="card-recessed">
            <div className="eyebrow">Clearspace · Min size</div>
            <p style={{marginTop:8,color:"var(--storm-gray)",fontSize:14,lineHeight:1.5}}>
              Clear margin = height of the M. Minimum print 16px / digital 20px. Never recolor the gradient.
            </p>
          </div>
        </div>
      </div>
    </section>
  );
}

// ── Section: Color ────────────────────────────────────────────────────
function SecColor(){
  const accent = ACCENTS.magenta;
  const core = [
    ["Deep Cosmos","#001033"],
    ["Midnight Navy","#1b2540"],
    ["Electric Blue","#0050f8"],
    ["Cyan Light","#5fbdf7"],
    ["Ice Veil","#e0f6ff"],
    ["Ghost Canvas","#f8f9fc"],
    ["Pure Surface","#ffffff"],
    ["Slate Ink","#6b7184"],
  ];
  return (
    <section className="sec">
      <div className="wrap">
        <SecHead num="03" title="Color" right="Settled palette · electric magenta signal"/>

        {/* Hero gradient strip */}
        <div style={{
          height:140, borderRadius:20, marginBottom:24,
          background:"var(--hero-grad)",
          boxShadow:"rgba(0,39,80,.04) 0 0 0 1px",
          position:"relative", overflow:"hidden",
        }}>
          <DotHalftone color="#ffffff" opacity={0.18} size={10} dot={1.1}/>
          <div style={{position:"absolute",left:24,bottom:18,zIndex:2,color:"#fafeff",fontSize:13,fontWeight:500,letterSpacing:"-0.005em"}}>
            Hero Gradient · #001033 → #0050f8 → #5fbdf7
          </div>
        </div>

        <div className="grid grid-4" style={{marginBottom:32}}>
          {core.map(([name,hex])=>(
            <div key={hex} className="swatch">
              <div className="chip" style={{background:hex}}/>
              <div className="meta">
                <span className="name">{name}</span>
                <span className="hex">{hex.toUpperCase()}</span>
              </div>
            </div>
          ))}
        </div>

        <div className="eyebrow" style={{marginBottom:16}}>Electric magenta role</div>
        <div className="grid grid-3">
          <div className="spec-card" style={{padding:0, overflow:"hidden"}}>
            <div style={{height:140, background:accent.hex, display:"grid", placeItems:"center"}}>
              <span className="btn" style={{background:accent.hex, color:accent.ink, boxShadow:"rgba(24,37,66,.32) 0 1px 3px, rgba(24,37,66,.44) 0 12px 24px -12px", pointerEvents:"none"}}>
                Book a call →
              </span>
            </div>
            <div style={{padding:"16px 20px 20px"}}>
              <div style={{display:"flex",justifyContent:"space-between",alignItems:"baseline",gap:16}}>
                <div style={{fontWeight:500}}>{accent.name}</div>
                <div className="caption" style={{fontFamily:"var(--font-mono)"}}>{accent.hex}</div>
              </div>
              <div className="caption" style={{marginTop:6,lineHeight:1.5}}>{accent.desc}</div>
            </div>
          </div>
          <div className="spec-card" style={{background:"#001033", color:"#fafeff", position:"relative", overflow:"hidden"}}>
            <DotHalftone color="#5fbdf7" opacity={0.16} size={10} dot={1.1}/>
            <div style={{position:"relative"}}>
              <div className="eyebrow" style={{color:"rgba(250,254,255,.65)"}}>On dark</div>
              <div className="display" style={{fontSize:40,lineHeight:1.05,margin:"18px 0",color:"#fafeff"}}>
                <span style={{color:accent.hex}}>Signal</span> before scale.
              </div>
              <div className="caption" style={{color:"rgba(250,254,255,.7)",lineHeight:1.5}}>Use magenta as the conversion signal, not as a background wash.</div>
            </div>
          </div>
          <div className="spec-card">
            <div className="eyebrow">Typography accent</div>
            <div className="display" style={{fontSize:42,lineHeight:1.05,margin:"18px 0"}}>
              Keep the sentence navy. Make the <span style={{color:accent.hex}}>signal</span> visible.
            </div>
            <div className="caption" style={{lineHeight:1.5}}>Magenta can emphasize one short phrase inside a headline or metric. Avoid full magenta headlines.</div>
          </div>
        </div>
      </div>
    </section>
  );
}

// ── Section: Typography ───────────────────────────────────────────────
function SecType(){
  const display = TYPE_SYSTEM.display;
  const body = TYPE_SYSTEM.body;
  return (
    <section className="sec">
      <div className="wrap">
        <SecHead num="04" title="Typography" right="DM Sans display · Geist body"/>

        <div className="grid grid-2" style={{marginBottom:32}}>
          <div className="spec-card">
            <div className="eyebrow">Display · {display.name}</div>
            <div style={{fontFamily:display.family,fontWeight:display.weight,fontSize:64,lineHeight:.98,letterSpacing:"-0.01em",margin:"18px 0",color:"var(--midnight-navy)"}}>
              Gravity for the pipeline.
            </div>
            <div className="caption" style={{lineHeight:1.5}}>{display.desc}</div>
          </div>
          <div className="spec-card">
            <div className="eyebrow">Body/UI · {body.name}</div>
            <p style={{fontFamily:body.family,fontWeight:body.weight,fontSize:18,lineHeight:1.55,letterSpacing:"-0.005em",margin:"18px 0",color:"var(--storm-gray)"}}>
              Geist carries the operational layer: forms, labels, navigation, case-study details, and the explanatory copy that connects brand gravity back to qualified pipeline.
            </p>
            <div className="caption" style={{lineHeight:1.5}}>{body.desc}</div>
          </div>
        </div>

        {/* Active sample */}
        <div className="card" style={{padding:48}}>
          <div className="eyebrow">Type scale</div>
          <div style={{
            fontFamily:display.family, fontWeight:display.weight,
            fontSize:"clamp(48px, 6vw, 88px)", lineHeight:1.04, letterSpacing:"-0.01em",
            margin:"24px 0 16px", color:"var(--midnight-navy)",
            fontFeatureSettings:'"ss04","ss06","ss09","ss10","ss11"',
          }}>
            Handle everything that happens after gravity takes hold.
          </div>
          <p className="lead" style={{maxWidth:680, marginTop:0}}>
            Body copy sits in Geist at 16/24 with subtle negative tracking. It carries the dashboard-density feel
            of the brand: measured, technical, deliberate. Numbers like <span className="chip">1,420,069</span> are tabular.
          </p>

          <div style={{marginTop:48, display:"grid", gap:0}}>
            {[
              ["Display",       "48/1.04/-0.48",  48, display.family, display.weight, true],
              ["Heading LG",    "40/1.05/-0.40",  40, display.family, display.weight, true],
              ["Heading",       "28/1.17/-0.14",  28, "var(--font-body)", 500, false],
              ["Heading SM",    "22/1.29/-0.22",  22, "var(--font-body)", 500, false],
              ["Subheading",    "18/1.33/-0.09",  18, "var(--font-body)", 450, false],
              ["Body",          "16/1.5/-0.16",   16, "var(--font-body)", 400, false],
              ["Caption",       "13/1.0/-0.21",   13, "var(--font-body)", 500, false],
            ].map(([n,m,sz,ff,fw,disp])=>(
              <div key={n} style={{display:"grid", gridTemplateColumns:"180px 1fr 140px", alignItems:"baseline", gap:20, borderTop:"1px solid rgba(27,37,64,.06)", padding:"18px 0"}}>
                <div className="eyebrow">{n}</div>
                <div style={{
                  fontFamily:ff, fontWeight:fw,
                  fontSize:sz, lineHeight: sz>=40?1.05:1.3,
                  letterSpacing: sz>=40?"-0.01em":"-0.005em",
                  color:"var(--midnight-navy)",
                  fontFeatureSettings: disp ? '"ss04","ss06","ss09","ss10","ss11"' : "normal",
                }}>
                  Event horizon clarity
                </div>
                <div className="caption" style={{fontFamily:"var(--font-mono)", textAlign:"right"}}>{m}</div>
              </div>
            ))}
          </div>
        </div>
      </div>
    </section>
  );
}

// ── Section: Dot system ───────────────────────────────────────────────
function SecDots({ t }){
  const accent = ACCENTS.magenta;
  return (
    <section className="sec">
      <div className="wrap">
        <SecHead num="05" title="The dot system" right="One primitive · many compositions"/>

        <p className="lead" style={{maxWidth:680, marginBottom:32}}>
          Every illustration in the Mighty Orbit system is built from a single primitive:
          a dot. Dots form globes, halftones, gradients, gravitational fields — and the brand's
          signature event horizon.
        </p>

        <div className="grid grid-2" style={{marginBottom:20}}>
          {/* Event horizon */}
          <div className="dot-tile" style={{aspectRatio:"1.4/1"}}>
            <OrbitRings color="rgba(224,246,255,.10)" count={6}/>
            <DotCanvas density={1.0} highlight={accent.hex} highlightR={0.18} ringR={0.12} centerVoid={0.04} pullStrength={0.10} swirl={0.7} baseSize={1.3}/>
            <div className="label">Event horizon · animated</div>
          </div>
          {/* Halftone field */}
          <div className="dot-tile" style={{background:"linear-gradient(180deg,#001033,#0050f8)"}}>
            <DotHalftone color="#ffffff" opacity={0.35} size={9} dot={1.2}/>
            <div className="label">Halftone gradient</div>
          </div>
        </div>

        <div className="grid grid-3">
          <div className="dot-tile light">
            <DotHalftone color="#1b2540" opacity={0.22} size={8} dot={1.0}/>
            <div className="label">Ink halftone</div>
          </div>
          <div className="dot-tile" style={{background:"#001033"}}>
            <OrbitRings color="rgba(224,246,255,.16)" count={8}/>
            <div className="label">Orbit rings</div>
          </div>
          <div className="dot-tile" style={{background:"#1b2540"}}>
            <DotCanvas density={0.6} color={accent.hex} highlight={null} ringR={0.12} centerVoid={0.03} pullStrength={0.06} swirl={1.2} baseSize={1.6}/>
            <div className="label">Accent swirl</div>
          </div>
        </div>

        <div className="card-recessed" style={{marginTop:32}}>
          <div className="eyebrow">Usage rules</div>
          <ul style={{margin:"16px 0 0",paddingLeft:18,color:"var(--storm-gray)",fontSize:14,lineHeight:1.6}}>
            <li>Dots stay white (or pure accent) on dark surfaces — never tinted blue on blue.</li>
            <li>Event horizon animation runs only in hero / brand moments. Static halftones for content surfaces.</li>
            <li>Orbit blueprint lines stay at ≤16% opacity. They guide the eye; they don't compete.</li>
            <li>Accent color highlights the inner ring only — never the entire field.</li>
          </ul>
        </div>
      </div>
    </section>
  );
}

// ── Section: Motions (sales / marketing illustrations) ───────────────
function SecMotions({ t }){
  const accent = ACCENTS.magenta;
  // Shared tile palette: blue gradient bg
  const darkBg = "linear-gradient(180deg,#001033 0%, #002a8e 60%, #0050f8 110%)";
  return (
    <section className="sec">
      <div className="wrap">
        <SecHead num="06" title="Motion & video" right="Dot field · WebGL shader · VSL frames"/>

        <p className="lead" style={{maxWidth:680, marginBottom:32}}>
          The motion language pairs dot-field illustrations with video surfaces. VSL headers can sit inside
          a WebGL-style shader field so the page feels alive before the play button is clicked.
        </p>

        <WebGLShaderPanel accent={accent}/>

        {/* Hero row: Globe + label */}
        <div className="card" style={{padding:0, overflow:"hidden", marginBottom:20, background:darkBg, color:"#fafeff", position:"relative", minHeight:420, display:"flex", flexDirection:"column"}}>
          <OrbitRings color="rgba(224,246,255,.10)" count={6}/>
          <div style={{position:"absolute", inset:0}}>
            <Globe color="#FFFFFF" accent={accent.hex} density={1.3}/>
          </div>
          <div style={{position:"relative", padding:"32px 36px 28px", marginTop:"auto", zIndex:2, display:"flex", justifyContent:"space-between", alignItems:"flex-end", gap:24, background:"linear-gradient(180deg, transparent, rgba(0,16,51,.65) 50%, rgba(0,16,51,.92))"}}>
            <div>
              <div className="eyebrow" style={{color:"rgba(250,254,255,.65)"}}>01 · The brand</div>
              <div className="display" style={{fontSize:36, lineHeight:1.05, margin:"10px 0 8px", color:"#fafeff"}}>
                Orbit Globe
              </div>
              <div className="caption" style={{color:"rgba(250,254,255,.7)", maxWidth:"42ch"}}>
                A rotating dot-rendered planet. Use as brand object on hero, keynote covers,
                or anywhere the agency needs a single iconic image.
              </div>
            </div>
            <div style={{textAlign:"right", flexShrink:0}}>
              <span className="badge-tag" style={{color:"#fafeff", boxShadow:"rgba(224,246,255,.16) 0 0 0 1px"}}>BRAND OBJECT</span>
            </div>
          </div>
        </div>

        {/* 2x2 — Funnel, Convergence, Pipeline, Broadcast */}
        <div className="grid grid-2">
          <MotionTile
            num="02" tag="PROSPECT FLOW"
            title="Funnel"
            desc="Prospects spawn across the mouth, the field pulls them toward the throat, they exit as a concentrated stream. Sized for hero illustrations and case study covers."
            bg={darkBg}>
            <Funnel color="#FFFFFF" accent={accent.hex} density={1.3} mouthWidth={0.9} throatWidth={0.08}/>
          </MotionTile>
          <MotionTile
            num="03" tag="LEAD GENERATION"
            title="Convergence"
            desc="Multiple channels converge to one. Five emitters around the rim, each feeding particles toward the accent core. Replace with your real channel count."
            bg={darkBg}>
            <Convergence color="#FFFFFF" accent={accent.hex} sources={5} density={1.2}/>
          </MotionTile>
          <MotionTile
            num="04" tag="PIPELINE"
            title="Stages"
            desc="Lead → MQL → SQL → Opp → Won. Particles cluster at each stage; a fraction advances every cycle. Drop-off is real and visible."
            bg={darkBg}>
            <Pipeline color="#FFFFFF" accent={accent.hex} density={1.0}/>
          </MotionTile>
          <MotionTile
            num="05" tag="DISTRIBUTION"
            title="Broadcast"
            desc="The inverse of gravity. A center emitter radiates outward — ad spend, distribution, reach. Use when the metaphor is push, not pull."
            bg={darkBg}>
            <Broadcast color="#FFFFFF" accent={accent.hex} density={1.2}/>
          </MotionTile>
        </div>

        <div className="card-recessed" style={{marginTop:32}}>
          <div className="eyebrow">Usage</div>
          <ul style={{margin:"16px 0 0",paddingLeft:18,color:"var(--storm-gray)",fontSize:14,lineHeight:1.6}}>
            <li><strong>VSL shader panel</strong> — video-first landing headers, webinar pages, and paid traffic tests.</li>
            <li><strong>Globe</strong> — hero of any brand surface. Pair with display headline only.</li>
            <li><strong>Funnel</strong> — case studies, pricing pages, conversion-focused content.</li>
            <li><strong>Convergence</strong> — channels page, methodology, integrations.</li>
            <li><strong>Pipeline</strong> — dashboards, reports, sales-ops content.</li>
            <li><strong>Broadcast</strong> — paid media, distribution, awareness campaigns.</li>
          </ul>
        </div>
      </div>
    </section>
  );
}

function WebGLShaderPanel({ accent }){
  const ref = React.useRef(null);

  React.useEffect(() => {
    const canvas = ref.current;
    const gl = canvas?.getContext("webgl", { alpha:false, antialias:false });
    if (!gl) return;

    const vert = `
      attribute vec2 a_pos;
      varying vec2 v_uv;
      void main(){
        v_uv = a_pos * 0.5 + 0.5;
        gl_Position = vec4(a_pos, 0.0, 1.0);
      }
    `;
    const frag = `
      precision mediump float;
      varying vec2 v_uv;
      uniform vec2 u_res;
      uniform float u_time;
      uniform vec3 u_accent;

      float line(float value, float width){
        return smoothstep(width, 0.0, abs(value));
      }

      void main(){
        vec2 uv = (gl_FragCoord.xy / u_res.xy) * 2.0 - 1.0;
        uv.x *= u_res.x / u_res.y;
        float radius = length(uv);
        float angle = atan(uv.y, uv.x);
        float horizon = line(radius - (0.56 + 0.025 * sin(u_time * 0.7 + angle * 2.0)), 0.018);
        float rings = line(fract(radius * 8.0 - u_time * 0.06) - 0.5, 0.018) * (1.0 - smoothstep(0.35, 1.25, radius));
        float grid = line(fract((uv.x + 0.12 * sin(uv.y * 4.0 + u_time * 0.25)) * 9.0) - 0.5, 0.012) * 0.28;
        float sweep = smoothstep(0.9, 0.0, abs(sin(angle * 2.0 + u_time * 0.9))) * smoothstep(1.1, 0.2, radius) * 0.12;
        vec3 navy = vec3(0.0, 0.06, 0.20);
        vec3 blue = vec3(0.0, 0.30, 0.95);
        vec3 cyan = vec3(0.37, 0.74, 0.97);
        vec3 base = mix(navy, blue, smoothstep(1.15, 0.05, radius));
        base = mix(base, cyan, smoothstep(0.05, 1.2, uv.y + 0.9) * 0.34);
        vec3 color = base + vec3(rings * 0.18 + grid * 0.05 + sweep);
        color = mix(color, u_accent, horizon * 0.42);
        gl_FragColor = vec4(color, 1.0);
      }
    `;

    const compile = (type, source) => {
      const shader = gl.createShader(type);
      gl.shaderSource(shader, source);
      gl.compileShader(shader);
      return shader;
    };
    const program = gl.createProgram();
    gl.attachShader(program, compile(gl.VERTEX_SHADER, vert));
    gl.attachShader(program, compile(gl.FRAGMENT_SHADER, frag));
    gl.linkProgram(program);
    gl.useProgram(program);

    const buffer = gl.createBuffer();
    gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
    gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1,-1, 1,-1, -1,1, -1,1, 1,-1, 1,1]), gl.STATIC_DRAW);
    const pos = gl.getAttribLocation(program, "a_pos");
    gl.enableVertexAttribArray(pos);
    gl.vertexAttribPointer(pos, 2, gl.FLOAT, false, 0, 0);

    const res = gl.getUniformLocation(program, "u_res");
    const time = gl.getUniformLocation(program, "u_time");
    const accentUniform = gl.getUniformLocation(program, "u_accent");
    const rgb = hexToRgb01(accent.hex);
    gl.uniform3f(accentUniform, rgb[0], rgb[1], rgb[2]);

    let frame = 0;
    const resize = () => {
      const dpr = Math.min(window.devicePixelRatio || 1, 2);
      const rect = canvas.getBoundingClientRect();
      canvas.width = Math.max(1, Math.floor(rect.width * dpr));
      canvas.height = Math.max(1, Math.floor(rect.height * dpr));
      gl.viewport(0, 0, canvas.width, canvas.height);
    };
    const render = (now) => {
      resize();
      gl.uniform2f(res, canvas.width, canvas.height);
      gl.uniform1f(time, now * 0.001);
      gl.drawArrays(gl.TRIANGLES, 0, 6);
      frame = requestAnimationFrame(render);
    };
    frame = requestAnimationFrame(render);
    return () => cancelAnimationFrame(frame);
  }, [accent.hex]);

  return (
    <div className="card" style={{padding:0,overflow:"hidden",background:"#001033",color:"#fafeff",position:"relative",minHeight:560,marginBottom:20}}>
      <canvas ref={ref} style={{position:"absolute",inset:0,width:"100%",height:"100%"}}/>
      <div style={{position:"absolute",inset:0,background:"radial-gradient(circle at 50% 48%, rgba(0,16,51,.10), rgba(0,16,51,.78) 72%)"}}/>
      <div style={{position:"relative",zIndex:2,padding:"36px 36px 28px",textAlign:"center"}}>
        <div className="eyebrow" style={{color:"rgba(250,254,255,.65)"}}>VSL header component</div>
        <div className="display" style={{fontSize:"clamp(40px,5vw,72px)",lineHeight:1.02,margin:"14px auto 12px",maxWidth:"16ch",color:"#fafeff"}}>
          Build a pipeline your sales team can feel.
        </div>
        <p className="lead" style={{color:"rgba(250,254,255,.76)",maxWidth:680,margin:"0 auto 28px"}}>
          Headline, proof, CTA, and video all live inside the same orbital shader field.
        </p>
        <div style={{maxWidth:860,margin:"0 auto",border:`1px solid rgba(231,36,255,.46)`,borderRadius:24,padding:10,background:"rgba(0,16,51,.58)",boxShadow:"0 24px 80px rgba(0,0,0,.28)"}}>
          <div style={{aspectRatio:"16/9",borderRadius:16,overflow:"hidden",position:"relative",background:"linear-gradient(135deg, rgba(248,249,252,.92), rgba(224,246,255,.76))"}}>
            <DotHalftone color="#001033" opacity={0.10} size={12} dot={1.2}/>
            <div style={{position:"absolute",inset:0,display:"grid",gridTemplateColumns:"1.15fr .85fr",alignItems:"center",gap:0}}>
              <div style={{padding:36,textAlign:"left",color:"var(--midnight-navy)"}}>
                <div className="eyebrow">Qualified lead audit</div>
                <div style={{fontFamily:"var(--font-display)",fontWeight:600,fontSize:36,lineHeight:1.05,letterSpacing:"-0.01em",margin:"12px 0"}}>
                  See where the pipeline is leaking before you add spend.
                </div>
                <div className="caption" style={{lineHeight:1.5,maxWidth:"38ch"}}>Sample VSL frame: Loom, webinar clip, or short founder walkthrough.</div>
              </div>
              <div style={{height:"100%",background:"linear-gradient(180deg,#001033,#0050f8)",position:"relative",overflow:"hidden"}}>
                <OrbitRings color="rgba(224,246,255,.16)" count={6}/>
                <div style={{position:"absolute",inset:0,display:"grid",placeItems:"center"}}>
                  <div style={{width:74,height:74,borderRadius:999,display:"grid",placeItems:"center",background:accent.hex,color:accent.ink,boxShadow:"0 18px 48px rgba(231,36,255,.34)",fontSize:26}}>▶</div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  );
}

function hexToRgb01(hex){
  const clean = hex.replace("#", "");
  const n = parseInt(clean, 16);
  return [((n >> 16) & 255) / 255, ((n >> 8) & 255) / 255, (n & 255) / 255];
}

function MotionTile({ num, tag, title, desc, bg, children }){
  return (
    <div className="card" style={{padding:0, overflow:"hidden", background:bg, color:"#fafeff", position:"relative", minHeight:320, display:"flex", flexDirection:"column"}}>
      <div style={{position:"absolute", inset:0}}>
        {children}
      </div>
      <div style={{position:"relative", padding:24, marginTop:"auto", zIndex:2, background:"linear-gradient(180deg, transparent, rgba(0,16,51,.65) 55%, rgba(0,16,51,.85))"}}>
        <div style={{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:12,marginBottom:8}}>
          <div className="eyebrow" style={{color:"rgba(250,254,255,.65)"}}>{num} · {tag}</div>
        </div>
        <div className="display" style={{fontSize:28, lineHeight:1.1, marginBottom:6, color:"#fafeff"}}>{title}</div>
        <div className="caption" style={{color:"rgba(250,254,255,.7)", lineHeight:1.5, maxWidth:"44ch"}}>
          {desc}
        </div>
      </div>
    </div>
  );
}

// ── Section: Components ───────────────────────────────────────────────
function SecComponents({ t }){
  return (
    <section className="sec">
      <div className="wrap">
        <SecHead num="07" title="Components" right="Buttons · Cards · Forms · Badges · Nav"/>

        {/* Buttons */}
        <div className="eyebrow" style={{marginBottom:14}}>Buttons</div>
        <div className="card" style={{padding:32, marginBottom:32}}>
          <div className="row" style={{marginBottom:16}}>
            <button className="btn btn-primary">Book a call →</button>
            <button className="btn btn-dark">Book a call →</button>
            <button className="btn btn-ghost-light">See the method</button>
            <span className="badge"><span className="dot"/>Production · active</span>
            <span className="badge-tag">URGENT</span>
          </div>
          <div className="row" style={{marginBottom:16}}>
            <button className="btn btn-primary btn-lg">Book a call →</button>
            <button className="btn btn-dark btn-lg">Book a call →</button>
            <button className="btn btn-ghost-light btn-lg">See the method</button>
          </div>
          <div className="row">
            <button className="btn btn-primary btn-sm">Small action</button>
            <button className="btn btn-dark btn-sm">Small action</button>
            <button className="btn btn-ghost-light btn-sm">Small action</button>
          </div>
          {/* On dark */}
          <div style={{marginTop:24,background:"#001033",borderRadius:16,padding:24,position:"relative",overflow:"hidden"}}>
            <DotHalftone color="#5fbdf7" opacity={0.10} size={10} dot={1.1}/>
            <div className="row" style={{position:"relative"}}>
              <button className="btn btn-primary">Book a call →</button>
              <button className="btn btn-ghost-dark">View method</button>
              <button className="btn btn-dark">Review funnel</button>
            </div>
          </div>
        </div>

        {/* Cards */}
        <div className="eyebrow" style={{marginBottom:14}}>Cards · Floating badges</div>
        <div className="grid grid-3" style={{marginBottom:32}}>
          <div className="card">
            <div className="eyebrow">Feature card</div>
            <div className="display" style={{fontSize:28,lineHeight:1.1,margin:"12px 0"}}>
              Investigate.
            </div>
            <p style={{margin:0,fontSize:14,color:"var(--storm-gray)",lineHeight:1.5}}>
              Find where your audience already gravitates. Map the field before you broadcast.
            </p>
          </div>
          <div className="card">
            <div className="eyebrow">Feature card</div>
            <div className="display" style={{fontSize:28,lineHeight:1.1,margin:"12px 0"}}>
              Pull.
            </div>
            <p style={{margin:0,fontSize:14,color:"var(--storm-gray)",lineHeight:1.5}}>
              Build content, channels, and offers that bend the field toward you.
            </p>
          </div>
          <div className="card">
            <div className="eyebrow">Feature card</div>
            <div className="display" style={{fontSize:28,lineHeight:1.1,margin:"12px 0"}}>
              Orbit.
            </div>
            <p style={{margin:0,fontSize:14,color:"var(--storm-gray)",lineHeight:1.5}}>
              Compounding retention. Once they're in, they stay in. Long-tail growth, not blips.
            </p>
          </div>
        </div>

        {/* Forms */}
        <div className="eyebrow" style={{marginBottom:14}}>Forms · Inputs</div>
        <div className="card" style={{padding:32, marginBottom:32}}>
          <div className="grid grid-2">
            <div>
              <label className="input-label">Work email</label>
              <input className="input" placeholder="you@company.com" defaultValue="ada@lovelace.co"/>
              <div className="input-help">We only use this to prep your acquisition review.</div>
            </div>
            <div>
              <label className="input-label">Monthly revenue</label>
              <input className="input" placeholder="$10k – $1M+" defaultValue="$250k MRR"/>
              <div className="input-help">Helps us size the pipeline opportunity.</div>
            </div>
            <div style={{gridColumn:"1 / -1"}}>
              <label className="input-label">What's your goal?</label>
              <textarea className="input" rows={3} defaultValue="We have demand, but the path from click to qualified meeting is leaking." style={{resize:"vertical"}}/>
            </div>
          </div>
          <div style={{marginTop:20,display:"flex",justifyContent:"space-between",alignItems:"center",gap:16,flexWrap:"wrap"}}>
            <div className="caption">Zero-radius inputs are intentional. Pills are for action.</div>
            <button className="btn btn-primary">Send brief →</button>
          </div>
        </div>

        {/* Nav (light variant) */}
        <div className="eyebrow" style={{marginBottom:14}}>Navigation · Light variant</div>
        <div className="card" style={{padding:8, marginBottom:32}}>
          <div className="nav-top nav-light">
            <img src="assets/mightyorbit-signature.png" alt="Mighty Orbit" style={{height:22}}/>
            <nav className="nav-links">
              <a href="#">Work</a>
              <a href="#">Method</a>
              <a href="#">Proof</a>
              <a href="#">About</a>
            </nav>
            <div style={{display:"flex",gap:8}}>
              <button className="btn btn-primary btn-sm">Book a call</button>
            </div>
          </div>
        </div>

        {/* Product UI mock */}
        <div className="eyebrow" style={{marginBottom:14}}>Product UI · Sample card</div>
        <div className="product-card">
          <div className="product-sidebar">
            <div className="icon active">◍</div>
            <div className="icon">◉</div>
            <div className="icon">◌</div>
            <div className="icon">◎</div>
            <div className="icon" style={{marginTop:"auto"}}>⚙</div>
          </div>
          <div style={{padding:24}}>
            <div style={{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:18,gap:16,flexWrap:"wrap"}}>
              <div>
                <div className="eyebrow">Campaign · Acquisition loop</div>
                <div style={{fontSize:22,fontWeight:500,letterSpacing:"-0.22px",marginTop:4}}>Qualified pipeline review — Q2 / FY26</div>
              </div>
              <div style={{display:"flex",gap:8}}>
                <span className="badge"><span className="dot"/>Live</span>
                <button className="btn btn-primary btn-sm">Export →</button>
              </div>
            </div>
            <div className="grid grid-3">
              {[
                ["Pull radius","0.7 LY","+14%"],
                ["Mean retention","142 d","+6%"],
                ["Inbound trajectory","68%","+22%"],
              ].map(([k,v,d])=>(
                <div key={k} className="card-recessed">
                  <div className="caption">{k}</div>
                  <div className="display" style={{fontSize:36, lineHeight:1, margin:"8px 0 6px"}}>{v}</div>
                  <div className="caption" style={{color:"var(--accent-ink)",background:"var(--accent)",display:"inline-block",padding:"2px 8px",borderRadius:999,fontWeight:500,fontSize:11}}>{d}</div>
                </div>
              ))}
            </div>
          </div>
        </div>
      </div>
    </section>
  );
}

// ── Section: Landing page mock ────────────────────────────────────────
function SecLanding({ t }){
  const accent = ACCENTS.magenta;
  const display = TYPE_SYSTEM.display;
  return (
    <section className="sec" style={{padding:"96px 0 0"}}>
      <div className="wrap">
        <SecHead num="08" title="In the field" right="Sample landing page applying the system"/>
      </div>

      {/* Section 1: Two-column "after the pull" */}
      <div style={{background:"#fff", padding:"96px 0", borderTop:"1px solid rgba(27,37,64,.06)"}}>
        <div className="wrap">
          <div className="grid grid-2" style={{alignItems:"center",gap:48}}>
            <div>
              <div className="eyebrow">After the pull</div>
              <h3 className="display" style={{fontSize:48,margin:"16px 0 16px",fontFamily:display.family,fontWeight:display.weight}}>
                Once they're in, they stay in.
              </h3>
              <p className="lead">
                Gravity is the cheapest channel you'll ever run. We design the field, then track the orbit —
                from first touch through decade-long compounding retention.
              </p>
              <div style={{display:"flex",gap:12,marginTop:24,flexWrap:"wrap"}}>
                <button className="btn btn-primary">Book a call →</button>
                <button className="btn btn-ghost-light">See the case files</button>
              </div>
            </div>
            <div style={{position:"relative",aspectRatio:"4/3",borderRadius:20,overflow:"hidden",background:"linear-gradient(180deg,#001033,#0050f8 70%,#5fbdf7)"}}>
              <OrbitRings color="rgba(224,246,255,.14)" count={6}/>
              <Funnel color="#FFFFFF" accent={accent.hex} density={1.3} mouthWidth={0.9} throatWidth={0.08}/>
            </div>
          </div>
        </div>
      </div>

      {/* Section 2: 3-up methodology */}
      <div style={{background:"var(--ghost-canvas)", padding:"96px 0"}}>
        <div className="wrap">
          <div style={{textAlign:"center", marginBottom:48}}>
            <div className="eyebrow">Method</div>
            <h3 className="display" style={{fontSize:48,margin:"16px 0 0",fontFamily:display.family,fontWeight:display.weight}}>
              Three phases. One trajectory.
            </h3>
          </div>
          <div className="grid grid-3">
            {[
              ["01","Map","Identify where your audience already orbits. Channel mix, content gaps, intent signal."],
              ["02","Bend","Build content + offers that shape the gravitational field around your category."],
              ["03","Hold","Compound retention with sequenced touch — newsletters, communities, owned channels."],
            ].map(([n,h,b])=>(
              <div key={n} className="card">
                <div className="eyebrow">Phase {n}</div>
                <div className="display" style={{fontSize:36, lineHeight:1.1, margin:"12px 0 12px", fontFamily:display.family, fontWeight:display.weight}}>{h}.</div>
                <p style={{margin:0,fontSize:14,color:"var(--storm-gray)",lineHeight:1.55}}>{b}</p>
              </div>
            ))}
          </div>
        </div>
      </div>

      {/* CTA banner — dark */}
      <div style={{background:"linear-gradient(180deg,#001033 0%, #002a8e 50%, #001033 100%)", padding:"96px 0", position:"relative", overflow:"hidden"}}>
        <OrbitRings color="rgba(224,246,255,.10)" count={6}/>
        <DotCanvas density={0.7} highlight={accent.hex} highlightR={0.16} ringR={0.10} centerVoid={0.04} pullStrength={0.10} swirl={0.8} baseSize={1.1}/>
        <div className="wrap" style={{position:"relative",zIndex:2,textAlign:"center",color:"#fafeff"}}>
          <div className="eyebrow" style={{color:"rgba(250,254,255,.65)"}}>Next intake · 2 slots open</div>
          <h3 className="display" style={{fontSize:"clamp(40px,6vw,72px)",margin:"16px auto 16px",maxWidth:"18ch",fontFamily:display.family,fontWeight:display.weight}}>
            Step past the horizon.
          </h3>
          <p className="lead" style={{color:"rgba(250,254,255,.85)",maxWidth:560,margin:"0 auto 32px"}}>
            Book a 30-minute pull session. We'll map your gravity well and tell you, honestly,
            whether we can move your mass.
          </p>
          <div style={{display:"flex",gap:12,justifyContent:"center",flexWrap:"wrap"}}>
            <button className="btn btn-primary btn-lg">Book a call →</button>
            <button className="btn btn-ghost-dark btn-lg">Email instead</button>
          </div>
        </div>
      </div>
    </section>
  );
}

// Export everything
Object.assign(window, {
  ACCENTS, TYPE_SYSTEM, HEADLINES, PRINCIPLES,
  SecHero, SecFoundations, SecLogo, SecColor, SecType, SecDots, SecMotions, SecComponents, SecLanding,
  SecHead, WebGLShaderPanel,
});
