// Home page — single-scroll long-form built to mirror the Canva mockup
const HomePage = ({ navigate }) => {
  return (
    <main>
      {/* HERO */}
      <HeroSection navigate={navigate} />

      {/* TRUSTED BY MARQUEE */}
      <section className="section-tight" style={{ paddingTop: 0, color: "rgb(0, 0, 0)", textAlign: "center", opacity: "1", padding: "80px 0px 60px", height: "252px" }}>
        <div className="container" style={{ marginBottom: 40, textAlign: "center" }}>
          <div style={{
            fontFamily: "var(--font-display)",
            fontWeight: 600,
            fontSize: "clamp(18px, 1.6vw, 22px)",
            letterSpacing: "-0.01em",
            color: "var(--c-fg)"
          }}>
            Tante aziende si fidano già di noi
          </div>
        </div>
        <LogoMarquee logos={[
        "indeed", "scalable-capital", "serenis", "walliance", "baker-hughes",
        "moneyfarm", "coverflex", "italiana-assicurazioni", "confindustria",
        "stellantis", { text: "Deloitte." }, "fineco", "istat", "iliad", "unicef"]
        } />
      </section>

      {/* MEDIA SECTION */}
      <section id="media-section" className="section" style={{ background: "#fff", padding: "60px 0px 182.699px", margin: "6px 0px -100px" }}>
        <div className="container">
          <h2 style={{
            fontFamily: "var(--font-display)", fontWeight: 700,
            fontSize: "clamp(34px, 4.6vw, 60px)", lineHeight: 1.08,
            letterSpacing: "-0.025em", margin: 0, textAlign: "center",
            textWrap: "balance", maxWidth: 1100, marginInline: "auto"
          }}>
            Siamo un <HiBox bg="#3FB28E" italic>media digitale</HiBox> e<br />
            facciamo divulgazione sui social
          </h2>
          <p style={{
            textAlign: "center", marginTop: 28,
            fontSize: "clamp(14px, 1.05vw, 16px)", fontWeight: 600, color: "var(--c-fg)"
          }}>
            E lo facciamo attraverso le nostre verticali Media:
          </p>

          <MediaCarousel>
            <MediaCard
              slug="media-economico"
              navigate={navigate}
              img="assets/media/card-economico.webp"
              logo="assets/media/logo-economico.webp"
              handle="@ilpuntoeconomico"
              tagline="La community per chi vuole davvero capirne di più di"
              highlight="economia e attualità"
              hlBg="#FFE2A8"
              hoverBg="#ffb641"
              glow="assets/media/glow-yellow.webp" />
            
            <MediaCard
              slug="media-techy"
              navigate={navigate}
              img="assets/media/card-techy.webp"
              logo="assets/media/logo-techy.webp"
              handle="@techy_ita"
              tagline="La community per chi vuole capirne di più di"
              highlight="innovazione, tecnologia e AI"
              hlBg="#FFD6E8"
              hoverBg="#fb037c"
              glow="assets/media/glow-pink.webp" />
            
          </MediaCarousel>
          <style>{`
            .media-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 360px)); justify-content: center; gap: 28px; margin-top: 64px; }
            .media-dots { display: none; }
            @media (max-width: 860px) {
              /* Mobile: card Media impilate (entrambe visibili scorrendo), niente carosello */
              .media-grid {
                grid-template-columns: 1fr !important;
                gap: 20px; margin-top: 36px;
                max-width: 440px; margin-inline: auto;
              }
              .media-card-img { min-height: 0 !important; flex: 0 0 auto !important; margin-bottom: 16px !important; }
              .media-card-cover { max-height: 210px; width: auto !important; max-width: 76%; }
              .media-dots { display: none; }
            }
          `}</style>
        </div>
      </section>

      {/* MEDIA NUMBERS */}
      <section className="section" style={{ background: "#f6f6f6", padding: "100px 0px 120px" }}>
        <div className="container">
          <h2 style={{
            fontFamily: "var(--font-display)", fontWeight: 700,
            fontSize: "clamp(34px, 4.6vw, 60px)", lineHeight: 1.08,
            letterSpacing: "-0.025em", margin: 0, textAlign: "center",
            textWrap: "balance", maxWidth: 1100, marginInline: "auto"
          }}>
            Portiamo il tuo brand<br />
            davanti a <HiBox bg="#3FB28E">milioni di persone</HiBox>
          </h2>

          <div className="media-numbers" style={{
            display: "grid", gridTemplateColumns: "repeat(3, 1fr)",
            marginTop: 96, alignItems: "start"
          }}>
            <NumberStat value="1M+" desc={<>Le nostre sono tra le community<br />più grandi delle rispettive verticali</>} />
            <NumberStat value="50M+" desc={<>Le impression che generiamo<br />ogni 3 mesi tra i nostri canali</>} divider />
            <NumberStat value="45+" desc={<>I brand con cui abbiamo<br />collaborato negli ultimi 12 mesi</>} divider />
          </div>
          <style>{`
            @media (max-width: 880px){
              .media-numbers{ grid-template-columns: 1fr !important; gap: 56px; }
              .media-numbers > *{ border-left: 0 !important; }
            }
          `}</style>
        </div>
      </section>

      {/* CONTENT STUDIO INTRO */}
      <section style={{ background: "#fff", padding: "100px 56px 30px" }}>
        <div className="container">
          <h2 style={{
            fontFamily: "var(--font-display)", fontWeight: 700,
            fontSize: "clamp(34px, 4.6vw, 60px)", lineHeight: 1.08,
            letterSpacing: "-0.025em", margin: 0, textAlign: "center",
            textWrap: "balance", maxWidth: 1100, marginInline: "auto"
          }}>
            Siamo un <HiBox bg="#6B5CFF">content studio</HiBox><br />
            e raccontiamo il tuo brand al mondo
          </h2>
          <p style={{
            textAlign: "center", marginTop: 28,
            fontSize: "clamp(14px, 1.05vw, 16px)", fontWeight: 600, color: "var(--c-fg)"
          }}>E lo facciamo creando contenuti per il tuo brand che le persone vogliono vedere:

          </p>
        </div>
      </section>

      {/* AGENCY STACKED SCROLL */}
      <AgencyStack navigate={navigate} />
      

      {/* CTA — split: Media (green) + Agency (blue) */}
      <section style={{ background: "#F2F3F2", padding: "clamp(64px, 9vw, 140px) 0" }}>
        <div className="container">
          <div className="cta-split" style={{
            display: "grid", gridTemplateColumns: "1fr 1px 1fr",
            gap: "clamp(32px, 5vw, 80px)", alignItems: "stretch"
          }}>
            {/* LEFT — Media */}
            <div style={{ textAlign: "center", display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "space-between", gap: 36 }}>
              <h3 style={{
                flex: "0 0 auto",
                fontFamily: "var(--font-display)", fontWeight: 700,
                fontSize: "clamp(30px, 3vw, 48px)", lineHeight: 1.15,
                letterSpacing: "-0.02em", margin: 0, color: "#0A0A0A",
                maxWidth: 560, textWrap: "balance"
              }}>
                Vuoi mostrare il tuo brand a <HiBox bg="#3FB28E">milioni di persone?</HiBox>
              </h3>
              <div style={{ display: "flex", flexDirection: "column", alignItems: "center", gap: 18 }}>
                <div style={{ fontSize: 16, color: "#0A0A0A", opacity: 0.85 }}>Scopri i nostri Media:</div>
                <a href="#media" onClick={(e) => {e.preventDefault();navigate("media");}} style={{
                  background: "#3FB28E", color: "#fff",
                  fontFamily: "var(--font-display)", fontWeight: 700, fontSize: 17,
                  padding: "16px 30px", borderRadius: "999px 999px 999px 0px",
                  display: "inline-flex", alignItems: "center", gap: 14,
                  textDecoration: "none",
                  transition: "transform 200ms, filter 200ms"
                }}
                onMouseEnter={(e) => {e.currentTarget.style.filter = "brightness(1.05)";e.currentTarget.style.transform = "translateY(-1px)";}}
                onMouseLeave={(e) => {e.currentTarget.style.filter = "none";e.currentTarget.style.transform = "none";}}>
                  Scopri di più <ArrowRight />
                </a>
              </div>
            </div>

            {/* divider */}
            <div className="cta-divider" style={{ width: 1, alignSelf: "stretch", background: "rgba(0,0,0,0.12)" }}></div>

            {/* RIGHT — Agency */}
            <div style={{ textAlign: "center", display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "space-between", gap: 36 }}>
              <h3 style={{
                flex: "0 0 auto",
                fontFamily: "var(--font-display)", fontWeight: 700,
                fontSize: "clamp(30px, 3vw, 48px)", lineHeight: 1.15,
                letterSpacing: "-0.02em", margin: 0, color: "#0A0A0A",
                maxWidth: 560, textWrap: "balance"
              }}>
                Vuoi produrre contenuti che attirano <HiBox bg="#3B5BFF">davvero l'attenzione?</HiBox>
              </h3>
              <div style={{ display: "flex", flexDirection: "column", alignItems: "center", gap: 18 }}>
                <div style={{ fontSize: 16, color: "#0A0A0A", opacity: 0.85 }}>Scopri la nostra Agency:</div>
                <a href="#agency" onClick={(e) => {e.preventDefault();navigate("agency");}} style={{
                  background: "#3B5BFF", color: "#fff",
                  fontFamily: "var(--font-display)", fontWeight: 700, fontSize: 17,
                  padding: "16px 30px", borderRadius: "999px 999px 999px 0px",
                  display: "inline-flex", alignItems: "center", gap: 14,
                  textDecoration: "none",
                  transition: "transform 200ms, filter 200ms"
                }}
                onMouseEnter={(e) => {e.currentTarget.style.filter = "brightness(1.08)";e.currentTarget.style.transform = "translateY(-1px)";}}
                onMouseLeave={(e) => {e.currentTarget.style.filter = "none";e.currentTarget.style.transform = "none";}}>
                  Scopri di più <ArrowRight />
                </a>
              </div>
            </div>
          </div>
        </div>
        <style>{`
          @media (max-width: 880px){
            .cta-split { grid-template-columns: 1fr !important; }
            .cta-divider { width: auto !important; height: 1px !important; align-self: stretch !important; }
          }
        `}</style>
      </section>
    </main>);

};

