// Octopak website — How we work (/process)
const { Button, Card } = window.OctopakDesignSystem_bc06ed;
const { SectionHead, ClosingCTA, Icon, WhatsAppGlyph, waLink, WA_DEFAULT, FAQList, FiveStepStrip, FIVE_STEPS, routeToHref } = window;
const { useEffect } = React;

const PROCESS_FAQS = [
  { q: "How long does the whole process take?", a: "Six to eight weeks from mockup sign-off, all in. The first few weeks are talking, checking artwork, and getting the mockup right. Production runs after sign-off." },
  { q: "What do I need to send you to start?", a: "Your artwork in print-ready form, or close to it. Vector files (AI, EPS, PDF) are best; 300 dpi raster works for photography. If you are missing pieces, send what you have; Octopak tells you what is workable." },
  { q: "Will I see a proof before production?", a: "Yes. Every customised job goes through a digital mockup before anything prints. Physical mockups are available on request, adding one to two weeks and a possible cost depending on the product." },
  { q: "Can I make changes after mockup sign-off?", a: "Small changes, sometimes. Anything that affects the print plate, the dieline, or the substrate restarts parts of the process. Octopak tells you what is feasible before you sign off." },
  { q: "Do you help with design?", a: "Octopak is a packaging partner, not a design studio. We check your artwork, advise on print method, paper, colour, and finishes, and sort out file-level issues. The brand and artwork come from you; we make sure they are produced well." },
];

// HowTo + FAQPage + BreadcrumbList schema, injected into <head> (same pattern
// as GuideView's useGuideSchema). HowTo is built from the shared FIVE_STEPS,
// FAQPage from PROCESS_FAQS, BreadcrumbList is static.
function useProcessSchema() {
  useEffect(() => {
    const steps = FIVE_STEPS || [];
    const blocks = [
      {
        "@context": "https://schema.org",
        "@type": "HowTo",
        "name": "How a customised packaging job runs at Octopak",
        "description": "Five steps from first message to delivered pallet, typically six to eight weeks from mockup sign-off.",
        "totalTime": "P56D",
        "step": steps.map((s, i) => ({
          "@type": "HowToStep",
          "position": i + 1,
          "name": s.t,
          "text": s.b,
        })),
      },
      {
        "@context": "https://schema.org",
        "@type": "FAQPage",
        "mainEntity": PROCESS_FAQS.map((f) => ({
          "@type": "Question",
          "name": f.q,
          "acceptedAnswer": { "@type": "Answer", "text": f.a },
        })),
      },
      {
        "@context": "https://schema.org",
        "@type": "BreadcrumbList",
        "itemListElement": [
          { "@type": "ListItem", "position": 1, "name": "Home", "item": "https://octopak.com/" },
          { "@type": "ListItem", "position": 2, "name": "How we work", "item": "https://octopak.com/process" },
        ],
      },
    ];
    const nodes = blocks.map((b) => {
      const s = document.createElement("script");
      s.type = "application/ld+json";
      s.setAttribute("data-process-schema", "");
      s.textContent = JSON.stringify(b);
      document.head.appendChild(s);
      return s;
    });
    return () => nodes.forEach((n) => n.remove());
  }, []);
}

