// ─────────────────────────────────────────────────────────────────────
// SHARED SOLUTION TEMPLATE
// One App that composes the six canonical sections every Solution page
// uses, in order. Each per-solution bundle (svc-<slug>.jsx) defines the
// section components and publishes them on window.SVC_SECTIONS; this
// template reads from that global and renders the page.
//
// Astro mount order (see each solution's .astro route):
//   1. primitives.jsx           — shared chrome (Header / Footer / etc.)
//   2. svc-icons.jsx            — icon library used by SubServicesAlt
//   3. svc-<slug>.jsx           — defines window.SVC_SECTIONS
//   4. svc-template.jsx (this)  — defines window.SvcApp
//   5. mount snippet            — ReactDOM renders <SvcApp />
// ─────────────────────────────────────────────────────────────────────

function App() {
  const S = window.SVC_SECTIONS || {};
  const {
    SolutionHero,
    Overview,
    UseCases,
    SubServicesAlt,
    WhyArgos,
    Outcome
  } = S;

  // Soft-fail if a section is missing — render an inline placeholder so
  // the page still loads and the gap is obvious to a reviewer.
  const Slot = (name, Component, extraProps) => {
    if (typeof Component === "function") {
      return <Component {...(extraProps || {})} />;
    }
    return (
      <section style={{
        padding: "clamp(40px, 6vw, 60px) clamp(20px, 6vw, 96px)",
        fontFamily: "var(--font-display)",
        color: "#0E1F3E",
        background: "#FFF6E5",
        borderTop: "1px solid rgba(14,31,62,0.12)",
        borderBottom: "1px solid rgba(14,31,62,0.12)"
      }}>
        <div style={{ maxWidth: 1600, margin: "0 auto", fontSize: 14 }}>
          Missing section: <code>{name}</code>
        </div>
      </section>);
  };

  return (
    <div>
      {Slot("SolutionHero", SolutionHero, { onCTA: () => {} })}
      {Slot("Overview", Overview)}
      {Slot("UseCases", UseCases)}
      {Slot("SubServicesAlt", SubServicesAlt)}
      {Slot("WhyArgos", WhyArgos)}
      {Slot("Outcome", Outcome)}
    </div>);
}

window.SvcApp = App;
