/* pages-categories.jsx — Morar, Investir, Litoral */
const { useState: useS1, useEffect: useE1 } = React;

/* Shared page hero */
function PageHero({ eyebrow, title, subtitle, tone = "stone", num = "", src }) {
  const { Reveal, Ph } = window.S;
  return (
    <section style={{ position: "relative", height: "78vh", minHeight: 560, overflow: "hidden" }}>
      <Ph tag={src ? "" : `hero · ${eyebrow.toLowerCase()}`} tone={tone} num={num} src={src} style={{ position: "absolute", inset: 0 }}/>
      <div style={{
        position: "absolute", inset: 0,
        background: "linear-gradient(180deg, rgba(16,38,25,0.35) 0%, rgba(28,61,46,0.05) 35%, rgba(184,149,86,0.18) 70%, rgba(16,38,25,0.85) 100%)",
      }}></div>
      <div className="wrap" style={{
        position: "relative", height: "100%", color: "var(--paper)",
        padding: "140px var(--gutter) 56px",
        display: "flex", flexDirection: "column", justifyContent: "flex-end",
      }}>
        <Reveal delay={120}>
          <div className="eyebrow" style={{ color: "rgba(232,217,179,0.85)", marginBottom: 28 }}>
            <span className="dot"></span>{eyebrow}
          </div>
          <h1 className="display" style={{ margin: 0, fontSize: "clamp(40px, 6vw, 96px)" }} dangerouslySetInnerHTML={{ __html: title }}></h1>
          {subtitle && (
            <p style={{
              maxWidth: 520, marginTop: 32,
              fontFamily: "var(--serif)", fontStyle: "italic", fontSize: 22, fontWeight: 300,
              lineHeight: 1.35, color: "rgba(250,247,240,0.92)",
            }}>{subtitle}</p>
          )}
        </Reveal>
      </div>
    </section>
  );
}