/* ============ Media card ============ */
function NumberStat({ value, desc, divider }) {
  // Render value with the trailing "+" colored separately
  const m = String(value).match(/^(.*?)(\+)?$/);
  const main = m[1];
  const plus = m[2];
  return (
    <div style={{
      paddingInline: "clamp(20px, 3vw, 48px)",
      borderLeft: divider ? "1px solid #D9D7D2" : "none",
      textAlign: "left"
    }}>
      <div style={{
        fontFamily: "var(--font-display)", fontWeight: 800,
        fontSize: "clamp(72px, 8vw, 128px)", lineHeight: 0.95,
        letterSpacing: "-0.04em", color: "#0A0A0A",
        display: "flex", alignItems: "flex-start", justifyContent: "center", gap: 4, textAlign: "center"
      }}>
        <span style={{ textAlign: "center" }}>{main}</span>
        {plus && <span style={{ color: "#F96339" }}>+</span>}
      </div>
      <div style={{
        marginTop: 28,
        fontSize: "clamp(14px, 1.05vw, 16px)",
        lineHeight: 1.45, color: "#0A0A0A", textAlign: "center"
      }}>
        {desc}
      </div>
    </div>);

}

function MediaCarousel({ children }) {
  const ref = React.useRef(null);
  const [active, setActive] = React.useState(0);
  const count = React.Children.count(children);
  const onScroll = () => {
    const el = ref.current;
    if (!el) return;
    const center = el.scrollLeft + el.clientWidth / 2;
    let best = 0,bestD = Infinity;
    Array.from(el.children).forEach((c, i) => {
      const cc = c.offsetLeft + c.offsetWidth / 2;
      const d = Math.abs(cc - center);
      if (d < bestD) {bestD = d;best = i;}
    });
    setActive(best);
  };
  const goTo = (i) => {
    const el = ref.current;
    if (!el) return;
    const c = el.children[i];
    if (!c) return;
    el.scrollTo({ left: c.offsetLeft - (el.clientWidth - c.offsetWidth) / 2, behavior: "smooth" });
  };
  return (
    <div>
      <div className="media-grid" ref={ref} onScroll={onScroll}>
        {children}
      </div>
      <div className="media-dots">
        {Array.from({ length: count }).map((_, i) =>
        <button key={i} type="button" aria-label={"Vai al canale " + (i + 1)}
        className={"media-dot" + (i === active ? " is-active" : "")}
        onClick={() => goTo(i)} />
        )}
      </div>
    </div>);

}

