// Mid-page sections: value props, trust counters, trips, how it works, why, included, gallery.
// All photos are real Shubie River Wranglers — muddy-brown tidal bore action only.
const PHOTOS = {
  // Big front-on splash shots
  splash:  "assets/photos/action-splash.jpeg",
  action1: "assets/photos/action-boat.jpeg",
  action2: "assets/photos/action-splash.jpeg",
  action3: "assets/photos/action-wave.jpeg",
  // Calmer / cruising shots
  raft:    "assets/photos/family-wave.webp",
  river:   "assets/photos/red-boat.jpeg",
  team:    "assets/photos/jumping-mud.jpeg",
  // Mud & after-shots
  coast:   "assets/photos/mud-friends.webp",
  group:   "assets/photos/mud-group.jpeg",
  mudSlide:"assets/photos/mud-slide.webp",
  rainy:   "assets/photos/rainy-day.webp",
};

/* ---------------------------------- VALUE STRIP (3 pillars w/ body copy) ---------------------------------- */
function ValueStrip() {
  const items = [
    { title: "Professional Guides",
      copy: "Trained, Transport Canada-certified river masters who've ridden the Shubie for thousands of tides.",
      cta: "Meet the crew", href: "#about" },
    { title: "Award-Winning",
      copy: "Tripadvisor Travellers' Choice Best of the Best — seven years running, 2020 to 2026.",
      cta: "See the reviews", href: "#reviews" },
    { title: "No Paddling Required",
      copy: "Just hold on and enjoy the wave. We do the work — you get the bucket-list story.",
      cta: "See how it works", href: "#how" },
  ];
  return (
    <section style={{ position: "relative", overflow: "hidden", color: "var(--bone)" }}>
      {/* Full-bleed photo background */}
      <div aria-hidden="true" style={{
        position: "absolute", inset: 0,
        backgroundImage: `url(assets/photos/tier-2.jpeg)`,
        backgroundSize: "cover",
        backgroundPosition: "center",
        filter: "saturate(0.95) contrast(1.02)",
      }} />
      <div aria-hidden="true" style={{
        position: "absolute", inset: 0,
        background: "linear-gradient(180deg, rgba(11,11,14,0.82) 0%, rgba(11,11,14,0.66) 50%, rgba(11,11,14,0.85) 100%)",
      }} />

      <div className="wrap" style={{ position: "relative", padding: "96px 20px" }}>
        <div className="vp-grid" style={{
          display: "grid",
          gridTemplateColumns: "repeat(auto-fit, minmax(260px, 1fr))",
          gap: 48,
        }}>
          {items.map((it, i) => (
            <div key={i} style={{ display: "flex", flexDirection: "column", gap: 14 }}>
              <span style={{
                width: 44, height: 44,
                display: "inline-flex", alignItems: "center", justifyContent: "center",
                background: "var(--red)", color: "#fff",
                borderRadius: 99,
                flexShrink: 0,
              }}>
                <IconCheck size={22} stroke={2.6} />
              </span>
              <h3 className="display" style={{ fontSize: "clamp(22px, 2.4vw, 28px)", margin: 0, color: "var(--bone)", lineHeight: 1 }}>
                {it.title}
              </h3>
              <p style={{ margin: 0, fontSize: 15.5, color: "rgba(246,243,238,0.82)", lineHeight: 1.55, maxWidth: 360 }}>
                {it.copy}
              </p>
              <a href={it.href} className="narrow" style={{
                marginTop: 6,
                display: "inline-flex", alignSelf: "flex-start", alignItems: "center", gap: 8,
                fontSize: 12, letterSpacing: ".16em",
                color: "var(--bone)",
                borderBottom: "1.5px solid var(--red)",
                paddingBottom: 4,
              }}>
                {it.cta} <IconArrow size={13} style={{ color: "var(--red)" }} />
              </a>
            </div>
          ))}
        </div>
      </div>
    </section>
  );
}

