/* method-page.jsx, "The Method": a soft, light, oracular sequence (Co-Star cadence, Monics warmth) */
const { useEffect: useMethodFx } = React;

const MP = {
  bg: "#ebeae4",        // brand Base White
  bg2: "#e2dfd5",       // soft cream panel
  cream: "#282828",     // ink (kept name so all text refs flip together)
  soft: "#7d7669",      // brand Taupe
  accent: "#9a9184",    // lightened taupe for labels
  line: "rgba(40,40,40,0.14)",
};
const MPvars = { "--ink": MP.cream, color: MP.cream, background: MP.bg };
const PAD = "clamp(28px,6vw,110px)";

function MethodPage() {
  const [mvActive, setMvActive] = React.useState(-1);
  // reveal-on-scroll
  useMethodFx(() => {
    const io = new IntersectionObserver((es) => {
      es.forEach(e => {
        if (e.target.classList.contains("loop")) {
          e.target.classList.toggle("in", e.isIntersecting);
        } else if (e.isIntersecting) {
          e.target.classList.add("in"); io.unobserve(e.target);
        }
      });
    }, { threshold: 0.18, rootMargin: "0px 0px -8% 0px" });
    document.querySelectorAll(".reveal").forEach(el => io.observe(el));
    // thread: track which movement is on screen
    const mio = new IntersectionObserver((es) => {
      es.forEach(e => { if (e.isIntersecting) setMvActive(Number(e.target.getAttribute("data-mv"))); });
    }, { threshold: 0.45 });
    document.querySelectorAll("[data-mv]").forEach(el => mio.observe(el));
    return () => { io.disconnect(); mio.disconnect(); };
  }, []);

  const movements = [
    { t: "Sense", domain: "The Body", line: "The body reads a space before you do.",
      body: "Air that feels clean to breathe, water worth drinking, floors that wake the soles of your feet. We compose what the senses meet first, so a space welcomes you before you think to look." },
    { t: "Shape", domain: "The Space", line: "Calm the space, and the mind follows.",
      body: "Proportion, light, and the path your body takes through a room; we shape these so the space asks nothing of you, and the noise in your head finds somewhere to soften. Visual clutter measurably raises cortisol: decluttering and flow aren't aesthetics, they lower the cognitive load a room places on you." },
    { t: "Regulate", domain: "The Nervous System", line: "Every culture knew how a space should make you feel.",
      body: "Hygge, Vastu, feng shui: different names for the same instinct, rebuilt as a measurable protocol. Warm 2700K light at night, daylight spectrum by morning, materials and colour tuned to how the body responds, so the nervous system can finally exhale." },
    { t: "Restore", domain: "Your Energy", line: "A space that recharges you, not drains you.",
      body: "You spend nearly 90% of life indoors, and a building can pour energy back into you or quietly draw it down. This is the root that supplements, food and biohacking all skip: wellbeing begins not in what you take, but in where you live." },
  ];

  return (
    <div className="mk" style={{ ...MPvars, width: "100%", overflowX: "clip" }}>
      {/* header */}
      <div style={{ position: "relative", zIndex: 10, padding: `40px ${PAD} 0`, display: "flex", justifyContent: "space-between", alignItems: "flex-start" }}>
        <HoverMenuLeft color={MP.cream} logoSize={30} items={["Projects", "Services", "About"]} />
        <HoverMenu color={MP.cream} items={["Method", "Schedule a call"]} />
      </div>

      {/* hero, one thought, vast space */}
      <section className="snap" style={{ position: "relative", minHeight: "62vh", display: "flex", flexDirection: "column", justifyContent: "center", padding: `clamp(40px,5vw,72px) ${PAD}`, maxWidth: 1500, margin: "0 auto", overflow: "visible" }}>
        <div className="reveal" style={{ position: "relative" }}>
          <div className="label" style={{ fontSize: 13, color: MP.soft, letterSpacing: "0.4em", marginBottom: "clamp(26px,4vw,44px)" }}>The Method</div>
          <h1 className="serif" style={{ fontSize: "clamp(32px,4.8vw,74px)", fontWeight: 300, lineHeight: 1.0, margin: 0, letterSpacing: "-0.02em", maxWidth: "16ch" }}>
            A space can quiet your mind and <span className="ital" style={{ color: MP.soft }}>return you to yourself.</span>
          </h1>
          <p className="journal" style={{ fontSize: "clamp(19px,1.9vw,26px)", color: MP.soft, margin: "clamp(32px,4vw,50px) 0 0", maxWidth: 600, lineHeight: 1.5 }}>
            Most of life unfolds indoors. We design spaces that quietly give that feeling back.
          </p>
        </div>
        <div className="reveal" style={{ display: "flex", alignItems: "center", gap: 16, marginTop: "clamp(36px,5vw,64px)" }}>
          <span style={{ width: 64, height: 1, background: MP.soft, display: "inline-block" }} />
          <span className="label" style={{ fontSize: 12, color: MP.soft, letterSpacing: "0.3em" }}>Scroll</span>
        </div>
      </section>

      {/* the single atmospheric breath */}
      <section style={{ position: "relative", width: "100%", height: "min(86vh,860px)", overflow: "hidden", background: MP.bg2 }}>
        <Plate slot="method-hero" src="method-hero.jpg" tone="#c9c2b2" style={{ position: "absolute", inset: 0 }} placeholder="Drop a soft, atmospheric interior" />
        <div style={{ position: "absolute", inset: 0, background: "linear-gradient(180deg, rgba(235,234,228,0.18) 0%, rgba(235,234,228,0) 30%, rgba(33,30,25,0.14) 56%, rgba(33,30,25,0.42) 100%)", pointerEvents: "none" }} />
        <div className="reveal" style={{ position: "absolute", left: 0, right: 0, bottom: "clamp(36px,6vw,72px)", textAlign: "center", padding: `0 ${PAD}`, pointerEvents: "none" }}>
          <p className="serif ital" style={{ fontSize: "clamp(22px,2.8vw,36px)", fontWeight: 300, lineHeight: 1.25, margin: 0, color: "#f4efe5", textShadow: "0 2px 40px rgba(0,0,0,0.4)" }}>
            Spatial Sensory Intelligence<sup style={{ fontSize: "0.5em", letterSpacing: 0, verticalAlign: "0.55em", marginLeft: "0.14em", fontStyle: "normal" }}>™</sup>
          </p>
        </div>
      </section>

      {/* four movements over one continuous field of light, shades evolving into each other */}
      <div style={{ position: "relative" }}>
        <div aria-hidden="true" style={{ position: "absolute", inset: 0, pointerEvents: "none",
          WebkitMaskImage: "linear-gradient(180deg, transparent 0%, #000 8%, #000 92%, transparent 100%)",
          maskImage: "linear-gradient(180deg, transparent 0%, #000 8%, #000 92%, transparent 100%)",
          background: `
            radial-gradient(circle 46vmax at 34% 6%, rgba(255,255,253,0.95) 0%, rgba(255,255,253,0.5) 34%, rgba(235,234,228,0) 62%),
            radial-gradient(circle 40vmax at 72% 22%, rgba(125,118,105,0.14) 0%, rgba(125,118,105,0.06) 40%, rgba(235,234,228,0) 66%),
            radial-gradient(circle 48vmax at 64% 38%, rgba(255,255,253,0.9) 0%, rgba(255,255,253,0.45) 36%, rgba(235,234,228,0) 64%),
            radial-gradient(circle 42vmax at 26% 55%, rgba(125,118,105,0.13) 0%, rgba(125,118,105,0.05) 42%, rgba(235,234,228,0) 68%),
            radial-gradient(circle 48vmax at 38% 68%, rgba(255,255,253,0.92) 0%, rgba(255,255,253,0.48) 34%, rgba(235,234,228,0) 62%),
            radial-gradient(circle 44vmax at 66% 92%, rgba(255,255,253,0.9) 0%, rgba(255,255,253,0.42) 36%, rgba(235,234,228,0) 64%)
          ` }} />
        {movements.map((m, i) => (
          <section key={m.t} data-mv={i} className="snap" style={{ position: "relative", minHeight: "62vh", display: "flex", alignItems: "center", justifyContent: "center",
            padding: `clamp(36px,5vw,64px) ${PAD}`, background: "transparent" }}>
            <div className="reveal" style={{ position: "relative", maxWidth: 560, textAlign: "center",
              marginLeft: i % 2 === 0 ? "max(0px, calc(50% - 620px))" : "auto",
              marginRight: i % 2 === 0 ? "auto" : "max(0px, calc(50% - 620px))" }}>
              <div className="label" style={{ fontSize: 12.5, color: MP.soft, letterSpacing: "0.32em", marginBottom: "clamp(22px,3vw,34px)" }}>
                {m.t} · {m.domain}
              </div>
              <h2 className="serif" style={{ fontSize: "clamp(24px,3vw,40px)", fontWeight: 300, lineHeight: 1.12, margin: 0, letterSpacing: "-0.02em" }}>
                {m.line}
              </h2>
              <p className="journal" style={{ fontSize: "clamp(16px,1.6vw,19px)", color: MP.soft, margin: "clamp(24px,3vw,36px) auto 0", maxWidth: 440, lineHeight: 1.75 }}>
                {m.body}
              </p>
            </div>
          </section>
        ))}
      </div>

      {/* the thread: a quiet guide through the four movements */}
      <nav className="method-thread" aria-label="Method progress" style={{ position: "fixed", right: "clamp(18px,3vw,44px)", top: "50%", transform: "translateY(-50%)", zIndex: 40,
        display: "flex", flexDirection: "column", alignItems: "flex-end", gap: 0 }}>
        {movements.map((m, i) => (
          <React.Fragment key={m.t}>
            {i > 0 && <span aria-hidden="true" style={{ width: 1, height: 34, background: MP.line, marginRight: 3.5 }} />}
            <button onClick={() => { const el = document.querySelector(`[data-mv=\"${i}\"]`); if (el) window.scrollTo({ top: el.getBoundingClientRect().top + window.pageYOffset - (window.innerHeight - el.offsetHeight) / 2, behavior: "smooth" }); }}
              aria-label={m.t}
              style={{ display: "flex", alignItems: "center", gap: 10, background: "none", border: "none", cursor: "pointer", padding: 0 }}>
              <span className="label" style={{ fontSize: 10.5, letterSpacing: "0.26em", color: mvActive === i ? MP.cream : "rgba(125,118,105,0.55)", transition: "color .5s ease" }}>{m.t}</span>
              <span aria-hidden="true" style={{ width: 8, height: 8, borderRadius: "50%", transition: "all .5s ease",
                background: mvActive === i ? MP.cream : "transparent", border: `1px solid ${mvActive === i ? MP.cream : "rgba(125,118,105,0.55)"}`,
                boxShadow: mvActive === i ? "0 0 14px rgba(255,255,252,0.9)" : "none" }} />
            </button>
          </React.Fragment>
        ))}
      </nav>
      <section className="snap" style={{ minHeight: "72vh", display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center", textAlign: "center", padding: `clamp(44px,6vw,80px) ${PAD}` }}>
        <div className="reveal loop" style={{ display: "flex", flexDirection: "column", alignItems: "center", width: "100%" }}>
          <div className="label" style={{ fontSize: 13, color: MP.soft, letterSpacing: "0.34em", marginBottom: "clamp(30px,4vw,52px)" }}>One System</div>
          <div className="neu-inset onesys-desk" style={{ width: "min(88vw, 780px)", height: "min(88vw, 780px)", display: "flex", alignItems: "center", justifyContent: "center" }}>
          <svg viewBox="0 0 640 640" width="94%" height="94%" style={{ display: "block", overflow: "visible" }} aria-hidden="true">
            <defs>
              <filter id="ringblur" x="-30%" y="-30%" width="160%" height="160%"><feGaussianBlur stdDeviation="11" /></filter>
              <path id="arc1" d="M 20 320 A 300 300 0 0 1 620 320" fill="none" />
              <path id="arc2" d="M 100 320 A 220 220 0 0 1 540 320" fill="none" />
              <path id="arc3" d="M 180 320 A 140 140 0 0 1 460 320" fill="none" />
            </defs>
            {/* halos of light under each line */}
            <g fill="none" stroke="#ffffff" strokeWidth="26" filter="url(#ringblur)">
              <circle className="ring-glow g1" cx="320" cy="320" r="300" opacity="0.95" />
              <circle className="ring-glow g2" cx="320" cy="320" r="225" opacity="0.9" />
              <circle className="ring-glow g3" cx="320" cy="320" r="150" opacity="0.85" />
              <circle className="ring-glow g4" cx="320" cy="320" r="85" opacity="0.8" />
            </g>
            {/* whisper-thin ink lines */}
            <g fill="none" stroke={MP.soft} strokeWidth="0.8" opacity="0.55">
              <circle className="ring r1" cx="320" cy="320" r="300" pathLength="1" />
              <circle className="ring r2" cx="320" cy="320" r="225" pathLength="1" />
              <circle className="ring r3" cx="320" cy="320" r="150" pathLength="1" />
              <circle className="ring r4" cx="320" cy="320" r="85" pathLength="1" />
            </g>
            {/* names rest in the clear space between rings */}
            <g fill={MP.cream} style={{ fontFamily: "'IvyPresto Headline','Cormorant Garamond',serif", fontWeight: 300 }} textAnchor="middle">
              <text x="320" y="55" fontSize="20" fontStyle="italic">Sense</text>
              <text x="320" y="130" fontSize="20" fontStyle="italic">Shape</text>
              <text x="320" y="200" fontSize="20" fontStyle="italic">Regulate</text>
              <text x="320" y="316" fontSize="20" fontStyle="italic">Restore</text>
            </g>
            <g fill={MP.soft} style={{ fontFamily: "'Hanken Grotesk',sans-serif", letterSpacing: "0.16em" }} textAnchor="middle">
              <text x="320" y="76" fontSize="9.5">THE BODY</text>
              <text x="320" y="151" fontSize="9.5">THE SPACE</text>
              <text x="320" y="221" fontSize="9.5">NERVOUS SYSTEM</text>
              <text x="320" y="337" fontSize="9.5">YOUR ENERGY</text>
            </g>
          </svg>
          </div>
          {/* phone: the system reads as a vertical descent instead of a scaled-down dish */}
          <div className="onesys-phone" style={{ display: "none", flexDirection: "column", alignItems: "center", width: "100%", padding: "8px 0" }}>
            {[["Sense", "The Body"], ["Shape", "The Space"], ["Regulate", "Nervous System"], ["Restore", "Your Energy"]].map(([t, d], i) => (
              <React.Fragment key={t}>
                {i > 0 && <span aria-hidden="true" style={{ width: 1, height: 34, background: "rgba(125,118,105,0.35)", margin: "14px 0" }} />}
                <div className="neu-seal" style={{ width: "min(64vw, 250px)", height: "min(64vw, 250px)", flexDirection: "column", gap: 8, borderRadius: "50%" }}>
                  <span className="serif ital" style={{ fontSize: 26, fontWeight: 300, color: MP.cream, lineHeight: 1 }}>{t}</span>
                  <span className="label" style={{ fontSize: 10.5, letterSpacing: "0.24em", color: MP.soft }}>{d.toUpperCase()}</span>
                </div>
              </React.Fragment>
            ))}
          </div>
          <p className="journal" style={{ fontSize: "clamp(17px,1.9vw,22px)", color: MP.soft, margin: "clamp(32px,4vw,52px) 0 0", maxWidth: 540, lineHeight: 1.55 }}>
            We work inward, from what the body senses on the surface down to the energy held at the core.
          </p>
        </div>
      </section>

      {/* closing, the seal, the invitation */}
      <section className="snap" style={{ minHeight: "58vh", display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center", textAlign: "center", padding: `clamp(44px,6vw,80px) ${PAD}` }}>
        <div className="reveal" style={{ display: "flex", flexDirection: "column", alignItems: "center" }}>
          <div className="neu-seal" style={{ width: 148, height: 148 }}>
            <Seal size={64} stroke={MP.cream} />
          </div>
          <h2 className="serif" style={{ fontSize: "clamp(30px,3.8vw,56px)", fontWeight: 300, lineHeight: 1.04, margin: "clamp(30px,4vw,46px) 0 0", letterSpacing: "-0.02em", maxWidth: "14ch" }}>
            Come feel the <span className="ital" style={{ color: MP.soft }}>difference.</span>
          </h2>
          <p className="journal" style={{ fontSize: "clamp(17px,1.9vw,21px)", color: MP.soft, margin: "28px 0 clamp(40px,5vw,52px)", maxWidth: 460, lineHeight: 1.5 }}>
            A free, unhurried call to understand your space and how we might work together.
          </p>
          <a href="index.html" className="arrowlink neu-btn" style={{ display: "inline-block", fontFamily: "'Redonda Compressed','Hanken Grotesk',sans-serif", textTransform: "uppercase", fontSize: "clamp(12px,1.1vw,14px)", letterSpacing: "0.22em", color: MP.cream, textDecoration: "none", padding: "16px 42px", borderRadius: 44 }}>Connect <span className="arw">→</span></a>
        </div>
      </section>

      {/* footer */}
      <footer style={{ background: MP.bg2, color: MP.cream, padding: `clamp(52px,6vw,72px) ${PAD} clamp(28px,3vw,36px)`, borderTop: `1px solid ${MP.line}` }}>
        <div className="foot-grid" style={{ display: "grid", gridTemplateColumns: "repeat(auto-fit, minmax(150px, 1fr))", gap: 30, maxWidth: 1180, margin: "0 auto", textAlign: "center" }}>
          {[["Explore", ["Projects", "Services", "Method"]],
            ["Studio", ["About", "Journal", "Contact"]],
            ["Contact", ["hello@monics.studio", "+39 347 4374756", "+971 56 382 7107", "Via Giuseppe Mazzini 9, 20123 Milano MI"]],
            ["Studios", ["Milano, Italy", "Dubai, UAE"]],
            ["Follow", ["Instagram", "Pinterest", "LinkedIn"]],
            ["Sister company", ["monicsvieira.com"]]].map(([h, items]) => (
            <div key={h} className={"foot-" + h.toLowerCase().replace(/[^a-z]+/g, "-")}>
              <div className="label" style={{ fontSize: 12, color: MP.soft, marginBottom: 13, letterSpacing: "0.22em" }}>{h}</div>
              {items.map(it => {
                const map = { "Projects": "projects.html", "Services": "services.html", "Method": "method.html", "About": "about.html", "Journal": "https://substack.com/@taniamonics", "hello@monics.studio": "mailto:hello@monics.studio", "monicsvieira.com": "https://monicsvieira.com", "+39 347 4374756": "tel:+393474374756", "+971 56 382 7107": "tel:+971563827107", "Instagram": "https://www.instagram.com/monics.studio", "Pinterest": "https://pin.it/2Lt0WGTY0", "LinkedIn": "https://www.linkedin.com/in/tania-monics/" };
                const href = map[it];
                const ext = href && href.startsWith("http");
                const st = { fontSize: 15, lineHeight: 1.85, color: MP.cream, cursor: "pointer", textDecoration: "none", display: "block" };
                return href
                  ? <a key={it} href={href} style={st} {...(ext ? { target: "_blank", rel: "noopener noreferrer" } : {})}>{it}</a>
                  : <div key={it} style={st}>{it}</div>;
              })}
            </div>
          ))}
        </div>
        <div style={{ height: 1, background: MP.line, margin: "clamp(40px,5vw,48px) 0 clamp(28px,3vw,32px)" }} />
        <div className="foot-base" style={{ display: "flex", justifyContent: "space-between", flexWrap: "wrap", gap: 16, alignItems: "center" }}>
          <Wordmark size={19} color={MP.cream} />
          <div className="label" style={{ fontSize: 12, color: MP.soft, letterSpacing: "0.2em" }}>© 2026 Monics Studio · Spatial Sensory Intelligence</div>
        </div>
      </footer>
    </div>
  );
}

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