/* Orvio — seções do site */

// ---- Símbolo Orvio (usa defs do HTML via <use>) ----
function OrvioMark({ size = 40, variant = "grad" }) {
  const href = variant === "mono" ? "#orvio-mark-mono"
             : variant === "balance" ? "#orvio-mark-balance"
             : "#orvio-mark";
  return (
    <svg viewBox="-100 -100 200 200" width={size} height={size} aria-hidden="true"
         style={variant === "mono" ? { color: "var(--fg)" } : null}>
      <use href={href} />
    </svg>
  );
}

function Wordmark({ className = "" }) {
  return <span className={"wordmark " + className}>orvio</span>;
}

// ---- Ícones dos princípios (stroke 1.75, grid 24, cap round) ----
const stroke = { fill: "none", stroke: "currentColor", strokeWidth: 1.75, strokeLinecap: "round", strokeLinejoin: "round" };
const GLYPHS = {
  clareza: (
    <svg viewBox="0 0 24 24" className="value-glyph"><g {...stroke}>
      <rect x="3" y="3" width="7" height="7" rx="1.5" /><rect x="14" y="3" width="7" height="7" rx="1.5" />
      <rect x="3" y="14" width="7" height="7" rx="1.5" /><rect x="14" y="14" width="7" height="7" rx="1.5" />
    </g></svg>
  ),
  movimento: (
    <svg viewBox="0 0 24 24" className="value-glyph"><g {...stroke}>
      <path d="M3 17 A 9 9 0 1 1 17 19" /><circle cx="18.5" cy="18.5" r="1.6" fill="currentColor" stroke="none" />
    </g></svg>
  ),
  leveza: (
    <svg viewBox="0 0 24 24" className="value-glyph"><g {...stroke}>
      <path d="M4 8h16" /><path d="M6 12.5h12" /><path d="M9 17h6" />
    </g></svg>
  ),
  foco: (
    <svg viewBox="0 0 24 24" className="value-glyph"><g {...stroke}>
      <circle cx="12" cy="12" r="8.5" /><circle cx="12" cy="12" r="2.2" fill="currentColor" stroke="none" />
    </g></svg>
  ),
  confianca: (
    <svg viewBox="0 0 24 24" className="value-glyph"><g {...stroke}>
      <path d="M12 3l7 3v5c0 4.5-3 7.5-7 9-4-1.5-7-4.5-7-9V6z" /><path d="M9 12l2 2 4-4" />
    </g></svg>
  ),
  escala: (
    <svg viewBox="0 0 24 24" className="value-glyph"><g {...stroke}>
      <rect x="4" y="13" width="7" height="7" rx="1.5" /><path d="M13 11V6.5A1.5 1.5 0 0 1 14.5 5H19" /><circle cx="19" cy="5" r="1.6" fill="currentColor" stroke="none" />
    </g></svg>
  ),
};

const VALUES = [
  { id: "clareza",   n: "01", t: "Clareza",   d: "Cada coisa no seu lugar. Interfaces que mostram o essencial e silenciam o resto." },
  { id: "movimento", n: "02", t: "Movimento", d: "Produto que evolui com você. O que entrega hoje é o ponto de partida de amanhã." },
  { id: "leveza",    n: "03", t: "Leveza",    d: "Menos atrito, mais ar. Espaço para respirar entre uma decisão e a próxima." },
  { id: "foco",      n: "04", t: "Foco",      d: "Só o que importa, visível. Sem ruído, sem disputa por atenção." },
  { id: "confianca", n: "05", t: "Confiança", d: "Premium, mas sem peso. Tecnologia que inspira segurança e não treme." },
  { id: "escala",    n: "06", t: "Escala",    d: "Um sistema, muitos produtos. A mesma base sustenta tudo o que vem a seguir." },
];

// ---- Reveal wrapper ----
function Reveal({ as: Tag = "div", d, className = "", children, ...rest }) {
  return <Tag className={"reveal " + className} data-d={d} {...rest}>{children}</Tag>;
}

// ============================================================
function Nav() {
  const [scrolled, setScrolled] = React.useState(false);
  React.useEffect(() => {
    const on = () => setScrolled(window.scrollY > 24);
    on(); window.addEventListener("scroll", on, { passive: true });
    return () => window.removeEventListener("scroll", on);
  }, []);
  return (
    <nav className="nav" data-scrolled={scrolled ? "1" : "0"}>
      <div className="wrap">
        <a className="nav-logo" href="#top" aria-label="Orvio — início">
          <OrvioMark size={30} /><Wordmark />
        </a>
        <div className="nav-links">
          <a href="#manifesto">Manifesto</a>
          <a href="#principios">Princípios</a>
          <a href="#arquitetura">Arquitetura</a>
        </div>
        <a className="nav-cta" href="#arquitetura"><span className="dot" />Em breve</a>
      </div>
    </nav>
  );
}

