// Main app — homepage + contact sheet toggle

const { useState: useStateApp } = React;

// Simplified visual previews for the contact sheet — captures composition at a glance
const SheetThumbs = [
  { name: 'Hero', sub: '“School inside a world.”', render: () => (
    <svg viewBox="0 0 160 100">
      <rect width="160" height="100" fill="#0A0A0F"/>
      <circle cx="80" cy="50" r="40" fill="rgba(125,255,196,0.06)"/>
      {Array.from({length: 40}).map((_, i) => <circle key={i} cx={(i*37)%160} cy={(i*59)%100} r="0.6" fill="rgba(125,255,196,0.5)"/>)}
      <rect x="14" y="38" width="86" height="6" rx="1" fill="#F5F5F7"/>
      <rect x="14" y="48" width="62" height="6" rx="1" fill="#F5F5F7"/>
      <rect x="14" y="62" width="80" height="2.5" rx="1" fill="#71717A"/>
      <rect x="14" y="68" width="50" height="2.5" rx="1" fill="#71717A"/>
      <rect x="14" y="78" width="34" height="8" rx="2" fill="#7DFFC4"/>
      <rect x="52" y="78" width="34" height="8" rx="2" fill="none" stroke="rgba(255,255,255,0.2)"/>
    </svg>
  )},
  { name: 'Proof bar', sub: '402 · 20 · 91% · 89% · 86% · 369', render: () => (
    <svg viewBox="0 0 160 100">
      <rect width="160" height="100" fill="#0F0F14"/>
      {[0,1,2,3,4,5].map(i => (
        <g key={i} transform={`translate(${4 + i*26}, 30)`}>
          <text fontSize="11" fill="#F5F5F7" fontFamily="Geist" fontWeight="600">{['402','20','91','89','86','369'][i]}</text>
          <rect y="18" width="20" height="1.5" fill="#71717A"/>
          <text y="28" fontSize="4" fill="#71717A" fontFamily="Geist Mono">{['STDNT','CNTRY','MATH','SCI','ELA','UC A-G'][i]}</text>
          <line x1="-2" y1="-5" x2="-2" y2="30" stroke="rgba(255,255,255,0.06)"/>
        </g>
      ))}
      <text x="156" y="14" fontSize="3.5" fill="#F59E0B" fontFamily="Geist Mono" textAnchor="end">UC A-G</text>
    </svg>
  )},
  { name: 'Six worlds', sub: 'Every lesson is a place.', render: () => (
    <svg viewBox="0 0 160 100">
      <rect width="160" height="100" fill="#0A0A0F"/>
      <text x="6" y="14" fontSize="6" fill="#F5F5F7" fontWeight="600">Every lesson is a place.</text>
      {[
        { c: '#1a2240' }, { c: '#2a1a10' }, { c: '#0e1e1a' }, { c: '#181428' }, { c: '#1e1010' }, { c: '#0f1820' }
      ].map((w, i) => (
        <g key={i} transform={`translate(${6 + (i%3)*52}, ${30 + Math.floor(i/3)*32})`}>
          <rect width="48" height="28" rx="2" fill={w.c}/>
          <circle cx="24" cy="13" r="10" fill="rgba(125,255,196,0.1)"/>
          <rect x="2" y="20" width="20" height="2" fill="rgba(255,255,255,0.6)"/>
          {i < 5 && <rect x="2" y="3" width="10" height="3" rx="1.5" fill="none" stroke="#7DFFC4" strokeWidth="0.3"/>}
        </g>
      ))}
    </svg>
  )},
  { name: 'Three doors', sub: 'Families · Schools · Partners', render: () => (
    <svg viewBox="0 0 160 100">
      <rect width="160" height="100" fill="#0A0A0F"/>
      {[
        { x: 6, vis: 'dash' }, { x: 56, vis: 'diag' }, { x: 106, vis: 'net' }
      ].map((d, i) => (
        <g key={i} transform={`translate(${d.x}, 14)`}>
          <rect width="48" height="72" rx="3" fill="#16161D" stroke="rgba(255,255,255,0.1)" strokeWidth="0.3"/>
          {d.vis === 'dash' && (
            <g transform="translate(4, 4)">
              {[0,1,2].map(r => <rect key={r} y={6 + r*7} width="40" height="2" rx="1" fill="#1E1E27"/>)}
              {[0,1,2].map(r => <rect key={r} y={6 + r*7} width={20 + r*4} height="2" rx="1" fill="#7DFFC4"/>)}
            </g>
          )}
          {d.vis === 'diag' && (
            <g transform="translate(4, 4)" stroke="rgba(125,255,196,0.6)" fill="none" strokeWidth="0.5">
              <rect x="2" y="4" width="10" height="6"/>
              <rect x="16" y="4" width="10" height="6"/>
              <rect x="30" y="4" width="10" height="6"/>
              <rect x="8" y="22" width="26" height="6" fill="rgba(125,255,196,0.1)"/>
              <line x1="7" y1="10" x2="14" y2="22"/>
              <line x1="21" y1="10" x2="21" y2="22"/>
              <line x1="35" y1="10" x2="28" y2="22"/>
            </g>
          )}
          {d.vis === 'net' && (
            <g transform="translate(24, 28)">
              <line x1="0" y1="0" x2="-14" y2="-14" stroke="#7DFFC4" strokeWidth="0.3"/>
              <line x1="0" y1="0" x2="14" y2="-14" stroke="rgba(255,255,255,0.2)" strokeWidth="0.3"/>
              <line x1="0" y1="0" x2="-14" y2="14" stroke="rgba(255,255,255,0.2)" strokeWidth="0.3"/>
              <line x1="0" y1="0" x2="14" y2="14" stroke="rgba(255,255,255,0.2)" strokeWidth="0.3"/>
              <line x1="0" y1="0" x2="0" y2="-20" stroke="rgba(255,255,255,0.2)" strokeWidth="0.3"/>
              <circle r="2" fill="#7DFFC4"/>
              <circle cx="-14" cy="-14" r="1" fill="#7DFFC4"/>
              <circle cx="14" cy="-14" r="1" fill="#71717A"/>
              <circle cx="-14" cy="14" r="1" fill="#71717A"/>
              <circle cx="14" cy="14" r="1" fill="#71717A"/>
              <circle cx="0" cy="-20" r="1" fill="#71717A"/>
            </g>
          )}
          <text x="4" y="56" fontSize="4.5" fill="#F5F5F7" fontWeight="600">{['Families','Schools','Partners'][i]}</text>
          <rect x="4" y="60" width="24" height="6" rx="1" fill={i === 0 ? '#7DFFC4' : 'none'} stroke="rgba(255,255,255,0.2)" strokeWidth="0.3"/>
        </g>
      ))}
    </svg>
  )},
  { name: 'How it works', sub: '5 steps · prompt → world → grade', render: () => (
    <svg viewBox="0 0 160 100">
      <rect width="160" height="100" fill="#0F0F14"/>
      <text x="6" y="12" fontSize="5" fill="#F5F5F7" fontWeight="600">How it actually works.</text>
      {['01','02','03','04','05'].map((n, i) => (
        <g key={i} transform={`translate(6, ${20 + i*14})`}>
          <text fontSize="3.5" fill="#71717A" fontFamily="Geist Mono">{n}</text>
          <rect x="14" y="-4" width="68" height="2.5" rx="1" fill="#F5F5F7"/>
          <rect x="14" y="0" width="48" height="1.5" rx="1" fill="#71717A"/>
          <rect x="92" y="-6" width="60" height="11" rx="1.5" fill="#16161D" stroke="rgba(255,255,255,0.1)" strokeWidth="0.3"/>
          <line x1="0" y1="-10" x2="160" y2="-10" stroke="rgba(255,255,255,0.06)" strokeWidth="0.3"/>
        </g>
      ))}
    </svg>
  )},
  { name: 'Trust strip', sub: 'WASC · UC · World Labs · CVC', render: () => (
    <svg viewBox="0 0 160 100">
      <rect width="160" height="100" fill="#0A0A0F"/>
      <g transform="translate(8, 36)">
        {['W','UC','∿','CVC'].map((g, i) => (
          <g key={i} transform={`translate(${i*36}, 0)`}>
            <text fontSize="9" fill="#F59E0B" fontWeight="700" fontFamily="Geist Mono">{g}</text>
            <text x="14" y="-3" fontSize="3.5" fill="#A1A1AA">WASC acc.</text>
            <text x="14" y="3" fontSize="3.5" fill="#A1A1AA">{['WASC','UC A-G','World Labs','CVC'][i]}</text>
          </g>
        ))}
      </g>
      <text x="80" y="68" fontSize="3.5" fill="#71717A" textAnchor="middle" fontFamily="Geist Mono">Founded 2017 · Stanford · Palo Alto · China · Singapore</text>
    </svg>
  )},
  { name: 'SofAI demo', sub: 'Interactive · 3 modes', render: () => (
    <svg viewBox="0 0 160 100">
      <rect width="160" height="100" fill="#0A0A0F"/>
      <rect x="6" y="8" width="70" height="84" rx="3" fill="#16161D" stroke="rgba(255,255,255,0.1)" strokeWidth="0.3"/>
      <circle cx="14" cy="16" r="3" fill="#7DFFC4"/>
      <rect x="22" y="14" width="20" height="2" fill="#F5F5F7"/>
      <rect x="10" y="26" width="40" height="10" rx="2" fill="none" stroke="rgba(255,255,255,0.15)" strokeWidth="0.3"/>
      <rect x="38" y="40" width="34" height="6" rx="2" fill="#1E1E27"/>
      <rect x="10" y="50" width="44" height="8" rx="2" fill="none" stroke="rgba(255,255,255,0.15)" strokeWidth="0.3"/>
      <rect x="10" y="62" width="60" height="6" rx="2" fill="none" stroke="#7DFFC4" strokeWidth="0.3"/>
      <rect x="10" y="72" width="60" height="6" rx="2" fill="none" stroke="rgba(255,255,255,0.15)" strokeWidth="0.3"/>
      <rect x="10" y="82" width="60" height="6" rx="2" fill="none" stroke="rgba(255,255,255,0.15)" strokeWidth="0.3"/>
      <rect x="84" y="8" width="70" height="84" rx="3" fill="#16161D" stroke="rgba(255,255,255,0.1)" strokeWidth="0.3"/>
      <text x="90" y="22" fontSize="5" fill="#F5F5F7" fontWeight="600">One identity.</text>
      <text x="90" y="28" fontSize="5" fill="#F5F5F7" fontWeight="600">Three lenses.</text>
      {[0,1,2].map(i => (
        <g key={i} transform={`translate(90, ${38 + i*16})`}>
          <rect width="14" height="5" rx="1" fill="rgba(125,255,196,0.15)"/>
          <text x="2" y="4" fontSize="3" fill="#7DFFC4" fontFamily="Geist Mono">{['STUD','PRNT','TCHR'][i]}</text>
          <rect x="18" y="0" width="42" height="2" rx="1" fill="#E5E5EA"/>
          <rect x="18" y="3" width="34" height="1.5" rx="0.5" fill="#71717A"/>
        </g>
      ))}
    </svg>
  )},
  { name: 'Manifesto excerpt', sub: '258 million children…', render: () => (
    <svg viewBox="0 0 160 100">
      <rect width="160" height="100" fill="#0A0A0F"/>
      <text x="10" y="14" fontSize="3" fill="#71717A" fontFamily="Geist Mono">FROM THE MANIFESTO</text>
      <text x="10" y="34" fontSize="9" fill="#F5F5F7" fontWeight="600">There are <tspan fill="#7DFFC4">258 million</tspan></text>
      <text x="10" y="46" fontSize="9" fill="#F5F5F7" fontWeight="600">children on this planet</text>
      <text x="10" y="58" fontSize="9" fill="#F5F5F7" fontWeight="600">not in school today...</text>
      <text x="10" y="76" fontSize="9" fill="#7DFFC4" fontWeight="600">An imagination problem.</text>
      <line x1="10" y1="86" x2="150" y2="86" stroke="rgba(255,255,255,0.06)"/>
      <text x="10" y="93" fontSize="3" fill="#71717A" fontFamily="Geist Mono">§ 01 · IMAGINATION</text>
    </svg>
  )},
  { name: 'Final CTA', sub: '“The next school year starts in a world.”', render: () => (
    <svg viewBox="0 0 160 100">
      <rect width="160" height="100" fill="#08080C"/>
      {Array.from({length: 50}).map((_, i) => <circle key={i} cx={(i*43)%160} cy={(i*67)%100} r={0.4 + (i%3)*0.3} fill="rgba(125,255,196,0.4)"/>)}
      <circle cx="80" cy="50" r="50" fill="rgba(125,255,196,0.04)"/>
      <text x="80" y="42" fontSize="9" fill="#F5F5F7" fontWeight="600" textAnchor="middle">The next school year</text>
      <text x="80" y="54" fontSize="9" fill="#F5F5F7" fontWeight="600" textAnchor="middle">starts in a world.</text>
      <rect x="62" y="64" width="36" height="9" rx="2" fill="#7DFFC4"/>
      <text x="80" y="71" fontSize="4.5" fill="#08080C" fontWeight="600" textAnchor="middle">Begin enrollment →</text>
    </svg>
  )},
  { name: 'Footer', sub: 'Address · credentials · nav', render: () => (
    <svg viewBox="0 0 160 100">
      <rect width="160" height="100" fill="#0F0F14"/>
      <line x1="0" y1="0.5" x2="160" y2="0.5" stroke="rgba(255,255,255,0.06)"/>
      <rect x="6" y="12" width="5" height="5" rx="1" fill="#7DFFC4"/>
      <rect x="14" y="13" width="34" height="3" fill="#F5F5F7"/>
      <rect x="6" y="22" width="40" height="2" fill="#71717A"/>
      <rect x="6" y="26" width="32" height="2" fill="#71717A"/>
      <rect x="6" y="30" width="44" height="2" fill="#71717A"/>
      <rect x="6" y="40" width="24" height="4" rx="2" fill="rgba(245,158,11,0.15)" stroke="rgba(245,158,11,0.4)" strokeWidth="0.2"/>
      {['Learn','Apply','School'].map((c, i) => (
        <g key={i} transform={`translate(${64 + i*32}, 12)`}>
          <rect width="20" height="2" fill="#71717A"/>
          {[0,1,2,3].map(r => <rect key={r} y={6 + r*5} width="22" height="2" fill="#E5E5EA"/>)}
        </g>
      ))}
      <line x1="0" y1="84" x2="160" y2="84" stroke="rgba(255,255,255,0.06)"/>
      <rect x="6" y="90" width="50" height="2" fill="#71717A"/>
      <rect x="100" y="90" width="50" height="2" fill="#71717A"/>
    </svg>
  )},
];

