// home.jsx — V6: rectilinear home page.
// A more architectural, editorial take on the BorderUX bento.
// Dark frame, max-width content, asymmetric grid, tight gutters, near-square corners.

const RectStyles = "";

function Globe() {
  // simple latitude/longitude lattice — purely decorative
  return (
    <svg viewBox="0 0 200 200" aria-hidden="true">
      <circle cx="100" cy="100" r="92" fill="none" stroke="#1A1815" strokeWidth="1" opacity="0.5" />
      {[20, 40, 60, 80].map((r) => (
        <ellipse key={r} cx="100" cy="100" rx="92" ry={r} fill="none" stroke="#1A1815" strokeWidth="0.8" opacity="0.45" />
      ))}
      {[0, 30, 60, 90, 120, 150].map((a) => (
        <line key={a} x1="100" y1="8" x2="100" y2="192"
          stroke="#1A1815" strokeWidth="0.6" opacity="0.35"
          transform={`rotate(${a} 100 100)`} />
      ))}
      {/* dotted continents-ish pattern */}
      {Array.from({ length: 80 }).map((_, i) => {
        const a = (i * 47) % 360;
        const r = 20 + ((i * 13) % 70);
        const x = 100 + Math.cos((a * Math.PI) / 180) * r;
        const y = 100 + Math.sin((a * Math.PI) / 180) * r * 0.7;
        return <circle key={i} cx={x} cy={y} r="1.4" fill="#1A1815" opacity="0.65" />;
      })}
    </svg>
  );
}

function IconCell({ kind }) {
  const stroke = "#1A1815";
  const sw = 1.6;
  if (kind === "gauge") return (
    <svg viewBox="0 0 32 32"><path d="M5 22 A 11 11 0 0 1 27 22" fill="none" stroke={stroke} strokeWidth={sw} strokeLinecap="round" /><line x1="16" y1="22" x2="22" y2="14" stroke={stroke} strokeWidth={sw} strokeLinecap="round" /><circle cx="16" cy="22" r="1.6" fill={stroke} /></svg>
  );
  if (kind === "truck") return (
    <svg viewBox="0 0 32 32"><rect x="3" y="11" width="14" height="11" fill="none" stroke={stroke} strokeWidth={sw} /><path d="M17 14 H 24 L 28 18 V 22 H 17 Z" fill="none" stroke={stroke} strokeWidth={sw} /><circle cx="9" cy="24" r="2.4" fill="none" stroke={stroke} strokeWidth={sw} /><circle cx="22" cy="24" r="2.4" fill="none" stroke={stroke} strokeWidth={sw} /></svg>
  );
  if (kind === "pin") return (
    <svg viewBox="0 0 32 32"><path d="M16 5 C 21 5 25 9 25 14 C 25 20 16 28 16 28 C 16 28 7 20 7 14 C 7 9 11 5 16 5 Z" fill="none" stroke={stroke} strokeWidth={sw} /><circle cx="16" cy="14" r="3" fill="none" stroke={stroke} strokeWidth={sw} /></svg>
  );
  if (kind === "cube") return (
    <svg viewBox="0 0 32 32"><path d="M16 5 L 27 11 V 22 L 16 28 L 5 22 V 11 Z" fill="none" stroke={stroke} strokeWidth={sw} strokeLinejoin="round" /><path d="M5 11 L 16 17 L 27 11" fill="none" stroke={stroke} strokeWidth={sw} /><line x1="16" y1="17" x2="16" y2="28" stroke={stroke} strokeWidth={sw} /></svg>
  );
  return null;
}