// ============================================================
function Hero() {
  return (
    <header className="hero" id="top">
      <div className="bg-field">
        <div className="blob petrol" style={{ width: 720, height: 720, top: "-18%", left: "-12%" }} />
        <div className="blob graph"  style={{ width: 640, height: 640, top: "4%", right: "-12%" }} />
        <div className="blob coral"  style={{ width: 460, height: 460, top: "24%", left: "58%", opacity: "calc(var(--glow) * 0.55)" }} />
        <div className="grid-mask" />
      </div>
      <div className="wrap hero-grid">
        <div className="hero-text">
          <Reveal className="hero-eyebrow eyebrow" d="1">Ecossistema digital</Reveal>
          <Reveal as="h1" className="hero-name" d="2"><span className="wordmark">orvio</span></Reveal>
          <Reveal as="p" className="hero-tagline" d="3">Tecnologia em movimento.</Reveal>
          <Reveal as="p" className="hero-sub" d="4">
            Soluções digitais para pessoas e empresas. Criamos tecnologia que
            resolve problemas reais — clara, leve e sem ruído.
          </Reveal>
        </div>
        <Reveal className="hero-mark" d="2">
          <div className="rings" aria-hidden="true"><span /><span /><span /></div>
          <OrvioMark size={440} />
        </Reveal>
      </div>
      <div className="hero-scroll"><span>Role</span><span className="line" /></div>
    </header>
  );
}

// ============================================================
function Manifesto() {
  return (
    <section className="band manifesto" id="manifesto">
      <div className="wrap">
        <Reveal as="h2" d="1">
          Tecnologia com <span className="accent">clareza</span>,<br />em movimento.
        </Reveal>
        <div className="manifesto-body">
          <Reveal as="p" d="2">
            A Orvio é um ecossistema digital em formação. Existimos para trazer
            clareza ao que é tecnologia: produtos que evoluem, com menos atrito
            e mais foco no que importa.
          </Reveal>
          <Reveal as="p" d="3">
            A ideia central é movimento com clareza — equilíbrio presente,
            crescimento à frente. Onde o círculo termina, o movimento começa.
          </Reveal>
        </div>
      </div>
    </section>
  );
}

// ============================================================
function Principios() {
  return (
    <section className="band" id="principios">
      <div className="wrap">
        <div className="section-head">
          <Reveal className="eyebrow" d="1">Princípios</Reveal>
          <Reveal as="h2" d="1">Seis ideias que sustentam<br />tudo o que construímos.</Reveal>
        </div>
        <div className="values-grid">
          {VALUES.map((v, i) => (
            <Reveal key={v.id} className="value" d={String((i % 3) + 1)}>
              <span className="value-idx">{v.n}</span>
              {GLYPHS[v.id]}
              <h3>{v.t}</h3>
              <p>{v.d}</p>
            </Reveal>
          ))}
        </div>
      </div>
    </section>
  );
}

// ============================================================
function Arquitetura() {
  const slots = [
    { o: "orvio", p: "·····", desc: "Mais um nasce do mesmo sistema.", status: "Em breve" },
    { o: "orvio", p: "·····", desc: "O ecossistema cresce com método.", status: "Em breve" },
    { o: "orvio", p: "·····", desc: "Um roadmap, sem pressa.", status: "Em breve" },
  ];
  return (
    <section className="band arch" id="arquitetura">
      <div className="bg-field">
        <div className="blob graph" style={{ width: 560, height: 560, top: "20%", right: "-14%", opacity: "calc(var(--glow) * 0.7)" }} />
      </div>
      <div className="wrap">
        <div className="section-head">
          <Reveal className="eyebrow" d="1">Arquitetura de marca</Reveal>
          <Reveal as="h2" d="1">Um ecossistema.<br />Vários produtos.</Reveal>
          <Reveal as="p" d="2">
            A Orvio assina cada produto. Todos nascem do mesmo sistema —
            tipografia, símbolo, curvas. Muda apenas o acento da categoria.
          </Reveal>
        </div>

        <Reveal className="arch-diagram" d="1">
          <div className="arch-mother">
            <OrvioMark size={30} /><Wordmark />
            <span className="tag">orvio</span>
          </div>
          <div className="arch-stem" />
          <div className="arch-slots">
            <div className="slot balance">
              <div className="slot-head">
                <OrvioMark variant="balance" size={36} />
                <span className="slot-orbit">Primeiro em órbita</span>
              </div>
              <div className="slot-name"><span className="o">orvio</span> <span className="b">balance</span></div>
              <p className="slot-desc">O começo de algo maior. Fique de olho — vem aí.</p>
              <span className="slot-status"><span className="pulse" />Em breve</span>
            </div>
            {slots.map((s, i) => (
              <div className="slot" key={i}>
                <div className="slot-name"><span className="o">{s.o}</span><span className="p">{s.p}</span></div>
                <p className="slot-desc">{s.desc}</p>
                <span className="slot-status"><span className="pulse" />{s.status}</span>
              </div>
            ))}
          </div>
        </Reveal>

        <Reveal className="arch-note" d="2">
          <div>
            <div className="k">Convenção</div>
            <div className="v"><b>orvio</b> + nome descritivo. Ex.: <b>orvio balance</b>.</div>
          </div>
          <div>
            <div className="k">Acento</div>
            <div className="v">Uma cor para cada solução. O Balance é <b>verde-água</b>.</div>
          </div>
        </Reveal>
      </div>
    </section>
  );
}

