/* global React, useViewport, PageIntro, EditorialCarousel, ThreadBadge,
           SpecificationSection, SpecifierDownloads, EnquiryBlock */
/*
 * PintoDetail — Pinto (2021, Alexander Lotersztain). Dwell.
 *
 * A contemporary reimagining of the classic bean bag — sculptural, refined,
 * 840 × 1100 × 350 mm, requires 400 L fill (supplied unfilled). Single SKU.
 * Indoor & outdoor (with water-repellent fabric). GECA certified. Made in
 * Australia.
 */

const { useState: useStatePnt, useEffect: useEffectPnt } = React;

const PINTO_SLIDES_BASE = [
  { title: "Pinto", image: "images/collections/pinto/hero/01.webp", pos: "center bottom" },
  { title: "Pinto", image: "images/collections/pinto/hero/02.webp", pos: "center bottom" },
  { title: "Pinto", image: "images/collections/pinto/hero/03.webp" },
];
const PINTO_SLIDES = (window.IMG && window.IMG.extend) ? window.IMG.extend("pinto", "hero", PINTO_SLIDES_BASE) : PINTO_SLIDES_BASE;

function PintoCarousel() {
  const vw = useViewport();
  const isMobile = vw < 760;
  const [i, setI] = useStatePnt(0);
  const [paused, setPaused] = useStatePnt(false);
  useEffectPnt(() => {
    if (paused) return;
    const id = setInterval(() => setI((x) => (x + 1) % PINTO_SLIDES.length), 7000);
    return () => clearInterval(id);
  }, [paused]);
  return (
    <section onMouseEnter={() => setPaused(true)} onMouseLeave={() => setPaused(false)}
      style={{ position: "relative", width: "100%", aspectRatio: "16 / 9",
        maxHeight: isMobile ? "82vh" : "90vh", minHeight: isMobile ? 460 : 560,
        overflow: "hidden", background: "#1a1917" }}>
      {PINTO_SLIDES.map((ss, idx) => (
        <div key={idx} style={{ position: "absolute", inset: 0, opacity: idx === i ? 1 : 0, transition: "opacity 1100ms ease" }}>
          <img src={ss.image} srcSet={window.IMG && window.IMG.srcsetFor(ss.image)} sizes={window.IMG && window.IMG.sizes()} alt={ss.title} loading={idx === 0 ? "eager" : "lazy"}
            style={{ width: "100%", height: "100%", objectFit: "cover", objectPosition: ss.pos || "center", display: "block" }} />
        </div>
      ))}
      <div style={{ position: "absolute", inset: 0,
        background: "linear-gradient(to bottom, transparent 50%, rgba(26,25,23,0.55) 100%)", pointerEvents: "none" }} />
      <div style={{ position: "absolute", left: 0, right: 0, bottom: isMobile ? 84 : 100,
        padding: isMobile ? "0 24px" : "0 32px", textAlign: "center", color: "#f5f3ef" }}>
        <h3 style={{ fontFamily: "var(--font-display, Poppins, sans-serif)", fontWeight: 500,
          fontSize: isMobile ? "clamp(20px, 5vw, 26px)" : "clamp(22px, 1.9vw, 32px)",
          lineHeight: 1.18, letterSpacing: "-0.01em", margin: "0 auto", maxWidth: "26ch", textWrap: "balance" }}>
          {PINTO_SLIDES[i].title}
        </h3>
      </div>
      <div style={{ position: "absolute", bottom: isMobile ? 36 : 44, left: 0, right: 0,
        display: "flex", justifyContent: "center", gap: 10 }}>
        {PINTO_SLIDES.map((_, idx) => (
          <button key={idx} onClick={() => setI(idx)} aria-label={`Show slide ${idx + 1}`}
            style={{ width: idx === i ? 24 : 6, height: 2,
              background: idx === i ? "rgba(245,243,239,0.95)" : "rgba(245,243,239,0.4)",
              border: "none", cursor: "pointer", padding: 0,
              transition: "width 320ms ease, background 320ms ease" }} />
        ))}
      </div>
    </section>
  );
}

