const { useState, useEffect, useRef, useMemo } = React;

// ---------- Icons ----------
const Icon = {
  chevron: (p) => <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" {...p}><polyline points="6 9 12 15 18 9"/></svg>,
  close: (p) => <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" {...p}><line x1="5" y1="5" x2="19" y2="19"/><line x1="19" y1="5" x2="5" y2="19"/></svg>,
  a11y: (p) => <svg viewBox="0 0 24 24" fill="currentColor" {...p}><circle cx="12" cy="4.5" r="2"/><path d="M5 9h14v2.2l-5.3 1v9.3h-2.1v-5h-1.2v5H8.3V12.2L3 11.2V9z" /></svg>,
  textSize: (p) => <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" {...p}><path d="M4 7V5h10v2M9 5v14M6 19h6"/><path d="M15 11V9h6v2M18 9v10M16 19h4"/></svg>,
  lineH: (p) => <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" {...p}><line x1="3" y1="6" x2="21" y2="6"/><line x1="3" y1="12" x2="21" y2="12"/><line x1="3" y1="18" x2="21" y2="18"/></svg>,
  align: (p) => <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" {...p}><line x1="3" y1="6" x2="21" y2="6"/><line x1="3" y1="12" x2="15" y2="12"/><line x1="3" y1="18" x2="18" y2="18"/></svg>,
  font: (p) => <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" {...p}><path d="M6 19V6h5a3 3 0 0 1 0 6H6"/><path d="M6 12h6a3 3 0 0 1 0 6H6"/></svg>,
  contrast: (p) => <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" {...p}><circle cx="12" cy="12" r="9"/><path d="M12 3v18a9 9 0 0 0 0-18z" fill="currentColor"/></svg>,
  gray: (p) => <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" {...p}><path d="M12 3a9 9 0 1 0 0 18c-2 0-4-4-4-9s2-9 4-9z" fill="currentColor"/><circle cx="12" cy="12" r="9"/></svg>,
  image: (p) => <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" {...p}><rect x="3" y="5" width="18" height="14" rx="2"/><line x1="3" y1="5" x2="21" y2="19"/></svg>,
  motion: (p) => <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" {...p}><rect x="3" y="6" width="14" height="12" rx="2"/><line x1="3" y1="6" x2="21" y2="19"/><path d="M17 10l4-2v8l-4-2"/></svg>,
  link: (p) => <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" {...p}><path d="M10 14a4 4 0 0 0 5.66 0l3-3a4 4 0 1 0-5.66-5.66l-1.5 1.5"/><path d="M14 10a4 4 0 0 0-5.66 0l-3 3a4 4 0 1 0 5.66 5.66l1.5-1.5"/></svg>,
  outline: (p) => <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" {...p}><rect x="3" y="3" width="8" height="8" rx="1"/><rect x="13" y="3" width="8" height="8" rx="1"/><rect x="3" y="13" width="8" height="8" rx="1"/><rect x="13" y="13" width="8" height="8" rx="1"/></svg>,
  eye: (p) => <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" {...p}><path d="M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12z"/><circle cx="12" cy="12" r="3"/><line x1="3" y1="3" x2="21" y2="21"/></svg>,
  reset: (p) => <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" {...p}><path d="M3 12a9 9 0 1 0 3-6.7"/><polyline points="3 4 3 10 9 10"/></svg>,
};