// ============================================================
function Constelacao() {
  return (
    <section className="constel">
      <div className="bg-field">
        <div className="blob petrol" style={{ width: 700, height: 700, top: "-30%", left: "20%", opacity: "calc(var(--glow) * 0.8)" }} />
      </div>
      <div className="constel-orbits" aria-hidden="true">
        <svg viewBox="-260 -260 520 520">
          <g fill="none" stroke="currentColor" style={{ color: "var(--ink-4)" }}>
            <circle r="80" strokeWidth="1" opacity="0.55" />
            <circle r="140" strokeWidth="1" opacity="0.4" />
            <circle r="200" strokeWidth="1" opacity="0.28" />
            <circle r="250" strokeWidth="1" opacity="0.16" />
          </g>
          <path d="M 200 0 A 200 200 0 0 1 -141 141" fill="none" stroke="url(#orvio-stroke)" strokeWidth="2.5" strokeLinecap="round" opacity="0.85" />
          <circle cx="200" cy="0" r="4" fill="var(--accent-2, #FFA572)" />
          <circle cx="-99" cy="99" r="2.5" fill="var(--fg-3)" opacity="0.7" />
          <circle cx="56" cy="-130" r="2" fill="var(--fg-3)" opacity="0.5" />
          <circle cx="-200" cy="-60" r="2" fill="var(--fg-3)" opacity="0.4" />
        </svg>
      </div>
      <div className="wrap">
        <Reveal className="eyebrow" d="1">A marca em movimento</Reveal>
        <Reveal as="h2" d="2">
          Onde o círculo termina,<br />o <span className="accent">movimento</span> começa.
        </Reveal>
      </div>
    </section>
  );
}

// ============================================================
function Footer() {
  const Social = ({ label, href = "#", d }) => (
    <a href={href} aria-label={label} target={href !== "#" ? "_blank" : undefined} rel={href !== "#" ? "noopener noreferrer" : undefined}>
      <svg viewBox="0 0 24 24" width="16" height="16"><g {...stroke}>{d}</g></svg>
    </a>
  );
  return (
    <footer className="footer">
      <div className="wrap">
        <div className="footer-top">
          <div className="footer-brand">
            <div className="nav-logo"><OrvioMark size={32} /><Wordmark /></div>
            <p>Um ecossistema digital. Criamos produtos claros, leves e em movimento.</p>
          </div>
          <div className="footer-cols">
            <div className="footer-col">
              <h4>Marca</h4>
              <a href="#manifesto">Manifesto</a>
              <a href="#principios">Princípios</a>
              <a href="#arquitetura">Arquitetura</a>
            </div>
            <div className="footer-col">
              <h4>Orvio</h4>
              <a href="#top">Sobre</a>
              <a href="#arquitetura">Produtos</a>
              <a href="/contato">Contato</a>
            </div>
          </div>
        </div>
        <div className="footer-bottom">
          <span className="meta">© Orvio · 2026 — Rio Grande do Sul · Brasil</span>
          <div className="footer-social">
            <Social label="LinkedIn" d={<><rect x="3" y="3" width="18" height="18" rx="3" /><path d="M7 10v7M7 7v.01M11 17v-4a2 2 0 0 1 4 0v4M11 17v-7" /></>} />
            <Social label="Instagram" href="https://www.instagram.com/orvioapp" d={<><rect x="3" y="3" width="18" height="18" rx="5" /><circle cx="12" cy="12" r="4" /><circle cx="17" cy="7" r="0.6" fill="currentColor" stroke="none" /></>} />
            <Social label="X" d={<path d="M5 5l14 14M19 5L5 19" />} />
          </div>
        </div>
      </div>
    </footer>
  );
}

Object.assign(window, { OrvioMark, Wordmark, Nav, Hero, Manifesto, Principios, Arquitetura, Constelacao, Footer });