/* ---------------------------------- EAGLE RESCUE (story · dark left-right) ---------------------------------- */
function WhyRaftWithUs() {
  const paragraphs = [
    "The bald eagles on the Shubenacadie river are a huge part in helping us deliver such great tours every day, so it was nice to be able to help one out when it needed a hand. Our close encounter only added to the enormous amount of respect we already had for these incredible birds.",
    "What started as a normal day turned into a wild and unique Shubenacadie experience. We were out rafting when we came across an injured eagle on the sandbar. After seeing this eagle struggle to take off from the sandbar we knew something was wrong. After several failed attempts to fly off the sand bar, the eagle found himself caught in the incoming tide and quickly swept away by the tidal bore.",
    "We watched and tried to position ourselves down the river and close enough to the eagle to lend a hand however we could. Despite continuing to struggle and encountering some quite large waves, it was able to maintain its upright posture.",
    "Now, we had a strong sense that the eagle had sustained a severe injury that prevented him from taking flight. We managed to get him into the boat safely and we did our best to keep him at ease as we travelled back to our rafting location.",
    "Once we arrived back to our site @hopeforwildlife arrived to take the eagle and provide him with the care he required. The eagle recovered completely from its injuries and was eventually released to its natural environment.",
  ];

  return (
    <section style={{ background: "#000", color: "var(--bone)" }}>
      <div className="wrap" style={{ padding: "84px 20px" }}>
        <div className="eagle-row" style={{
          display: "grid", gap: 40, gridTemplateColumns: "1fr", alignItems: "start",
        }}>
          {/* LEFT — text */}
          <div>
            <div className="eyebrow" style={{ color: "var(--red)" }}>A true story</div>
            <h2 className="display" style={{
              fontSize: "clamp(24px, 3.4vw, 38px)",
              margin: "10px 0 24px", lineHeight: 1.1,
              color: "var(--bone)",
            }}>
              Shubie River Wranglers<br/>Eagle Rescue.
            </h2>
            <div style={{ display: "flex", flexDirection: "column", gap: 14 }}>
              {paragraphs.map((p, i) => (
                <p key={i} style={{
                  margin: 0, fontSize: 15, lineHeight: 1.7,
                  color: "rgba(246,243,238,0.78)",
                }}>
                  {p}
                </p>
              ))}
            </div>

            <div style={{
              marginTop: 24, paddingTop: 16,
              borderTop: "1px solid var(--line-on-dark)",
              fontSize: 13, color: "rgba(246,243,238,0.55)",
            }}>
              In partnership with{" "}
              <a href="https://hopeforwildlife.net/" target="_blank" rel="noopener noreferrer" style={{
                color: "var(--bone)", borderBottom: "1px solid var(--red)", paddingBottom: 1,
              }}>Hope for Wildlife</a>
            </div>
          </div>

          {/* RIGHT — media: all 4 in one row */}
          <div className="eagle-media">
            <div className="eagle-tile eagle-tile--video">
              <video
                src="assets/videos/eagle.mp4"
                controls
                playsInline
                preload="metadata"
                poster="assets/photos/eagle-release.webp"
                style={{ width: "100%", height: "100%", display: "block", objectFit: "cover", background: "#000" }}
              />
            </div>
            {[
              "assets/photos/eagle-closeup.webp",
              "assets/photos/eagle-smile.webp",
              "assets/photos/eagle-release.webp",
            ].map((src, i) => (
              <div key={i} className="eagle-tile" style={{
                background: `#111 url(${src}) center/cover no-repeat`,
              }} />
            ))}
          </div>
        </div>
      </div>

      <style>{`
        .eagle-row {
          display: grid;
          grid-template-columns: 1fr;
          gap: 40px;
          align-items: start;
        }
        .eagle-media {
          display: grid;
          grid-template-columns: repeat(4, 1fr);
          gap: 10px;
        }
        .eagle-tile {
          aspect-ratio: 3 / 4;
          background: #111;
          border: 1px solid var(--line-on-dark);
          overflow: hidden;
        }
        .eagle-tile--video { background: #000; }
        @media (min-width: 880px) {
          .eagle-row { grid-template-columns: minmax(0, 1fr) minmax(0, 0.9fr); gap: 56px; align-items: start; }
        }
      `}</style>
    </section>
  );
}

/* ---------------------------------- TRUST / COUNTERS ---------------------------------- */
function Counter({ to, suffix = "", duration = 1600 }) {
  const [val, setVal] = React.useState(0);
  const [armed, setArmed] = React.useState(false);
  const ref = React.useRef(null);

  // Watch viewport intersection — flip `armed` once, then disconnect.
  // Separated from the animation so StrictMode double-effect can't strand us
  // mid-callback (the previous "started.current" guard could deadlock if the
  // first observer fired with isIntersecting:false during the dev double-mount).
  React.useEffect(() => {
    if (!ref.current) return;
    // Fallback: if IO is missing, animate immediately.
    if (typeof IntersectionObserver === "undefined") { setArmed(true); return; }
    const obs = new IntersectionObserver((entries) => {
      for (const e of entries) {
        if (e.isIntersecting || e.intersectionRatio > 0) {
          setArmed(true);
          obs.disconnect();
          return;
        }
      }
    }, { threshold: 0, rootMargin: "0px 0px -10% 0px" });
    obs.observe(ref.current);
    // Belt-and-braces: if the section is already near the fold on first paint,
    // kick off after a tick anyway.
    const fallback = setTimeout(() => {
      const r = ref.current?.getBoundingClientRect();
      if (r && r.top < window.innerHeight + 200) setArmed(true);
    }, 250);
    return () => { obs.disconnect(); clearTimeout(fallback); };
  }, []);

  React.useEffect(() => {
    if (!armed) return;
    const start = performance.now();
    let raf;
    const tick = (now) => {
      const t = Math.min(1, (now - start) / duration);
      const eased = 1 - Math.pow(1 - t, 3);
      setVal(Math.floor(to * eased));
      if (t < 1) raf = requestAnimationFrame(tick);
      else setVal(to);
    };
    raf = requestAnimationFrame(tick);
    return () => { if (raf) cancelAnimationFrame(raf); };
  }, [armed, to, duration]);

  return <span ref={ref}>{val.toLocaleString()}{suffix}</span>;
}