// ---------- Header ----------
function Header({ lang, setLang, onHeroRef, onBook, t, navOpen, setNavOpen }) {
  const [scrolled, setScrolled] = useState(false);
  const [onHero, setOnHero] = useState(true);
  // Two-phase close so the liquid animation can play out before unmount
  const [navClosing, setNavClosing] = useState(false);
  useEffect(() => {
    const onScroll = () => {
      const y = window.scrollY;
      setScrolled(y > 40);
      setOnHero(y < (onHeroRef?.current?.offsetHeight || 800) - 120);
    };
    onScroll();
    window.addEventListener("scroll", onScroll, { passive: true });
    return () => window.removeEventListener("scroll", onScroll);
  }, []);
  const closeNav = () => {
    if (!navOpen || navClosing) return;
    setNavClosing(true);
    setTimeout(() => {
      setNavOpen(false);
      setNavClosing(false);
    }, 520);
  };
  const toggleNav = () => {
    if (navOpen) closeNav();
    else setNavOpen(true);
  };
  // Cross-page-aware anchors: from blog.html (also served as /blog), prepend index.html
  const path = typeof window !== "undefined" ? window.location.pathname : "";
  const onBlog = /(?:^|\/)blog(?:\.html)?\/?$/.test(path);
  const onHome = !onBlog;
  const homeBase = onHome ? "" : "index.html";
  const home = (anchor) => `${homeBase}${anchor}`;
  return (
    <header className={`site-header ${scrolled ? "scrolled" : ""} ${onHero && !scrolled && onHome ? "on-hero" : ""}`}>
      <div className="container inner">
        <a href={onHome ? "#top" : "index.html"} className="brand unstyled" onClick={closeNav} aria-label="Seecamping Langau – Startseite">
          <BrandMark />
          <span className="brand-text">Seecamping Langau</span>
        </a>
        <nav className={`nav-links ${navOpen ? (navClosing ? "is-mobile-closing" : "is-mobile-open") : ""}`} aria-label={t.nav.home}>
          <a href={home("#places")} onClick={closeNav}>{t.nav.places}</a>
          <a href={home("#activities")} onClick={closeNav}>{t.nav.activities}</a>
          <a href={home("#bistro")} onClick={closeNav}>{t.nav.bistro}</a>
          <a href={home("#about")} onClick={closeNav}>{t.nav.about}</a>
          <a href={home("#faq")} onClick={closeNav}>{t.nav.faq}</a>
          <a href="blog.html" onClick={closeNav} aria-current={!onHome ? "page" : undefined}>{t.nav.blog}</a>
        </nav>
        <div className="nav-right">
          <button className="lang-toggle unstyled" onClick={() => setLang(lang === "de" ? "en" : "de")} aria-label={`Sprache wechseln zu ${lang === "de" ? "Englisch" : "Deutsch"}`}>
            <span className={lang === "de" ? "active" : ""}>DE</span>
            <span className="sep">/</span>
            <span className={lang === "en" ? "active" : ""}>EN</span>
          </button>
          <button className="btn btn-primary btn-header" onClick={onBook}>{t.nav.book}</button>
          <button className="nav-burger unstyled" onClick={toggleNav} aria-label={navOpen ? "Menü schließen" : "Menü öffnen"} aria-expanded={navOpen}>
            <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8">
              {navOpen
                ? <><line x1="5" y1="5" x2="19" y2="19"/><line x1="19" y1="5" x2="5" y2="19"/></>
                : <><line x1="4" y1="7" x2="20" y2="7"/><line x1="4" y1="12" x2="20" y2="12"/><line x1="4" y1="17" x2="20" y2="17"/></>}
            </svg>
          </button>
        </div>
      </div>
    </header>
  );
}

// ---------- NavLiquid: gooey metaball background for the burger drawer ----------
function NavLiquid() {
  return (
    <div className="nav-liquid" aria-hidden="true">
      <svg className="nav-liquid-svg" viewBox="0 0 400 800" preserveAspectRatio="xMidYMid slice" xmlns="http://www.w3.org/2000/svg">
        <defs>
          <filter id="nav-goo">
            {/* Blur the shapes */}
            <feGaussianBlur in="SourceGraphic" stdDeviation="22"/>
            {/* Threshold the blur to create gooey borders */}
            <feColorMatrix values="
              1 0 0 0 0
              0 1 0 0 0
              0 0 1 0 0
              0 0 0 28 -14"/>
          </filter>
          <radialGradient id="nav-blob-1" cx="50%" cy="50%" r="50%">
            <stop offset="0%" stopColor="#7da062"/>
            <stop offset="100%" stopColor="#3d5b2c"/>
          </radialGradient>
          <radialGradient id="nav-blob-2" cx="50%" cy="50%" r="50%">
            <stop offset="0%" stopColor="#5e8a8d"/>
            <stop offset="100%" stopColor="#2d5052"/>
          </radialGradient>
          <radialGradient id="nav-blob-3" cx="50%" cy="50%" r="50%">
            <stop offset="0%" stopColor="#b58a48"/>
            <stop offset="100%" stopColor="#7a5a30"/>
          </radialGradient>
        </defs>
        <g filter="url(#nav-goo)" opacity="0.55">
          <circle className="blob b1" cx="120" cy="160" r="78" fill="url(#nav-blob-1)"/>
          <circle className="blob b2" cx="280" cy="320" r="92" fill="url(#nav-blob-2)"/>
          <circle className="blob b3" cx="100" cy="520" r="84" fill="url(#nav-blob-3)"/>
          <circle className="blob b4" cx="300" cy="680" r="70" fill="url(#nav-blob-1)"/>
          <circle className="blob b5" cx="200" cy="420" r="60" fill="url(#nav-blob-2)"/>
        </g>
      </svg>
    </div>
  );
}