function MediaCard({ img, logo, handle, tagline, highlight, hlBg, hoverBg, glow, slug, navigate }) {
  const [hover, setHover] = React.useState(false);
  return (
    <div className="media-card lift" style={{
      background: "#F5F3EE",
      borderRadius: 18,
      padding: "28px 28px 32px",
      display: "flex", flexDirection: "column", gap: 0,
      overflow: "hidden"
    }}>
      <div className="media-card-img" style={{
        flex: "1 1 auto",
        display: "flex", alignItems: "center", justifyContent: "center",
        position: "relative", marginBottom: 24, minHeight: 320
      }}>
        {glow &&
        <img src={glow} alt="" aria-hidden="true" style={{
          position: "absolute", top: "50%", left: "50%",
          transform: "translate(-50%, -50%)",
          width: "110%", aspectRatio: "1/1", height: "auto",
          objectFit: "contain", pointerEvents: "none", zIndex: 0
        }} />
        }
        <img src={img} alt={handle} className="media-card-cover" style={{ position: "relative", zIndex: 1, width: "85%", height: "auto", objectFit: "contain" }} />
      </div>
      <img src={logo} alt="" style={{ width: 56, height: 56, borderRadius: 999, marginBottom: 18, display: "block" }} />
      <div style={{
        fontFamily: "var(--font-display)", fontWeight: 700,
        fontSize: "clamp(22px, 1.9vw, 28px)", letterSpacing: "-0.02em",
        marginBottom: 14
      }}>{handle}</div>
      <div style={{ fontSize: 15, lineHeight: 1.45, color: "#0A0A0A", marginBottom: 24 }}>
        {tagline}{" "}
        <span style={{ position: "relative", display: "inline-block", padding: "0.04em 0.18em", background: hlBg }}>
          <span style={{ position: "absolute", left: "-0.12em", top: "-6%", height: "112%", width: "0.18em" }}>
            <svg viewBox="0 0 14 80" preserveAspectRatio="none" style={{ width: "100%", height: "100%" }}>
              <rect x="6" y="4" width="2" height="72" fill="#0A0A0A" />
              <rect x="0" y="2" width="14" height="2.5" fill="#0A0A0A" />
              <rect x="0" y="75.5" width="14" height="2.5" fill="#0A0A0A" />
            </svg>
          </span>
          {highlight}
          <span style={{ position: "absolute", right: "-0.12em", top: "-6%", height: "112%", width: "0.18em" }}>
            <svg viewBox="0 0 14 80" preserveAspectRatio="none" style={{ width: "100%", height: "100%" }}>
              <rect x="6" y="4" width="2" height="72" fill="#0A0A0A" />
              <rect x="0" y="2" width="14" height="2.5" fill="#0A0A0A" />
              <rect x="0" y="75.5" width="14" height="2.5" fill="#0A0A0A" />
            </svg>
          </span>
        </span>
      </div>
      <a href={slug ? "#" + slug : "#"} onClick={(e) => {e.preventDefault();if (slug && navigate) navigate(slug);}}
      onMouseEnter={() => setHover(true)} onMouseLeave={() => setHover(false)}
      style={{
        alignSelf: "flex-start",
        background: hover ? hoverBg : "#E5E5E5",
        color: hover ? "#fff" : "#0A0A0A",
        padding: "12px 22px", fontWeight: 700, fontSize: 15,
        borderRadius: "999px 999px 999px 0px", display: "inline-flex", alignItems: "center", gap: 8,
        transition: "background 200ms, color 200ms"
      }}>
        Scopri di più <ArrowRight />
      </a>
    </div>);

}

