/* ============================================================
 shared.jsx - content data + reusable components
 Exports to window: C (components), DATA, ROUTES, LINKS
 ============================================================ */
const { useState, useEffect, useRef } = React;

const LINKS = {
 book: "https://bookdirect.prenohq.com/inst/#home?propertyId=862IjqrDOItjIabf6ozfWAL5I9gmZ7WWLeM6QFp4WPaLEagZU0NTc1MyI=&JDRN=Y",
 email: "info@arikilakehouse.co.nz",
 ig: "https://www.instagram.com/arikilakehouse/",
 phone: "+64 00 000 0000",
};

const ROUTES = [
 { id: "home", label: "Home" },
 { id: "space", label: "The Space" },
 { id: "corporate", label: "Corporate" },
 { id: "sports", label: "Sports" },
 { id: "gatherings", label: "Gatherings" },
 { id: "about", label: "About" },
 { id: "enquire", label: "Enquire" },
];

const Arw = () => <span className="arw" aria-hidden="true">→</span>;

/* small reusable bits ----------------------------------------------------- */
function Eyebrow({ children, center, className = "" }) {
 return <div className={`eyebrow ${center ? "center" : ""} ${className}`}>{children}</div>;
}

function Reveal({ children, className = "", delay = 0, tag = "div", ...rest }) {
 const Tag = tag;
 const d = delay ? ` d${delay}` : "";
 return <Tag className={`reveal${d} ${className}`} {...rest}>{children}</Tag>;
}

function Btn({ href, onClick, children, variant = "solid", external, ...rest }) {
 const cls = `btn btn--${variant}`;
 if (onClick) return <button className={cls} onClick={onClick} {...rest}>{children}</button>;
 return (
 <a className={cls} href={href}
 target={external ? "_blank" : undefined}
 rel={external ? "noopener noreferrer" : undefined} {...rest}>
 {children}
 </a>
 );
}

function NavLink({ to, children, className = "", go }) {
 return <a href={"#" + to} className={className} onClick={(e) => { e.preventDefault(); go(to); }}>{children}</a>;
}

/* image slot wrapper — when src is given, also renders a plain-DOM photo backdrop
 (robust in exports/screenshots) behind the swappable image-slot */
function Slot({ id, label, className = "", style, src, backdropClass = "" }) {
 return (
 <React.Fragment>
 {src ? <div className={`ph ph--img ${backdropClass}`} style={{ backgroundImage: `url("${src}")` }}></div> : null}
 <image-slot id={id} placeholder={label} fit="cover" src={src} className={className} style={style}></image-slot>
 </React.Fragment>
 );
}

/* scrolling marquee strip */
function Marquee({ items }) {
 const seq = (k) => items.map((t, i) => (
 <span key={k + i}>{t}<span className="tld">~</span></span>
 ));
 return (
 <div className="marquee" aria-hidden="true">
 <div className="marquee__track">{seq("a")}{seq("b")}</div>
 </div>
 );
}

/* full-bleed film band — plays video if present, falls back to poster photo */
function FilmBand({ src, poster, kicker, title, note }) {
 const [failed, setFailed] = useState(false);
 return (
 <section className="film">
 {!failed && src ? (
 <video src={src} poster={poster} autoPlay loop playsInline
 ref={(el) => { if (el) { el.muted = true; } }}
 onError={() => setFailed(true)}></video>
 ) : (
 <div className="film__img" style={{ backgroundImage: `url("${poster}")` }}></div>
 )}
 <div className="film__cap">
 <div>
 <span className="kicker">{kicker}</span>
 <h3 className="display">{title}</h3>
 </div>
 {note ? <span className="film__note">{note}</span> : null}
 </div>
 </section>
 );
}

function Stat({ num, label }) {
 return (
 <div className="stat">
 <div className="stat__num display">{num}</div>
 <div className="stat__lbl">{label}</div>
 </div>
 );
}

