/* global React, ReactDOM, useTweaks, TweaksPanel, TweakSection, TweakColor, TweakRadio, TweakToggle */
const { useState, useEffect, useRef, useMemo } = React;

/* ----------------------------------------------------------------
   COPY — DE / IT
---------------------------------------------------------------- */
const COPY = {
  de: {
    nav: ["Leistungen", "Referenzen", "Team", "FAQ", "Termin", "Kontakt"],
    cta: "Anfrage senden",
    heroEyebrow: "Elektriker in Mölten · seit 2019",
    heroTitle1: "Ein Anruf,",
    heroTitle2: "ein Termin,",
    heroTitle3: "fertig.",
    heroSub:
    "Elektroinstallationen, Beleuchtung, Antennentechnik, Glasfaser und Photovoltaik — persönlich, zuverlässig und direkt erreichbar in Mölten.",
    heroPrimary: "Projekt anfragen",
    heroSecondary: "Leistungen ansehen",
    servicesEyebrow: "04 Leistungsbereiche",
    servicesTitle: "Vier Kabel.\nEin Anschluss.",
    servicesSub:
    "Vom Sicherungskasten bis zur Photovoltaikanlage am Dach — alles aus einer Hand, ohne Subunternehmer.",
    services: [
    { slug: "elektro", n: "01", title: "Elektro & Beleuchtung", body: "Neu- und Umbauten, Schaltschränke, Smart-Home, dimmbare Lichtszenen und Aussenbeleuchtung.", items: ["Hausinstallation", "Schaltanlagen", "KNX / Smart Home", "Notbeleuchtung"] },
    { slug: "antenne", n: "02", title: "Antennentechnik", body: "SAT-, DVB-T- und Multischalter-Anlagen für Einzelhaus oder ganze Wohnanlagen.", items: ["SAT & Multifeed", "DVB-T2", "Multischalter", "Signalmessung"] },
    { slug: "glasfaser", n: "03", title: "Glasfaser", body: "FTTH-Hausanschluss, Spleißen, Patchen und Inbetriebnahme — bis 10 Gbit ins Wohnzimmer.", items: ["FTTH Hausanschluss", "Spleißarbeiten", "LAN-Verkabelung Cat6/7", "WLAN Mesh"] },
    { slug: "photovoltaik", n: "04", title: "Photovoltaik", body: "Auslegung, Montage, Speicher und Wallbox — schlüsselfertig inkl. Netzanmeldung.", items: ["Module & Wechselrichter", "Batteriespeicher", "Wallbox", "Monitoring"] }],

    statEyebrow: "Zahlen",
    stats: [
    { n: "7+", l: "Jahre Erfahrung" },
    { n: "420+", l: "Anlagen installiert" },
    { n: "48h", l: "Reaktionszeit" }],

    refEyebrow: "Referenzen",
    refTitle: "Ausgewählte Anlagen.",
    refSub: "Ein kleiner Querschnitt aus den letzten Aufträgen rund um Mölten, Bozen und das Etschtal.",
    refs: [
    { img: "assets/refs/03-led.jpg", tag: "Beleuchtung", title: "LED-Decke Wohnung", meta: "Indirekt · Holzdecke · 2024" },
    { img: "assets/refs/04-kasten.jpg", tag: "Elektro", title: "Aussenverteilung", meta: "Steckdosenkasten · CEE · 2024" },
    { img: "assets/refs/05-dach.jpg", tag: "Elektro", title: "Rohrinstallation Dach", meta: "Vorbereitung PV · 2024" },
    { img: "assets/refs/06-antenne.jpg", tag: "Antenne", title: "Antennenanlage", meta: "DVB-T2 + SAT + Eolo · 2024" },
    { img: "assets/refs/07-led.jpg", tag: "Beleuchtung", title: "LED-Profil Bad", meta: "Lichtrahmen + Akzent · 2024" },
    { img: "assets/refs/08-kueche.jpg", tag: "Beleuchtung", title: "Profiküche", meta: "Panel-Licht + Lastverteilung · 2023" },
    { img: "assets/refs/09-verteiler.jpg", tag: "Elektro", title: "Verteilerkasten", meta: "Hauptverteilung · Messgerät · 2024" },
    { img: "assets/refs/10-led.jpg", tag: "Beleuchtung", title: "LED-Stube", meta: "Holzbalken indirekt · 2023" },
    { img: "assets/refs/15-pv.jpg", tag: "Photovoltaik", title: "PV-Anlage am Hofdach", meta: "Aufdach · Mölten · 2024" }],

    aboutEyebrow: "Über uns",
    aboutTitle: "ELEKTRIX.\nDein Elektriker am Berg.",
    aboutBody1:
    "Seit 2019 verlege ich Kabel, montiere Schaltschränke und schraube Module aufs Dach — von der kleinen Lichtschalterumstellung bis zur kompletten Hofsanierung.",
    aboutBody2:
    "Werkstatt in Mölten, 1.140 m über Bozen. Kurze Wege im ganzen Etschtal, Sarntal und Burggrafenamt. Ein Mann, ein Anruf, ein Termin — kein Callcenter.",
    aboutMeta: [
    ["Inhaber", "Markus Unterkofler"],
    ["Sitz", "39010 Mölten (BZ)"],
    ["Tätig seit", "2019"],
    ["Sprachen", "Deutsch · Italiano"]],

    processEyebrow: "Ablauf",
    processTitle: "Vom ersten Anruf\nbis zur Inbetriebnahme.",
    process: [
    { n: "01", t: "Anruf oder Mail", b: "Du beschreibst kurz was ansteht. Ich melde mich innerhalb von 48 Stunden zurück." },
    { n: "02", t: "Lokalaugenschein", b: "Termin vor Ort. Wir gehen die Anlage durch, ich messe nach und nehme Foto-Notizen." },
    { n: "03", t: "Angebot", b: "Schriftlich, gegliedert nach Position, mit Material- und Arbeitskosten getrennt." },
    { n: "04", t: "Ausführung", b: "Sauber, pünktlich, mit Schutzfolie. Übergabe inkl. Konformitätserklärung." }],

    contactEyebrow: "Kontakt",
    contactTitle: "Anfrage senden.",
    contactSub:
    "Schick mir kurz worum es geht — ich melde mich werktags innerhalb von 48 Stunden zurück.",
    form: {
      name: "Name",
      email: "E-Mail",
      phone: "Telefon",
      topic: "Bereich",
      message: "Worum geht's?",
      send: "Anfrage senden",
      sent: "Danke! Deine Anfrage ist angekommen."
    },
    topics: ["Elektro & Beleuchtung", "Antennentechnik", "Glasfaser", "Photovoltaik", "Etwas anderes"],
    footerTag: "Elektro · Antenne · Glasfaser · Photovoltaik",
    footerRights: "© 2026 ELEKTRIX des Unterkofler Markus · MwSt-Nr. IT 0000 0000 000"
  },
  it: {
    nav: ["Servizi", "Lavori", "Team", "FAQ", "Appuntamento", "Contatti"],
    cta: "Richiedi preventivo",
    heroEyebrow: "Elettricista a Meltina · dal 2019",
    heroTitle1: "Una chiamata,",
    heroTitle2: "un appuntamento,",
    heroTitle3: "fatto.",
    heroSub:
    "Impianti elettrici, illuminazione, antenne, fibra ottica e fotovoltaico — disponibile di persona, a Meltina e in tutto l'Alto Adige.",
    heroPrimary: "Richiedi preventivo",
    heroSecondary: "Vedi i servizi",
    servicesEyebrow: "04 aree di intervento",
    servicesTitle: "Quattro cavi.\nUn unico spinotto.",
    servicesSub:
    "Dal quadro elettrico al fotovoltaico in copertura — tutto da un unico interlocutore, senza subappalti.",
    services: [
    { slug: "elektro", n: "01", title: "Elettrico & illuminazione", body: "Nuovi impianti e ristrutturazioni, quadri, smart-home, scenari luce dimmerabili, illuminazione esterna.", items: ["Impianti civili", "Quadri elettrici", "KNX / Smart Home", "Illuminazione di sicurezza"] },
    { slug: "antenne", n: "02", title: "Antenne", body: "Impianti SAT, DVB-T e multiswitch per singola abitazione o intero condominio.", items: ["SAT & Multifeed", "DVB-T2", "Multiswitch", "Misure di segnale"] },
    { slug: "glasfaser", n: "03", title: "Fibra ottica", body: "Allaccio FTTH, giunzioni, patch e collaudo — fino a 10 Gbit in salotto.", items: ["Allaccio FTTH", "Giunzioni", "Cablaggio Cat6/7", "WiFi Mesh"] },
    { slug: "photovoltaik", n: "04", title: "Fotovoltaico", body: "Dimensionamento, montaggio, accumulo e wallbox — chiavi in mano con pratiche di rete incluse.", items: ["Moduli & inverter", "Accumulo", "Wallbox", "Monitoraggio"] }],

    statEyebrow: "Numeri",
    stats: [
    { n: "7+", l: "Anni di esperienza" },
    { n: "420+", l: "Impianti realizzati" },
    { n: "48h", l: "Tempo di risposta" }],

    refEyebrow: "Lavori",
    refTitle: "Impianti selezionati.",
    refSub: "Una piccola panoramica degli ultimi lavori intorno a Meltina, Bolzano e la Val d'Adige.",
    refs: [
    { img: "assets/refs/03-led.jpg", tag: "Illuminazione", title: "Soffitto LED", meta: "Indiretta · soffitto in legno · 2024" },
    { img: "assets/refs/04-kasten.jpg", tag: "Elettrico", title: "Quadro esterno", meta: "Cassetta CEE · 2024" },
    { img: "assets/refs/05-dach.jpg", tag: "Elettrico", title: "Tubi in copertura", meta: "Predisposizione FV · 2024" },
    { img: "assets/refs/06-antenne.jpg", tag: "Antenne", title: "Impianto antenne", meta: "DVB-T2 + SAT + Eolo · 2024" },
    { img: "assets/refs/07-led.jpg", tag: "Illuminazione", title: "LED in bagno", meta: "Cornice + accento · 2024" },
    { img: "assets/refs/08-kueche.jpg", tag: "Illuminazione", title: "Cucina professionale", meta: "Pannelli + distribuzione · 2023" },
    { img: "assets/refs/09-verteiler.jpg", tag: "Elettrico", title: "Quadro elettrico", meta: "Distribuzione principale · 2024" },
    { img: "assets/refs/10-led.jpg", tag: "Illuminazione", title: "LED in stube", meta: "Travi in legno · indiretta · 2023" },
    { img: "assets/refs/15-pv.jpg", tag: "Fotovoltaico", title: "Impianto FV su tetto", meta: "Aufdach · Meltina · 2024" }],

    aboutEyebrow: "Chi siamo",
    aboutTitle: "ELEKTRIX.\nIl tuo elettricista in montagna.",
    aboutBody1:
    "Dal 2019 stendo cavi, monto quadri e avvito moduli sul tetto — dalla piccola modifica di un interruttore al rifacimento completo di un maso.",
    aboutBody2:
    "Officina a Meltina, 1.140 m sopra Bolzano. Tragitti brevi in tutta la Val d'Adige, Val Sarentino e Burgraviato. Una persona, una telefonata, un appuntamento — niente call-center.",
    aboutMeta: [
    ["Titolare", "Markus Unterkofler"],
    ["Sede", "39010 Meltina (BZ)"],
    ["Attivo dal", "2019"],
    ["Lingue", "Deutsch · Italiano"]],

    processEyebrow: "Iter",
    processTitle: "Dalla telefonata\nalla messa in servizio.",
    process: [
    { n: "01", t: "Telefonata o mail", b: "Mi racconti in due righe di cosa si tratta. Rispondo entro 48 ore." },
    { n: "02", t: "Sopralluogo", b: "Appuntamento in loco. Verifichiamo l'impianto, prendo misure e foto." },
    { n: "03", t: "Preventivo", b: "Scritto, diviso per voci, con materiale e manodopera separati." },
    { n: "04", t: "Esecuzione", b: "Pulito, puntuale, con teli di protezione. Consegna con dichiarazione di conformità." }],

    contactEyebrow: "Contatti",
    contactTitle: "Richiedi preventivo.",
    contactSub:
    "Scrivimi di cosa hai bisogno — rispondo nei giorni lavorativi entro 48 ore.",
    form: {
      name: "Nome",
      email: "E-mail",
      phone: "Telefono",
      topic: "Area",
      message: "Di cosa si tratta?",
      send: "Invia richiesta",
      sent: "Grazie! Ho ricevuto la tua richiesta."
    },
    topics: ["Elettrico & illuminazione", "Antenne", "Fibra ottica", "Fotovoltaico", "Altro"],
    footerTag: "Elettrico · Antenne · Fibra · Fotovoltaico",
    footerRights: "© 2026 ELEKTRIX di Unterkofler Markus · P.IVA IT 0000 0000 000"
  }
};