function TrustBar() {
  const awards = [2026, 2025, 2024, 2023, 2022, 2021, 2020];
  return (
    <section className="dark" style={{ padding: "72px 0" }}>
      <div className="wrap">
        <div style={{ display: "grid", gridTemplateColumns: "1fr", gap: 40, alignItems: "end" }}>
          <div style={{ display: "grid", gridTemplateColumns: "minmax(0,1fr) auto", gap: 32, alignItems: "end" }}>
            <div>
              <div className="eyebrow" style={{ color: "var(--red)" }}>Trusted by adventurers</div>
              <h2 className="display" style={{ fontSize: "clamp(28px, 4vw, 48px)", margin: "10px 0 0", color: "var(--bone)" }}>
                Best of the Best.<br/>
                <span style={{ color: "var(--red)" }}>Seven years running.</span>
              </h2>
            </div>
            <div className="hide-sm" style={{ display: "flex", alignItems: "center", gap: 18 }}>
              <IconTripAdvisor size={48} style={{ color: "#00AA6C" }} />
              <div>
                <Stars value={5} size={16} />
                <div className="narrow" style={{ fontSize: 13, color: "rgba(246,243,238,0.7)", marginTop: 4 }}>
                  Travellers' Choice
                </div>
              </div>
            </div>
          </div>

          {/* Award badge wall */}
          <div style={{
            background: "var(--bone)",
            padding: "32px 24px",
            display: "grid",
            gridTemplateColumns: "repeat(auto-fit, minmax(110px, 1fr))",
            gap: 18,
            alignItems: "center",
            justifyItems: "center",
            border: "1px solid var(--line-on-dark)",
          }}>
            {awards.map((y) => (
              <img key={y}
                src={`assets/awards/${y}.${y === 2022 ? "png" : "webp"}`}
                alt={`Tripadvisor Travellers' Choice Best of the Best ${y}`}
                style={{ height: 120, width: "auto", maxWidth: "100%", objectFit: "contain" }}
              />
            ))}
          </div>

          {/* Counters */}
          <div style={{ display: "grid", gridTemplateColumns: "repeat(auto-fit, minmax(180px, 1fr))", gap: 0, marginTop: 8 }}>
            {[
              { n: 935, suf: "+", label: "5 Star Reviews", sub: "Tripadvisor + Google" },
              { n: 10000, suf: "+", label: "Tours Completed", sub: "Since 2013" },
              { n: 20000, suf: "+", label: "Happy Customers", sub: "From across Canada & beyond" },
              { n: 12, suf: "+", label: "Years Operating", sub: "Family-run · Nova Scotian" },
            ].map((c, i, arr) => (
              <div key={i} style={{
                padding: "28px 24px",
                borderRight: i < arr.length - 1 ? "1px solid var(--line-on-dark)" : "none",
                borderTop: "1px solid var(--line-on-dark)",
              }}>
                <div className="display" style={{ fontSize: "clamp(32px, 4vw, 48px)", color: "var(--bone)", lineHeight: 1 }}>
                  <Counter to={c.n} suffix={c.suf} />
                </div>
                <div className="narrow" style={{ fontSize: 13, color: "var(--red)", letterSpacing: ".14em", marginTop: 10 }}>{c.label}</div>
                <div style={{ fontSize: 12, color: "rgba(246,243,238,0.55)", marginTop: 4 }}>{c.sub}</div>
              </div>
            ))}
          </div>

          {/* CTA */}
          <div style={{
            marginTop: 28,
            display: "flex", flexWrap: "wrap", alignItems: "center", justifyContent: "space-between", gap: 18,
            paddingTop: 28, borderTop: "1px solid var(--line-on-dark)",
          }}>
            <div style={{ display: "flex", alignItems: "center", gap: 12, color: "rgba(246,243,238,0.7)", fontSize: 14 }}>
              <IconAward size={18} style={{ color: "var(--red)" }} />
              Join the crowd that already gave us 5 stars.
            </div>
            <div style={{ display: "flex", flexWrap: "wrap", gap: 12 }}>
              <a href="#reviews" className="btn btn-ghost-dark">Read the reviews <IconArrow size={14} /></a>
              <a href="#book" className="btn btn-primary btn-lg">Book your trip <IconArrow size={16} /></a>
            </div>
          </div>
        </div>
      </div>
    </section>
  );
}