function BrandMark() {
  return (
    <svg width="34" height="34" viewBox="0 0 34 34" style={{ flexShrink: 0 }}>
      <circle cx="17" cy="17" r="16" fill="none" stroke="currentColor" strokeWidth="1"/>
      <path d="M4 22 C 9 18, 13 24, 17 20 S 25 16, 30 22" fill="none" stroke="currentColor" strokeWidth="1.2"/>
      <path d="M4 25 C 9 21, 13 27, 17 23 S 25 19, 30 25" fill="none" stroke="currentColor" strokeWidth="1.2" opacity="0.6"/>
      <path d="M11 13 L14 9 L17 13 Z M15 15 L19 8 L23 15 Z" fill="currentColor" opacity="0.9"/>
    </svg>
  );
}

// ---------- Hero ----------
function Hero({ t, onBook, heroRef }) {
  const [imgIdx, setImgIdx] = React.useState(0);
  const images = [
    "assets/img/hero-1.jpg",
    "assets/img/hero-2.jpg",
    "assets/img/hero-3.jpg",
  ];

  React.useEffect(() => {
    const reduceMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
    const stopMotion = document.body.classList.contains("a11y-stop-motion");
    if (reduceMotion || stopMotion) return;
    const id = setInterval(() => setImgIdx(i => (i + 1) % images.length), 6000);
    return () => clearInterval(id);
  }, []);

  return (
    <section className="hero hero-full" id="top" ref={heroRef}>
      <div className="hero-bg">
        {images.map((src, i) => (
          <div
            key={src}
            className={`hero-bg-img ${i === imgIdx ? "is-active" : ""}`}
            style={{ backgroundImage: `url('${src}')` }}
            aria-hidden="true"
          />
        ))}
        <div className="hero-bg-shade" aria-hidden="true"/>
      </div>

      <div className="hero-center">
        <BrandMarkLarge/>
        <h1 className="hero-wordmark">Seecamping Langau</h1>
        <div className="hero-sub">{t.meta.region} · {t.hero.kicker}</div>
        <div className="hero-cta-row">
          <button className="btn btn-inverse btn-arrow" onClick={onBook}>{t.hero.bookCta}</button>
          <a href="#places" className="btn btn-ghost hero-btn-ghost">{t.hero.scrollCta}</a>
        </div>
      </div>
      <a href="#stats" className="hero-scroll-cue" aria-label={t.hero.scrollCta}>
        <svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" strokeWidth="1.6" aria-hidden="true">
          <path d="M6 9l6 6 6-6"/>
        </svg>
      </a>
    </section>
  );
}

// ---------- Stats strip (lives between Hero and Gallery) ----------
function StatsStrip({ t }) {
  return (
    <section className="stats-strip" id="stats" aria-label="Eckdaten">
      <div className="container">
        <div className="stats-row">
          {t.hero.stats.map((s, i) => (
            <div key={i} className="stats-item">
              <div className="k">{s.k}</div>
              <div className="v">{s.v}</div>
            </div>
          ))}
        </div>
      </div>
    </section>
  );
}

function BrandMarkLarge() {
  return (
    <svg className="hero-mark" viewBox="0 0 120 120" aria-hidden="true">
      <circle cx="60" cy="60" r="56" fill="none" stroke="currentColor" strokeWidth="1.4"/>
      <path d="M14 78 C 30 66, 46 86, 60 74 S 90 58, 106 78"
            fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round"/>
      <path d="M14 88 C 30 76, 46 96, 60 84 S 90 68, 106 88"
            fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" opacity="0.55"/>
      <path d="M38 50 L48 34 L58 50 Z M52 56 L66 30 L80 56 Z"
            fill="currentColor" opacity="0.92"/>
    </svg>
  );
}