/* ----------------------------------------------------------------
   INLINE ICONS (originals, simple line)
---------------------------------------------------------------- */
const Icon = {
  wifi: (p) =>
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <path d="M2 8.5C5 5.5 8.5 4 12 4s7 1.5 10 4.5" />
      <path d="M5 12c2-2 4.5-3 7-3s5 1 7 3" />
      <path d="M8 15.5c1.2-1.2 2.5-1.8 4-1.8s2.8.6 4 1.8" />
      <circle cx="12" cy="19" r="1.2" fill="currentColor" />
    </svg>,

  cam: (p) =>
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinejoin="round" {...p}>
      <rect x="3" y="8" width="13" height="9" rx="1" />
      <path d="M16 11l5-2v9l-5-2z" />
      <circle cx="9.5" cy="12.5" r="2" />
    </svg>,

  speaker: (p) =>
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinejoin="round" {...p}>
      <rect x="5" y="3" width="14" height="18" rx="2" />
      <circle cx="12" cy="9" r="2" />
      <circle cx="12" cy="15.5" r="3" />
    </svg>,

  bulb: (p) =>
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <path d="M9 18h6" />
      <path d="M10 21h4" />
      <path d="M12 3a6 6 0 0 0-3.5 10.9c.6.5 1 1.2 1 2V16h5v-.1c0-.8.4-1.5 1-2A6 6 0 0 0 12 3z" />
    </svg>,

  plug: (p) =>
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <path d="M9 2v5M15 2v5" />
      <path d="M6 7h12v3a5 5 0 0 1-5 5h-2a5 5 0 0 1-5-5z" />
      <path d="M12 15v4M12 19h4" />
    </svg>,

  bolt: (p) =>
  <svg viewBox="0 0 24 24" fill="currentColor" {...p}>
      <path d="M13 2L4 14h7l-2 8 9-12h-7z" />
    </svg>,

  arrow: (p) =>
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <path d="M5 12h14M13 6l6 6-6 6" />
    </svg>,

  arrowDown: (p) =>
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <path d="M12 5v14M6 13l6 6 6-6" />
    </svg>,

  check: (p) =>
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <path d="M5 12l4 4 10-10" />
    </svg>

};

