/* ============================================================
   SKI NEW ENGLAND — Advertise / media kit
   Pitches the audience, not the banner. Numbers live in AUD so they
   update in one place each season.
   ============================================================ */
const AD_EMAIL = "ads@skinewengland.com";

const AUD = [
  ["50K", "Visits", "per month"],
  ["+253%", "Growth", "year over year"],
  ["71", "Mountains", "every lift-served hill"],
  ["6", "States", "the whole region"],
];

const WHY = [
  ["In-market, not browsing", "People open this site to decide where to drive that morning. They are not reading about skiing — they are about to go."],
  ["Regional by definition", "Almost all traffic is New England and the neighbouring metros. No waste on an audience that will never visit your mountain."],
  ["Concentrated season", "December through March is when your budget needs to work. That is exactly when this audience shows up, every day, checking snow."],
];

const PACKAGES = [
  { id: "home", name: "Home page", price: "1,800", lede: "The front door.",
    body: "Top of the site on every visit — the first thing a skier sees before they go anywhere else. One sponsor, all season." },
  { id: "conditions", name: "Daily conditions", price: "1,100", lede: "The morning check.",
    body: "The page people open before deciding where to drive. Our fastest-growing section — this rate is locked for the season." },
  { id: "weather", name: "Weather & forecast", price: "700", lede: "Before they commit.",
    body: "Skiers reading the next storm and planning a weekend. Earlier in the decision than conditions, and a longer read." },
  { id: "resorts", name: "Resort pages", price: "600", lede: "One mountain, one sponsor.",
    body: "Your business on a single mountain's page — lodging, rentals, tuning, lessons — reaching skiers already planning that trip." },
  { id: "news", name: "News & field reports", price: "400", lede: "The cheapest way in.",
    body: "Forecasts and on-the-ground reports, read start to finish. Our most engaged audience and the easiest place to start." },
];

/* White card on blue — the same tile the home page uses for conditions. */
function AudStat({ v, label, note }) {
  return (
    <div style={{ background: "var(--paper)", border: "1px solid var(--line)", borderRadius: 6, padding: "16px 16px 18px", boxShadow: "var(--shadow-card)", display: "flex", flexDirection: "column", minWidth: 0 }}>
      <span className="mono tnum" style={{ fontSize: 32, fontWeight: 600, lineHeight: 0.85, color: "var(--blue-600)" }}>{v}</span>
      <span className="eyebrow" style={{ fontSize: 9, color: "var(--ink-900)", marginTop: 14 }}>{label}</span>
      <span className="mono" style={{ fontSize: 10.5, color: "var(--muted-2)", marginTop: 4 }}>{note}</span>
    </div>
  );
}

function PackageRow({ p, i, active, onPick }) {
  return (
    <button onClick={() => onPick(p)} className="pkg-row" data-active={active ? "1" : undefined}>
      <span className="mono pkg-num">0{i + 1}</span>
      <span className="pkg-t">
        <span className="display pkg-name">{p.name}</span>
        <span className="serif pkg-body"><strong style={{ color: "var(--ink-900)", fontWeight: 700 }}>{p.lede}</strong> {p.body}</span>
      </span>
      <span className="pkg-p">
        <span className="display tnum">${p.price}</span>
        <i className="mono">/ season</i>
      </span>
      <span className="mono pkg-go">Reserve &rarr;</span>
    </button>
  );
}