/* ---------------------------------- TRIPS ---------------------------------- */
const TRIPS = [
  {
    tier: "01",
    name: "Regular Tide",
    intensity: 2,
    intensityLabel: "Splashy & fun",
    waveCopy: "2 – 4 ft waves",
    weight: "Weight requirement 50 lb",
    desc: "Small to medium waves with plenty of excitement! As a result, this tour is great for first-timers or for families with young kids. A gentle introduction to Tidal Bore Rafting.",
    includes: ["Mud Sliding"],
    img: "assets/photos/tier-1.jpeg",
    tagline: "Start here",
  },
  {
    tier: "02",
    name: "High Tide",
    intensity: 4,
    intensityLabel: "Big rolling waves",
    waveCopy: "4 – 8 ft waves",
    weight: "Weight requirement 50 lb",
    desc: "Medium to Large waves! The full experience of active waves and playing within the rapids. Great for rafters of all levels!",
    includes: ["Mud Sliding"],
    img: "assets/photos/tier-2.jpeg",
    tagline: "Most popular",
    popular: true,
  },
  {
    tier: "03",
    name: "Extreme Tide",
    intensity: 5,
    intensityLabel: "10-ft monsters",
    waveCopy: "8 – 12 ft waves",
    weight: "Weight requirement 50 lb",
    desc: "Often times the largest waves on the river! This suits adventure seekers who feel comfortable being tossed around. Prepare for everything that the Shubie can throw at you!",
    includes: ["Mud Sliding"],
    img: "assets/photos/tier-3.jpeg",
    tagline: "Bucket-list",
  },
];

function IntensityMeter({ value = 3, label }) {
  return (
    <div style={{ display: "flex", alignItems: "center", gap: 10 }}>
      <div style={{ display: "flex", gap: 4 }}>
        {[1,2,3,4,5].map(i => (
          <div key={i} style={{
            width: 18, height: 6, borderRadius: 1,
            background: i <= value ? "var(--red)" : "rgba(11,11,14,0.12)",
          }} />
        ))}
      </div>
      <div className="narrow" style={{ fontSize: 11, letterSpacing: ".16em", color: "rgba(11,11,14,0.65)" }}>{label}</div>
    </div>
  );
}

function TripCard({ trip }) {
  return (
    <article style={{
      position: "relative",
      background: "var(--white)",
      border: "1px solid var(--line)",
      borderRadius: 2,
      display: "flex", flexDirection: "column",
      overflow: "hidden",
      boxShadow: trip.popular ? "0 24px 60px -28px rgba(219,0,1,0.45)" : "0 18px 40px -28px rgba(11,11,14,0.25)",
      borderColor: trip.popular ? "var(--red)" : "var(--line)",
    }} className="lift">
      {/* Photo header */}
      <div style={{ position: "relative", height: 220, background: "var(--ink)", overflow: "hidden" }}>
        <div aria-hidden="true" style={{
          position: "absolute", inset: 0,
          backgroundImage: `url(${trip.img})`, backgroundSize: "cover", backgroundPosition: "center",
          filter: "saturate(0.95)",
        }} />
        <div aria-hidden="true" style={{
          position: "absolute", inset: 0,
          background: "linear-gradient(180deg, rgba(0,0,0,0.0), rgba(0,0,0,0.6))",
        }} />
        <div style={{ position: "absolute", left: 20, bottom: 16, right: 20, color: "var(--bone)" }}>
          <div className="narrow" style={{ fontSize: 11, letterSpacing: ".22em", color: "rgba(246,243,238,0.85)" }}>
            TIER · {trip.tier}
          </div>
          <h3 className="display" style={{ fontSize: 44, margin: "4px 0 0", color: "var(--bone)" }}>
            {trip.name}
          </h3>
        </div>
      </div>

      {/* Body */}
      <div style={{ padding: 24, display: "flex", flexDirection: "column", gap: 16, flex: 1 }}>
        <div>
          <div className="narrow" style={{ fontSize: 11, color: "var(--red)", letterSpacing: ".18em", marginBottom: 6 }}>
            WAVE INTENSITY · {trip.waveCopy}
          </div>
          <IntensityMeter value={trip.intensity} label={trip.intensityLabel} />
        </div>

        {/* Weight requirement (subtle) */}
        <div className="narrow" style={{
          display: "inline-flex", alignItems: "center", alignSelf: "flex-start", gap: 6,
          fontSize: 11,
          color: "rgba(11,11,14,0.5)",
          letterSpacing: ".14em",
        }}>
          <IconShield size={12} style={{ color: "rgba(11,11,14,0.4)" }} />
          {trip.weight}
        </div>

        <div>
          <div className="narrow" style={{ fontSize: 11, color: "rgba(11,11,14,0.5)", letterSpacing: ".18em", marginBottom: 6 }}>
            ABOUT THIS TOUR
          </div>
          <p style={{ margin: 0, fontSize: 14.5, lineHeight: 1.55 }}>{trip.desc}</p>
        </div>

        <hr className="ticket-rule" style={{ color: "var(--ink)", margin: 0 }} />

        <div>
          <div className="narrow" style={{ fontSize: 11, color: "rgba(11,11,14,0.5)", letterSpacing: ".18em", marginBottom: 10 }}>
            WHAT'S INCLUDED
          </div>
          <ul className="clean" style={{ display: "flex", flexDirection: "column", gap: 8 }}>
            {trip.includes.map((it, i) => (
              <li key={i} style={{ display: "flex", alignItems: "flex-start", gap: 10, fontSize: 14 }}>
                <span style={{ color: "var(--red)", marginTop: 2 }}><IconCheck size={16} /></span>
                {it}
              </li>
            ))}
          </ul>
        </div>

        <div style={{ marginTop: "auto", paddingTop: 12 }}>
          <a href="#book" className="btn btn-primary btn-block btn-lg">
            Book Now <IconArrow size={16} />
          </a>
        </div>
      </div>
    </article>
  );
}