function Brandmark({ className = "", style }) {
 return <img src="assets/brandmark.svg" alt="Ariki Lake House" className={className} style={style} />;
}
function Wordmark({ className = "", style }) {
 return <img src="assets/logo-wordmark.svg" alt="Ariki Lake House" className={className} style={style} />;
}

/* FAQ accordion item */
function Faq({ q, a }) {
 const [open, setOpen] = useState(false);
 const ref = useRef(null);
 return (
 <div className={`faq__item ${open ? "open" : ""}`}>
 <button className="faq__q" onClick={() => setOpen(o => !o)}>
 <span>{q}</span><span className="pl">+</span>
 </button>
 <div className="faq__a" ref={ref} style={{ maxHeight: open ? (ref.current ? ref.current.scrollHeight : 400) : 0 }}>
 <p>{a}</p>
 </div>
 </div>
 );
}

/* CTA band reused across pages */
function CtaBand({ go, title = "Plan your team's stay", text = "Take over the whole house on the shores of Lake Karapiro. Book direct, or tell us what your team needs and we'll tailor it.", bg = "assets/aerial-dam.jpg" }) {
 return (
 <section className="section ctaband">
 {bg ? <div className="ctaband__bg" style={{ backgroundImage: `url("${bg}")` }}></div> : null}
 <img src="assets/brandmark.svg" className="brandmark-bg" alt="" aria-hidden="true" />
 <div className="wrap">
 <Reveal><h2 className="display">{title}</h2></Reveal>
 <Reveal delay={1}><p>{text}</p></Reveal>
 <Reveal delay={2}>
 <div className="hero__cta">
 <Btn href={LINKS.book} external variant="lightsolid">Book Direct <Arw /></Btn>
 <Btn onClick={() => go("enquire")} variant="light">Enquire <Arw /></Btn>
 </div>
 </Reveal>
 </div>
 </section>
 );
}

/* ============================================================
 CONTENT DATA
 ============================================================ */