const ContactSheet = ({ onBack }) => (
  <div className="sheet">
    <div className="container">
      <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'end', flexWrap: 'wrap', gap: 16 }}>
        <div>
          <span className="eyebrow t-xs"><span className="bar"></span> CONTACT SHEET · HOMEPAGE</span>
          <h2 className="t-h2" style={{ marginTop: 12 }}>10 sections at a glance.</h2>
          <p className="ink-2" style={{ marginTop: 12, maxWidth: 540 }}>Click any thumbnail to jump to it. Toggle to <b>Full page</b> in the bottom-right to scroll the whole homepage.</p>
        </div>
        <div className="mono ink-3" style={{ fontSize: 12, letterSpacing: '0.08em' }}>v0.1 · 2026-05-19</div>
      </div>
      <div className="sheet-grid">
        {SheetThumbs.map((t, i) => (
          <a key={i} className="sheet-card" href={`#section-${i+1}`} onClick={() => setTimeout(onBack, 50)}>
            <div className="sheet-thumb">{t.render()}</div>
            <div className="sheet-label">
              <div>
                <div className="name">{t.name}</div>
                <div className="ink-3" style={{ fontSize: 11, marginTop: 2 }}>{t.sub}</div>
              </div>
              <span className="idx">{String(i+1).padStart(2,'0')}</span>
            </div>
          </a>
        ))}
      </div>
    </div>
  </div>
);

const Homepage = () => (
  <>
    <Nav/>
    <a id="section-1"></a><Hero/>
    <a id="section-2"></a><ProofBar/>
    <a id="section-3"></a><Worlds/>
    <a id="section-4"></a><ThreeDoors/>
    <a id="section-5"></a><Steps/>
    <a id="section-6"></a><TrustStrip/>
    <a id="section-7"></a><SofAIDemo/>
    <a id="section-8"></a><ManifestoQuote/>
    <a id="section-9"></a><FinalCTA/>
    <a id="section-10"></a><Footer/>
  </>
);

const App = () => {
  const [view, setView] = useStateApp('full');
  return (
    <>
      {view === 'full' ? <Homepage/> : <ContactSheet onBack={() => setView('full')}/>}
      <div className="view-toggle">
        <button className={view === 'full' ? 'active' : ''} onClick={() => setView('full')}>Full page</button>
        <button className={view === 'sheet' ? 'active' : ''} onClick={() => { setView('sheet'); window.scrollTo({top:0}); }}>Contact sheet</button>
      </div>
    </>
  );
};

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