function Trips() {
  return (
    <section id="trips" className="section" style={{ background: "var(--bone)" }}>
      <style>{`
        .trips-header { display: grid; grid-template-columns: 1fr; gap: 24px; align-items: end; margin-bottom: 48px; }
        @media (min-width: 880px) {
          .trips-header { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 48px; align-items: center; }
        }
      `}</style>
      <div className="wrap">
        <div className="trips-header">
          <div>
            <div className="eyebrow" style={{ color: "var(--red)" }}>Choose your tide</div>
            <h2 className="display" style={{ fontSize: "clamp(28px, 4vw, 48px)", margin: "10px 0 0", lineHeight: 1.05 }}>
              Which Rafting Trip<br/>Is Right For Me?
            </h2>
          </div>
          <p style={{ margin: 0, fontSize: 16, lineHeight: 1.6, color: "rgba(11,11,14,0.7)", maxWidth: 540 }}>
            A true Nova Scotia Tidal Bore Rafting adventure! Experience the largest waves
            the Shubenacadie River has to offer on our 8 person Zodiac boats. Join us
            for a Rafting Tour on the worlds highest tides, and experience what the
            Bay of Fundy has to offer!
          </p>
        </div>

        <div style={{
          display: "grid",
          gridTemplateColumns: "repeat(auto-fit, minmax(290px, 1fr))",
          gap: 22,
          alignItems: "stretch",
        }}>
          {TRIPS.map((t, i) => <TripCard key={i} trip={t} />)}
        </div>
      </div>
    </section>
  );
}

/* ---------------------------------- HOW IT WORKS ---------------------------------- */
function HowItWorks() {
  const steps = [
    { n: "01", title: "Arrive & Gear Up", time: "30 min before tide",
      copy: "Meet us at our site in Green Oaks. We'll set you up with a wetsuit, booties, splash jacket, and helmet." },
    { n: "02", title: "Meet Your Guide", time: "10 min",
      copy: "Your river master walks you through the day and what to expect. No experience needed." },
    { n: "03", title: "Catch The Tidal Bore", time: "2 hrs on water",
      copy: "Ride the incoming Bay of Fundy tide as it surges up the Shubenacadie and builds wave after wave." },
    { n: "04", title: "Mud Slide & Celebrate", time: "Wrap & celebrate",
      copy: "Finish with a mud slide on the river bank, then warm up and swap stories." },
  ];

  return (
    <section id="how" style={{ background: "var(--white)", padding: "72px 0 96px" }}>
      <div className="wrap">
        <div style={{ display: "grid", gridTemplateColumns: "1fr", gap: 14, marginBottom: 56, maxWidth: 760 }}>
          <div className="eyebrow" style={{ color: "var(--red)" }}>How it works</div>
          <h2 className="display" style={{ fontSize: "clamp(28px, 4vw, 48px)", margin: 0 }}>
            Your Day On<br/>The Shubenacadie.
          </h2>
          <p style={{ margin: 0, fontSize: 17, color: "rgba(11,11,14,0.7)" }}>
            Never rafted before? You're in good company — most of our guests haven't either.
            It's four simple steps and a few hours you'll never forget.
          </p>
        </div>

        {/* Horizontal numbered timeline */}
        <div className="how-steps" style={{ position: "relative" }}>
          {/* connecting rule */}
          <div aria-hidden="true" className="how-rule" />
          <ol style={{
            listStyle: "none", margin: 0, padding: 0,
            display: "grid",
            gridTemplateColumns: "repeat(4, 1fr)",
            gap: 32,
            position: "relative",
          }}>
            {steps.map((s, i) => (
              <li key={i} style={{ display: "flex", flexDirection: "column", gap: 14 }}>
                <div style={{
                  width: 56, height: 56,
                  borderRadius: 99,
                  background: "var(--white)",
                  border: "1.5px solid var(--ink)",
                  display: "flex", alignItems: "center", justifyContent: "center",
                  fontFamily: "var(--font-display)", fontSize: 22, color: "var(--ink)",
                  position: "relative", zIndex: 1,
                }}>
                  {s.n}
                </div>
                <div className="narrow" style={{ fontSize: 11, color: "var(--red)", letterSpacing: ".18em" }}>{s.time}</div>
                <h3 className="display" style={{ fontSize: 22, margin: 0, lineHeight: 1.05 }}>{s.title}</h3>
                <p style={{ margin: 0, fontSize: 14.5, lineHeight: 1.55, color: "rgba(11,11,14,0.7)" }}>{s.copy}</p>
              </li>
            ))}
          </ol>
        </div>

        <div style={{
          marginTop: 40, paddingTop: 24, borderTop: "1px solid var(--line)",
          display: "flex", flexWrap: "wrap", alignItems: "center", justifyContent: "flex-end", gap: 16,
        }}>
          <a href="#book" className="btn btn-primary">Book your day <IconArrow size={16} /></a>
        </div>
      </div>
      <style>{`
        .how-rule {
          position: absolute;
          top: 28px; left: 28px; right: 28px; height: 1px;
          background: repeating-linear-gradient(to right, rgba(11,11,14,0.25) 0 6px, transparent 6px 12px);
          z-index: 0;
        }
        @media (max-width: 900px) {
          .how-steps ol { grid-template-columns: repeat(2, 1fr) !important; gap: 36px !important; }
          .how-rule { display: none; }
        }
        @media (max-width: 540px) {
          .how-steps ol { grid-template-columns: 1fr !important; }
        }
      `}</style>
    </section>
  );
}