const DATA = {
 stats: [
 { num: "32+", label: "Guests, one house" },
 { num: "700m", label: "To Lake Karapiro" },
 { num: "7 min", label: "To Cambridge" },
 { num: "1940s", label: "Heritage building" },
 ],

 spaces: [
 { no: "01", name: "Rangitira", cap: "Sleeps up to 18", slot: "space-rangitira",
 img: "assets/rangitira-living.jpg",
 ph: "Rangitira - open-plan living, lake view",
 text: "Our premium apartment. A large open-plan living area to gather in, framed by uninterrupted views over Lake Karapiro and Mt. Maungatautari. Comfort, light and space for the whole group." },
 { no: "02", name: "Hydro", cap: "Sleeps up to 14", slot: "space-hydro",
 img: "assets/hydro-bar.jpg",
 ph: "Hydro - heritage interior, warm light",
 text: "A self-contained apartment rich in history. The heart of Ariki dates to the 1940s - the Hydro's kitchen walls are reinforced concrete once used to store dynamite for the building of Karapiro Dam." },
 { no: "03", name: "The Apartment", cap: "2 bedrooms · Sleeps up to 5 · $290 / night", slot: "space-apartment",
 img: "assets/bathroom.jpg",
 ph: "2-bedroom apartment add-on",
 text: "An attached two-bedroom apartment you can add to any booking - ideal for coaches, facilitators or organisers who want a quieter corner close to the action." },
 ],

 amenities: [
 { name: "Lake Karapiro", dist: "700 m", slot: "amen-lake", img: "assets/aerial-dam.jpg", ph: "Lake Karapiro - rowing water at dawn",
 text: "A stone's throw from the Domain. World-class rowing, kayaking and water skiing on the doorstep." },
 { name: "Grassroots Velodrome", dist: "10 min", slot: "amen-velo", ph: "Velodrome / cycling roads",
 text: "The country's best riding roads plus the world-class indoor Velodrome - a magnet for cycling squads." },
 { name: "Cambridge Town", dist: "7 min", slot: "amen-town", ph: "Cambridge town - cafés & eateries",
 text: "A short drive to the cafés, eateries and boutique streets of Cambridge for the team's downtime." },
 ],

 dayTrips: [
 { name: "Te Awa River Ride", dist: "5 min", slot: "amen-teawa", ph: "Te Awa - riverside cycle trail",
 text: "A riverside cycle trail running from Karapiro along the Waikato - ride towards Cambridge and beyond, almost from the door." },
 { name: "The Red Barn", dist: "15 min", slot: "amen-redbarn", ph: "The Red Barn - rustic venue, paddocks",
 text: "A much-loved rustic wedding and events venue just up the road - perfect when your stay at Ariki is part of a bigger celebration." },
 { name: "Sanctuary Mountain", dist: "20 min", slot: "amen-sanctuary", ph: "Maungatautari - forest sanctuary",
 text: "Walk beneath ancient forest at Maungatautari, the world's largest fenced eco-sanctuary - the mountain you see from the deck." },
 { name: "Hamilton Gardens", dist: "25 min", slot: "amen-gardens", ph: "Hamilton Gardens - themed gardens",
 text: "Award-winning themed gardens on the banks of the Waikato River - a relaxed outing between sessions." },
 { name: "Hobbiton", dist: "30 min", slot: "amen-hobbiton", ph: "Hobbiton Movie Set - the Shire",
 text: "The world-famous Hobbiton Movie Set at Matamata - an easy half-day out for the group." },
 { name: "Waitomo Caves", dist: "1 hr", slot: "amen-waitomo", ph: "Waitomo - glowworm caves",
 text: "Drift beneath glowworms or go black-water rafting in one of New Zealand's most famous underground worlds." },
 ],
 travelNote: "Further afield - Hamilton 25 min · Rotorua 1 hr · Auckland 90 min by car.",

 corpIncl: [
 { n: "01", h: "The whole house, yours alone", p: "No shared spaces, no other guests. Take over Rangitira and Hydro for the entire stay." },
 { n: "02", h: "Room to think", p: "Open-plan living that doubles as a breakout and strategy space, with the lake as your backdrop." },
 { n: "03", h: "Communal dining", p: "A long shared table for working lunches, team dinners and the conversations that matter." },
 { n: "04", h: "Away, but not far", p: "90 minutes from Auckland, 7 from Cambridge - far enough to reset, close enough to be easy." },
 ],
 corpIdeas: [
 { n: "01", h: "Speakers & facilitators", p: "We can point you towards local speakers and facilitators to anchor a session or a talk." },
 { n: "02", h: "Catering, your way", p: "Fully self-contained kitchens for self-catering, or we'll connect you with local caterers for a hosted meal." },
 { n: "03", h: "My Kitchen Rules, Ariki-style", p: "Book the whole property and split into teams across the three kitchens for a cook-off - a favourite for teams who want to compete outside the boardroom." },
 { n: "04", h: "Team building, sorted locally", p: "We know the area well and can help find team-building programmes and challenges that suit your group, from the lake to the paddocks nearby." },
 ],
 corpItin: [
 { when: "Day 1 · AM", h: "Arrive & settle", p: "Coffee on the deck, house orientation, kick-off session as the team lands." },
 { when: "Day 1 · PM", h: "Strategy block", p: "Facilitated working session in the open-plan living space, lake in full view." },
 { when: "Day 1 · EVE", h: "Long table dinner", p: "Shared meal at the communal table - the part of the offsite people remember." },
 { when: "Day 2 · AM", h: "Reset & walk", p: "Lakeside walk or row before the morning's deep-work session." },
 { when: "Day 2 · PM", h: "Align & depart", p: "Commitments, next steps, and the drive home with the team on the same page." },
 ],

 sportsIncl: [
 { n: "01", h: "Built by performance people", p: "Founded by two who've lived high-performance sport - the house is set up the way teams actually use it." },
 { n: "02", h: "Sleeps the whole squad", p: "Up to 32 in bunk rooms under one roof. No splitting the team across hotels." },
 { n: "03", h: "Recover well", p: "Communal living and dining for debriefs and downtime; quiet rooms for genuine rest." },
 { n: "04", h: "Train on the doorstep", p: "Lake Karapiro, the Grassroots Arena and the region's best training facilities and roads minutes from the door." },
 ],
 sportsIdeas: [
 { n: "01", h: "Local know-how", p: "We know the area well and can help point you to the right speakers, physios and support for your camp." },
 { n: "02", h: "Recovery, sorted", p: "We can collaborate with the Cambridge Sauna Project nearby, or arrange to have a sauna placed right onsite for the stay." },
 { n: "03", h: "Nutrition & catering", p: "Self-cater in the fully-equipped kitchens, or we'll connect you with local caterers who know what athletes need." },
 { n: "04", h: "Built around your programme", p: "Tell us your training load and goals and we'll help tailor a schedule around the lake, the Velodrome and the house." },
 ],
 gatherIncl: [
 { n: "01", h: "The whole house, yours alone", p: "No other guests and no shared spaces - open the doors between Rangitira and Hydro and it's all yours for the weekend." },
 { n: "02", h: "One long table", p: "A communal table big enough for everyone - the birthday dinner, the speeches, the late-night catch-ups." },
 { n: "03", h: "Beds for everyone", p: "Sleeps 32+ across bedrooms and bunk rooms, with a two-bedroom apartment add-on for anyone who needs a quieter corner." },
 { n: "04", h: "The lake out front", p: "Swims, kayaks, lakeside walks and golden-hour photos, 700 metres from the deck." },
 ],

 sportsItin: [
 { when: "Day 1", h: "Arrive & activate", p: "Settle in, light activation on the water, team meal and goal-setting." },
 { when: "Day 2", h: "Double day", p: "AM session on the lake, recovery block at the house, PM strength or skills." },
 { when: "Day 3", h: "Load & debrief", p: "Key training block, video review around the table, recovery and team night." },
 { when: "Day 4", h: "Sharpen & depart", p: "Final session, pack down, debrief and the road home as a tighter unit." },
 ],

 faqs: [
 { q: "How many people can stay?", a: "Ariki comfortably sleeps up to 32 guests across the Rangitira and Hydro apartments, with the option for more on trundler beds. You can also add an attached two-bedroom apartment sleeping up to five for $290 per night." },
 { q: "Is Ariki only for teams?", a: "Not at all. Families and groups of friends regularly take over the house for milestone birthdays, anniversaries and reunions - the same whole-house setup that works for teams works just as well for getting everyone together." },
 { q: "Can we book the whole property?", a: "Yes - most teams take over the entire house so there are no shared spaces or other guests. Open the doors between Rangitira and Hydro and the whole place is yours." },
 { q: "What's nearby for training and downtime?", a: "Lake Karapiro Domain is 700m away, the Grassroots Velodrome a 10-minute drive, and Cambridge town just 7 minutes for cafés and eateries. For day trips, Hobbiton is 30 minutes away, Hamilton Gardens 25 minutes, Waitomo Caves and Rotorua around an hour." },
 { q: "How do we book?", a: "You can book directly through our online system, or send us an enquiry and we'll tailor a package to your team's dates and needs." },
 { q: "Is catering available?", a: "The kitchens are fully self-contained for self-catering, and we can point you to excellent local providers for catered meals - just ask in your enquiry." },
 { q: "How far is it from Auckland, Tauranga and Hamilton?", a: "Roughly 90 minutes from Auckland, 60 minutes from Tauranga and under 30 minutes from Hamilton - close enough to be easy, far enough to feel away." },
 ],
};

/* export everything other files need */
window.C = { Arw, Eyebrow, Reveal, Btn, NavLink, Slot, Stat, Brandmark, Wordmark, Faq, CtaBand, Marquee, FilmBand };
window.DATA = DATA;
window.ROUTES = ROUTES;
window.LINKS = LINKS;