function CoverEconomic() {
  return (
    <div style={{ position: "absolute", inset: 0, padding: 28, display: "flex", flexDirection: "column", justifyContent: "space-between", color: "#fff" }}>
      <div style={{ fontFamily: "var(--font-mono)", fontSize: 11, letterSpacing: "0.18em", opacity: 0.8 }}>Episode 142</div>
      <div>
        <div style={{ fontFamily: "var(--font-display)", fontWeight: 800, fontSize: 30, lineHeight: 0.95, letterSpacing: "-0.025em" }}>
          Perché lo<br />spread<br />è tornato.
        </div>
      </div>
    </div>);

}
function CoverTech() {
  return (
    <div style={{ position: "absolute", inset: 0, padding: 28, color: "#fff" }}>
      <div style={{ fontFamily: "var(--font-mono)", fontSize: 11, letterSpacing: "0.18em", opacity: 0.85 }}>// AI · LIVE</div>
      <div style={{ marginTop: 12, fontFamily: "var(--font-display)", fontWeight: 800, fontSize: 30, lineHeight: 0.95, letterSpacing: "-0.025em" }}>
        Il modello<br />che cambia<br />tutto.
      </div>
      <div style={{ position: "absolute", right: 24, bottom: 24, width: 64, height: 64, borderRadius: "50%", background: "rgba(255,255,255,0.18)", display: "grid", placeItems: "center" }}>
        <PlayIcon size={28} />
      </div>
    </div>);

}
/* ============ Big stat ============ */
function BigStat({ value, label }) {
  return (
    <div>
      <div style={{
        fontFamily: "var(--font-display)", fontWeight: 800,
        fontSize: "clamp(64px, 8vw, 120px)", lineHeight: 1, letterSpacing: "-0.04em", color: "#fff"
      }}>{value}</div>
      <div style={{ fontSize: 16, fontWeight: 500, color: "rgba(255,255,255,0.85)", marginTop: 16, maxWidth: 320, lineHeight: 1.4 }}>
        {label}
      </div>
    </div>);

}

