/* OpenHero source by Cristian Olivera Chávez. MIT License Copyright (c) 2026 Cristian Olivera Chávez Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ "use client"; import { useEffect, useRef, useState } from "react"; import { Icon } from "@iconify/react"; export default function Page() { const [showPreloader, setShowPreloader] = useState(true); const cursorRef = useRef(null); const trailRef = useRef(null); const scrollLineRef = useRef(null); const navRef = useRef(null); const portalVideoRef = useRef(null); const heroTextRef = useRef(null); const heroRef = useRef(null); const projectTrackRef = useRef(null); const circValRef = useRef(null); const c1Ref = useRef(null); const c2Ref = useRef(null); const c3Ref = useRef(null); const preloaderTimerRef = useRef(null); const projectIndexRef = useRef(0); const projectCardGap = 24; const tickerItems = [ ["Atmospheric Equilibrium", "Biophilic Integration"], ["Carbon-Negative Structuralism", "Regenerative Ecosystems"], ["Living Facade Systems", "Hydro-Responsive Architecture"], ["Mycorrhizal Networks", "Atmospheric Equilibrium"], ]; const pillarCards = [ { tag: "01 · Atmosphere", title: "Atmospheric Equilibrium", text: "Every structure is calibrated to restore the thermal, hydrological, and gaseous balance of its immediate biome—a self-correcting climate engine embedded in form.", icon: "ph:star-four-light", color: "var(--amber)", }, { tag: "02 · Biology", title: "Biophilic Integration", text: "Living systems do not ornament our buildings—they constitute them. Root structures, fungal webs, and photosynthetic surfaces are load-bearing elements of the new vernacular.", icon: "ph:leaf-light", color: "var(--sage)", }, { tag: "03 · Carbon", title: "Carbon-Negative Structuralism", text: "Net negative from groundbreaking to centennial. Mass timber, hempcrete, and algae-seeded concrete sequester more than the entire construction footprint generates.", icon: "ph:bolt-light", color: "oklch(75% 0.1 340)", }, { tag: "04 · Ecology", title: "Regenerative Ecosystems", text: "Each project increases local biodiversity by minimum 3×. Corridors of continuous habitat connect structure to landscape, so wildlife navigates the city as seamlessly as water.", icon: "ph:globe-light", color: "oklch(72% 0.1 250)", }, ]; const projectCards = [ { kv: "Vertical Forest · 2024", title: "The Verdant Tower", loc: "Singapore, SG — 87 Storeys", }, { kv: "Wetland Campus · 2024", title: "Aquifer House", loc: "Rotterdam, NL — 4.2 Ha", }, { kv: "Desert Terraforming · 2023", title: "Dune Meridian", loc: "Al Ula, SA — 220 Ha", }, { kv: "Urban Rewilding · 2023", title: "The Hollow City", loc: "Oslo, NO — 14 Districts", }, ]; useEffect(() => { preloaderTimerRef.current = window.setTimeout(() => { setShowPreloader(false); }, 1400); const cursor = cursorRef.current; const trail = trailRef.current; const scrollLine = scrollLineRef.current; const nav = navRef.current; const portalVideo = portalVideoRef.current; const heroText = heroTextRef.current; const hero = heroRef.current; const circVal = circValRef.current; const c1 = c1Ref.current; const c2 = c2Ref.current; const c3 = c3Ref.current; let mouseX = 0; let mouseY = 0; let trailX = 0; let trailY = 0; let ticking = false; const animateCount = ( el: HTMLSpanElement | null, target: number, duration: number, decimals = 0 ) => { if (!el) return; const start = performance.now(); const step = (now: number) => { const progress = Math.min((now - start) / duration, 1); const eased = 1 - Math.pow(1 - progress, 4); const value = target * eased; el.textContent = decimals ? value.toFixed(decimals) : String(Math.round(value)); if (progress < 1) requestAnimationFrame(step); }; requestAnimationFrame(step); }; const handleMouseMove = (e: MouseEvent) => { mouseX = e.clientX; mouseY = e.clientY; if (cursor) { cursor.style.left = `${mouseX}px`; cursor.style.top = `${mouseY}px`; } }; const animateTrail = () => { trailX += (mouseX - trailX) * 0.12; trailY += (mouseY - trailY) * 0.12; if (trail) { trail.style.left = `${trailX}px`; trail.style.top = `${trailY}px`; } requestAnimationFrame(animateTrail); }; const handleMouseDown = () => { if (cursor) cursor.style.transform = "translate(-50%, -50%) scale(0.5)"; }; const handleMouseUp = () => { if (cursor) cursor.style.transform = "translate(-50%, -50%) scale(1)"; }; const interactiveSelectors = ".btn-liquid, .cta-submit, .bio-card, .project-card, .metric-orb, a, button"; const interactiveElements = document.querySelectorAll(interactiveSelectors); interactiveElements.forEach((el) => { el.addEventListener("mouseenter", () => { if (trail) { trail.style.width = "60px"; trail.style.height = "60px"; } }); el.addEventListener("mouseleave", () => { if (trail) { trail.style.width = "40px"; trail.style.height = "40px"; } }); el.addEventListener("mousemove", (ev) => { const e = ev as MouseEvent; const rect = el.getBoundingClientRect(); const x = ((e.clientX - rect.left) / rect.width) * 100; const y = ((e.clientY - rect.top) / rect.height) * 100; el.style.setProperty("--mx", `${x}%`); el.style.setProperty("--my", `${y}%`); }); }); const handleScroll = () => { if (ticking) return; ticking = true; requestAnimationFrame(() => { const scrolled = window.scrollY; const maxScroll = document.body.scrollHeight - window.innerHeight || 1; const pct = (scrolled / maxScroll) * 100; if (scrollLine) scrollLine.style.width = `${pct}%`; if (nav) { nav.classList.toggle("scrolled", scrolled > 80); } if (portalVideo && scrolled < window.innerHeight * 1.5) { portalVideo.style.transform = `scale(${1.02 + scrolled * 0.0002}) translateY(${scrolled * 0.1}px)`; } if (heroText && scrolled < window.innerHeight) { heroText.style.transform = `translateY(${scrolled * -0.08}px)`; } const parallaxCards = document.querySelectorAll(".parallax-card"); parallaxCards.forEach((card) => { const rect = card.getBoundingClientRect(); if (rect.top < window.innerHeight && rect.bottom > 0) { const yOffset = (window.innerHeight - rect.top) * 0.05; card.style.transform = `translateY(-${yOffset}px)`; } }); ticking = false; }); }; const heroObserver = new IntersectionObserver( (entries, obs) => { if (entries[0]?.isIntersecting) { setTimeout(() => animateCount(c1, 94, 2200), 1400); setTimeout(() => animateCount(c2, 14200, 2400), 1500); setTimeout(() => animateCount(c3, 34, 2000), 1600); obs.disconnect(); } }, { threshold: 0.3 } ); if (hero) heroObserver.observe(hero); const revealObserver = new IntersectionObserver( (entries, obs) => { entries.forEach((entry) => { if (entry.isIntersecting) { entry.target.classList.add("visible"); obs.unobserve(entry.target); } }); }, { threshold: 0.15, rootMargin: "0px 0px -60px 0px" } ); document.querySelectorAll(".reveal-up").forEach((el) => revealObserver.observe(el)); const updateProjectTrack = () => { const track = projectTrackRef.current; if (!track) return; const firstCard = track.querySelector(".project-card"); if (!firstCard) return; const cardWidth = firstCard.getBoundingClientRect().width; track.style.transform = `translateX(-${projectIndexRef.current * (cardWidth + projectCardGap)}px)`; }; const handleResize = () => { updateProjectTrack(); }; updateProjectTrack(); window.addEventListener("mousemove", handleMouseMove); window.addEventListener("mousedown", handleMouseDown); window.addEventListener("mouseup", handleMouseUp); window.addEventListener("scroll", handleScroll, { passive: true }); window.addEventListener("resize", handleResize); const circTimer = window.setInterval(() => { if (!circVal) return; const now = new Date(); const h = String(now.getHours()).padStart(2, "0"); const m = String(now.getMinutes()).padStart(2, "0"); circVal.textContent = `${h}:${m}`; }, 1000); let canvasCleanup: (() => void) | undefined; const canvas = document.getElementById("dust") as HTMLCanvasElement | null; if (canvas) { const ctx = canvas.getContext("2d"); if (ctx) { const particles: Array<{ x: number; y: number; vx: number; vy: number; size: number; alpha: number; warm: boolean; }> = []; const resizeCanvas = () => { canvas.width = window.innerWidth; canvas.height = window.innerHeight; }; resizeCanvas(); window.addEventListener("resize", resizeCanvas); for (let i = 0; i < 80; i++) { particles.push({ x: Math.random() * window.innerWidth, y: Math.random() * window.innerHeight, vx: (Math.random() - 0.5) * 0.25, vy: -Math.random() * 0.4 - 0.05, size: Math.random() * 2 + 0.5, alpha: Math.random() * 0.35 + 0.05, warm: Math.random() > 0.3, }); } const drawDust = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); particles.forEach((p) => { p.x += p.vx + Math.sin(Date.now() * 0.0003 + p.y * 0.01) * 0.2; p.y += p.vy; if (p.y < -5) { p.y = canvas.height + 5; p.x = Math.random() * canvas.width; } ctx.beginPath(); ctx.arc(p.x, p.y, p.size, 0, Math.PI * 2); ctx.fillStyle = p.warm ? `oklch(88% 0.14 85 / ${p.alpha})` : `oklch(72% 0.14 145 / ${p.alpha * 0.5})`; ctx.fill(); }); requestAnimationFrame(drawDust); }; drawDust(); canvasCleanup = () => { window.removeEventListener("resize", resizeCanvas); }; } } if (portalVideo) { const fallback = document.getElementById("lp-fallback"); const handleCanPlay = () => { if (fallback) { fallback.style.opacity = "0"; fallback.style.transition = "opacity 1s"; } }; const handleError = () => { portalVideo.style.display = "none"; }; portalVideo.addEventListener("canplay", handleCanPlay); portalVideo.addEventListener("error", handleError); return () => { if (preloaderTimerRef.current) window.clearTimeout(preloaderTimerRef.current); window.removeEventListener("mousemove", handleMouseMove); window.removeEventListener("mousedown", handleMouseDown); window.removeEventListener("mouseup", handleMouseUp); window.removeEventListener("scroll", handleScroll); window.removeEventListener("resize", handleResize); window.clearInterval(circTimer); heroObserver.disconnect(); revealObserver.disconnect(); portalVideo.removeEventListener("canplay", handleCanPlay); portalVideo.removeEventListener("error", handleError); canvasCleanup?.(); }; } return () => { if (preloaderTimerRef.current) window.clearTimeout(preloaderTimerRef.current); window.removeEventListener("mousemove", handleMouseMove); window.removeEventListener("mousedown", handleMouseDown); window.removeEventListener("mouseup", handleMouseUp); window.removeEventListener("scroll", handleScroll); window.removeEventListener("resize", handleResize); window.clearInterval(circTimer); heroObserver.disconnect(); revealObserver.disconnect(); canvasCleanup?.(); }; }, []); const moveProjects = (direction: number) => { const track = projectTrackRef.current; if (!track) return; const firstCard = track.querySelector(".project-card"); if (!firstCard) return; const maxIndex = Math.max(projectCards.length - 2, 0); projectIndexRef.current = Math.min( Math.max(projectIndexRef.current + direction, 0), maxIndex ); const cardWidth = firstCard.getBoundingClientRect().width; track.style.transform = `translateX(-${projectIndexRef.current * (cardWidth + projectCardGap)}px)`; }; return ( <> {showPreloader && (
The Line & Living
)}