function ProcessView({ onNavigate }) {
  useProcessSchema();
  return (
    <div>
      <section className="page-head">
        <div className="octo-container">
          <p className="octo-eyebrow">How we work</p>
          <h1 className="page-head__title">From first message to delivered pallet.</h1>
          <p className="page-head__lead">A customised packaging job is a series of decisions, not a single transaction. This is how Octopak runs it, in five steps. The whole thing usually takes six to eight weeks from mockup sign-off.</p>
        </div>
      </section>

      {/* Five-step strip */}
      <section className="section section--tight">
        <div className="octo-container">
          <FiveStepStrip extras={{
            "01": (
              <a className="wedge-card__link" href={waLink(WA_DEFAULT)} target="_blank" rel="noreferrer"
                style={{ display: "inline-flex", alignItems: "center", gap: 6 }}>
                <WhatsAppGlyph size={16} /> WhatsApp us
              </a>
            ),
            "02": (
              <a className="wedge-card__link" href={routeToHref("guide#what-to-send")}
                onClick={(e) => { e.preventDefault(); onNavigate("guide#what-to-send"); }}>
                See what to send us →
              </a>
            ),
          }} />
        </div>
      </section>

      {/* What we help with, and what we do not */}
      <section className="section section--sunken">
        <div className="octo-container about-intro__grid">
          <div>
            <p className="octo-eyebrow">A packaging partner</p>
            <h2 className="section__title" style={{ marginBottom: "var(--space-4)" }}>Where we help, and where we hand off.</h2>
            <p style={{ color: "var(--text-muted)" }}>
              Octopak is a packaging partner with hands-on guidance through production. The brand and the artwork are yours; once you have those, we take it from there and make sure they are made well. Here is the honest split, so the conversation starts in the right place.
            </p>
          </div>
          <div className="grid-2" style={{ gridTemplateColumns: "1fr 1fr", gap: "var(--space-4)" }}>
            <Card variant="default">
              <h4 style={{ margin: "0 0 8px" }}>Where we help</h4>
              <ul style={{ margin: 0, paddingLeft: "1.1em", color: "var(--text-muted)", fontSize: "var(--fs-sm)", lineHeight: 1.6 }}>
                <li>File checks for print readiness</li>
                <li>Recommendations on print method, paper, colour, and finishes</li>
                <li>File-level tweaks: resolution, colour profile, bleed, dieline fit</li>
                <li>Walking you through trade-offs between options</li>
                <li>Owning quality and accountability from sign-off to delivery</li>
              </ul>
            </Card>
            <Card variant="default">
              <h4 style={{ margin: "0 0 8px" }}>Where we hand off</h4>
              <ul style={{ margin: 0, paddingLeft: "1.1em", color: "var(--text-muted)", fontSize: "var(--fs-sm)", lineHeight: 1.6 }}>
                <li>Creating a brand, logo, or visual identity from scratch</li>
                <li>Designing artwork from a mood board, sketches, or references</li>
                <li>Design as a standalone paid service</li>
              </ul>
              <p style={{ margin: "var(--space-3) 0 0", color: "var(--text-muted)", fontSize: "var(--fs-sm)" }}>
                If you are still shaping the brand, that part happens before you come to us. Once the artwork is ready, we will take good care of it.
              </p>
            </Card>
          </div>
        </div>
      </section>

      {/* File & artwork guidance */}
      <section className="section">
        <div className="octo-container">
          <SectionHead eyebrow="Files & artwork" title="A little technical guidance." />
          <div className="grid-2">
            <Card variant="default">
              <h4 style={{ margin: "0 0 10px", display: "flex", alignItems: "center", gap: 8 }}><Icon name="file" size={20} /> File formats accepted</h4>
              <p style={{ color: "var(--text-muted)", margin: 0, lineHeight: 1.65 }}>
                Vector files (AI, EPS, PDF) for logos and line art. Raster files (TIFF or high-quality JPEG) at 300 dpi minimum for photography. Brand colours as Pantone codes where you have them. If your files are not yet in these formats, send what you have; we will tell you what is workable.
              </p>
            </Card>
            <Card variant="default">
              <h4 style={{ margin: "0 0 10px", display: "flex", alignItems: "center", gap: 8 }}><Icon name="ruler" size={20} /> Dielines &amp; bleed basics</h4>
              <p style={{ color: "var(--text-muted)", margin: 0, lineHeight: 1.65 }}>
                A dieline is the flat cutting template for your packaging; bleed is the 3 to 5mm of extra artwork that runs past the cut line so the print reaches the edge cleanly. Bring a dieline if you have one. If you do not, Octopak sends you one once we have agreed the size and format.
              </p>
            </Card>
          </div>
          <p style={{ marginTop: "var(--space-5)", textAlign: "center" }}>
            <a href={routeToHref("guide#what-to-send")} onClick={(e) => { e.preventDefault(); onNavigate("guide#what-to-send"); }}>
              Read more in our Print &amp; Materials Guide: What to send us →
            </a>
          </p>
        </div>
      </section>

      {/* Mockup options */}
      <section className="section">
        <div className="octo-container">
          <SectionHead eyebrow="Mockups" title="Digital mockup standard, physical on request." />
          <div className="grid-2" style={{ gap: "var(--space-5)", marginBottom: "var(--space-6)" }}>
            <p style={{ color: "var(--text-muted)", lineHeight: 1.7, margin: 0 }}>
              Every customised job goes through a digital mockup before production. Octopak sends a digital proof showing how your artwork will print on the chosen substrate, with colour and finish indicated as accurately as a screen can show. You sign off before anything prints.
            </p>
            <p style={{ color: "var(--text-muted)", lineHeight: 1.7, margin: 0 }}>
              Physical mockups are available on request. They are useful when colour accuracy or tactile finishes (foil, embossing, spot UV, paper texture) are decision-critical. The trade-off is one to two extra weeks and a possible mockup cost, depending on the product. Octopak tells you upfront whether a physical mockup is worth it for your job.
            </p>
          </div>
          <div className="grid-2">
            <Card variant="default">
              <h4 style={{ margin: "0 0 8px" }}>Digital mockup</h4>
              <p style={{ color: "var(--text-muted)", margin: 0, fontSize: "var(--fs-sm)", lineHeight: 1.6 }}>
                Standard for every customised job. Included. Sent for sign-off before production starts.
              </p>
            </Card>
            <Card variant="default">
              <h4 style={{ margin: "0 0 8px" }}>Physical mockup</h4>
              <p style={{ color: "var(--text-muted)", margin: 0, fontSize: "var(--fs-sm)", lineHeight: 1.6 }}>
                By request. Adds one to two weeks to the schedule, at a cost that depends on the product. Useful when colour or tactile finishes need to be confirmed in hand.
              </p>
            </Card>
          </div>
        </div>
      </section>

      {/* Common questions */}
      <section className="section section--sunken">
        <div className="octo-container octo-container--narrow">
          <SectionHead eyebrow="Common questions" title="About the process." center />
          <FAQList items={PROCESS_FAQS} onNavigate={onNavigate} />
        </div>
      </section>

      <ClosingCTA onNavigate={onNavigate} title="Got the artwork? Let's start."
        sub="We reply within three business days, usually sooner." />
    </div>
  );
}

Object.assign(window, { ProcessView });