/* ---------------------------------- WHY RAFT WITH US (merged credibility + welcome) ---------------------------------- */
function WhyUs() {
  const points = [
    { icon: <IconShield />, t: "Safety-first crew",
      c: "Transport Canada-certified guides, OFA-3 first-aid, marine radios on every boat." },
    { icon: <IconAward />,  t: "Award-winning",
      c: "Tripadvisor Best of the Best seven years running — Travelers' Choice 2020 – 2026." },
    { icon: <IconUsers />,  t: "Locally run",
      c: "Family-owned and operated. Same guides who grew up on this river still lead every trip." },
    { icon: <IconWave />,   t: "12+ years on the Shubie",
      c: "We've ridden the bore hundreds of times. Nobody knows this tide better." },
  ];

  return (
    <section id="about" className="dark section" style={{ position: "relative" }}>
      <div className="wrap">
        {/* Top: heading on left, story paragraphs on right */}
        <div className="whyus-top">
          <div>
            <div className="eyebrow" style={{ color: "var(--red)" }}>Why raft with us</div>
            <h2 className="display" style={{
              fontSize: "clamp(28px, 4vw, 48px)", margin: "10px 0 0",
              color: "var(--bone)", lineHeight: 0.95,
            }}>
              Two brothers.<br/>
              <span style={{ color: "var(--red)" }}>One stubborn wave.</span>
            </h2>
          </div>

          <div className="whyus-story" style={{ display: "flex", flexDirection: "column", gap: 14 }}>
            <p style={{ margin: 0, fontSize: 16.5, lineHeight: 1.6, color: "rgba(246,243,238,0.82)" }}>
              We started in 2013 with one Zodiac and a hunch that the Shubenacadie tidal bore
              was the most underrated adventure in Canada. A decade later, our crew has guided
              hundreds of first-timers to the wave — and still gets fired up every single tide.
            </p>
            <p style={{ margin: 0, fontSize: 16.5, lineHeight: 1.6, color: "rgba(246,243,238,0.82)" }}>
              We're proudly Nova Scotian, family-run, and obsessed with making sure every guest
              leaves muddy, grinning, and already planning their next trip.
            </p>
          </div>
        </div>

        {/* Bottom: photo collage + CTA */}
        <div className="whyus-bottom" style={{
          marginTop: 56,
          display: "grid", gap: 40, gridTemplateColumns: "1fr",
        }}>
          <div style={{
            display: "grid", gap: 10,
            gridTemplateColumns: "2fr 1fr",
            gridTemplateRows: "200px 200px",
          }} className="whyus-collage">
            <div style={{ gridRow: "1 / span 2", background: `var(--ink) url(${PHOTOS.splash}) center/cover` }} />
            <div style={{ background: `var(--ink) url(${PHOTOS.team}) center/cover` }} />
            <div style={{ background: `var(--ink) url(${PHOTOS.coast}) center/cover` }} />
          </div>

          <div style={{ display: "flex", flexDirection: "column", justifyContent: "center", gap: 20 }}>
            <div style={{ display: "flex", flexWrap: "wrap", gap: 14, alignItems: "center" }}>
              <a href="#book" className="btn btn-primary btn-lg">Book your trip <IconArrow size={16} /></a>
              <div style={{ display: "flex", alignItems: "center", gap: 10, fontSize: 13, color: "rgba(246,243,238,0.65)" }}>
                <IconLocation size={16} style={{ color: "var(--red)" }} />
                South Maitland, NS · 45 min from Halifax
              </div>
            </div>
          </div>
        </div>
      </div>
      <style>{`
        .whyus-top {
          display: grid;
          grid-template-columns: 1fr;
          gap: 28px;
          align-items: start;
        }
        @media (min-width: 820px) {
          .whyus-top {
            grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
            gap: 56px;
            align-items: center;
          }
          .whyus-story { max-width: 520px; }
        }
        @media (min-width: 960px) {
          .whyus-bottom { grid-template-columns: 1.1fr 1fr; align-items: start; gap: 56px; }
          .whyus-collage { grid-template-rows: 240px 240px; }
        }
      `}</style>
    </section>
  );
}