/* MORAR */
function MorarPage({ openProperty, openContact }) {
  const { Reveal, NumLabel, PropertyCard, Ph, PROPERTIES } = window.S;
  const morarProps = PROPERTIES.filter(p => p.category === "morar");

  const neighborhoods = [
    { name: "Batel", essence: "A centralidade clássica de Curitiba — escritórios, gastronomia e a vida cultural mais densa da cidade.", landmark: "Praça do Japão · Shopping Crystal", tone: "stone" },
    { name: "Ecoville", essence: "Reduto verde estabelecido, traçado urbano amplo e arquitetura contemporânea.", landmark: "Eco Parque · Universidade Positivo", tone: "cool" },
    { name: "Bigorrilho", essence: "Bairro de arquitetura premium, com torres recentes de alto padrão e ruas arborizadas.", landmark: "Parque Barigui · Avenida Vicente Machado", tone: "warm" },
    { name: "Água Verde", essence: "Valorização sustentada, ruas baixas e proximidade ao centro estendido.", landmark: "Parque da Pedreira · República Argentina", tone: "night" },
  ];

  return (
    <div className="page" data-screen-label="Morar">
      <PageHero
        eyebrow="Morar em Curitiba"
        title="Uma seleção pensada<br/><em>além</em> do imóvel."
        subtitle="Endereços onde arquitetura, localização e rotina convivem com a mesma exigência."
        tone="cool"
        num="i"
        src="assets/oas/10-living-vista-curitiba.png"
      />

      {/* Lead */}
      <section style={{ padding: "140px var(--gutter)" }}>
        <div className="wrap" style={{ display: "grid", gridTemplateColumns: "1fr 1.4fr", gap: 80 }}>
          <Reveal><NumLabel n="i.">Filosofia</NumLabel></Reveal>
          <Reveal delay={200}>
            <h2 className="h2" style={{ margin: 0 }}>
              Curitiba se mora por <em style={{ fontStyle: "italic" }}>endereço.</em>
            </h2>
            <p className="body" style={{ marginTop: 32, fontSize: 16, lineHeight: 1.75 }}>
              Acreditamos que um imóvel só faz sentido quando se conhece a rotina daquele endereço. Um café que abre cedo. Uma rua baixa que segura o valor. Um parque a três quadras. A 10HOUSE seleciona residências nos bairros mais desejados de Curitiba — sempre olhando para o entorno antes da planta.
            </p>
          </Reveal>
        </div>
      </section>

      {/* Neighborhoods — editorial cards */}
      <section style={{ padding: "0 var(--gutter) 120px" }}>
        <div className="wrap">
          <Reveal style={{ marginBottom: 56 }}>
            <h2 className="h2" style={{ margin: 0, maxWidth: "16ch" }}>
              Os bairros mais <em style={{ fontStyle: "italic" }}>desejados.</em>
            </h2>
          </Reveal>
          <div style={{ display: "flex", flexDirection: "column", gap: 24 }}>
            {neighborhoods.map((n, i) => (
              <Reveal key={n.name} delay={i * 100}>
                <div style={{
                  display: "grid", gridTemplateColumns: "1.6fr 1fr 1fr", gap: 32,
                  padding: "40px 0", borderTop: "1px solid var(--rule)",
                  alignItems: "start",
                }} className="nb-row">
                  <div>
                    <div style={{ fontFamily: "var(--mono)", fontSize: 10, letterSpacing: "0.22em", textTransform: "uppercase", color: "var(--ink-3)" }}>
                      0{i + 1} · Curitiba
                    </div>
                    <div style={{ fontFamily: "var(--serif)", fontSize: "clamp(38px, 4.4vw, 64px)", lineHeight: 1, marginTop: 14, fontWeight: 300 }}>
                      {n.name}
                    </div>
                  </div>
                  <p className="body" style={{ margin: 0, fontSize: 14.5 }}>{n.essence}</p>
                  <div>
                    <div className="eyebrow" style={{ marginBottom: 8 }}>Referências</div>
                    <div style={{ fontFamily: "var(--serif)", fontStyle: "italic", fontSize: 16, color: "var(--ink-2)" }}>
                      {n.landmark}
                    </div>
                  </div>
                </div>
              </Reveal>
            ))}
          </div>
          <style>{`@media (max-width: 900px){ .nb-row { grid-template-columns: 1fr !important; gap: 16px !important; } }`}</style>
        </div>
      </section>

      {/* Properties */}
      <section className="dark-block" style={{ padding: "120px var(--gutter)" }}>
        <div className="wrap">
          <Reveal style={{ display: "flex", justifyContent: "space-between", alignItems: "end", flexWrap: "wrap", gap: 24, marginBottom: 56 }}>
            <div>
              <NumLabel n="ii.">Em curadoria</NumLabel>
              <h2 className="h2" style={{ margin: "24px 0 0", color: "var(--paper)" }}>Residências <em style={{ fontStyle: "italic" }}>selecionadas.</em></h2>
            </div>
            <p style={{ maxWidth: 320, color: "rgba(250,247,240,0.72)", fontFamily: "var(--sans)", fontSize: 13, lineHeight: 1.7, margin: 0 }}>
              Cada imóvel passou por leitura própria de localização, projeto e potencial antes de chegar à seleção.
            </p>
          </Reveal>
          <div style={{ display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: 36 }} className="props-grid">
            {morarProps.map((p, i) => (
              <Reveal key={p.ref} delay={i * 120}>
                <PropertyCard p={p} onOpen={openProperty} />
              </Reveal>
            ))}
          </div>
          <style>{`
            @media (max-width: 1050px){ .props-grid { grid-template-columns: 1fr 1fr !important; } }
            @media (max-width: 680px){ .props-grid { grid-template-columns: 1fr !important; } }
            .dark-block .prop .info .ref, .dark-block .prop .info .meta { color: rgba(232,217,179,0.7); }
            .dark-block .prop .info .title { color: var(--paper); }
            .dark-block .prop .info .price { color: var(--gold-soft); }
            .dark-block .prop:hover .info .title { color: var(--gold-soft); }
          `}</style>
        </div>
      </section>

      {/* CTA reservado */}
      <ReservedCTA onClick={openContact} msg="Olá, 10HOUSE. Tenho interesse em morar em Curitiba — gostaria de um atendimento da curadoria." />
    </div>
  );
}

