/// file: public/assets/js/modules/home-diamond-hero.js

/**
 * Home hero: dark luxury procedural crystal (Three.js).
 * Pointer: window.__saneksaHeroTarget (home-touch.js).
 * Implementation: ./home-diamond/scene.js
 */

import { THREE_MOD } from './home-diamond/constants.js';
import { createLuxuryDiamondScene } from './home-diamond/scene.js';

export function initHomeDiamondHero() {
  const canvas = document.getElementById('home-diamond-canvas');
  if (!canvas || !(canvas instanceof HTMLCanvasElement)) return;

  if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
    canvas.closest('[data-home-diamond-wrap]')?.classList.add('home-diamond-wrap--static-fallback');
    return;
  }

  void (async () => {
    let mod;
    try {
      mod = await import(/* @vite-ignore */ THREE_MOD);
    } catch (e) {
      console.warn('[home-diamond] Three.js failed to load', e);
      canvas.closest('[data-home-diamond-wrap]')?.classList.add('home-diamond-wrap--static-fallback');
      return;
    }
    createLuxuryDiamondScene(canvas, mod);
  })();
}