/* ============ Service Block ============ */
function ServiceBlock({ index, kicker, title, body, bullets, cta, onCta, navigate, visual, flip, shadow = "var(--c-violet)", background }) {
  return (
    <section className={"section " + (background || "")} style={{ position: "relative" }}>
      <div className="container">
        <div className="service-grid" style={{
          display: "grid",
          gridTemplateColumns: flip ? "1fr 1.05fr" : "1.05fr 1fr",
          gap: "clamp(40px, 6vw, 96px)", alignItems: "center"
        }}>
          {!flip && <div>{visual}</div>}
          <div>
            <div className="eyebrow" style={{ marginBottom: 14 }}>{index} — {kicker}</div>
            <h2 className="h2">{title}</h2>
            <p style={{ fontSize: 17, color: "var(--c-fg-soft)", marginTop: 24, lineHeight: 1.55, maxWidth: 520 }}>
              {body}
            </p>
            <ul style={{ listStyle: "none", padding: 0, margin: "32px 0", display: "grid", gap: 12, maxWidth: 520 }}>
              {bullets.map((b, i) =>
              <li key={i} style={{ display: "flex", alignItems: "center", gap: 12, fontWeight: 600 }}>
                  <span style={{ width: 18, height: 18, borderRadius: 999, background: "var(--c-fg)", color: "#fff", display: "grid", placeItems: "center", fontSize: 11 }}>✓</span>
                  {b}
                </li>
              )}
            </ul>
            <a href="#" onClick={(e) => {e.preventDefault();onCta && onCta();}} className="link-arrow">
              {cta} <ArrowRight />
            </a>
          </div>
          {flip && <div>{visual}</div>}
        </div>
      </div>
      <style>{`
        @media (max-width: 880px){
          .service-grid{ grid-template-columns: 1fr !important; }
        }
      `}</style>
    </section>);

}

