/* global React, useViewport, PageIntro, EditorialCarousel, ThreadBadge,
           SpecificationSection, SpecifierDownloads, EnquiryBlock */
/*
 * VolarDetail — collection detail page for Volar (2016).
 *
 * Light sculptural forms using cantilever design principles. A dining chair
 * and a bar stool — 425 × 425 footprint, cantilever frame in powder-coated
 * mild steel, six seat-top options spanning timber, plastic and upholstered.
 *
 * 2 SKUs. GECA certified. Manufactured Australia. Indoor standard, outdoor
 * with zinc undercoat (LDPE plastic tops only). Photography: Florian Groehn.
 */

const { useState: useStateVo, useEffect: useEffectVo } = React;

const VOLAR_SLIDES_BASE = [
  { title: "Volar", image: "images/collections/volar/hero/01.webp", pos: "center bottom" },
  { title: "Volar", image: "images/collections/volar/hero/02.webp" },
  { title: "Volar", image: "images/collections/volar/hero/03.webp" },
];
const VOLAR_SLIDES = (window.IMG && window.IMG.extend) ? window.IMG.extend("volar", "hero", VOLAR_SLIDES_BASE) : VOLAR_SLIDES_BASE;

function VolarCarousel() {
  const vw = useViewport();
  const isMobile = vw < 760;
  const [i, setI] = useStateVo(0);
  const [paused, setPaused] = useStateVo(false);

  useEffectVo(() => {
    if (paused) return;
    const id = setInterval(() => setI((x) => (x + 1) % VOLAR_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",
      }}>
      {VOLAR_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",
        }}>
          {VOLAR_SLIDES[i].title}
        </h3>
      </div>

      <div style={{
        position: "absolute", bottom: isMobile ? 36 : 44, left: 0, right: 0,
        display: "flex", justifyContent: "center", gap: 10,
      }}>
        {VOLAR_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 VolarDetail() {
  const vw = useViewport();
  const isMobile = vw < 720;

  return (
    <>
      <VolarCarousel />

      <PageIntro
        eyebrow="Volar · Alexander Lotersztain, 2016"
        title="A cantilevered stool of visual simplicity and quiet strength."
        body="Volar is a stool that pairs visual lightness with structural strength. The cantilever construction gives the form an architectural lift — a quietly resolved silhouette that reads well from every angle while delivering the durability needed for hospitality, commercial and educational interiors. A small fixture beneath the seat top holds accessories — a useful detail that earns its place without disrupting the form."
        compact
        noTopPad
      />

      {/* Editorial pair */}
      <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 }}>
          <div style={{ alignSelf: "center" }}>
            <div style={{ fontSize: 11, letterSpacing: "0.16em", textTransform: "uppercase", color: "#6c6862", fontWeight: 500, marginBottom: 14 }}>Dwell · Define · Endure</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" }}>
              Visual lightness, born of the structure.
            </h2>
            <p style={{ fontSize: isMobile ? 15 : 16, lineHeight: 1.55, color: "#1a1917", maxWidth: "46ch", margin: 0, fontWeight: 500 }}>
              Volar's cantilevered geometry gives the stool a light, lifted silhouette while maintaining the strength required for daily use. The form reads as quietly architectural, holding presence as a singular object without imposing on the space around it.
            </p>
          </div>
          <EditorialCarousel
            slides={[
              { video: "images/collections/volar/pillars/01.mp4", src: "images/collections/volar/hero/01.webp", pos: "center bottom", alt: "Volar stools along a concrete counter, brutalist interior", caption: "01 · In situ" },
              { src: "images/collections/volar/pillars/02.webp", alt: "Volar stools in two heights and colourways",      caption: "02 · Family" },
              { src: "images/collections/volar/pillars/03.webp",  alt: "Volar at Stokehouse, marble bar",                caption: "03 · In service" },
            ]}
            aspect="3/4"
          />
        </div>
      </section>

      {/* Three features */}
      <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 }}>Key features</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" }}>
            Lightness, re-imagined.
          </h2>
        </div>

        <div style={{ display: "grid", gridTemplateColumns: isMobile ? "1fr" : "repeat(3, 1fr)", gap: isMobile ? 48 : 40 }}>
          {[
            { no: "01", kicker: "Cantilevered form", title: "Visual lightness, structural strength.",
              body: "Volar's cantilevered geometry gives the stool a light, lifted silhouette while maintaining the strength required for daily use. The form reads as quietly architectural, holding presence as a singular object — the lightness is genuine, born of the structure rather than added as decoration.",
              image: "images/collections/volar/feature/01.webp", alt: "Volar's cantilever frame and footring detail" },
            { no: "02", kicker: "Seat options", title: "Solid timber or fully upholstered.",
              body: "The seat is offered in solid timber or fully upholstered, letting the same cantilevered frame read as either material-honest and tactile, or refined and soft underfoot. Timber for a warmer, more elemental feel; upholstery for a more comfortable, considered moment.",
              image: "images/collections/volar/feature/02.webp", alt: "Volar solid timber seat top" },
            { no: "03", kicker: "Accessory fixture", title: "A quiet detail beneath the seat.",
              body: "A small fixture beneath the seat top holds personal items — bags, jackets, helmets — clearing the floor and adding utility without disrupting the cantilevered form. An honest, quiet response to the way stools are actually used in hospitality and public settings.",
              image: "images/collections/volar/feature/03.webp", alt: "A backpack hung from the fixture beneath the Volar seat" },
          ].map((f) => (
            <div key={f.no}>
              <div style={{ aspectRatio: "4/5", background: "#e4e2da", overflow: "hidden", marginBottom: isMobile ? 18 : 24 }}>
                <img src={f.image} srcSet={window.IMG && window.IMG.srcsetFor(f.image)} sizes={window.IMG && window.IMG.sizes()} alt={f.alt} loading="lazy" style={{ width: "100%", height: "100%", objectFit: "cover", 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
        headline="Two stools, sharing one cantilever frame."
        meta={[
          ["Design", "Alexander Lotersztain, 2016"],
          ["Sectors", "Hospitality · Education · Corporate · Civic · Retail"],
          ["Environment", "Indoor · Outdoor (with zinc undercoat)"],
          ["Warranty", "5 year structural"],
          ["Certifications", "GECA certified"],
          ["Manufactured", "Australia"],
        ]}
        materials="Frame — powder-coated mild steel, cantilever structure for light sculptural form. Six seat-top options across three families: solid American Oak (natural or black-stained), LDPE plastic (white or black, the only outdoor-rated tops), or upholstered with Dunlop Enduro® foam over MDF substrate in COM/COL. Zinc undercoat available for outdoor specification of the frame."
        groups={[
          {
            label: "Seating",
            note: "Cantilever frame in powder-coated mild steel. Both pieces share a 425 × 425 mm footprint, with a 100 mm height step between dining and bar configurations.",
            items: [
              { sku: "VLR-01", name: "Volar dining chair",  dims: "425 × 425 × 650 H · seat 450" },
              { sku: "VLR-02", name: "Volar bar stool",     dims: "425 × 425 × 750 H · seat 650" },
            ],
          },
        ]}
        extras={[
          {
            label: "Solid timber tops · indoor only",
            rows: [
              { text: "American Oak — natural finish" },
              { text: "American Oak — black-stained" },
              { text: "Warmth and natural texture; not suitable for outdoor use.", muted: true },
            ],
          },
          {
            label: "LDPE plastic tops · indoor & outdoor",
            rows: [
              { text: "White LDPE plastic" },
              { text: "Black LDPE plastic" },
              { text: "The only seat-top option suitable for outdoor specification.", muted: true },
            ],
          },
          {
            label: "Upholstered tops · indoor only",
            rows: [
              { text: "Dunlop Enduro® foam over MDF substrate" },
              { text: "COM (Customer's Own Material)" },
              { text: "COL (Customer's Own Leather)" },
            ],
          },
          {
            label: "Frame finish",
            rows: [
              { text: "Powder coat — white" },
              { text: "Powder coat — black" },
              { text: "Custom colour matching available" },
              { text: "Zinc undercoat required for outdoor specification.", muted: true },
            ],
          },
        ]}
        finishHeadline="A small fixture beneath the seat top holds bags, jackets and helmets — utility without disrupting the form."
      />

      {/* Specified in — 3-up (real Volar 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 neighbourhood bar to a museum café and a regional airport.
          </h2>
        </div>
        <div style={{ display: "grid", gridTemplateColumns: isMobile ? "1fr" : "repeat(3, 1fr)", gap: isMobile ? 28 : 32 }}>
          {[
            { name: "Birubi Street",                  city: null,           year: 2019, category: "Hospitality", image: "images/collections/volar/feature/04.webp" },
            { name: "Kyoto Kyocera Museum of Art",     city: "Kyoto, JPN",   year: 2023, category: "Cultural",    image: "images/collections/volar/hero/02.webp" },
            { name: "Whitsundays Airport",            city: "Whitsundays, AUS", year: 2021, category: "Aviation",  image: "images/collections/volar/feature/05.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", 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>

      <SpecifierDownloads collection="Volar" />

      <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 => ["mochi", "stump", "cup"].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="Volar" />
    </>
  );
}

window.VolarDetail = VolarDetail;