/* About section is intentionally merged into WhyUs above. Keep no-op exports so existing imports don't break. */
function About() { return null; }

/* ---------------------------------- INCLUDED + PRACTICAL ---------------------------------- */
function Included() {
  const list = [
    "Wetsuit, splash jacket, booties & helmet",
    "Coast Guard-approved life vest",
    "Professional river guide for every boat",
    "Tidal bore wave ride + mud slide session",
    "Hot showers + changing rooms",
    "Free parking at our base camp",
  ];
  return (
    <section id="tides" style={{ background: "var(--white)", borderTop: "1px solid var(--line)", padding: "64px 0" }}>
      <div className="wrap">
        <div className="included-row" style={{
          display: "grid",
          gap: 32,
          gridTemplateColumns: "1fr",
          alignItems: "center",
        }}>
          <div>
            <div className="eyebrow" style={{ color: "var(--red)" }}>What's included</div>
            <h2 className="display" style={{ fontSize: "clamp(22px, 3.2vw, 34px)", margin: "8px 0 0", lineHeight: 1 }}>
              Everything's included but<br/>your sense of adventure.
            </h2>
          </div>
          <ul className="clean" style={{
            display: "grid", gridTemplateColumns: "1fr 1fr", gap: "10px 24px",
            margin: 0, padding: 0,
          }}>
            {list.map((x, i) => (
              <li key={i} style={{ display: "flex", gap: 10, alignItems: "flex-start", fontSize: 14.5, lineHeight: 1.45 }}>
                <span style={{ color: "var(--red)", flexShrink: 0, marginTop: 1 }}><IconCheck size={16} /></span>
                {x}
              </li>
            ))}
          </ul>
        </div>
      </div>
      <style>{`
        @media (min-width: 900px) {
          .included-row { grid-template-columns: 1fr 1.2fr; gap: 56px; }
        }
      `}</style>
    </section>
  );
}

function Info({ icon, title, text }) {
  return (
    <div style={{ display: "flex", gap: 14, padding: "12px 0", borderBottom: "1px dashed var(--line)" }}>
      <div style={{ marginTop: 2 }}>{icon}</div>
      <div>
        <div className="narrow" style={{ fontSize: 11, letterSpacing: ".18em", color: "rgba(11,11,14,0.55)" }}>{title}</div>
        <div style={{ fontSize: 14.5, marginTop: 2 }}>{text}</div>
      </div>
    </div>
  );
}

Object.assign(window, {
  PHOTOS, ValueStrip, WhyRaftWithUs, TrustBar, Trips, HowItWorks, WhyUs, About, Included, Counter, Gallery, RiverMap,
});

/* ---------------------------------- GALLERY (slider) ---------------------------------- */
const GALLERY = [
  { src: PHOTOS.splash,   alt: "Big tidal bore splash" },
  { src: PHOTOS.team,     alt: "Group jumping in life vests on the mudflats" },
  { src: PHOTOS.action1,  alt: "Red Zodiac riding the leading wave" },
  { src: PHOTOS.coast,    alt: "Group covered in mud, peace signs all around" },
  { src: PHOTOS.action3,  alt: "Guests laughing as the wave hits the boat" },
  { src: PHOTOS.river,    alt: "Smiling guests on board" },
  { src: PHOTOS.mudSlide, alt: "Mud sliding the chocolate-brown flats" },
  { src: PHOTOS.rainy,    alt: "Guests in rain gear on a moody afternoon tide" },
  { src: PHOTOS.group,    alt: "The full crew, muddy and grinning" },
  { src: PHOTOS.raft,     alt: "Family waving from the red Zodiac" },
];

