<!-- HONEYCOMB-STAGING · part 1 -->
===== FILE: public/honeycomb-staging/foundation.js =====
/* ============================================================
   SOLIDIVISM FOUNDATION v1.0
   The most impressive kind — clean, solid, unbreakable.
   Claimed by The King, October 8, 2026.
   
   Principles:
   1. Everything visible IS solid. Everything solid IS visible.
   2. No separation between render and collision — one system.
   3. Built to be seen. Built to hold.
   ============================================================ */

const Solidivism = (function() {
  'use strict';

  let scene, camera, renderer, player;
  let colliders = [];
  let buildings = [];
  let labelMeshes = [];

  // ── INIT: The foundation ──

  // ── EPISTEMOLOGY OBSERVATION (fire-and-forget, never breaks 3D) ──
  function observe(eventType, data) {
    try {
      if (typeof Epistemology !== 'undefined' && Epistemology.handleObservation) {
        Epistemology.handleObservation(eventType, data);
      }
    } catch (e) {
      // Silent: observation failure must NEVER break 3D
      // Diagnosable via Epistemology.Health.report()
    }
  }

  function init(containerId) {
    const container = document.getElementById(containerId);
    
    // Scene: dark tactical void
    scene = new THREE.Scene();
    scene.background = new THREE.Color(0x0a0a0e);
    
    // Camera: cinematic third-person
    camera = new THREE.PerspectiveCamera(
      60, window.innerWidth / window.innerHeight, 0.1, 500
    );
    camera.position.set(0, 12, 83); // Behind avatar at new spawn
    
    // Renderer: maximum quality (with error capture for diagnostics)
    try {
      renderer = new THREE.WebGLRenderer({ antialias: true });
    } catch (rendererErr) {
      var errDiv = document.createElement('div');
      errDiv.id = 'webgl-error';
      errDiv.style.cssText = 'position:fixed;top:10px;left:10px;background:#ff0000;color:#fff;padding:20px;z-index:99999;font-family:monospace;max-width:80%;';
      errDiv.textContent = 'RENDERER_FAIL: ' + rendererErr.message + ' | STACK: ' + (rendererErr.stack || 'none').substring(0, 800);
      document.body.appendChild(errDiv);
      throw rendererErr;
    }
    renderer.setSize(container.clientWidth, container.clientHeight);
    renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
    container.appendChild(renderer.domElement);
    observe('session.start', { timestamp: new Date().toISOString(), userAgent: navigator.userAgent });
    
    // Lights: dramatic tactical lighting
    const ambient = new THREE.AmbientLight(0xffffff, 0.4);
    scene.add(ambient);
    
    const keyLight = new THREE.DirectionalLight(0xff3333, 1.2);
    keyLight.position.set(30, 50, 30);
    scene.add(keyLight);
    
    const fillLight = new THREE.DirectionalLight(0x3388ff, 0.5);
    fillLight.position.set(-30, 20, -30);
    scene.add(fillLight);
    
    const rimLight = new THREE.PointLight(0xff0000, 1.2, 150);
    rimLight.position.set(0, 10, 0);
    scene.add(rimLight);
    
    // Ground: tactical grid
    createGround();
    
    // Player: the avatar
    createPlayer();
    
    buildLoginRoom();
    buildForumRoom();
    // Start the loop
  // ── ROOM 2: FORUM — The Heart ──
  function buildForumRoom() {
    const HEX = 15;
    const cx = 0, cz = -26;
    const floorMat = new THREE.MeshStandardMaterial({ color: 0x0a0a0a, roughness: 0.7, metalness: 0.2 });
    const floor = new THREE.Mesh(new THREE.CylinderGeometry(HEX, HEX, 1, 6), floorMat);
    floor.rotation.y = Math.PI / 6;
    floor.position.set(cx, 0.5, cz);
    floor.receiveShadow = true;
    scene.add(floor);
    const wallMat = new THREE.MeshStandardMaterial({ color: 0xCC0000, emissive: 0xCC0000, emissiveIntensity: 0.8, roughness: 0.4, metalness: 0.1 });
    const wallH = 4, wallT = 1;
    for (let i = 0; i < 6; i++) {
      if (i === 1) continue;
      const a1 = (Math.PI / 180) * (60 * i + 30);
      const a2 = (Math.PI / 180) * (60 * (i + 1) + 30);
      const x1 = cx + Math.cos(a1) * HEX, z1 = cz + Math.sin(a1) * HEX;
      const x2 = cx + Math.cos(a2) * HEX, z2 = cz + Math.sin(a2) * HEX;
      const len = Math.sqrt((x2-x1)*(x2-x1) + (z2-z1)*(z2-z1));
      const wall = new THREE.Mesh(new THREE.BoxGeometry(len, wallH, wallT), wallMat);
      wall.position.set((x1+x2)/2, wallH/2, (z1+z2)/2);
      wall.rotation.y = -Math.atan2(z2-z1, x2-x1);
      wall.castShadow = true;
      scene.add(wall);
      if (typeof addCollider === 'function') addCollider(wall);
    }
    const canvas = document.createElement('canvas');
    canvas.width = 512; canvas.height = 128;
    const ctx = canvas.getContext('2d');
    ctx.fillStyle = '#FF3333'; ctx.font = 'bold 72px monospace'; ctx.textAlign = 'center';
    ctx.fillText('FORUM', 256, 88);
    const label = new THREE.Mesh(new THREE.PlaneGeometry(16, 4), new THREE.MeshBasicMaterial({ map: new THREE.CanvasTexture(canvas), transparent: true }));
    label.position.set(cx, 10, cz);
    scene.add(label);
    window.FORUM_INSPECTIO