<!-- SOLID CITY · part 2475 -->

  if (H.regrid) H.regrid();
}
function watchStop() {
  var W = window.CityWatch, r = W && W.routes && W.routes.grand; if (!r || r._ancestorsHomes) return;
  var orig = r.build; r._ancestorsHomes = true;
  r.build = function () {
    var w = orig.apply(this, arguments), at = Math.min(1, w.length);
    w.splice(at, 0, { x: 700, z: -880, y: 250, v: 230, cap: { cap: "NĀ HALE O NĀ KŪPUNA", sub: "The Ancestors' Homes · 'ohana compounds · green benches", say: "The Ancestors' Homes: Hawaiian families living on the green benches around the Ancestral Roads — hale, plantation homes, and Dickey roofs among the taro and the trees." }, agl: false });
    return w;
  };
}
function triYAt(t, o, x, z) {
  var ax = t[o], ay = t[o + 1], az = t[o + 2], bx = t[o + 3], by = t[o + 4], bz = t[o + 5], cx = t[o + 6], cy = t[o + 7], cz = t[o + 8];
  var den = (bz - cz) * (ax - cx) + (cx - bx) * (az - cz);
  if (Math.abs(den) < 1e-9) return null;
  var w0 = ((bz - cz) * (x - cx) + (cx - bx) * (z - cz)) / den;
  var w1 = ((cz - az) * (x - cx) + (ax - cx) * (z - cz)) / den;
  var w2 = 1 - w0 - w1;
  if (w0 < -0.01 || w1 < -0.01 || w2 < -0.01) return null;
  return w0 * ay + w1 * by + w2 * cy;
}
function standY(x, z, py) {
  var rects = M.rects; if (!rects) return -1000;
  /* THE GATE SPLIT (2026-10-14, from the study of the published
   * controllers: Unreal steps up 0.45 m, Unity 0.1–0.4 m, Godot snaps
   * 0.1 m grounded-only): one 1.6 m gate let a walker step onto
   * chest-high surfaces and hid real seams from his feet. On foot the
   * gate is now 0.45 m — the mountain walk census reads clean under
   * it, worst riser 0.44 m. A DRIVER keeps the proven 1.6: at speed
   * on a 38% grade the car's own ground runs ahead of a tight gate
   * between frames, and the drive proofs were sworn under 1.6. The
   * mode is read from the city's own state — S here is SC.api.S
   * (verified in city.js, where the api object is built as
   * { T: T, S: S, ... } and S.drive stands while a car is driven).
   * The gate is a ceiling only: anything at or below the feet is
   * always eligible, so landing and falling are untouched. */
  var gate = (typeof S !== 'undefined' && S && S.drive) ? 1.6 : 0.45;
  var best = -1000;
  for (var i = 0; i < rects.length; i++) {
    var r = rects[i], dx = x - r.cx, dz = z - r.cz;
    var lx = dx * r.cos - dz * r.sin, lz = dx * r.sin + dz * r.cos;
    if (Math.abs(lx - r.lx) <= r.hw && Math.abs(lz - r.lz) <= r.hd) {
      if (py == null || r.y <= py + gate) { if (r.y > best) best = r.y; }
    }
  }
  // the pitched surfaces (roads, driveways, paths, pads) — the same reading
  // the ward joins get: the highest triangle that passes the walker's gate
  if (M.triIx) {
    var bx = Math.floor(x / 16), bz = Math.floor(z / 16);
    for (var gx = bx - 1; gx <= bx + 1; gx++) for (var gz = bz - 1; gz <= bz + 1; gz++) {
      var cell = M.triIx[gx + ':' + gz]; if (!cell) continue;
      for (var ci = 0; ci < cell.length; ci++) {
        var ty = triYAt(M.tris, cell[ci], x, z);
        if (ty == null) continue;
        if (py == null || ty <= py + gate) { if (ty > best) best = ty; }
      }
    }
  }
  return best;
}
function load() {
  M.state = 'loading';
  var ga = A.groundAt || (typeof groundAt === 'function' ? groundAt : null);
  var p; try { p = import('/city/mountain-homes.js?v=20261014j'); } catch (e) { p = Promise.reject(e); }
  p.then(function (mod) {
    var make = mod.createMountainHomes || mod.default;
    var g = make({ THREE: A.T, groundAt: ga });
    A.world.add(g); M.group = g; M.state = 'ready';
    M.rects = (g.userData && g.userData.standRects) || null;
    M.tris = (g.userData && g.userData.standTris) || null;
    if (M.tris) {
      M.triIx = {};
      for (var ti = 0; ti + 8 < M.tris.length; ti += 9) {
        var tcx = (M.tris[ti] + M.tris[ti + 3] + M.tris[ti + 6]) / 3, tcz = (M.tris[ti + 2] + M.tris[ti + 5] + M.tris[ti + 8]) / 3;
        var tk = Math.floor(tcx / 16) + ':' + Math.floor(tcz / 16);
        (M.triIx[tk] = M.triIx[tk] || []).push(ti);
      }
    }
    collide(g.userData || {}); hyperStop(); watchStop();
  }).catch(function (e) { M.state = 'failed'; try { console.warn('[city] Ancestors homes skipped:', e && e.message); } catch (x) {} });
}
function update(dt) {
  if (M.state === 'idle') { if (A.isBuilt && !A.isBuilt()) return; M.wait -= dt; if (M.wait <= 0) load(); return; }
  if (M.state !== 'ready' || document.hidden) return;
  var c = A.camera.position, d = Math.hypot(c.x + A.origin.x - POS.x, c.z + A.origin.z - POS.z);
  M.group.visible = d < 11000;
  if (S.mode === 'walk') {
    var pd = Math.hypot(S.p.x - POS.x, S.p.z - POS.z);
    if (pd < 420 && !M.said) { M.said = true; if (window.CityHyper && CityHyper.narrate) CityHyper.narrate("<b>Nā Hale o nā Kūpuna</b> — the Ancestors' Homes. 'Ohana compounds on the green benches; every door opens.", 7); }
    else if (pd > 700) M.said = false;
  }
}
function radar(g, blip, fl) { if (M.state === 'ready') bli