// AR Ventures — site
// ─────────────────────────────────────────────────────────────────────────────
// Editorial, restrained presentation for a long-standing real-estate equity
// fund. All theme values are driven by CSS custom properties on <html> so the
// Tweaks panel can swap palettes/accent live.

const { useEffect, useMemo, useState } = React;

// ── Palettes ────────────────────────────────────────────────────────────────
// Each palette is [bg, paper, ink]. Accent is independent so the same accent
// can ride across the three base palettes.
const PALETTES = {
  cream:  { bg: "#F4F0E8", paper: "#FBF8F1", ink: "#1A1815" },
  ivory:  { bg: "#EFEBE0", paper: "#F7F2E5", ink: "#1D1C18" },
  fog:    { bg: "#ECECE8", paper: "#F5F5F1", ink: "#151719" },
  ink:    { bg: "#15140F", paper: "#1F1D17", ink: "#F0EBDC" },
};

const ACCENTS = {
  oxblood: "oklch(0.42 0.085 25)",
  navy:    "oklch(0.40 0.075 255)",
  forest:  "oklch(0.42 0.07 155)",
  rust:    "oklch(0.55 0.10 50)",
};

const PALETTE_OPTIONS = [
  ["#F7F6F2", "#15171C", "#FCFBF7"],   // bone (default)
  ["#F4F0E8", "#1A1815", "#FBF8F1"],   // cream
  ["#ECECE8", "#151719", "#F5F5F1"],   // fog
  ["#15140F", "#F0EBDC", "#1F1D17"],   // ink
];
const PALETTE_NAMES = ["bone", "cream", "fog", "ink"];

const ACCENT_OPTIONS = ["#243A6B", "#7A2B22", "#2C4A35", "#A26431"];
const ACCENT_NAMES = ["navy", "oxblood", "forest", "rust"];

// ── Content ─────────────────────────────────────────────────────────────────
// Single source — easier to tweak than chasing markup. Keep this honest: no
// invented numbers. The user supplied 1970 + seven states; everything else is
// either qualitative or marked as a representative placeholder.

const TENETS = [
  {
    n: "01",
    title: "Patience over pace.",
    body:
      "We hold assets through cycles. Our average ownership period is measured in decades, not quarters — a discipline that lets us pass on deals our peers chase.",
  },
  {
    n: "02",
    title: "Conservative leverage.",
    body:
      "Capital structures are built to survive the bottom of any cycle. We underwrite to durable cash flow first; appreciation is a consequence, not a thesis.",
  },
  {
    n: "03",
    title: "Aligned partners, on the ground.",
    body:
      "Every investment is co-underwritten with a local operator who shares meaningful equity. We invest our own capital alongside every commitment we make.",
  },
];

const FOOTPRINT = [
  { idx: "I",   name: "Salt Lake City, Utah",  meta: "Headquarters · 1970", hq: true },
  { idx: "II",  name: "California",            meta: "Multifamily · Office" },
  { idx: "III", name: "Texas",                 meta: "Industrial · Multifamily" },
  { idx: "IV",  name: "Idaho",                 meta: "Mixed-Use · Land" },
  { idx: "V",   name: "Missouri",              meta: "Multifamily · Retail" },
  { idx: "VI",  name: "Arkansas",              meta: "Retail · Industrial" },
  { idx: "VII", name: "New York",              meta: "Office · Mixed-Use" },
];

// Representative holdings reference removed — Holdings section deleted.

// ── App ─────────────────────────────────────────────────────────────────────

const TWEAK_DEFAULTS = /*EDITMODE-BEGIN*/{
  "palette": ["#F7F6F2", "#15171C", "#FCFBF7"],
  "accent": "#243A6B",
  "headline": "italic",
  "showMonogram": true
}/*EDITMODE-END*/;

function App() {
  const [t, setTweak] = useTweaks(TWEAK_DEFAULTS);

  // Apply theme as CSS variables on <html> so styles.css stays declarative.
  useEffect(() => {
    const root = document.documentElement;
    const [bg, ink, paper] = t.palette;
    root.style.setProperty("--bg", bg);
    root.style.setProperty("--ink", ink);
    root.style.setProperty("--paper", paper);
    root.style.setProperty("--accent", t.accent);

    // Derived ink alphas — recompute so they read on whichever ink the
    // current palette uses (light ink on dark bg needs different alphas).
    const isDarkBg = bg.toLowerCase() < "#888888"; // crude but fine for our 4 swatches
    const inkRgb = hexToRgb(ink);
    const setAlpha = (name, a) =>
      root.style.setProperty(name, `rgba(${inkRgb}, ${a})`);
    setAlpha("--ink-2", isDarkBg ? 0.72 : 0.66);
    setAlpha("--ink-3", isDarkBg ? 0.45 : 0.4);
    setAlpha("--rule", isDarkBg ? 0.2 : 0.14);
    setAlpha("--rule-soft", isDarkBg ? 0.12 : 0.08);
  }, [t.palette, t.accent]);

  return (
    <>
      <Nav showMonogram={t.showMonogram} />
      <Hero headlineStyle={t.headline} />
      <Feature />
      <Stats />
      <Approach />
      <Footprint />
      <Inquiry />
      <Footer />
      <Tweaks t={t} setTweak={setTweak} />
    </>
  );
}