const SERVICE_ICONS = [Icon.bulb, Icon.cam, Icon.wifi, Icon.bolt];

/* ----------------------------------------------------------------
   LOGO — recreation in pure HTML/CSS of the bracket-wordmark-plug
---------------------------------------------------------------- */
function Logo({ size = 36, compact = false }) {
  return (
    <div className="logo" style={{ height: size }} aria-label="ELEKTRIX">
      <span className="logo-bracket">[</span>
      <span className="logo-word">
        <span style={{ color: "var(--lime)" }}>ELEKTRI</span>
        <span style={{ color: "#0A0A0A" }}>X</span>
      </span>
    </div>);

}

/* ----------------------------------------------------------------
   NAV
---------------------------------------------------------------- */
function Nav({ t, onContact, lang, setLang, lime }) {
  const [scrolled, setScrolled] = useState(false);
  const [open, setOpen] = useState(false);
  useEffect(() => {
    const h = () => setScrolled(window.scrollY > 12);
    h();
    window.addEventListener("scroll", h, { passive: true });
    return () => window.removeEventListener("scroll", h);
  }, []);
  const ids = ["leistungen", "referenzen", "ueber-uns", "faq", "termin", "kontakt"];
  return (
    <header className={"nav " + (scrolled ? "is-scrolled" : "")}>
      <a href="#top" className="nav-logo" aria-label="ELEKTRIX home">
        <Logo size={28} compact={true} />
      </a>
      <nav className="nav-links">
        {t.nav.map((label, i) =>
        <a key={i} href={"#" + ids[i]}>{label}</a>
        )}
      </nav>
      <div className="nav-right">
        <div className="lang">
          <button className={lang === "de" ? "is-on" : ""} onClick={() => setLang("de")}>DE</button>
          <span>·</span>
          <button className={lang === "it" ? "is-on" : ""} onClick={() => setLang("it")}>IT</button>
        </div>
        <a href="#kontakt" className="btn btn-primary nav-cta" onClick={onContact}>
          {t.cta} <Icon.arrow width="16" height="16" />
        </a>
        <button className="nav-burger" onClick={() => setOpen(!open)} aria-label="menu">
          <span /><span /><span />
        </button>
      </div>
      {open &&
      <div className="nav-mobile">
          {t.nav.map((label, i) =>
        <a key={i} href={"#" + ids[i]} onClick={() => setOpen(false)}>{label}</a>
        )}
          <a href="#kontakt" className="btn btn-primary" onClick={() => setOpen(false)}>{t.cta}</a>
        </div>
      }
    </header>);

}

/* ----------------------------------------------------------------
   HERO
---------------------------------------------------------------- */
function Hero({ t, variant }) {
  return (
    <section id="top" className={"hero hero-" + variant}>
      <div className="hero-grid">
        <div className="hero-meta">
          <span className="dot" />
          <span className="mono">{t.heroEyebrow}</span>
        </div>

        <h1 className="hero-title">
          <span className="line">{t.heroTitle1}</span>
          <span className="line line-lime">{t.heroTitle2}</span>
          <span className="line">{t.heroTitle3}</span>
        </h1>

        <p className="hero-sub">{t.heroSub}</p>

        <div className="hero-ctas">
          <a href="#kontakt" className="btn btn-primary btn-lg">
            {t.heroPrimary} <Icon.arrow width="18" height="18" />
          </a>
          <a href="#leistungen" className="btn btn-ghost btn-lg">
            {t.heroSecondary}
          </a>
        </div>

        <div className="hero-tags">
          {t.services.map((s, i) => {
            const I = SERVICE_ICONS[i];
            return (
              <a key={i} className="hero-tag" href={"leistung.html?s=" + s.slug}>
                <I width="18" height="18" />
                <span>{s.title}</span>
              </a>);

          })}
        </div>
      </div>

      {/* Right side hero photo */}
      <div className="hero-circuit" aria-hidden="true">
        <div className="hero-photo-wrap">
          <img src="assets/refs/07-led.jpg" alt="" className="hero-photo" />
          <div className="hero-photo-grid"></div>
          <div className="hero-photo-scan"></div>
        </div>
        <div className="hero-photo-badge">
          <span className="mono">LIGHT · DESIGN</span>
          <strong>LED-Profil im Bad</strong>
        </div>
        <div className="hero-photo-stat">
          <span className="mono">— Realisiert 2024</span>
          <strong>2 700 K</strong>
          <span className="mono small">warmweiß · dimmbar</span>
        </div>
      </div>

      <div className="hero-scroll">
        <Icon.arrowDown width="14" height="14" /> <span className="mono">scroll</span>
      </div>
    </section>);

}

function CircuitArt() {
  return (
    <svg viewBox="0 0 480 720" preserveAspectRatio="xMidYMid meet">
      <defs>
        <pattern id="dots" x="0" y="0" width="14" height="14" patternUnits="userSpaceOnUse">
          <circle cx="1" cy="1" r="1" fill="#0A0A0A" opacity=".18" />
        </pattern>
      </defs>
      <rect x="0" y="0" width="480" height="720" fill="url(#dots)" />
      {/* the big bracket from the logo, scaled up */}
      <path d="M40 60 H440 V200" fill="none" stroke="#0A0A0A" strokeWidth="2" />
      <path d="M40 60 V660 H440" fill="none" stroke="#0A0A0A" strokeWidth="2" />
      {/* connector tabs */}
      <line x1="120" y1="660" x2="120" y2="680" stroke="#0A0A0A" strokeWidth="2" />
      <line x1="200" y1="660" x2="200" y2="680" stroke="#0A0A0A" strokeWidth="2" />
      <line x1="280" y1="660" x2="280" y2="680" stroke="#0A0A0A" strokeWidth="2" />
      <line x1="360" y1="660" x2="360" y2="680" stroke="#0A0A0A" strokeWidth="2" />

      {/* nodes along the wire */}
      {[
      { x: 130, y: 200, label: "01" },
      { x: 260, y: 320, label: "02" },
      { x: 130, y: 440, label: "03" },
      { x: 360, y: 560, label: "04" }].
      map((n, i) =>
      <g key={i}>
          <circle cx={n.x} cy={n.y} r="22" fill="#F6F6F4" stroke="#0A0A0A" strokeWidth="2" />
          <text x={n.x} y={n.y + 4} textAnchor="middle" fontSize="11" fontFamily="IBM Plex Mono, monospace" fill="#0A0A0A">{n.label}</text>
        </g>
      )}

      {/* lime square accent */}
      <rect x="320" y="120" width="60" height="60" fill="var(--lime)" />
      <rect x="320" y="120" width="60" height="60" fill="none" stroke="#0A0A0A" strokeWidth="2" />
      <text x="350" y="156" textAnchor="middle" fontFamily="Archivo, sans-serif" fontWeight="900" fontSize="40" fill="#0A0A0A">X</text>

      {/* big bolt mark bottom-left */}
      <g transform="translate(60,500)">
        <path d="M0 0 L40 0 L20 40 L60 40 L10 110 L25 60 L0 60 Z" fill="var(--lime)" stroke="#0A0A0A" strokeWidth="2" strokeLinejoin="round" />
      </g>
    </svg>);

}

/* ----------------------------------------------------------------
   MARQUEE
---------------------------------------------------------------- */
function Marquee({ t }) {
  const items = t.services.map((s) => s.title);
  const row = [...items, ...items, ...items, ...items];
  return (
    <div className="marquee" aria-hidden="true">
      <div className="marquee-track">
        {row.map((x, i) =>
        <span key={i} className="marquee-item">
            <Icon.bolt width="22" height="22" /> {x}
          </span>
        )}
      </div>
    </div>);

}

/* ----------------------------------------------------------------
   SERVICES
---------------------------------------------------------------- */
function Services({ t, lang }) {
  return (
    <section id="leistungen" className="section section-light">
      <SectionHead eyebrow={t.servicesEyebrow} title={t.servicesTitle} sub={t.servicesSub} />
      <div className="services-grid">
        {t.services.map((s, i) => {
          const I = SERVICE_ICONS[i];
          const photos = [
            "assets/refs/10-led.jpg",         // Elektro & Beleuchtung
            "assets/refs/06-antenne.jpg",      // Antenne
            "assets/refs/12-glasfaser.jpg",   // Glasfaser (cables in conduit)
            "assets/refs/15-pv.jpg"               // Photovoltaik
          ];
          return (
            <a key={i} className="service-card" style={{ "--i": i }} href={"leistung.html?s=" + s.slug}>
              <div className="service-photo">
                <img src={photos[i]} alt={s.title} loading="lazy" />
              </div>
              <div className="service-head">
                <span className="mono service-n">{s.n}</span>
                <I className="service-icon" width="36" height="36" />
              </div>
              <h3 className="service-title">{s.title}</h3>
              <p className="service-body">{s.body}</p>
              <ul className="service-list">
                {s.items.map((it, j) =>
                <li key={j}>
                    <Icon.check width="14" height="14" /> {it}
                  </li>
                )}
              </ul>
              <div className="service-foot">
                <span className="service-link">
                  <span>{lang === "de" ? "Mehr erfahren" : "Scopri di più"}</span> <Icon.arrow width="16" height="16" />
                </span>
              </div>
            </a>);

        })}
      </div>
    </section>);

}

/* ----------------------------------------------------------------
   STATS
---------------------------------------------------------------- */
function Stats({ t }) {
  return (
    <section className="section section-dark">
      <div className="stats-row">
        <span className="mono stats-eyebrow">— {t.statEyebrow}</span>
        <div className="stats-grid">
          {t.stats.map((s, i) =>
          <div key={i} className="stat">
              <div className="stat-n">{s.n}</div>
              <div className="stat-l">{s.l}</div>
            </div>
          )}
        </div>
      </div>
    </section>);

}

/* ----------------------------------------------------------------
   REFERENCES
---------------------------------------------------------------- */
function Refs({ t }) {
  return (
    <section id="referenzen" className="section section-light">
      <SectionHead eyebrow={t.refEyebrow} title={t.refTitle} sub={t.refSub} />
      <div className="refs-grid">
        {t.refs.map((r, i) =>
        <article key={i} className={"ref-card ref-card-" + i}>
            <div className="ref-img">
              <img src={r.img} alt={r.title} loading="lazy" />
              <span className="mono ref-img-tag">{r.tag}</span>
            </div>
            <div className="ref-meta">
              <h3 className="ref-title">{r.title}</h3>
              <span className="mono ref-sub">{r.meta}</span>
            </div>
          </article>
        )}
      </div>
    </section>);

}

function PhotoSlot({ kind, label, idx }) {
  // Visually distinct, illustrative slots — branded, clearly intentional placeholders
  // until the user supplies real on-site photos.
  const scenes = {
    pv:
    <svg viewBox="0 0 600 400" preserveAspectRatio="xMidYMid slice">
        <defs>
          <linearGradient id={"sky" + idx} x1="0" x2="0" y1="0" y2="1">
            <stop offset="0" stopColor="#9bbfd9" />
            <stop offset="1" stopColor="#cfe0ec" />
          </linearGradient>
        </defs>
        <rect width="600" height="400" fill={"url(#sky" + idx + ")"} />
        <circle cx="490" cy="80" r="40" fill="#ffd84a" />
        {/* roof */}
        <path d="M0 320 L600 220 L600 400 L0 400 Z" fill="#3a3a3a" />
        {/* PV modules grid */}
        <g transform="translate(40 200) rotate(-9)">
          {[0, 1, 2, 3].map((r) =>
        [0, 1, 2, 3, 4, 5].map((c) =>
        <g key={r + "-" + c} transform={"translate(" + c * 86 + " " + r * 46 + ")"}>
                <rect width="80" height="42" fill="#1a2e52" stroke="#0a1428" strokeWidth="1.5" />
                <line x1="40" y1="0" x2="40" y2="42" stroke="#2a4376" strokeWidth="1" />
                <line x1="0" y1="14" x2="80" y2="14" stroke="#2a4376" strokeWidth="0.8" />
                <line x1="0" y1="28" x2="80" y2="28" stroke="#2a4376" strokeWidth="0.8" />
              </g>
        )
        )}
        </g>
      </svg>,

    panel:
    <svg viewBox="0 0 600 400" preserveAspectRatio="xMidYMid slice">
        <rect width="600" height="400" fill="#d8d6cf" />
        <rect x="120" y="40" width="360" height="320" fill="#f2f1ec" stroke="#bbb8ae" strokeWidth="2" />
        {/* rows of breakers */}
        {[0, 1, 2, 3, 4].map((r) =>
      <g key={r} transform={"translate(140 " + (70 + r * 58) + ")"}>
            <rect width="320" height="40" fill="#1a1a1a" />
            {Array.from({ length: 12 }).map((_, c) =>
        <g key={c} transform={"translate(" + (8 + c * 26) + " 6)"}>
                <rect width="20" height="28" fill="#e6e2d8" stroke="#1a1a1a" strokeWidth="0.5" />
                <rect x="6" y="8" width="8" height="6" fill={c % 3 === 0 ? "#c5f23d" : "#7a7a7a"} />
              </g>
        )}
          </g>
      )}
        <rect x="120" y="40" width="360" height="22" fill="#1a1a1a" />
        <circle cx="135" cy="51" r="3" fill="#c5f23d" />
      </svg>,

    fiber:
    <svg viewBox="0 0 600 400" preserveAspectRatio="xMidYMid slice">
        <rect width="600" height="400" fill="#0e0e10" />
        {/* glowing fiber strands */}
        {Array.from({ length: 14 }).map((_, i) => {
        const y = 30 + i * 26;
        const hue = i % 3 === 0 ? "#c5f23d" : i % 2 === 0 ? "#5ed3ff" : "#ff9b54";
        return (
          <g key={i}>
              <path d={"M-20 " + y + " Q 200 " + (y - 40 + i % 5 * 15) + " 620 " + (y + 20) + ""}
            fill="none" stroke={hue} strokeWidth="1.2" opacity="0.85" />
              <circle cx={520 + i % 4 * 12} cy={y + 16} r="2.5" fill={hue} />
            </g>);

      })}
        {/* patch panel hint */}
        <rect x="30" y="320" width="540" height="60" fill="#1c1c1f" stroke="#2a2a2e" />
        {Array.from({ length: 24 }).map((_, i) =>
      <circle key={i} cx={50 + i * 22} cy="350" r="6" fill="#0a0a0a" stroke="#c5f23d" strokeWidth="1" />
      )}
      </svg>,

    light:
    <svg viewBox="0 0 600 400" preserveAspectRatio="xMidYMid slice">
        <defs>
          <radialGradient id={"glow" + idx} cx="50%" cy="35%" r="55%">
            <stop offset="0" stopColor="#ffe9a8" stopOpacity="0.95" />
            <stop offset="1" stopColor="#1c1814" stopOpacity="0" />
          </radialGradient>
        </defs>
        <rect width="600" height="400" fill="#1c1814" />
        <rect width="600" height="400" fill={"url(#glow" + idx + ")"} />
        {/* hanging pendants */}
        {[150, 300, 450].map((x, i) =>
      <g key={i}>
            <line x1={x} y1="0" x2={x} y2="120" stroke="#3a3027" strokeWidth="1.5" />
            <circle cx={x} cy="140" r="22" fill="#2a221b" stroke="#5a4a3a" strokeWidth="1" />
            <ellipse cx={x} cy="170" rx="50" ry="14" fill="#ffd98a" opacity="0.35" />
            <circle cx={x} cy="140" r="8" fill="#ffe7a0" />
          </g>
      )}
        {/* table line */}
        <rect x="40" y="290" width="520" height="6" fill="#2a221b" />
      </svg>

  };
  return (
    <div className="photo-slot">
      {scenes[kind] || scenes.panel}
      <span className="photo-slot-tag mono">FOTO · {label.toUpperCase()}</span>
    </div>);

}

function Placeholder({ label, idx }) {
  // subtle diagonal stripes, monospace label — explicit "drop a photo here"
  const id = "ph-" + idx;
  return (
    <svg viewBox="0 0 600 400" preserveAspectRatio="xMidYMid slice" className="ph-svg">
      <defs>
        <pattern id={id} patternUnits="userSpaceOnUse" width="14" height="14" patternTransform="rotate(45)">
          <rect width="14" height="14" fill="#EFEFEC" />
          <line x1="0" y1="0" x2="0" y2="14" stroke="#E1E1DC" strokeWidth="6" />
        </pattern>
      </defs>
      <rect width="600" height="400" fill={"url(#" + id + ")"} />
      <text x="24" y="376" fontFamily="IBM Plex Mono, monospace" fontSize="13" fill="#6B6B6B">
        FOTO · {label.toUpperCase()}
      </text>
    </svg>);

}

/* ----------------------------------------------------------------
   ABOUT
---------------------------------------------------------------- */
function About({ t }) {
  return (
    <section id="ueber-uns" className="section section-light section-about">
      <div className="about-grid">
        <div className="about-portrait">
          <PortraitPlaceholder />
          <div className="about-portrait-tag mono">Markus · Mölten · 1.140 m</div>
        </div>
        <div className="about-text">
          <span className="mono eyebrow">— {t.aboutEyebrow}</span>
          <h2 className="section-title">
            {t.aboutTitle.split("\n").map((l, i) => <span key={i}>{l}<br /></span>)}
          </h2>
          <p className="about-body">{t.aboutBody1}</p>
          <p className="about-body">{t.aboutBody2}</p>
          <dl className="about-meta">
            {t.aboutMeta.map(([k, v], i) =>
            <div key={i}>
                <dt className="mono">{k}</dt>
                <dd>{v}</dd>
              </div>
            )}
          </dl>
        </div>
      </div>
    </section>);

}

function PortraitPlaceholder() {
  // Real photo — LED Stube, captures the brand: warm finish, technical excellence.
  return (
    <div className="portrait-slot">
      <img src="assets/refs/10-led.jpg" alt="LED-Beleuchtung in der Stube" className="portrait-img" />
      <span className="photo-slot-tag mono">ANLAGE · LED-STUBE</span>
    </div>);
}

/* ----------------------------------------------------------------
   PROCESS
---------------------------------------------------------------- */
function Process({ t }) {
  const ref = useRef(null);
  const [active, setActive] = useState(false);
  useEffect(() => {
    if (!ref.current) return;
    const io = new IntersectionObserver(
      (entries) => entries.forEach(e => { if (e.isIntersecting) { setActive(true); io.disconnect(); } }),
      { threshold: 0.25 }
    );
    io.observe(ref.current);
    return () => io.disconnect();
  }, []);
  const total = t.process.length;
  return (
    <section id="ablauf" className="section section-cream" ref={ref}>
      <SectionHead eyebrow={t.processEyebrow} title={t.processTitle} />
      <div className={`process-track ${active ? "is-active" : ""}`} style={{ "--step-count": total }}>
        <div className="process-track-line" />
        <div className="process-track-fill" />
        <div className="process-track-spark" />
      </div>
      <ol className={`process-list ${active ? "is-active" : ""}`}>
        {t.process.map((p, i) =>
        <li key={i} className="process-step" style={{ "--i": i }}>
            <div className="process-dot" aria-hidden="true" />
            <div className="process-n mono">{p.n}</div>
            <div className="process-body">
              <h3>{p.t}</h3>
              <p>{p.b}</p>
            </div>
          </li>
        )}
      </ol>
    </section>);

}

/* ----------------------------------------------------------------
   CONTACT
---------------------------------------------------------------- */
function Contact({ t, lang }) {
  const [form, setForm] = useState({ name: "", email: "", phone: "", topic: t.topics[0], message: "" });
  const [sent, setSent] = useState(false);
  const u = (k) => (e) => setForm((f) => ({ ...f, [k]: e.target.value }));
  const submit = (e) => {
    e.preventDefault();
    const subject = encodeURIComponent(`[ELEKTRIX-Anfrage] ${form.topic} · ${form.name}`);
    const lines = [
      `Name: ${form.name}`,
      `E-Mail: ${form.email}`,
      `Telefon: ${form.phone || "—"}`,
      `Bereich: ${form.topic}`,
      "",
      "Worum geht's:",
      form.message,
      "",
      "— gesendet via elektrix.it",
    ];
    const body = encodeURIComponent(lines.join("\n"));
    window.location.href = `mailto:info@elektrix.it?subject=${subject}&body=${body}`;
    setSent(true);
    setTimeout(() => setSent(false), 4000);
  };
  return (
    <section id="kontakt" className="section section-dark section-contact">
      <div className="contact-grid">
        <div className="contact-left">
          <span className="mono eyebrow on-dark">— {t.contactEyebrow}</span>
          <h2 className="section-title on-dark">{t.contactTitle}</h2>
          <p className="contact-sub">{t.contactSub}</p>

          <div className="contact-cards">
            <a href="tel:+393479489636" className="contact-card">
              <span className="mono">{t.legalLabels.tel}</span>
              <strong>{window.LEGAL.tel}</strong>
            </a>
            <a href="mailto:info@elektrix.it" className="contact-card">
              <span className="mono">{t.legalLabels.mail}</span>
              <strong>{window.LEGAL.mail}</strong>
            </a>
            <a href="mailto:elektrix@pec.bz.it" className="contact-card">
              <span className="mono">{t.legalLabels.pec}</span>
              <strong>{window.LEGAL.pec}</strong>
            </a>
            <div className="contact-card">
              <span className="mono">{t.legalLabels.sitz}</span>
              <strong>{window.LEGAL.sitz}</strong>
            </div>
          </div>
        </div>

        <form className="contact-form" onSubmit={submit}>
          <div className="field">
            <label className="mono">{t.form.name}</label>
            <input required value={form.name} onChange={u("name")} placeholder="Markus Mustermann" />
          </div>
          <div className="field-row">
            <div className="field">
              <label className="mono">{t.form.email}</label>
              <input required type="email" value={form.email} onChange={u("email")} placeholder="name@beispiel.it" />
            </div>
            <div className="field">
              <label className="mono">{t.form.phone}</label>
              <input value={form.phone} onChange={u("phone")} placeholder="+39 …" />
            </div>
          </div>
          <div className="field">
            <label className="mono">{t.form.topic}</label>
            <div className="topic-grid">
              {t.topics.map((tp) =>
              <button key={tp} type="button"
              className={"topic " + (form.topic === tp ? "is-on" : "")}
              onClick={() => setForm((f) => ({ ...f, topic: tp }))}>
                  {tp}
                </button>
              )}
            </div>
          </div>
          <div className="field">
            <label className="mono">{t.form.message}</label>
            <textarea required rows="5" value={form.message} onChange={u("message")} placeholder="…" />
          </div>
          <div className="field consent-field">
            <label className="consent-row">
              <input required type="checkbox" />
              <span>{lang === "it"
                ? <>Ho letto l'<a href="datenschutz.html">informativa privacy</a> e acconsento al trattamento dei dati per evadere la richiesta (art. 6 par. 1 lett. b GDPR).</>
                : <>Ich habe die <a href="datenschutz.html">Datenschutzerklärung</a> gelesen und willige in die Verarbeitung meiner Daten zur Bearbeitung der Anfrage ein (Art. 6 Abs. 1 lit. b DSGVO).</>}</span>
            </label>
          </div>
          <button type="submit" className="btn btn-primary btn-lg btn-full">
            {sent ? t.form.sent : t.form.send} {!sent && <Icon.arrow width="18" height="18" />}
          </button>
        </form>
      </div>
    </section>);

}

/* ----------------------------------------------------------------
   COOKIE BANNER — minimal, GDPR-friendly
---------------------------------------------------------------- */
function CookieBanner({ lang }) {
  const [show, setShow] = useState(false);
  useEffect(() => {
    try {
      const v = localStorage.getItem("ekx_consent");
      if (!v) setShow(true);
    } catch (e) { setShow(true); }
  }, []);
  const decide = (value) => {
    try { localStorage.setItem("ekx_consent", value); } catch (e) {}
    if (value === "all" && typeof window.__loadEkxFonts === "function") {
      window.__loadEkxFonts();
    }
    setShow(false);
  };
  if (!show) return null;
  const T = lang === "it"
    ? {
        title: "Cookie & Privacy",
        body: "Questo sito utilizza solo cookie tecnici necessari e un'entry locale per ricordare la Sua scelta. Il chatbot opzionale si collega ad Anthropic (USA) solo se Lei lo apre. Nessun tracker pubblicitario.",
        accept: "Accetta tutti",
        only:   "Solo necessari",
        more:   "Dettagli",
      }
    : {
        title: "Cookies & Datenschutz",
        body: "Diese Website verwendet nur technisch notwendige Cookies und einen lokalen Eintrag für deine Wahl. Der optionale Chatbot verbindet sich mit Anthropic (USA), wenn du ihn öffnest. Keine Werbe-Tracker.",
        accept: "Alle akzeptieren",
        only:   "Nur notwendige",
        more:   "Details",
      };
  return (
    <div className="cookie-banner" role="dialog" aria-label={T.title}>
      <div className="cookie-banner-inner">
        <div className="cookie-banner-copy">
          <strong className="mono">{T.title}</strong>
          <p>{T.body}</p>
        </div>
        <div className="cookie-banner-actions">
          <a className="cookie-link" href="cookies.html">{T.more}</a>
          <button className="btn btn-ghost cookie-btn" onClick={() => decide("necessary")}>{T.only}</button>
          <button className="btn btn-primary cookie-btn" onClick={() => decide("all")}>{T.accept}</button>
        </div>
      </div>
    </div>
  );
}

/* ----------------------------------------------------------------
   STICKY CALL BAR — mobile only; Anruf · WhatsApp · Termin
---------------------------------------------------------------- */
function StickyCallBar({ lang }) {
  const labels = lang === "it"
    ? { call: "Chiama", wa: "WhatsApp", book: "Appuntamento" }
    : { call: "Anrufen", wa: "WhatsApp", book: "Termin" };
  return (
    <div className="sticky-call" aria-label={labels.call}>
      <a href="tel:+393479489636" className="sticky-call-btn sticky-call-primary">
        <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.2" strokeLinecap="round" strokeLinejoin="round">
          <path d="M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72c.13.96.37 1.9.72 2.81a2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45c.91.35 1.85.59 2.81.72A2 2 0 0 1 22 16.92z" />
        </svg>
        <span>{labels.call}</span>
      </a>
      <a href="https://wa.me/393479489636" target="_blank" rel="noopener" className="sticky-call-btn sticky-call-wa">
        <svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor">
          <path d="M17.5 14.4c-.3-.1-1.7-.8-1.9-.9-.3-.1-.5-.1-.7.1-.2.3-.8.9-.9 1.1-.2.2-.3.2-.6.1-.3-.1-1.2-.5-2.3-1.4-.9-.8-1.4-1.7-1.6-2-.2-.3 0-.5.1-.6.1-.1.3-.3.4-.5.1-.2.2-.3.3-.5.1-.2 0-.4 0-.5 0-.1-.7-1.7-1-2.3-.3-.6-.5-.5-.7-.5h-.6c-.2 0-.5.1-.8.4-.3.3-1 1-1 2.5 0 1.5 1.1 2.9 1.2 3.1.1.2 2.1 3.2 5 4.5.7.3 1.2.5 1.7.6.7.2 1.3.2 1.8.1.6-.1 1.7-.7 1.9-1.4.2-.7.2-1.3.2-1.4-.1-.1-.3-.1-.6-.3zM12 2C6.5 2 2 6.5 2 12c0 1.8.5 3.5 1.3 5L2 22l5.1-1.3c1.4.8 3.1 1.2 4.9 1.2 5.5 0 10-4.5 10-10S17.5 2 12 2z" />
        </svg>
        <span>{labels.wa}</span>
      </a>
      <a href="#termin" className="sticky-call-btn sticky-call-book">
        <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.2" strokeLinecap="round" strokeLinejoin="round">
          <rect x="3" y="4" width="18" height="18" rx="2" />
          <line x1="16" y1="2" x2="16" y2="6" />
          <line x1="8" y1="2" x2="8" y2="6" />
          <line x1="3" y1="10" x2="21" y2="10" />
        </svg>
        <span>{labels.book}</span>
      </a>
    </div>
  );
}

/* ----------------------------------------------------------------
   FOOTER
---------------------------------------------------------------- */
function Footer({ t, lang }) {
  const legalLabel   = lang === "it" ? "Note legali" : "Impressum";
  const privacyLabel = lang === "it" ? "Privacy"     : "Datenschutz";
  const cookiesLabel = lang === "it" ? "Cookie"      : "Cookies";
  return (
    <footer className="footer">
      <div className="footer-top">
        <div className="footer-wordmark">
          <span className="wm-bracket">[</span>
          <span className="wm-lime">ELEKTRI</span>
          <span className="wm-black">X</span>
        </div>
        <nav className="footer-legal-nav" aria-label="Legal">
          <a href="impressum.html">{legalLabel}</a>
          <span className="legal-sep">·</span>
          <a href="datenschutz.html">{privacyLabel}</a>
          <span className="legal-sep">·</span>
          <a href="cookies.html">{cookiesLabel}</a>
        </nav>
      </div>
      <div className="footer-legal">
        <div><span className="mono">{t.legalLabels.firma}</span><strong>{window.LEGAL.firma}</strong></div>
        <div><span className="mono">{t.legalLabels.sitz}</span><strong>{window.LEGAL.sitz}</strong></div>
        <div><span className="mono">{t.legalLabels.mwst}</span><strong>{window.LEGAL.mwst}</strong></div>
        <div><span className="mono">{t.legalLabels.sf}</span><strong>{window.LEGAL.sf}</strong></div>
        <div><span className="mono">{t.legalLabels.sdi}</span><strong>{window.LEGAL.sdi}</strong></div>
        <div><span className="mono">{t.legalLabels.pec}</span><strong>{window.LEGAL.pec}</strong></div>
        <div><span className="mono">{t.legalLabels.bank}</span><strong>{window.LEGAL.bank}</strong></div>
        <div><span className="mono">{t.legalLabels.iban}</span><strong>{window.LEGAL.iban}</strong></div>
      </div>
      <div className="footer-bottom">
        <span className="mono">{t.footerTag}</span>
        <span className="mono">© 2026 ELEKTRIX des Unterkofler Markus</span>
      </div>
    </footer>);

}

/* ----------------------------------------------------------------
   SECTION HEAD
---------------------------------------------------------------- */
function SectionHead({ eyebrow, title, sub }) {
  return (
    <div className="section-head">
      <span className="mono eyebrow">— {eyebrow}</span>
      <h2 className="section-title">
        {title.split("\n").map((l, i) => <span key={i}>{l}<br /></span>)}
      </h2>
      {sub && <p className="section-sub">{sub}</p>}
    </div>);

}

/* ----------------------------------------------------------------
   APP
---------------------------------------------------------------- */
function App() {
  const TWEAK_DEFAULTS = /*EDITMODE-BEGIN*/{
    "lang": "de",
    "accent": "#C5F23D",
    "heroVariant": "split",
    "darkSection": true
  } /*EDITMODE-END*/;

  const [tweaks, setTweak] = useTweaks(TWEAK_DEFAULTS);
  const lang = tweaks.lang === "it" ? "it" : "de";
  const t = { ...COPY[lang], ...window.EXTRA_COPY[lang] };

  useEffect(() => {
    document.documentElement.style.setProperty("--lime", tweaks.accent);
    document.documentElement.lang = lang;
  }, [tweaks.accent, lang]);

  return (
    <>
      <Nav t={t} lang={lang} setLang={(l) => setTweak("lang", l)} lime={tweaks.accent} />
      <main>
        <Hero t={t} variant={tweaks.heroVariant} />
        <Marquee t={t} />
        <Services t={t} lang={lang} />
        <Stats t={t} />
        <Refs t={t} />
        <About t={t} />
        <Process t={t} />
        <FAQ t={t} />
        <Booking t={t} lang={lang} />
        <Contact t={t} lang={lang} />
      </main>
      <Footer t={t} lang={lang} />
      <CookieBanner lang={lang} />
      <StickyCallBar lang={lang} />

      <TweaksPanel title="Tweaks">
        <TweakSection title="Sprache / Lingua">
          <TweakRadio label="Language" valueKey="lang" tweaks={tweaks} setTweak={setTweak}
          options={[{ value: "de", label: "DE" }, { value: "it", label: "IT" }]} />
        </TweakSection>
      </TweaksPanel>
    </>);

}

const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(<App />);