/* ===== Troyamarin — App root + data ===== */
const { useEffect: useE4 } = React;

// Optimized photo assets (see assets/optimized/)
const IMG = {
  heroVideo: 'assets/optimized/index/hero-bg.mp4',
  heroPoster: 'assets/optimized/index/hf_20260409_160437_cb1fb378-f2b4-4423-8608-5a8412dabbf1.jpg',
  about: 'assets/optimized/index/hf_20260409_155532_1a7f158a-5b4a-46f7-b67a-bc99daf261b7.jpg',

  demirciCover: 'assets/optimized/demirci-140/20251212_122330.jpg',
  canakkaleStrait: 'assets/optimized/index/hf_20260409_155558_992830fa-22fd-49d2-810a-2b434c67e040.jpg',
  mountainValley: 'assets/optimized/index/hf_20260409_155604_b19f88c8-72d4-41de-a52c-10b55f282599.jpg',
  assosHarbor: 'assets/optimized/index/hf_20260409_160423_b6caf2a6-b07d-4e2f-bc39-8a4f42820696.jpg',

};

// Parcels shown on the 3D terrain (x,y in plane coords from island center; h = stem height)
const PARCELS = [
  { id: 'p1', x: -42, y: -28, h: 82, tag: 'Deniz Manzaralı', title: 'Assos Sırtı', loc: 'Ayvacık, Çanakkale',
    area: '1.240 m²', zoning: 'Konut imarlı', deed: 'Müstakil', price: '₺4.250.000' },
  { id: 'p2', x: 46, y: -6, h: 62, tag: 'Yatırımlık', title: 'Zeytin Vadisi', loc: 'Küçükkuyu, Çanakkale',
    area: '5.800 m²', zoning: 'Tarla', deed: 'Hisseli', price: '₺2.900.000' },
  { id: 'p3', x: 40, y: 40, h: 46, tag: 'Koy Cephesi', title: 'Datça Sahili', loc: 'Datça, Muğla',
    area: '900 m²', zoning: 'Konut imarlı', deed: 'Müstakil', price: '₺6.750.000' },
  { id: 'p4', x: -34, y: 36, h: 50, tag: 'Bağ & Bahçe', title: 'Bozburun Tepe', loc: 'Marmaris, Muğla',
    area: '3.100 m²', zoning: 'Bağ-bahçe', deed: 'Müstakil', price: '₺3.480.000' },
];

const LISTINGS = [
  { id: 'l1', img: IMG.demirciCover, badge: 'FIRSAT', type: 'Sağlık & Ekolojik Yaşam Arazisi', title: 'Kaz Dağları eteğinde 140 ada — 76.722 m² dev arazi',
    loc: 'Demirci · Çanakkale', area: '76.722 m²', zoning: 'Tarım', deed: 'Müstakil', price: '₺75M', unit: 'pazarlıklı', link: 'ilan-detay.html' },
  { id: 'l2', img: IMG.assos, badge: 'YENİ', type: 'Konut İmarlı Arsa', title: 'Assos\'ta Ege manzaralı parsel',
    loc: 'Ayvacık · Çanakkale', area: '1.240 m²', zoning: '%30', deed: 'Müstakil', price: '₺4.25M', unit: 'KDV dahil', link: '#' },
  { id: 'l3', img: IMG.beachCove, badge: 'SEÇKİN', type: 'Konut İmarlı Arsa', title: 'Datça koyunda eşsiz konum',
    loc: 'Datça · Muğla', area: '900 m²', zoning: '%25', deed: 'Müstakil', price: '₺6.75M', unit: 'KDV dahil', link: '#' },
  { id: 'l4', img: IMG.greenValley, badge: 'YENİ', type: 'Bağ & Bahçe', title: 'Bozburun yarımadası bağ',
    loc: 'Marmaris · Muğla', area: '3.100 m²', zoning: 'Bağ', deed: 'Müstakil', price: '₺3.48M', unit: 'KDV dahil', link: '#' },
  { id: 'l5', img: IMG.martyrsSunset, badge: 'YATIRIM', type: 'Geniş Tarla', title: 'Troya ovası verimli arazi',
    loc: 'Merkez · Çanakkale', area: '12.400 m²', zoning: 'Tarım', deed: 'Müstakil', price: '₺5.10M', unit: 'pazarlıklı', link: '#' },
  { id: 'l6', img: IMG.hikeRidge, badge: 'SEÇKİN', type: 'Villa İmarlı Arsa', title: 'Bodrum Yalıkavak tepe',
    loc: 'Bodrum · Muğla', area: '1.050 m²', zoning: '%20', deed: 'Müstakil', price: '₺9.20M', unit: 'KDV dahil', link: '#' },
];

const REGIONS = [
  { id: 'canakkale', name: 'Çanakkale', sub: 'Assos · Küçükkuyu · Merkez', region: 'Ege & Marmara', count: 24,
    map: 'https://maps.google.com/maps?q=39.55,26.45&t=k&z=11&output=embed',
    pins: [{ x: 22, y: 84, label: 'Assos' }, { x: 40, y: 62, label: 'Küçükkuyu' }, { x: 68, y: 32, label: 'Merkez' }] },
  { id: 'mugla', name: 'Muğla', sub: 'Bodrum · Datça · Marmaris', region: 'Ege Kıyıları', count: 31,
    map: 'https://maps.google.com/maps?q=36.85,27.8&t=k&z=9&output=embed',
    pins: [{ x: 10, y: 30, label: 'Bodrum' }, { x: 7, y: 60, label: 'Datça' }, { x: 83, y: 72, label: 'Marmaris' }] },
];

function useReveal() {
  useE4(() => {
    const els = document.querySelectorAll('.reveal:not(.in)');
    const io = new IntersectionObserver((ents) => {
      ents.forEach((e) => { if (e.isIntersecting) { e.target.classList.add('in'); io.unobserve(e.target); } });
    }, { threshold: 0.12, rootMargin: '0px 0px -8% 0px' });
    els.forEach((el) => io.observe(el));
    return () => io.disconnect();
  });
}

function App() {
  useReveal();
  return (
    <React.Fragment>
      <Nav />
      <Hero parcels={PARCELS} bgVideo={IMG.heroVideo} bgPoster={IMG.heroPoster} />
      <FeaturedListings items={LISTINGS} />
      <RegionsMap regions={REGIONS} />
      <About img={IMG.about} />
      <Services bg={IMG.assosHarbor} />
      <Contact />
      <Footer />
    </React.Fragment>
  );
}

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