function AdvertisePage({ go, data }) {
  const [pick, setPick] = useState("conditions");
  const [name, setName] = useState("");
  const [org, setOrg] = useState("");
  const [note, setNote] = useState("");
  const chosen = PACKAGES.find((p) => p.id === pick) || PACKAGES[1];

  const mailto = () => {
    const subject = "Sponsorship enquiry — " + chosen.name;
    const body = [
      "Package: " + chosen.name + " ($" + chosen.price + " " + chosen.unit + ")",
      "Name: " + (name || "—"),
      "Mountain / business: " + (org || "—"),
      "",
      note || "",
    ].join("\n");
    return "mailto:" + AD_EMAIL + "?subject=" + encodeURIComponent(subject) + "&body=" + encodeURIComponent(body);
  };

  const field = {
    width: "100%", padding: "12px 14px", borderRadius: 6, border: "1px solid var(--line)",
    background: "var(--paper)", color: "var(--ink-900)", fontFamily: "var(--f-sans, inherit)", fontSize: 14.5,
  };

  return (
    <div>
      <PageHead eyebrow="Partner with us" title="ADVERTISE" edge={null}
        sub="Reach New England skiers at the exact moment they are deciding where to go. Not a general audience — the one that is already looking your way." />

      <section style={{ position: "relative", background: "var(--retro-900)", color: "#fff", borderTop: "1px solid rgba(255,255,255,0.12)", padding: "40px 0 78px" }}>
        <div className="wrap">
          <div className="adv-statbox" style={{ marginBottom: 46 }}>
            {AUD.map(([v, l, n]) => <AudStat key={l} v={v} label={l} note={n} />)}
          </div>
          <SectionHead eyebrow="Why this audience" title="INTENT, NOT IMPRESSIONS" light />
          <div className="adv-3up" style={{ display: "grid", gridTemplateColumns: "repeat(3,minmax(0,1fr))", gap: 20 }}>
            {WHY.map(([t, b], i) => (
              <div key={t} style={{ paddingTop: 18, borderTop: "1px solid rgba(255,255,255,0.22)" }}>
                <div className="mono tnum" style={{ fontSize: 11.5, color: "var(--blue-300)", fontWeight: 600 }}>0{i + 1}</div>
                <div className="display" style={{ fontSize: 19, fontWeight: 700, marginTop: 12, letterSpacing: "-0.01em", color: "#fff" }}>{t}</div>
                <p className="serif" style={{ fontSize: 15, lineHeight: 1.55, color: "rgba(255,255,255,0.76)", margin: "10px 0 0" }}>{b}</p>
              </div>
            ))}
          </div>
        </div>
        <SnowEdge fill="var(--paper)" />
      </section>

      <section style={{ position: "relative", background: "var(--paper)", padding: "54px 0 78px" }}>
        <div className="wrap">
          <SectionHead eyebrow="What's available" title="SEASON PACKAGES" />
          <div className="pkg-list">
            {PACKAGES.map((p, i) => (
              <PackageRow key={p.id} p={p} i={i} active={pick === p.id}
                onPick={(x) => { setPick(x.id); const el = document.getElementById("ad-contact"); if (el) window.scrollTo({ top: el.getBoundingClientRect().top + window.scrollY - 80, behavior: "smooth" }); }} />
            ))}
          </div>
          <div className="mono" style={{ fontSize: 11.5, color: "var(--muted-2)", marginTop: 18, textAlign: "center" }}>
            Season runs Nov 15 – Apr 15 · Half-season and monthly available · First-season rates shown
          </div>
        </div>
        <SnowEdge fill="var(--retro-900)" />
      </section>

      <section id="ad-contact" style={{ background: "var(--retro-900)", color: "#fff", padding: "54px 0 70px" }}>
        <div className="wrap">
          <div className="adv-2up" style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: 40, alignItems: "start" }}>
            <div>
              <div className="eyebrow" style={{ color: "var(--blue-300)", marginBottom: 10 }}>Get in touch</div>
              <h2 className="display" style={{ margin: 0, fontSize: "clamp(26px,3.4vw,40px)" }}>LET'S TALK</h2>
              <p className="serif" style={{ fontSize: 16.5, lineHeight: 1.5, color: "rgba(255,255,255,0.76)", margin: "14px 0 0", maxWidth: 440 }}>
                Tell us which mountain or shop you're with and what you want out of the season. We'll come back with a plan and a rate — usually the same day.
              </p>
              <a href={"mailto:" + AD_EMAIL} className="mono" style={{ display: "block", marginTop: 22, fontSize: 13.5, fontWeight: 600, color: "#fff" }}>{AD_EMAIL}</a>
              <a href="Media Kit.html" target="_blank" rel="noopener" style={{ display: "inline-flex", alignItems: "center", gap: 9, marginTop: 18, padding: "11px 20px", borderRadius: 99, border: "1.5px solid rgba(255,255,255,0.38)", color: "#fff", textDecoration: "none", fontFamily: "var(--f-display)", fontWeight: 700, fontSize: 13.5 }}>
                <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="M12 3v12" /><path d="M7.5 10.5 12 15l4.5-4.5" /><path d="M4.5 19.5h15" /></svg>
                Media kit (one page)
              </a>
            </div>
            <div style={{ background: "var(--paper)", border: "1px solid var(--line)", borderRadius: 8, padding: "26px 26px 24px", boxShadow: "var(--shadow-card)" }}>
              <div style={{ display: "flex", flexDirection: "column", gap: 14 }}>
                <div>
                  <div className="eyebrow" style={{ fontSize: 9.5, color: "var(--muted)", marginBottom: 7 }}>Package</div>
                  <div style={{ display: "flex", gap: 6, flexWrap: "wrap" }}>
                    {PACKAGES.map((p) => (
                      <button key={p.id} onClick={() => setPick(p.id)} style={{
                        padding: "9px 15px", borderRadius: 99, cursor: "pointer", fontFamily: "var(--f-mono)", fontSize: 11.5, fontWeight: 600, whiteSpace: "nowrap", lineHeight: 1.1,
                        border: "1px solid " + (pick === p.id ? "var(--ink-900)" : "var(--line)"),
                        background: pick === p.id ? "var(--ink-900)" : "transparent",
                        color: pick === p.id ? "#fff" : "var(--muted)",
                      }}>{p.name}</button>
                    ))}
                  </div>
                </div>
                <div>
                  <div className="eyebrow" style={{ fontSize: 9.5, color: "var(--muted)", marginBottom: 7 }}>Your name</div>
                  <input value={name} onChange={(e) => setName(e.target.value)} style={field} placeholder="Jane Carver" />
                </div>
                <div>
                  <div className="eyebrow" style={{ fontSize: 9.5, color: "var(--muted)", marginBottom: 7 }}>Mountain or business</div>
                  <input value={org} onChange={(e) => setOrg(e.target.value)} style={field} placeholder="Magic Mountain" />
                </div>
                <div>
                  <div className="eyebrow" style={{ fontSize: 9.5, color: "var(--muted)", marginBottom: 7 }}>What are you after?</div>
                  <textarea value={note} onChange={(e) => setNote(e.target.value)} rows={3} style={{ ...field, resize: "vertical" }} placeholder="Season pass push for the holidays…" />
                </div>
                <a href={mailto()} style={{
                  display: "block", textAlign: "center", marginTop: 4, padding: "13px 18px", borderRadius: 99,
                  background: "var(--ink-900)", color: "#fff", textDecoration: "none",
                  fontFamily: "var(--f-display)", fontWeight: 700, fontSize: 14.5,
                }}>Send enquiry</a>
                <div className="mono" style={{ fontSize: 10.5, color: "var(--muted-2)", textAlign: "center" }}>Opens your email app — nothing is sent from this page</div>
              </div>
            </div>
          </div>
        </div>
      </section>
    </div>
  );
}

Object.assign(window, { AdvertisePage });