// ---------- Gallery ----------
function Gallery({ t }) {
  const tiles = [
    { span: "big", label: "Bergwerksee · Morgenstimmung", tone: "teal" },
    { span: "tall", label: "Kinder am Naturstrand", tone: "moss" },
    { span: "", label: "Stellplatz am Waldrand", tone: "ocker" },
    { span: "", label: "Seehütte · Steg", tone: "dark" },
    { span: "wide", label: "Freizeithaus · Sonnenterrasse", tone: "" },
    { span: "", label: "Wasserski am Abend", tone: "teal" },
  ];
  return (
    <section className="gallery" id="gallery">
      <div className="container">
        <div className="section-head">
          <div className="left">
            <div className="kicker">Bilder vom See</div>
          </div>
          <h2 className="h-1">Ein Campingplatz zum Anschauen.</h2>
        </div>
        <div className="gallery-grid">
          {tiles.map((g, i) => (
            <div key={i} className={`g-tile g-${g.span} ph ${g.tone}`} data-label={g.label}>
              <div className="g-meta">
                <span className="g-num">{String(i+1).padStart(2, "0")}</span>
                <span className="g-name">{g.label}</span>
              </div>
            </div>
          ))}
        </div>
      </div>
    </section>
  );
}

// ---------- Intro ----------
function Intro({ t }) {
  return (
    <section className="intro" id="intro">
      <div className="container intro-grid">
        <div className="intro-image ph moss" data-label="Bergwerksee · Drohnenaufnahme"></div>
        <div className="intro-text">
          <div className="kicker">{t.intro.kicker}</div>
          <h2 className="h-1">{t.intro.title}</h2>
          {t.intro.body.map((p, i) => <p key={i} className="body">{p}</p>)}
          <div className="intro-sig">{t.intro.signature}</div>
        </div>
      </div>
    </section>
  );
}

// ---------- Places ----------
function Places({ t, onBook }) {
  const labels = ["Stellplatz", "Zeltwiese", "Chalet Innen", "Safari bei Nacht", "Seehütte am Steg"];
  const tones = ["moss", "teal", "ocker", "dark", ""];
  const greenTones = ["tone-1", "tone-2", "tone-3", "tone-4", "tone-5"];
  const scrollerRef = useRef(null);
  const [activeIdx, setActiveIdx] = useState(0);
  const total = t.places.items.length;

  const scrollToIdx = (idx) => {
    const sc = scrollerRef.current;
    if (!sc) return;
    // Wrap around: -1 → last, total → 0
    const wrapped = ((idx % total) + total) % total;
    const cards = sc.querySelectorAll(".place-card");
    const target = cards[wrapped];
    if (target) target.scrollIntoView({ behavior: "smooth", inline: "start", block: "nearest" });
  };

  useEffect(() => {
    const sc = scrollerRef.current;
    if (!sc) return;
    const onScroll = () => {
      const cards = sc.querySelectorAll(".place-card");
      let best = 0, bestDist = Infinity;
      const center = sc.scrollLeft + sc.clientWidth / 2;
      cards.forEach((c, i) => {
        const cardCenter = c.offsetLeft + c.offsetWidth / 2;
        const d = Math.abs(cardCenter - center);
        if (d < bestDist) { bestDist = d; best = i; }
      });
      setActiveIdx(best);
    };
    sc.addEventListener("scroll", onScroll, { passive: true });
    return () => sc.removeEventListener("scroll", onScroll);
  }, []);
  return (
    <section className="places" id="places">
      <div className="container">
        <div className="section-head">
          <div className="left">
            <div className="kicker">{t.places.kicker}</div>
          </div>
          <h2 className="h-1">{t.places.title}</h2>
        </div>
      </div>
      <div className="container">
        <div className="places-grid" ref={scrollerRef}>
          {t.places.items.map((p, i) => (
            <button
              className={`place-card unstyled ${greenTones[i]}`}
              type="button"
              key={p.id}
              onClick={onBook}
              aria-label={`${p.name}: ${p.sub}, ${p.price} ${p.unit}, jetzt buchen`}>
              <div className="code">{p.code} / {String(i+1).padStart(2,"0")}</div>
              <div className={`img ph ${tones[i]}`} data-label={labels[i]} role="img" aria-label={labels[i]}></div>
              <div>
                <div className="name">{p.name}</div>
                <div className="sub">{p.sub}</div>
              </div>
              <div className="size mono">{p.size}</div>
              <div className="note">{p.note}</div>
              <div className="ams">
                {p.amenities.slice(0, 3).map(a => <span className="am" key={a}>{a}</span>)}
              </div>
              <div className="price-row">
                <span className="price">{p.price}</span>
                <span className="unit">{p.unit}</span>
              </div>
              <span className="card-cta" aria-hidden="true">{t.places.bookCta} →</span>
            </button>
          ))}
        </div>
        <div className="places-carousel-controls" aria-label="Karussell-Navigation">
          <button
            className="carousel-btn unstyled"
            onClick={() => scrollToIdx(activeIdx - 1)}
            aria-label="Vorherige Unterkunft">
            <svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" strokeWidth="1.8" aria-hidden="true">
              <polyline points="15 6 9 12 15 18"/>
            </svg>
          </button>
          <div className="carousel-dots" role="tablist">
            {t.places.items.map((p, i) => (
              <button
                key={p.id}
                className={`carousel-dot ${i === activeIdx ? "active" : ""}`}
                onClick={() => scrollToIdx(i)}
                role="tab"
                aria-selected={i === activeIdx}
                aria-label={`${i + 1}. ${p.name}`}/>
            ))}
          </div>
          <button
            className="carousel-btn unstyled"
            onClick={() => scrollToIdx(activeIdx + 1)}
            aria-label="Nächste Unterkunft">
            <svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" strokeWidth="1.8" aria-hidden="true">
              <polyline points="9 6 15 12 9 18"/>
            </svg>
          </button>
        </div>
        <div className="places-foot">
          <div className="muted">Alle Preise exkl. Ortstaxe € 2,20 / Person / Nacht. Hunde € 4 / Nacht. Kinder bis 5 Jahre frei.</div>
          <button className="btn btn-primary btn-arrow" onClick={onBook}>{t.places.bookCta}</button>
        </div>
      </div>
    </section>
  );
}