/* ============ YouTube mock visual ============ */
function YouTubeMock() {
  return (
    <BWindowFramed shadowColor="#FFC5A8" offset={16}>
      <div style={{ padding: 24, background: "#fff" }}>
        {/* fake search row */}
        <div style={{ display: "flex", gap: 8, marginBottom: 16 }}>
          <div style={{ flex: 1, height: 16, background: "#FFD6E8", borderRadius: 4 }} />
          <div style={{ width: 80, height: 16, background: "#FFD6E8", borderRadius: 4 }} />
        </div>
        <div style={{ height: 6, background: "#EEE", borderRadius: 4, marginBottom: 8, width: "70%" }} />
        <div style={{ height: 6, background: "#EEE", borderRadius: 4, marginBottom: 18, width: "55%" }} />
        {/* video thumbs */}
        <div style={{ display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: 10 }}>
          {["#0F5132", "#6B3FFE", "#FF2895"].map((c, i) =>
          <div key={i} style={{ aspectRatio: "16/10", background: "#F1EFEA", borderRadius: 6, position: "relative" }}>
              <div style={{ position: "absolute", inset: 0, display: "grid", placeItems: "center" }}>
                <div style={{ width: 32, height: 32, borderRadius: "50%", background: c, display: "grid", placeItems: "center" }}>
                  <PlayIcon size={14} />
                </div>
              </div>
            </div>
          )}
        </div>
        <div style={{ display: "grid", gridTemplateColumns: "repeat(3,1fr)", gap: 10, marginTop: 8 }}>
          {[1, 2, 3].map((i) =>
          <div key={i}>
              <div style={{ height: 6, background: "#EEE", borderRadius: 3, marginBottom: 4 }} />
              <div style={{ height: 6, background: "#EEE", borderRadius: 3, width: "70%" }} />
            </div>
          )}
        </div>
      </div>
    </BWindowFramed>);

}

/* ============ Short Form mock ============ */
function ShortFormMock() {
  return (
    <BWindowFramed shadowColor="#0A1F66" offset={16}>
      <div style={{ padding: 32, background: "#fff" }}>
        <div style={{ display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: 16 }}>
          {[
          { bg: "#E5E2FF", play: "#6B3FFE" },
          { bg: "#C5E8D8", play: "#0F5132" },
          { bg: "#FFD6BD", play: "#FF5C2E" }].
          map((c, i) =>
          <div key={i} style={{
            aspectRatio: "9/14", background: c.bg, borderRadius: 12, position: "relative",
            border: "1.2px solid " + c.play
          }}>
              <div style={{ position: "absolute", left: "50%", top: "40%", transform: "translate(-50%, -50%)" }}>
                <div style={{ width: 44, height: 44, borderRadius: "50%", background: c.play, display: "grid", placeItems: "center" }}>
                  <PlayIcon size={18} />
                </div>
              </div>
              <div style={{ position: "absolute", left: 12, right: 12, bottom: 12 }}>
                <div style={{ height: 4, background: "rgba(0,0,0,0.15)", borderRadius: 2 }} />
                <div style={{ height: 4, background: "rgba(0,0,0,0.15)", borderRadius: 2, marginTop: 6, width: "60%" }} />
              </div>
            </div>
          )}
        </div>
        {/* metric chips */}
        <div style={{ display: "flex", gap: 10, marginTop: 18, flexWrap: "wrap" }}>
          {[["Hook rate", "7,8%"], ["CTR", "4,2%"], ["ROAS", "2,3x"]].map(([k, v], i) =>
          <div key={i} style={{
            padding: "8px 12px", border: "1px solid #DCE5F5", borderRadius: 999,
            fontFamily: "var(--font-mono)", fontSize: 12, color: "#0A1F66"
          }}>
              <strong style={{ color: "#0F5132" }}>{v}</strong> · {k}
            </div>
          )}
        </div>
      </div>
    </BWindowFramed>);

}