function PintoDetail() {
  const vw = useViewport();
  const isMobile = vw < 720;
  return (
    <>
      <PintoCarousel />
      <PageIntro
        eyebrow="Pinto · Alexander Lotersztain, 2021"
        title="The classic bean bag, sculpturally reimagined."
        body="A contemporary reimagining of the bean bag — casual and playful in spirit, sculptural and sophisticated in silhouette. Pinto's organic, relaxed form invites calm repose into lounge environments, hospitality settings, educational interiors and informal civic spaces, with a quietly elegant presence that elevates the typology."
        compact noTopPad
      />

      <section style={{ padding: isMobile ? "56px 20px" : "96px max(24px, 3vw)", maxWidth: 1440, margin: "0 auto" }}>
        <div style={{ display: "grid", gridTemplateColumns: isMobile ? "1fr" : "1fr 1fr", gap: isMobile ? 32 : 48 }}>
          <EditorialCarousel
            slides={[
              { video: "images/collections/pinto/pillars/01.mp4", src: "images/collections/pinto/pillars/02.webp", alt: "Pinto in a library reading room", caption: "01 · In service" },
              { src: "images/collections/pinto/pillars/03.webp",    alt: "Pinto · sculptural forms stacked",   caption: "02 · Form" },
              { src: "images/collections/pinto/pillars/04.webp", alt: "Pinto across the colour range",        caption: "03 · Colour" },
            ]}
            aspect="3/4"
          />
          <div style={{ alignSelf: "center" }}>
            <div style={{ fontSize: 11, letterSpacing: "0.16em", textTransform: "uppercase", color: "#6c6862", fontWeight: 500, marginBottom: 14 }}>Dwell · Indoor & Outdoor</div>
            <h2 style={{ fontWeight: 500, fontSize: isMobile ? "clamp(22px, 5.5vw, 28px)" : "clamp(24px, 2.2vw, 32px)", lineHeight: 1.12, letterSpacing: "-0.01em", color: "#1a1917", margin: "0 0 16px 0", maxWidth: "22ch" }}>
              Organic, sculpted, resolved.
            </h2>
            <p style={{ fontSize: isMobile ? 15 : 16, lineHeight: 1.55, color: "#1a1917", maxWidth: "46ch", margin: 0, fontWeight: 500 }}>
              Pinto's silhouette balances clean lines with soft, organic curvature — a dialogue between geometric restraint and natural form. The piece reads as quietly sophisticated from every angle while still inviting the easy, relaxed use that defines the bean-bag typology.
            </p>
          </div>
        </div>
      </section>

      <section style={{ padding: isMobile ? "64px 20px" : "120px max(24px, 3vw)", maxWidth: 1440, margin: "0 auto" }}>
        <div style={{ maxWidth: 720, marginBottom: isMobile ? 40 : 64 }}>
          <div style={{ fontSize: 11, letterSpacing: "0.16em", textTransform: "uppercase", color: "#6c6862", fontWeight: 500, marginBottom: 14 }}>What Pinto does</div>
          <h2 style={{ fontFamily: "var(--font-display, Poppins, sans-serif)", fontWeight: 500, fontSize: isMobile ? "clamp(24px, 6vw, 30px)" : "clamp(26px, 2.6vw, 38px)", lineHeight: 1.12, letterSpacing: "-0.015em", color: "#1a1917", margin: 0, maxWidth: "26ch", textWrap: "balance" }}>
            Three things Pinto does well.
          </h2>
        </div>
        <div style={{ display: "grid", gridTemplateColumns: isMobile ? "1fr" : "repeat(3, 1fr)", gap: isMobile ? 48 : 40 }}>
          {[
            { no: "01", kicker: "Reimagined typology", title: "The bean bag, refined.",         body: "Pinto retains the casual, conforming comfort of the classic bean bag while elevating the typology through a more refined silhouette. The form references its heritage without copying it — replacing the loose feel of the original with a quietly resolved geometry." },
            { no: "02", kicker: "Sculptural form",     title: "Pure, intentional, resolved.",    body: "Soft, organic curvature paired with clean lines — a dialogue between geometric restraint and natural form. Pinto holds its own as a refined object from every angle while still inviting easy, relaxed use." },
            { no: "03", kicker: "Indoor & outdoor",    title: "Adaptable across settings.",      body: "Specified across breakout zones, lounges, hospitality and education interiors and informal civic spaces. With a water-repellent outdoor fabric, the same piece moves seamlessly between corporate floors and public terraces." },
          ].map((f) => (
            <div key={f.no}>
              <div style={{ aspectRatio: "4/5", background: "#e4e2da", overflow: "hidden", marginBottom: isMobile ? 18 : 24 }}>
                <img src={{ "01": "images/_legacy/collections/pnt-circle.webp", "02": "images/_legacy/collections/pnt-flower.webp", "03": "images/_legacy/collections/pnt-uq.webp" }[f.no]} alt={f.title} loading="lazy" style={{ width: "100%", height: "100%", objectFit: "cover", objectPosition: f.no === "03" ? "center 30%" : "center", display: "block" }} />
              </div>
              <div style={{ display: "flex", alignItems: "baseline", gap: 14, marginBottom: 12 }}>
                <div style={{ fontSize: 11, color: "#6c6862", fontWeight: 500, letterSpacing: "0.08em" }}>{f.no}</div>
                <div style={{ height: "0.5px", flex: 1, background: "rgba(26,25,23,0.25)" }} />
                <div style={{ fontSize: 11, letterSpacing: "0.14em", textTransform: "uppercase", color: "#6c6862", fontWeight: 500 }}>{f.kicker}</div>
              </div>
              <h3 style={{ fontFamily: "var(--font-display, Poppins, sans-serif)", fontWeight: 500, fontSize: isMobile ? 19 : 20, lineHeight: 1.22, letterSpacing: "-0.01em", color: "#1a1917", margin: "0 0 10px 0", maxWidth: "20ch" }}>
                {f.title}
              </h3>
              <p style={{ fontSize: 14, lineHeight: 1.6, color: "#6c6862", margin: 0, maxWidth: "38ch" }}>{f.body}</p>
            </div>
          ))}
        </div>
      </section>

      <SpecificationSection
        skuImageBase="images/collections/pinto/skus"
        headline="One SKU. Indoor or outdoor. Supplied unfilled."
        meta={[
          ["Design", "Alexander Lotersztain, 2021"],
          ["Sectors", "Hospitality · Corporate · Civic · Education"],
          ["Environment", "Indoor & Outdoor (water-repellent fabric)"],
          ["Warranty", "5 year structural"],
          ["Certifications", "GECA certified"],
          ["Manufactured", "Australia"],
        ]}
        materials="Base: black vinyl. Cover: Customer's Own Material (COM) or Customer's Own Leather (COL). Fill: 400 litres required — supplied unfilled. Outdoor specifications require water-repellent outdoor fabric."
        groups={[{
          label: "Bean bag",
          items: [
            { sku: "PNT-01", name: "Bean bag seat", dims: "840 × 1100 × 350 h · requires 400 L fill" },
          ],
        }]}
        extras={[
          {
            label: "Cover",
            note: "Customer's Own Material or Leather.",
            rows: [
              { text: "COM — Customer's Own Material" },
              { text: "COL — Customer's Own Leather" },
              { text: "Outdoor specifications require water-repellent outdoor fabric.", muted: true },
            ],
          },
          {
            label: "Base",
            rows: [
              { text: "Black vinyl" },
            ],
          },
          {
            label: "Fill",
            rows: [
              { text: "Supplied unfilled — 400 L of bean-bag fill required for installation." },
            ],
          },
        ]}
        finishHeadline="Black vinyl base, with COM or COL specifier-selected cover — water-repellent outdoor fabric for exterior installations."
      />

      <SpecifierDownloads collection="Pinto" />

      {/* Specified in — 3-up (real Pinto installations) */}
      <section style={{ padding: isMobile ? "56px 20px" : "96px max(24px, 3vw)", maxWidth: 1440, margin: "0 auto", borderTop: "0.5px solid rgba(26,25,23,0.18)" }}>
        <div style={{ marginBottom: isMobile ? 24 : 36 }}>
          <div style={{ fontSize: 11, letterSpacing: "0.16em", textTransform: "uppercase", color: "#6c6862", fontWeight: 500, marginBottom: 12 }}>Specified in</div>
          <h2 style={{ fontFamily: "var(--font-display, Poppins, sans-serif)", fontWeight: 500, fontSize: isMobile ? "clamp(22px, 5.5vw, 28px)" : "clamp(24px, 2.2vw, 32px)", lineHeight: 1.12, letterSpacing: "-0.01em", color: "#1a1917", margin: 0, maxWidth: "26ch", textWrap: "balance" }}>
            From a campus lawn to a pop-up cinema night.
          </h2>
        </div>
        <div style={{ display: "grid", gridTemplateColumns: isMobile ? "1fr" : "repeat(2, 1fr)", gap: isMobile ? 28 : 32, maxWidth: 940 }}>
          {[
            { name: "University of Queensland", city: "Brisbane, AUS", year: 2023, category: "Education",   image: "images/collections/pinto/pillars/05.webp", pos: "center 30%" },
            { name: "B.A.D Movie Night",       city: "Brisbane, AUS", year: 2021, category: "Cultural",    image: "images/collections/pinto/pillars/06.webp" },
          ].map((p) => (
            <div key={p.name}>
              <div style={{ aspectRatio: "3/2", background: "#e4e2da", overflow: "hidden" }}>
                <img src={p.image} srcSet={window.IMG && window.IMG.srcsetFor(p.image)} sizes={window.IMG && window.IMG.sizes()} alt={p.name} loading="lazy" style={{ width: "100%", height: "100%", objectFit: "cover", objectPosition: p.pos || "center", display: "block" }} />
              </div>
              <div style={{ height: "0.5px", background: "rgba(26,25,23,0.18)", marginTop: 14 }} />
              <div style={{ display: "flex", alignItems: "baseline", justifyContent: "space-between", marginTop: 12, gap: 12 }}>
                <div style={{ fontSize: 16, color: "#1a1917" }}>{p.name}</div>
                <div style={{ fontSize: 12, color: "#6c6862", letterSpacing: "0.04em" }}>{[p.city, p.year].filter(Boolean).join(" · ")}</div>
              </div>
              <div style={{ fontSize: 12, color: "#6c6862", letterSpacing: "0.04em", marginTop: 4 }}>{p.category}</div>
            </div>
          ))}
        </div>
      </section>

      <section style={{ padding: isMobile ? "56px 20px" : "96px max(24px, 3vw)", maxWidth: 1440, margin: "0 auto", borderTop: "0.5px solid rgba(26,25,23,0.18)" }}>
        <div style={{ fontSize: 11, letterSpacing: "0.16em", textTransform: "uppercase", color: "#6c6862", fontWeight: 500, marginBottom: 20 }}>Related collections</div>
        <div style={{ display: "grid", gridTemplateColumns: isMobile ? "1fr" : "repeat(3, 1fr)", gap: isMobile ? 32 : 32 }}>
          {(window.COLLECTIONS || []).filter(c => ["biggie", "cocoon", "mochi"].includes(c.slug)).map((c) => (
            <div key={c.slug}>
              <div style={{ aspectRatio: "4/5", background: "#e4e2da", overflow: "hidden" }}>
                {c.image && <img src={c.image} srcSet={window.IMG && window.IMG.srcsetFor(c.image)} sizes={window.IMG && window.IMG.sizes()} alt={c.name} loading="lazy" style={{ width: "100%", height: "100%", objectFit: "cover", display: "block" }} />}
              </div>
              <div style={{ height: "0.5px", background: "rgba(26,25,23,0.18)", marginTop: 14 }} />
              <div style={{ fontSize: 16, color: "#1a1917", marginTop: 12 }}>{c.name}</div>
              <div style={{ marginTop: 10, display: "flex", flexWrap: "wrap", rowGap: 6 }}>
                {c.threads.map(tk => <ThreadBadge key={tk} threadKey={tk} />)}
              </div>
            </div>
          ))}
        </div>
      </section>

      <EnquiryBlock collection="Pinto" />
    </>
  );
}

window.PintoDetail = PintoDetail;