// ---------- Activities ----------
function Activities({ t }) {
  return (
    <section className="activities" id="activities">
      <div className="container">
        <div className="section-head">
          <div className="left">
            <div className="kicker" style={{ color: "rgba(255,255,255,0.6)" }}>{t.activities.kicker}</div>
          </div>
          <h2 className="h-1" style={{ color: "var(--paper)" }}>{t.activities.title}</h2>
        </div>
      </div>
      <div className="container">
        <div className="act-grid">
          {t.activities.groups.map((g, i) => (
            <div className="act-col" key={i}>
              <h3>{g.name}</h3>
              <ul>
                {g.items.map(it => <li key={it}>{it}</li>)}
              </ul>
            </div>
          ))}
        </div>
      </div>
    </section>
  );
}

// ---------- Bistro ----------
function Bistro({ t }) {
  return (
    <section className="bistro" id="bistro">
      <div className="container bistro-grid">
        <div className="bistro-img ph ocker" data-label="Sonnenterrasse · Freizeithaus"></div>
        <div className="bistro-text">
          <div className="kicker">{t.bistro.kicker}</div>
          <h2 className="h-1" style={{ marginTop: 16, marginBottom: 20, maxWidth: "14ch" }}>{t.bistro.title}</h2>
          <p className="body">{t.bistro.body}</p>
          <div className="menu-card">
            <div className="menu-head">
              <h3>Aus der Küche</h3>
              <span className="hours">11:30 – 21:00</span>
            </div>
            {t.bistro.menu.map((m, i) => (
              <div key={i} className="menu-row">
                <div className="line"><span>{m.line}</span></div>
                <div className="price">{m.price}</div>
              </div>
            ))}
          </div>
        </div>
      </div>
    </section>
  );
}

// ---------- About ----------
function About({ t }) {
  return (
    <section className="about" id="about">
      <div className="container about-grid">
        <div className="about-text">
          <div className="kicker">{t.about.kicker}</div>
          <h2 className="h-1" style={{ marginTop: 16, marginBottom: 28, maxWidth: "12ch" }}>{t.about.title}</h2>
          {t.about.body.map((p, i) => <p key={i} className="body">{p}</p>)}
          <div className="timeline">
            {t.about.timeline.map((r, i) => (
              <div className="tl-row" key={i}>
                <div className="y">{r.y}</div>
                <div className="t">{r.t}</div>
              </div>
            ))}
          </div>
        </div>
        <div className="about-img ph dark" data-label="Tischlerei Allram · seit 1932"></div>
      </div>
    </section>
  );
}