/* ============ Social mock ============ */
function SocialMock() {
  return (
    <div style={{ position: "relative" }}>
      {/* back card: grid */}
      <div style={{ position: "relative", zIndex: 1 }}>
        <BWindowFramed shadowColor="#7A2A14" offset={14}>
          <div style={{ padding: 22, background: "#fff" }}>
            <div style={{ display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: 12 }}>
              {[
              ["Post", "#E5E2FF", "#6B3FFE"],
              ["Reel", "#FFD6BD", "#7A2A14"],
              ["Carosello", "#D7CCFF", "#3A1FB0"],
              ["Reel", "#FFD6BD", "#7A2A14"],
              ["Post", "#E5E2FF", "#6B3FFE"],
              ["Carosello", "#D7CCFF", "#3A1FB0"],
              ["Carosello", "#D7CCFF", "#3A1FB0"],
              ["Reel", "#FFD6BD", "#7A2A14"],
              ["Post", "#E5E2FF", "#6B3FFE"]].
              map(([label, bg, color], i) =>
              <div key={i} style={{
                aspectRatio: "1/1", background: bg, borderRadius: 8,
                display: "grid", placeItems: "center",
                fontFamily: "var(--font-display)", fontWeight: 800, fontSize: 14, color, letterSpacing: "-0.01em"
              }}>
                  {label}
                </div>
              )}
            </div>
          </div>
        </BWindowFramed>
      </div>
      {/* front card: schedule, overlapping */}
      <div style={{
        position: "absolute", right: -20, bottom: -32, width: "62%", zIndex: 2
      }} className="social-front">
        <BWindowFramed shadowColor="#6B3FFE" offset={10}>
          <div style={{ padding: 16, background: "#fff", display: "grid", gap: 8 }}>
            <ScheduleRow Glyph={InstagramGlyph} bg="#F0EDFF" border="#6B3FFE" name="Instagram" time="Lun · 07:05" arrowBg="#6B3FFE" />
            <ScheduleRow Glyph={LinkedInGlyph} bg="#DDE9FB" border="#0A66C2" name="LinkedIn" time="Lun · 10:25" arrowBg="#0A66C2" />
            <ScheduleRow Glyph={TikTokGlyph} bg="#F1EFEA" border="#0A0A0A" name="TikTok" time="Lun · 12:30" arrowBg="#0A0A0A" />
            <div style={{
              marginTop: 4, padding: "10px 12px", background: "#F1EFEA",
              borderRadius: 8, fontSize: 12, color: "#8A8A8A", fontWeight: 600, textAlign: "center"
            }}>
              3 contenuti programmati per domani
            </div>
          </div>
        </BWindowFramed>
      </div>
      <style>{`
        @media (max-width: 720px){
          .social-front{ position: relative !important; right:0 !important; bottom:0 !important; width: 100% !important; margin-top: 28px; }
        }
      `}</style>
    </div>);

}
function ScheduleRow({ Glyph, bg, border, name, time, arrowBg }) {
  return (
    <div style={{
      display: "flex", alignItems: "center", gap: 10,
      padding: "10px 12px", background: bg, borderRadius: 8, border: `1.2px solid ${border}`
    }}>
      <Glyph size={20} color={border} />
      <div style={{ fontWeight: 700, fontSize: 14, color: border }}>{name}</div>
      <div style={{ marginLeft: "auto", fontFamily: "var(--font-mono)", fontSize: 12, color: border, fontWeight: 600 }}>
        {time}
      </div>
      <div style={{ width: 26, height: 26, borderRadius: 6, background: arrowBg, color: "#fff", display: "grid", placeItems: "center" }}>
        <ArrowRight size={12} />
      </div>
    </div>);

}

window.HomePage = HomePage;