/* INVESTIR */
function InvestirPage({ openProperty, openContact }) {
  const { Reveal, NumLabel, PropertyCard, Ph, PROPERTIES } = window.S;
  const invProps = PROPERTIES.filter(p => p.category === "investir");

  const verticals = [
    { n: "01", title: "Pré-lançamentos estratégicos", body: "Acesso prioritário a unidades em projetos selecionados antes do lançamento público — em parceria com construtoras de assinatura." },
    { n: "02", title: "Imóveis para Airbnb", body: "Operação curada de renda em endereços litorâneos consolidados. Mobiliário, gestão e métricas de ocupação acompanhadas." },
    { n: "03", title: "Oportunidades selecionadas", body: "Imóveis fora do mercado aberto — repasses, sucessões e oportunidades que chegam pela nossa rede privada." },
    { n: "04", title: "Curadoria privada", body: "Mandato de aquisição: a 10HOUSE busca, negocia e seleciona em seu nome, de forma reservada." },
  ];

  return (
    <div className="page" data-screen-label="Investir">
      <PageHero
        eyebrow="Investir com inteligência"
        title="Patrimônio que <em>respira</em><br/>liquidez."
        subtitle="Imóveis selecionados com leitura de localização, projeto e potencial de valorização."
        tone="warm"
        num="ii"
      />

      {/* Lead */}
      <section style={{ padding: "140px var(--gutter) 100px" }}>
        <div className="wrap" style={{ display: "grid", gridTemplateColumns: "1fr 1.4fr", gap: 80 }}>
          <Reveal><NumLabel n="i.">Tese</NumLabel></Reveal>
          <Reveal delay={200}>
            <h2 className="h2" style={{ margin: 0, maxWidth: "20ch" }}>
              Uma localização onde exclusividade e <em style={{ fontStyle: "italic" }}>liquidez</em> caminham juntas.
            </h2>
            <p className="body" style={{ marginTop: 32, fontSize: 16, lineHeight: 1.75 }}>
              A 10HOUSE não opera com volume. Selecionamos um número limitado de oportunidades por estação — sempre com leitura objetiva de tese, ciclo e saída. O critério precede o entusiasmo.
            </p>
          </Reveal>
        </div>
      </section>

      {/* Verticals */}
      <section style={{ padding: "0 var(--gutter) 120px" }}>
        <div className="wrap" style={{ display: "grid", gridTemplateColumns: "repeat(4, 1fr)", gap: 0, borderTop: "1px solid var(--rule)" }} className="vert-grid">
          {verticals.map((v, i) => (
            <Reveal key={v.n} delay={i * 120} style={{
              padding: "48px 32px 48px 0",
              borderRight: i < 3 ? "1px solid var(--rule)" : "none",
            }}>
              <div style={{ fontFamily: "var(--serif)", fontStyle: "italic", fontSize: 28, color: "var(--gold)", marginBottom: 18 }}>
                — {v.n}
              </div>
              <h3 className="h3" style={{ margin: 0, fontSize: 22 }}>{v.title}</h3>
              <p className="body" style={{ marginTop: 16, fontSize: 13.5 }}>{v.body}</p>
            </Reveal>
          ))}
        </div>
        <style>{`
          @media (max-width: 1000px){ .vert-grid { grid-template-columns: 1fr 1fr !important; } .vert-grid > * { border-right: none !important; padding-right: 32px !important; } }
          @media (max-width: 600px){ .vert-grid { grid-template-columns: 1fr !important; } }
        `}</style>
      </section>

      {/* metrics editorial bar */}
      <section className="dark-block" style={{ padding: "100px var(--gutter)" }}>
        <div className="wrap" style={{ display: "grid", gridTemplateColumns: "1fr 1fr 1fr", gap: 60 }} className="mt-grid">
          {[
            { fig: "+12%", label: "Valorização média a.a. — endereços selecionados", footnote: "BC · Itapema · 2021–2025" },
            { fig: "0,72%", label: "Rentabilidade líquida mensal · operação Airbnb", footnote: "Carteira em gestão · 2025" },
            { fig: "< 8", label: "Imóveis novos por estação", footnote: "Filtro estatutário de curadoria" },
          ].map((m, i) => (
            <Reveal key={i} delay={i * 120}>
              <div style={{ fontFamily: "var(--serif)", fontWeight: 300, fontSize: "clamp(48px, 5vw, 84px)", lineHeight: 1, color: "var(--gold-soft)" }}>
                {m.fig}
              </div>
              <div style={{ marginTop: 18, color: "var(--paper)", fontSize: 14.5, lineHeight: 1.55 }}>{m.label}</div>
              <div style={{ marginTop: 14, fontFamily: "var(--mono)", fontSize: 10, letterSpacing: "0.2em", textTransform: "uppercase", color: "rgba(232,217,179,0.55)" }}>
                {m.footnote}
              </div>
            </Reveal>
          ))}
        </div>
        <style>{`@media (max-width: 900px){ .mt-grid { grid-template-columns: 1fr !important; gap: 40px !important; } }`}</style>
      </section>

      {/* Properties */}
      <section style={{ padding: "120px var(--gutter)" }}>
        <div className="wrap">
          <Reveal style={{ marginBottom: 48 }}>
            <NumLabel n="iii.">Em oportunidade</NumLabel>
            <h2 className="h2" style={{ margin: "24px 0 0" }}>Selecionados <em style={{ fontStyle: "italic" }}>nesta estação.</em></h2>
          </Reveal>
          <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: 36 }} className="props-grid">
            {invProps.map((p, i) => (
              <Reveal key={p.ref} delay={i * 120}>
                <PropertyCard p={p} onOpen={openProperty} />
              </Reveal>
            ))}
          </div>
        </div>
      </section>

      <ReservedCTA onClick={openContact} kicker="Receba acesso a oportunidades reservadas." msg="Olá, 10HOUSE. Tenho interesse em investir — gostaria de acesso às oportunidades reservadas." />
    </div>
  );
}