function Gallery() {
  const trackRef = React.useRef(null);
  const [i, setI] = React.useState(0);
  const total = GALLERY.length;

  // Scroll the track to a given index. When the jump crosses the loop boundary
  // (last→first), use instant-scroll so it doesn't rewind across the whole row;
  // otherwise smooth-scroll one slide at a time.
  const goTo = (nextIdx, opts = {}) => {
    const t = trackRef.current;
    if (!t) return;
    const child = t.children[nextIdx];
    if (!child) return;
    const isWrap = opts.wrap === true
      || (i === total - 1 && nextIdx === 0)
      || (i === 0 && nextIdx === total - 1);
    t.scrollTo({
      left: child.offsetLeft - t.offsetLeft,
      behavior: isWrap ? "auto" : "smooth",
    });
    setI(nextIdx);
  };

  const next = () => goTo((i + 1) % total);
  const prev = () => goTo((i - 1 + total) % total);

  // Sync state on manual scroll/swipe
  React.useEffect(() => {
    const track = trackRef.current;
    if (!track) return;
    let raf = null;
    const onScroll = () => {
      if (raf) return;
      raf = requestAnimationFrame(() => {
        raf = null;
        const x = track.scrollLeft;
        let nearest = 0, best = Infinity;
        Array.from(track.children).forEach((c, idx) => {
          const d = Math.abs(c.offsetLeft - track.offsetLeft - x);
          if (d < best) { best = d; nearest = idx; }
        });
        setI(nearest);
      });
    };
    track.addEventListener("scroll", onScroll, { passive: true });
    return () => track.removeEventListener("scroll", onScroll);
  }, []);

  // Autoplay — advances forward only. When wrapping back to first, jumps
  // without an animated rewind so the user never sees the slides scroll backwards.
  React.useEffect(() => {
    const id = setInterval(() => { goTo((i + 1) % total); }, 5500);
    return () => clearInterval(id);
  }, [i, total]);

  return (
    <section className="section" style={{
      background: "var(--bone)", position: "relative", overflow: "hidden",
      paddingTop: 32, paddingBottom: 64,
    }}>
      <div className="wrap">
        <div style={{ display: "flex", justifyContent: "space-between", alignItems: "end", flexWrap: "wrap", gap: 16, marginBottom: 28 }}>
          <div>
            <div className="eyebrow" style={{ color: "var(--red)" }}>The wave, the mud, the grin</div>
            <h2 className="display" style={{ fontSize: "clamp(26px, 3.6vw, 44px)", margin: "10px 0 0", lineHeight: 1.05 }}>
              The Shubie River<br/>Wranglers Experience.
            </h2>
          </div>
          <div style={{ display: "flex", alignItems: "center", gap: 12 }}>
            <div className="mono" style={{ fontSize: 12, color: "rgba(11,11,14,0.55)" }}>
              {String(i + 1).padStart(2, "0")} / {String(total).padStart(2, "0")}
            </div>
            <div style={{ display: "flex", gap: 6 }}>
              <button aria-label="Previous photo" onClick={prev}
                style={{ width: 44, height: 44, border: "1.5px solid var(--ink)", borderRadius: 2, display: "flex", alignItems: "center", justifyContent: "center" }}>
                <IconArrow size={18} style={{ transform: "rotate(180deg)" }} />
              </button>
              <button aria-label="Next photo" onClick={next}
                style={{ width: 44, height: 44, background: "var(--red)", color: "#fff", borderRadius: 2, display: "flex", alignItems: "center", justifyContent: "center" }}>
                <IconArrow size={18} />
              </button>
            </div>
          </div>
        </div>
      </div>

      {/* Track — horizontal scroll with snap */}
      <div ref={trackRef} className="gallery-track" style={{
        display: "flex",
        gap: 14,
        padding: "0 max(20px, calc((100vw - 1240px) / 2 + 48px))",
        overflowX: "auto",
        scrollSnapType: "x mandatory",
        scrollbarWidth: "none",
        WebkitOverflowScrolling: "touch",
      }}>
        {GALLERY.map((g, idx) => (
          <figure key={idx} className="gallery-item" style={{
            flex: "0 0 auto",
            margin: 0,
            aspectRatio: "4/3",
            background: `var(--ink) url(${g.src}) center/cover`,
            scrollSnapAlign: "start",
          }} />
        ))}
      </div>

      {/* Dots */}
      <div className="wrap" style={{ marginTop: 22, display: "flex", justifyContent: "center", gap: 8 }}>
        {GALLERY.map((_, idx) => (
          <button key={idx} aria-label={`Go to photo ${idx + 1}`} onClick={() => goTo(idx, { wrap: true })} style={{
            width: idx === i ? 32 : 10, height: 4, borderRadius: 2,
            background: idx === i ? "var(--red)" : "rgba(11,11,14,0.25)",
            transition: "width .25s ease, background .25s ease",
            border: 0, padding: 0,
          }} />
        ))}
      </div>

      {/* CTA */}
      <div className="wrap" style={{ marginTop: 28, display: "flex", flexWrap: "wrap", alignItems: "center", justifyContent: "center", gap: 14 }}>
        <a href="#book" className="btn btn-primary btn-lg">
          Book your trip <IconArrow size={16} />
        </a>
        <a href="#how" className="btn btn-ghost btn-lg">
          See how a day runs <IconArrow size={14} />
        </a>
      </div>

      <style>{`
        .gallery-track::-webkit-scrollbar { display: none; }
        .gallery-item { width: 78vw; }
        @media (min-width: 720px) {
          .gallery-item { width: clamp(360px, 42vw, 560px); }
        }
      `}</style>
    </section>
  );
}

/* ---------------------------------- RIVER MAP (full-width image) ---------------------------------- */
function RiverMap() {
  return (
    <section style={{ background: "var(--ink)", padding: 0, lineHeight: 0 }}>
      <img
        src="assets/photos/river-map.webp"
        alt="Rafting with River Wranglers — illustrated map of the Shubenacadie River from Maitland to Urbania, marking mud sliding, swim spots, rapids and tidal-bore landmarks."
        style={{ display: "block", width: "100%", height: "auto" }}
      />
    </section>
  );
}