function hexToRgb(hex) {
  const h = hex.replace("#", "");
  const x = h.length === 3 ? h.replace(/./g, (c) => c + c) : h;
  const n = parseInt(x, 16);
  return `${(n >> 16) & 255}, ${(n >> 8) & 255}, ${n & 255}`;
}

// ── Nav ─────────────────────────────────────────────────────────────────────

function Nav({ showMonogram }) {
  return (
    <header className="nav">
      <div className="container nav__inner">
        <a className="nav__brand" href="#top">
          <span>AR Ventures</span>
          {showMonogram && <span className="nav__brand-mark">Est. 1970</span>}
        </a>
        <nav className="nav__links" aria-label="Primary">
          <a href="#approach">Approach</a>
          <a href="/thesis">Thesis</a>
          <a href="#footprint">Footprint</a>
          <a href="/careers">Careers</a>
          <a href="#inquiry">Inquiries</a>
        </nav>
      </div>
    </header>
  );
}

// ── Hero ────────────────────────────────────────────────────────────────────

function Hero({ headlineStyle }) {
  // Two headline treatments: italic-accent (a single italic word picks up the
  // accent color) vs. plain (the whole headline stays neutral).
  const headline = headlineStyle === "italic" ? (
    <>Patient capital,<br/><em>durable</em> holdings.</>
  ) : (
    <>Patient capital, durable holdings.</>
  );

  return (
    <section className="container hero" id="top">
      <div className="hero__meta">
        <span className="eyebrow">AR Ventures — Real Estate Equity</span>
        <span className="eyebrow">Salt Lake City · Est. 1970</span>
      </div>

      <h1 className="hero__headline">{headline}</h1>

      <div className="hero__sub">
        <p className="hero__lede">
          A private real-estate equity fund investing across the American West
          and into select markets nationwide — held through more than five
          decades of cycles.
        </p>
        <div className="hero__aside">
          <p>
            Founded in Salt Lake City in 1970, AR Ventures partners with
            operators in seven states to acquire and steward income-producing
            real estate.
          </p>
          <p>
            We invest our own capital alongside every commitment.
          </p>
        </div>
      </div>
    </section>
  );
}

// ── Feature image ───────────────────────────────────────────────────────────
// One large editorial photograph between the hero and the stats ribbon. Caps
// the page's white-paper feel before the page settles back into type.
//
// Image: Unsplash — Joel Filipe, "modern multifamily exterior". Loaded at 2000w
// for retina; the <img> uses object-fit cover, so we don't need an art-directed
// crop. srcset trims bandwidth for narrower viewports.

function Feature() {
  const base = "https://images.unsplash.com/photo-1545324418-cc1a3fa10c00";
  const url = (w) => `${base}?w=${w}&q=80&auto=format&fit=crop`;
  return (
    <section className="feature">
      <div className="feature__frame">
        <img
          className="feature__img"
          src={url(2000)}
          srcSet={`${url(900)} 900w, ${url(1400)} 1400w, ${url(2000)} 2000w`}
          sizes="100vw"
          alt="Architectural exterior — representative of AR Ventures' holdings"
          loading="eager"
          decoding="async"
        />
        <div className="feature__caption">
          <span>Architectural exterior · representative</span>
          <span>fig. i</span>
        </div>
      </div>
    </section>
  );
}

// ── Stats ───────────────────────────────────────────────────────────────────
// Only figures we can stand behind: founding year, span of operation, state
// count. The other two are presented qualitatively to avoid invented AUM/IRR.

function Stats() {
  const items = [
    { value: <>1970</>,                   label: "Founded" },
    { value: <>56<sup>yrs</sup></>,       label: "Of Continuous Operation" },
    { value: <>7</>,                      label: "States" },
    { value: <>3<sup>gen</sup></>,        label: "Generations of Stewardship" },
  ];
  return (
    <section className="container section--tight">
      <div className="stats">
        {items.map((it, i) => (
          <div className="stat" key={i}>
            <div className="stat__value serif">{it.value}</div>
            <div className="stat__label">{it.label}</div>
          </div>
        ))}
      </div>
    </section>
  );
}

// ── Approach ────────────────────────────────────────────────────────────────

function Approach() {
  return (
    <section className="container section" id="approach">
      <header className="sec-head">
        <div className="sec-head__eyebrow">
          <span className="sec-head__num">— 01</span>
          <span className="eyebrow">Approach</span>
        </div>
        <h2 className="sec-head__title">
          We underwrite for the next cycle, not the current one.
        </h2>
      </header>

      <div className="approach__grid">
        {TENETS.map((t) => (
          <article className="tenet" key={t.n}>
            <div className="tenet__num">{t.n}</div>
            <h3 className="tenet__title serif">{t.title}</h3>
            <p className="tenet__body">{t.body}</p>
          </article>
        ))}
      </div>
    </section>
  );
}

// ── Footprint ───────────────────────────────────────────────────────────────