/* LITORAL */
function LitoralPage({ openProperty, openContact }) {
  const { Reveal, NumLabel, PropertyCard, Ph, PROPERTIES } = window.S;
  const litProps = PROPERTIES.filter(p => p.category === "litoral");

  return (
    <div className="page" data-screen-label="Litoral">
      <PageHero
        eyebrow="Litoral selecionado"
        title="Onde o oceano se torna <em>endereço.</em>"
        subtitle="Curadoria entre Balneário Camboriú, Itapema, Itajaí e Porto Belo."
        tone="sea"
        num="iii"
        src="assets/balneario-camboriu.jpeg"
      />

      <section style={{ padding: "140px var(--gutter)" }}>
        <div className="wrap" style={{ display: "grid", gridTemplateColumns: "1fr 1.4fr", gap: 80 }}>
          <Reveal><NumLabel n="i.">Atmosfera</NumLabel></Reveal>
          <Reveal delay={200}>
            <h2 className="h2" style={{ margin: 0 }}>
              Litoral catarinense, em sua versão <em style={{ fontStyle: "italic" }}>mais reservada.</em>
            </h2>
            <p className="body" style={{ marginTop: 32, fontSize: 16, lineHeight: 1.75 }}>
              Para além do skyline conhecido, há praias inteiras pensadas para quem prefere discrição. Selecionamos endereços onde a arquitetura, a vista e a privacidade chegam na mesma medida — para morar, descansar ou compor portfólio.
            </p>
          </Reveal>
        </div>
      </section>

      {/* Beach editorial — staggered */}
      <section style={{ padding: "0 var(--gutter) 120px" }}>
        <div className="wrap" style={{ display: "flex", flexDirection: "column", gap: 80 }}>
          {[
            { n: "01", name: "Balneário Camboriú", body: "A vitrine do litoral catarinense. Endereços frente-mar em andares altos, edifícios assinados e a vida urbana mais intensa da costa.", tone: "sea", src: "assets/balneario-camboriu.jpeg" },
            { n: "02", name: "Itapema", body: "Mar mais reservado, andares com vista limpa e ritmo desacelerado. Tornou-se referência para residências de descanso de alto padrão.", tone: "sand", src: "assets/itapema-aerea.jpeg" },
            { n: "03", name: "Itajaí", body: "Praia Brava e Cabeçudas — orlas reservadas, Mata Atlântica preservada e a melhor relação valor / exclusividade do litoral norte catarinense.", tone: "cool", src: "assets/itajai.jpeg" },
            { n: "04", name: "Porto Belo", body: "Pé-na-areia em praias reservadas — Bombas, Bombinhas, Praia do Estaleiro. Para quem procura discrição absoluta.", tone: "warm", src: "assets/porto-belo.jpeg" },
          ].map((b, i) => (
            <Reveal key={b.name} delay={i * 80}>
              <div style={{
                display: "grid",
                gridTemplateColumns: i % 2 === 0 ? "1.2fr 1fr" : "1fr 1.2fr",
                gap: 56,
                alignItems: "center",
              }} className="beach-row">
                {i % 2 === 0 ? (
                  <>
                    <div style={{ position: "relative", aspectRatio: "5/4" }}>
                      <Ph tag={b.src ? "" : `${b.name.toLowerCase()} · litoral`} tone={b.tone} num={b.n} src={b.src} style={{ position: "absolute", inset: 0 }} />
                    </div>
                    <div style={{ padding: "0 12px" }}>
                      <div className="eyebrow" style={{ marginBottom: 14 }}><span className="dot"></span>Praia {b.n}</div>
                      <h3 className="h2" style={{ margin: 0, fontSize: "clamp(36px, 4.2vw, 60px)" }}>{b.name}</h3>
                      <p className="body" style={{ marginTop: 24, fontSize: 15.5 }}>{b.body}</p>
                    </div>
                  </>
                ) : (
                  <>
                    <div style={{ padding: "0 12px" }}>
                      <div className="eyebrow" style={{ marginBottom: 14 }}><span className="dot"></span>Praia {b.n}</div>
                      <h3 className="h2" style={{ margin: 0, fontSize: "clamp(36px, 4.2vw, 60px)" }}>{b.name}</h3>
                      <p className="body" style={{ marginTop: 24, fontSize: 15.5 }}>{b.body}</p>
                    </div>
                    <div style={{ position: "relative", aspectRatio: "5/4" }}>
                      <Ph tag={b.src ? "" : `${b.name.toLowerCase()} · litoral`} tone={b.tone} num={b.n} src={b.src} style={{ position: "absolute", inset: 0 }} />
                    </div>
                  </>
                )}
              </div>
            </Reveal>
          ))}
        </div>
        <style>{`@media (max-width: 880px){ .beach-row { grid-template-columns: 1fr !important; } }`}</style>
      </section>

      {/* Properties */}
      <section className="dark-block" style={{ padding: "120px var(--gutter)" }}>
        <div className="wrap">
          <Reveal style={{ marginBottom: 48 }}>
            <NumLabel n="ii.">Em curadoria · litoral</NumLabel>
            <h2 className="h2" style={{ margin: "24px 0 0", color: "var(--paper)" }}>Endereços <em style={{ fontStyle: "italic" }}>selecionados.</em></h2>
          </Reveal>
          {litProps.length > 0 ? (
            <div style={{ display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: 36 }} className="props-grid">
              {litProps.map((p, i) => (
                <Reveal key={p.ref} delay={i * 120}>
                  <PropertyCard p={p} onOpen={openProperty} />
                </Reveal>
              ))}
            </div>
          ) : (
            <Reveal>
              <div style={{
                border: "1px solid rgba(232,217,179,0.2)",
                padding: "72px 64px",
                display: "grid", gridTemplateColumns: "1fr 1fr", gap: 64, alignItems: "center",
              }} className="empty-curated">
                <div>
                  <div className="eyebrow" style={{ color: "rgba(232,217,179,0.7)", marginBottom: 18 }}>
                    <span className="dot"></span>Próxima estação
                  </div>
                  <h3 style={{ fontFamily: "var(--serif)", fontSize: "clamp(28px, 3vw, 40px)", color: "var(--paper)", margin: 0, fontWeight: 300, lineHeight: 1.15 }}>
                    Seleção do litoral em <em style={{ fontStyle: "italic", color: "var(--gold-soft)" }}>formação.</em>
                  </h3>
                </div>
                <div>
                  <p style={{ color: "rgba(250,247,240,0.78)", fontSize: 15, lineHeight: 1.75, margin: 0 }}>
                    Os endereços que entram na curadoria 10HOUSE são apresentados de forma reservada — sempre fora do mercado aberto. Solicite a seleção privada para receber as próximas oportunidades do litoral catarinense em primeira mão.
                  </p>
                  <div style={{ marginTop: 28 }}>
                    <button className="btn on-dark" onClick={() => openContact("Olá, 10HOUSE. Gostaria de receber a seleção privada do litoral catarinense.")}>Receber seleção privada<span className="arr"></span></button>
                  </div>
                </div>
              </div>
              <style>{`@media (max-width: 900px){ .empty-curated { grid-template-columns: 1fr !important; padding: 48px 32px !important; gap: 32px !important; } }`}</style>
            </Reveal>
          )}
        </div>
      </section>

      <ReservedCTA onClick={openContact} msg="Olá, 10HOUSE. Tenho interesse no litoral catarinense — gostaria de um atendimento da curadoria." />
    </div>
  );
}