// ---------- FAQ ----------
function FAQ({ t }) {
  const [open, setOpen] = useState(-1);
  return (
    <section className="faq" id="faq">
      <div className="container faq-grid">
        <div>
          <div className="kicker">{t.faq.kicker}</div>
          <h2 className="h-1" style={{ marginTop: 16 }}>{t.faq.title}</h2>
        </div>
        <div className="faq-list">
          {t.faq.items.map((it, i) => {
            const isOpen = open === i;
            return (
              <div key={i} className={`faq-item ${isOpen ? "open" : ""}`}>
                <button
                  className="faq-q unstyled"
                  onClick={() => setOpen(isOpen ? -1 : i)}
                  aria-expanded={isOpen}
                  aria-controls={`faq-a-${i}`}
                  id={`faq-q-${i}`}>
                  <span>{it.q}</span><span className="plus" aria-hidden="true">{isOpen ? "–" : "+"}</span>
                </button>
                <div
                  id={`faq-a-${i}`}
                  className="faq-a"
                  role="region"
                  aria-labelledby={`faq-q-${i}`}
                  hidden={!isOpen}>
                  {it.a}
                </div>
              </div>
            );
          })}
        </div>
      </div>
    </section>
  );
}

// ---------- CTA band ----------
function CTABand({ t, onBook }) {
  return (
    <section className="cta-band">
      <div className="container inner">
        <h2>Der See wartet{"\u00A0"}nicht — <em style={{ fontStyle: "italic", color: "oklch(0.85 0.08 95)" }}>Ihr Platz schon.</em></h2>
        <div>
          <p>{t.hero.lede}</p>
          <div className="ctas">
            <button className="btn btn-inverse btn-arrow" onClick={onBook}>{t.nav.book}</button>
            <a href={`tel:${t.footer.phone.replace(/\s/g, "")}`} className="btn btn-ghost" style={{ color: "var(--paper)", borderColor: "rgba(255,255,255,0.3)" }}>{t.footer.phone}</a>
          </div>
        </div>
      </div>
    </section>
  );
}

// ---------- Footer ----------
function Footer({ t, onLegal }) {
  const path = typeof window !== "undefined" ? window.location.pathname : "";
  const onBlog = /(?:^|\/)blog(?:\.html)?\/?$/.test(path);
  const onHome = !onBlog;
  const homeBase = onHome ? "" : "index.html";
  const home = (anchor) => `${homeBase}${anchor}`;
  return (
    <footer className="footer">
      <div className="container">
        <div className="footer-grid">
          <div>
            <div className="footer-brand">Seecamping<br/>Langau.</div>
            <address className="footer-address" style={{ fontStyle: "normal" }}>{t.footer.col1}</address>
          </div>
          <nav aria-label="Footer Navigation">
            <h3>{t.nav.home}</h3>
            <ul>
              <li><a href={home("#places")}>{t.nav.places}</a></li>
              <li><a href={home("#activities")}>{t.nav.activities}</a></li>
              <li><a href={home("#bistro")}>{t.nav.bistro}</a></li>
              <li><a href={home("#about")}>{t.nav.about}</a></li>
              <li><a href={home("#faq")}>{t.nav.faq}</a></li>
              <li><a href="blog.html">{t.nav.blog}</a></li>
            </ul>
          </nav>
          <div>
            <h3>Kontakt</h3>
            <ul>
              <li><a href={`tel:${t.footer.phone.replace(/\s/g,"")}`}>{t.footer.phone}</a></li>
              <li><a href={`mailto:${t.footer.mail}`}>{t.footer.mail}</a></li>
              <li>{t.footer.hours}</li>
            </ul>
          </div>
          <div>
            <h3>Rechtliches</h3>
            <ul>
              {t.footer.legal.map(l => (
                <li key={l.id}>
                  <button className="unstyled" onClick={() => onLegal(l.id)}>{l.label}</button>
                </li>
              ))}
            </ul>
          </div>
        </div>
        <div className="footer-bot">
          <div>© {new Date().getFullYear()} Seecamping Langau · Familie Allram</div>
        </div>
      </div>
    </footer>
  );
}

Object.assign(window, { Header, Hero, StatsStrip, Gallery, Intro, Places, Activities, Bistro, About, FAQ, CTABand, Footer, Icon });