function Footprint() {
  return (
    <section className="footprint" id="footprint">
      <div className="container section">
        <header className="sec-head">
          <div className="sec-head__eyebrow">
            <span className="sec-head__num">— 02</span>
            <span className="eyebrow">Footprint</span>
          </div>
          <h2 className="sec-head__title">
            Seven states. One discipline.
          </h2>
        </header>

        <div className="fp-grid">
          <div className="fp-list">
            {FOOTPRINT.map((r) => (
              <div className="fp-row" key={r.idx}>
                <span className="fp-row__idx">{r.idx}</span>
                <span className="fp-row__name serif">
                  {r.name}
                  {r.hq && <span className="fp-row__hq">HQ</span>}
                </span>
                <span className="fp-row__meta">{r.meta}</span>
              </div>
            ))}
          </div>

          <aside className="fp-side">
            <div className="fp-side__img-wrap">
              <img
                className="fp-side__img"
                src="https://images.unsplash.com/photo-1480714378408-67cf0d13bc1b?w=1200&q=80&auto=format&fit=crop"
                srcSet="https://images.unsplash.com/photo-1480714378408-67cf0d13bc1b?w=700&q=80&auto=format&fit=crop 700w, https://images.unsplash.com/photo-1480714378408-67cf0d13bc1b?w=1200&q=80&auto=format&fit=crop 1200w"
                sizes="(max-width: 880px) 100vw, 40vw"
                alt="Architectural detail"
                loading="lazy"
                decoding="async"
              />
              <span className="fp-side__img-cap">fig. ii</span>
            </div>
            <span className="eyebrow fp-side__eye">From Utah, outward</span>
            <p className="fp-side__body serif">
              Our footprint follows relationships, not headlines. We expand
              into a market only when we find an operator we would write
              capital behind for the next twenty years.
            </p>
            <p className="fp-side__meta">
              Holdings are concentrated in income-producing multifamily,
              industrial, retail, and mixed-use assets. Selected ground-up
              developments are pursued in partnership with local sponsors.
            </p>
          </aside>
        </div>
      </div>
    </section>
  );
}

// ── Inquiry ─────────────────────────────────────────────────────────────────

function Inquiry() {
  return (
    <section className="inquiry" id="inquiry">
      <div className="container inquiry__grid">
        <div>
          <span className="eyebrow inquiry__eye">— 03 · Inquiries</span>
          <h2 className="inquiry__head serif">
            Direct lines, <em>only</em>.
          </h2>
          <p className="inquiry__body">
            AR Ventures is closed to public solicitation. Capital partners and
            operators may reach our principals directly.
          </p>
        </div>

        <div className="inq-card">
          <div className="inq-row">
            <span className="inq-row__k">Investors</span>
            <span className="inq-row__v">
              <a href="mailto:investors@arventures.com">investors@arventures.com</a>
            </span>
          </div>
          <hr className="inq-divider" />
          <div className="inq-row">
            <span className="inq-row__k">Operators</span>
            <span className="inq-row__v">
              <a href="mailto:operators@arventures.com">operators@arventures.com</a>
            </span>
          </div>
          <hr className="inq-divider" />
          <div className="inq-row">
            <span className="inq-row__k">Office</span>
            <span className="inq-row__v">
              Salt Lake City, Utah<br />
              <span style={{ fontFamily: "var(--mono)", fontSize: 12, color: "rgba(255,255,255,0.55)", letterSpacing: "0.06em" }}>
                By appointment only
              </span>
            </span>
          </div>
          <hr className="inq-divider" />
          <p className="inq-note">
            This site is informational. Nothing herein constitutes an offer to
            sell or a solicitation of an offer to buy any security.
          </p>
        </div>
      </div>
    </section>
  );
}

// ── Footer ──────────────────────────────────────────────────────────────────

function Footer() {
  return (
    <footer className="foot">
      <div className="container foot__inner">
        <span className="foot__brand">AR Ventures · MCMLXX</span>
        <span>© 2026 · All Rights Reserved</span>
      </div>
    </footer>
  );
}

// ── Tweaks ──────────────────────────────────────────────────────────────────

function Tweaks({ t, setTweak }) {
  return (
    <TweaksPanel title="Tweaks">
      <TweakSection label="Palette" />
      <TweakColor
        label="Theme"
        value={t.palette}
        options={PALETTE_OPTIONS}
        onChange={(v) => setTweak("palette", v)}
      />
      <TweakColor
        label="Accent"
        value={t.accent}
        options={ACCENT_OPTIONS}
        onChange={(v) => setTweak("accent", v)}
      />

      <TweakSection label="Headline" />
      <TweakRadio
        label="Treatment"
        value={t.headline}
        options={[
          { value: "italic", label: "Italic accent" },
          { value: "plain",  label: "Plain" },
        ]}
        onChange={(v) => setTweak("headline", v)}
      />

      <TweakSection label="Brand" />
      <TweakToggle
        label="‘Est. 1970’ mark"
        value={t.showMonogram}
        onChange={(v) => setTweak("showMonogram", v)}
      />
    </TweaksPanel>
  );
}

// ── Mount ───────────────────────────────────────────────────────────────────

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