/* Reserved CTA — used at bottom of pages */
function ReservedCTA({ onClick, kicker = "Atendimento reservado, mediante agendamento.", msg }) {
  const { Reveal, Ph } = window.S;
  return (
    <section style={{ padding: "140px var(--gutter)", position: "relative", overflow: "hidden", background: "var(--forest-deep)" }}>
      <Ph tag="atmosfera · escritório privado" tone="moss" style={{ position: "absolute", inset: 0, opacity: 0.35 }} />
      <div className="wrap" style={{ position: "relative", textAlign: "center", display: "flex", flexDirection: "column", alignItems: "center", gap: 32, color: "var(--paper)" }}>
        <Reveal>
          <div className="eyebrow" style={{ color: "rgba(232,217,179,0.7)" }}><span className="dot"></span>Atendimento privado</div>
        </Reveal>
        <Reveal delay={150}>
          <h2 className="h2" style={{ margin: 0, maxWidth: "20ch", fontSize: "clamp(34px, 4.6vw, 64px)", color: "var(--paper)" }}>
            {kicker.split(",").map((s, i, a) => (
              <span key={i}>
                {s}{i < a.length - 1 ? <em style={{ fontStyle: "italic", color: "var(--gold-soft)" }}>,</em> : null}
                {i < a.length - 1 ? <br/> : null}
              </span>
            ))}
          </h2>
        </Reveal>
        <Reveal delay={300}>
          <button className="btn on-dark" onClick={() => onClick(msg)}>Solicite atendimento<span className="arr"></span></button>
        </Reveal>
      </div>
    </section>
  );
}

window.Pages = window.Pages || {};
Object.assign(window.Pages, { MorarPage, InvestirPage, LitoralPage, ReservedCTA, PageHero });