function QuoteRotator() {
  const fallbackItems = [
    "What did your users do <em>yesterday</em> that nobody wrote down?",
    "What does your best operator do <em>without looking</em>?",
    "Which screen does the team <em>curse at</em> every shift?",
    "What's the workaround that's been there for <em>six months</em>?",
    "When did you last <em>watch someone</em> use the product?",
    "What's in your tickets that <em>never</em> reached design?",
  ];
  const items = (window.CONTENT && window.CONTENT.quotes && window.CONTENT.quotes.length > 0)
    ? window.CONTENT.quotes
    : fallbackItems;

  const [i, setI] = React.useState(0);
  React.useEffect(() => {
    const t = setInterval(() => setI((prev) => prev + 1), 7000);
    return () => clearInterval(t);
  }, []);
  return (
    <div className="quote-rotator" aria-live="polite">
      <p key={i} className="qtext"><span dangerouslySetInnerHTML={{ __html: items[i % items.length] }} /></p>
    </div>
  );
}

function Home() {
  window.useSEO({
    title: "UX Strategy & Design Systems Studio",
    description: "Border UX is a premier UX strategy, design systems, and research engineering studio. We design high-stakes enterprise workflows, telecom portals, and SOC interfaces."
  });

  const fallbackPillars = [
    {
      n: "01",
      title: "Learn from <em>people.</em>",
      body: "AI can read every doc, ticket, and Slack thread your company ever produced. But it can't sit next to your users and watch the workaround they've used for six months. <b>We can.</b>"
    },
    {
      n: "02",
      title: "Automate with <em>AI.</em>",
      body: "Our open-source tools synthesize what we find. Built on Claude, Gemini, and the rest. Thirty years of field research, codified into skills and workflows. <b>Free and open-source.</b>"
    },
    {
      n: "03",
      title: "Design with <em>care.</em>",
      body: "People, backed by AI, design and build consistent products that solve real problems with a human touch. <b>The methods didn't change. The speed did.</b>"
    }
  ];

  const pillars = (window.CONTENT && window.CONTENT.pillars && window.CONTENT.pillars.length > 0)
    ? window.CONTENT.pillars
    : fallbackPillars;

  const techTitle = (window.CONTENT && window.CONTENT.techTitle) || "The tech we build/on.";
  const servicesTitle = (window.CONTENT && window.CONTENT.servicesTitle) || "What we do to <em>solve this challenge</em>.";

  return (
    <div className="bx-page vrect">
      <Nav />
      
      <div className="vrect-frame">
        {/* MONUMENTAL WORDMARK */}
        <section className="vrect-mark">
          <h1 aria-label="Border UX">
            <svg viewBox="0 -20 1000 165" preserveAspectRatio="xMidYMid meet" style={{ width: "100%", display: "block", overflow: "visible" }}>
              <text
                x="0" y="125"
                textLength="1000"
                lengthAdjust="spacingAndGlyphs"
                style={{
                  fontFamily: "var(--font-display)",
                  fontSize: 175,
                  fontWeight: 600,
                  letterSpacing: "-0.055em",
                }}
                fill="var(--paper)"
              >BORDER<tspan fill="var(--tile-yellow)">·</tspan>UX</text>
            </svg>
          </h1>
        </section>

        {/* HERO — three big pillar cards across the top */}
        <section className="vrect-hero">
          {pillars.map((p, idx) => (
            <article key={p.n || idx} className={`hero-pillar hp-${idx + 1}`}>
              <div className="hp-num-row">
                <div className="hp-num"><b>{p.n}</b></div>
              </div>
              <div className="hp-body">
                <h2 dangerouslySetInnerHTML={{ __html: p.title }} />
                <p dangerouslySetInnerHTML={{ __html: p.body }} />
              </div>
            </article>
          ))}
        </section>

        {/* AI STACK — 4 brand-logo tiles */}
        <section className="vrect-logos">
          <article className="logo-tile lt-recursica">
            <div className="lt-slider">
              <div className="lt-slide-top">
                <svg viewBox="0 0 42 29" xmlns="http://www.w3.org/2000/svg" aria-label="Recursica">
                  <path fillRule="evenodd" clipRule="evenodd" d="M1.77523 0C0.794799 0 0 0.809574 0 1.80823V26.4002C0 27.3989 0.794798 28.2085 1.77523 28.2085H39.7652C40.7456 28.2085 41.5404 27.3989 41.5404 26.4002V1.80823C41.5404 0.809574 40.7456 0 39.7652 0H1.77523ZM2.66285 25.4785C2.66285 13.1982 12.2012 3.18703 24.1432 2.71235V25.4785H2.66285ZM29.4689 25.4785C27.508 25.4785 25.9184 23.8593 25.9184 21.862H29.4689V25.4785ZM38.8496 15.8949H25.9184V2.72325C32.8587 3.17048 38.4105 8.82554 38.8496 15.8949ZM38.8319 17.7031C38.4182 21.7746 35.2413 25.0106 31.2441 25.432V17.7031H38.8319ZM28.2262 17.7207C26.9516 17.7207 25.9184 18.7731 25.9184 20.0714H28.2262V17.7207Z" fill="currentColor"></path>
                </svg>
              </div>
              <div className="lt-slide-bottom">Recursica</div>
            </div>
          </article>
          <article className="logo-tile lt-n8n">
            <div className="lt-slider">
              <div className="lt-slide-top">
                <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" aria-label="n8n">
                  <path fillRule="evenodd" clipRule="evenodd" d="M24 8.4c0 1.325-1.102 2.4-2.462 2.4-1.146 0-2.11-.765-2.384-1.8h-3.436c-.602 0-1.115.424-1.214 1.003l-.101.592a2.38 2.38 0 01-.8 1.405c.412.354.704.844.8 1.405l.1.592A1.222 1.222 0 0015.719 15h.975c.273-1.035 1.237-1.8 2.384-1.8 1.36 0 2.461 1.075 2.461 2.4S20.436 18 19.078 18c-1.147 0-2.11-.765-2.384-1.8h-.975c-1.204 0-2.23-.848-2.428-2.005l-.101-.592a1.222 1.222 0 00-1.214-1.003H10.97c-.308.984-1.246 1.7-2.356 1.7-1.11 0-2.048-.716-2.355-1.7H4.817c-.308.984-1.246 1.7-2.355 1.7C1.102 14.3 0 13.225 0 11.9s1.102-2.4 2.462-2.4c1.183 0 2.172.815 2.408 1.9h1.337c.236-1.085 1.225-1.9 2.408-1.9 1.184 0 2.172.815 2.408 1.9h.952c.601 0 1.115-.424 1.213-1.003l.102-.592c.198-1.157 1.225-2.005 2.428-2.005h3.436c.274-1.035 1.238-1.8 2.384-1.8C22.898 6 24 7.075 24 8.4zm-1.23 0c0 .663-.552 1.2-1.232 1.2-.68 0-1.23-.537-1.23-1.2 0-.663.55-1.2 1.23-1.2.68 0 1.231.537 1.231 1.2zM2.461 13.1c.68 0 1.23-.537 1.23-1.2 0-.663-.55-1.2-1.23-1.2-.68 0-1.231.537-1.231 1.2 0 .663.55 1.2 1.23 1.2zm6.153 0c.68 0 1.231-.537 1.231-1.2 0-.663-.55-1.2-1.23-1.2-.68 0-1.231.537-1.231 1.2 0 .663.55 1.2 1.23 1.2zm10.462 3.7c.68 0 1.23-.537 1.23-1.2 0-.663-.55-1.2-1.23-1.2-.68 0-1.23.537-1.23 1.2 0 .663.55 1.2 1.23 1.2z" fill="currentColor"></path>
                </svg>
              </div>
              <div className="lt-slide-bottom">n8n</div>
            </div>
          </article>
          <article className="logo-tile lt-claude">
            <div className="lt-slider">
              <div className="lt-slide-top">
                <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" aria-label="Claude">
                  <path d="M4.709 15.955l4.72-2.647.08-.23-.08-.128H9.2l-.79-.048-2.698-.073-2.339-.097-2.266-.122-.571-.121L0 11.784l.055-.352.48-.321.686.06 1.52.103 2.278.158 1.652.097 2.449.255h.389l.055-.157-.134-.098-.103-.097-2.358-1.596-2.552-1.688-1.336-.972-.724-.491-.364-.462-.158-1.008.656-.722.881.06.225.061.893.686 1.908 1.476 2.491 1.833.365.304.145-.103.019-.073-.164-.274-1.355-2.446-1.446-2.49-.644-1.032-.17-.619a2.97 2.97 0 01-.104-.729L6.283.134 6.696 0l.996.134.42.364.62 1.414 1.002 2.229 1.555 3.03.456.898.243.832.091.255h.158V9.01l.128-1.706.237-2.095.23-2.695.08-.76.376-.91.747-.492.584.28.48.685-.067.444-.286 1.851-.559 2.903-.364 1.942h.212l.243-.242.985-1.306 1.652-2.064.73-.82.85-.904.547-.431h1.033l.76 1.129-.34 1.166-1.064 1.347-.881 1.142-1.264 1.7-.79 1.36.073.11.188-.02 2.856-.606 1.543-.28 1.841-.315.833.388.091.395-.328.807-1.969.486-2.309.462-3.439.813-.042.03.049.061 1.549.146.662.036h1.622l3.02.225.79.522.474.638-.079.485-1.215.62-1.64-.389-3.829-.91-1.312-.329h-.182v.11l1.093 1.068 2.006 1.81 2.509 2.33.127.578-.322.455-.34-.049-2.205-1.657-.851-.747-1.926-1.62h-.128v.17l.444.649 2.345 3.521.122 1.08-.17.353-.608.213-.668-.122-1.374-1.925-1.415-2.167-1.143-1.943-.14.08-.674 7.254-.316.37-.729.28-.607-.461-.322-.747.322-1.476.389-1.924.315-1.53.286-1.9.17-.632-.012-.042-.14.018-1.434 1.967-2.18 2.945-1.726 1.845-.414.164-.717-.37.067-.662.401-.589 2.388-3.036 1.44-1.882.93-1.086-.006-.158h-.055L4.132 18.56l-1.13.146-.487-.456.061-.746.231-.243 1.908-1.312-.006.006z" fill="currentColor"></path>
                </svg>
              </div>
              <div className="lt-slide-bottom">Claude</div>
            </div>
          </article>
          <article className="logo-tile lt-gemini">
            <div className="lt-slider">
              <div className="lt-slide-top">
                <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" aria-label="Gemini">
                  <path d="M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z" fill="currentColor"></path>
                </svg>
              </div>
              <div className="lt-slide-bottom"><span className="lt-gemini-text">Gemini</span></div>
            </div>
          </article>
          <aside className="logo-aside">
            <h3 dangerouslySetInnerHTML={{ __html: techTitle }} />
            <a className="la-learn" href="/open-source">Learn more →</a>
          </aside>
        </section>

        {/* QUOTE STRIP — rotates every 7s */}
        <section className="vrect-quote">
          <QuoteRotator />
        </section>

        {/* SERVICES ROW */}
        <section className="vrect-svc-wrap" id="services">
          <div className="vrect-svc-head">
            <h2 dangerouslySetInnerHTML={{ __html: servicesTitle }} />
          </div>
          <div className="vrect-svc">
            {CONTENT.services.map((s) => (
              <article key={s.n} className="svc-cell">
                <div className="svc-top">
                  <div className="n">{s.n}</div>
                  <h3>{s.title}</h3>
                </div>
                <div className="svc-bottom">
                  <p>{s.body}</p>
                  <a className="svc-learn" href="/services">Learn more →</a>
                </div>
              </article>
            ))}
          </div>
        </section>

        {/* RECURSICA FULL-WIDTH BANNER */}
        <RecursicaBlock />

        {/* COZY FULL-WIDTH BANNER — marketing sub-brand */}
        <CozyBlock />
      </div>

      <Footer />
    </div>
  );
}

window.Home = Home;
