/* Railo — gemeinsame Bausteine für alle Unterseiten.
   Apple-Stil, hell. Komponiert die Core-Komponenten aus dem DS-Bundle.
   Alle Komponenten werden ans window exportiert, weil jede Seite diese
   Datei als eigenes Babel-Script lädt. Bewusst schlank & deklarativ
   gehalten, damit die spätere echte Implementierung (Claude Code) klar
   ablesen kann, was wohin gehört. */
const { Button, IconButton, Eyebrow, Card, Badge, Tag, Stat, Input } =
  window.RailoDesignSystem_afb8b0;

/* ---------- Navigationsmodell — echte Dateien, echter Klickpfad ---------- */
const RAILO_NAV = [
  { key: "lok", label: "Lokführer:in werden", href: "Railo%20Lokfuehrer.html" },
  { key: "evu", label: "Für Unternehmen", href: "Railo%20Unternehmen.html" },
  { key: "ueber", label: "Über uns", href: "Railo%20Ueber%20Uns.html" },
];
const RAILO_HOME = "/";
const RAILO_GOLD = "#c79320";

/* ---------- o-Raster-Hintergrundbild (Ring + Schiene getrennt einfärbbar) ---------- */
function railoRasterImage(ringColor, railColor) {
  const tile = (tx, ty) =>
    `<g transform='translate(${tx},${ty})'><circle cx='28' cy='26' r='22' stroke='${ringColor}' stroke-width='3.4'/><path d='M22 40 L27 28' stroke='${railColor}' stroke-width='2'/><path d='M34 40 L29 28' stroke='${railColor}' stroke-width='2'/><path d='M17.7 40.9 H38.4' stroke='${railColor}' stroke-width='1.7' opacity='0.92'/><path d='M20.9 35.7 H35.1' stroke='${railColor}' stroke-width='1.5' opacity='0.78'/><path d='M23.8 30.9 H32.2' stroke='${railColor}' stroke-width='1.4' opacity='0.62'/></g>`;
  const svg = `<svg xmlns='http://www.w3.org/2000/svg' width='240' height='140' viewBox='0 0 240 140'><g fill='none' stroke-linecap='round'>${tile(20, 16)}${tile(140, 86)}</g></svg>`;
  return `url("data:image/svg+xml,${encodeURIComponent(svg)}")`;
}

/* ---------- Bildzeichen: das Tunnel-„o" ---------- */
function RailoO({ size = 34, color = "var(--text-primary)", track, style }) {
  return (
    <svg width={size} height={size} viewBox="0 0 100 100" style={{ display: "block", ...style }}>
      <circle cx="50" cy="50" r="34" fill="none" stroke={color} strokeWidth="11"></circle>
      <path d="M41 72 L48.5 53" stroke="#c79320" strokeWidth="3.1" strokeLinecap="round"></path>
      <path d="M59 72 L51.5 53" stroke="#c79320" strokeWidth="3.1" strokeLinecap="round"></path>
      <path d="M34 72 H66" stroke="#c79320" strokeWidth="3" strokeLinecap="round"></path>
      <path d="M39 64 H61" stroke="#c79320" strokeWidth="2.7" strokeLinecap="round"></path>
      <path d="M43.5 57 H56.5" stroke="#c79320" strokeWidth="2.4" strokeLinecap="round"></path>
    </svg>);
}

/* ---------- Wortmarke „Railo" mit Tunnel-„o" auf der Strecke ---------- */
function RailoLogo({ size = 24, color = "var(--text-primary)", accent = "var(--accent)" }) {
  return (
    <span style={{ display: "inline-flex", alignItems: "flex-end", position: "relative", paddingBottom: size * 0.2, lineHeight: 1 }}>
      <span style={{ fontFamily: "var(--font-display)", fontWeight: 600, letterSpacing: "-0.04em", fontSize: size, color }}>
        Rail
      </span>
      <span style={{ fontSize: size, lineHeight: 1, display: "inline-flex", alignItems: "flex-end", marginLeft: -size * 0.03 }}>
        <RailoO size={size * 0.64} color={color} track={accent} style={{ transform: `translateY(${-size * 0.075}px)` }} />
      </span>
      <svg width="100%" height={Math.max(6, size * 0.16)} viewBox="0 0 300 14" preserveAspectRatio="none" style={{ position: "absolute", left: 0, bottom: 0 }}>
        <path d="M3 4 H140 M160 4 H297" stroke={accent} strokeWidth="2.6" strokeLinecap="round"></path>
        <path d="M3 10 H140 M160 10 H297" stroke={accent} strokeWidth="2.6" strokeLinecap="round" opacity="0.5"></path>
      </svg>
    </span>);
}

/* ---------- Mobiles Vollbild-Menü (Overlay) ---------- */
function MobileMenu({ active, open, onClose, dark = false }) {
  React.useEffect(() => {
    if (open) {
      const prev = document.body.style.overflow;
      document.body.style.overflow = "hidden";
      return () => { document.body.style.overflow = prev; };
    }
  }, [open]);
  const text = dark ? "#fff" : "var(--text-primary)";
  const sub = dark ? "rgba(255,255,255,0.6)" : "var(--text-secondary)";
  return (
    <div role="dialog" aria-modal="true" aria-hidden={!open} style={{
      position: "fixed", inset: 0, zIndex: 200,
      background: dark ? "rgba(5,7,15,0.96)" : "rgba(255,255,255,0.96)",
      backdropFilter: "blur(24px)", WebkitBackdropFilter: "blur(24px)",
      display: "flex", flexDirection: "column",
      padding: "calc(env(safe-area-inset-top, 0px) + 16px) 22px 32px",
      opacity: open ? 1 : 0, pointerEvents: open ? "auto" : "none",
      transform: open ? "none" : "translateY(-8px)",
      transition: "opacity 260ms var(--ease-out), transform 260ms var(--ease-out)"
    }}>
      <div style={{ display: "flex", alignItems: "center", justifyContent: "space-between", height: 40 }}>
        <a href={RAILO_HOME} style={{ display: "inline-flex", alignItems: "center", textDecoration: "none" }}>
          <RailoLogo size={22} color={text} />
        </a>
        <button onClick={onClose} aria-label="Menü schließen" style={{
          appearance: "none", border: "none", background: "transparent", cursor: "pointer",
          width: 44, height: 44, display: "inline-flex", alignItems: "center", justifyContent: "center",
          color: text, margin: "-8px -10px -8px 0"
        }}><i data-lucide="x" style={{ width: 26, height: 26 }}></i></button>
      </div>
      <nav style={{ marginTop: 28, display: "flex", flexDirection: "column" }}>
        {RAILO_NAV.map((l) => {
          const on = l.key === active;
          return (
            <a key={l.key} href={l.href} style={{
              fontFamily: "var(--font-display)", fontWeight: 600,
              fontSize: 28, letterSpacing: "var(--tracking-title)",
              color: on ? "var(--accent)" : text, textDecoration: "none",
              padding: "18px 0", borderBottom: dark ? "1px solid rgba(255,255,255,0.1)" : "1px solid var(--border-subtle)",
              display: "flex", alignItems: "center", justifyContent: "space-between"
            }}>{l.label}<span style={{ color: sub, fontWeight: 400 }}>›</span></a>);
        })}
      </nav>
      <a href="Railo%20Lokfuehrer.html" style={{
        marginTop: 32, display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 8,
        fontFamily: "var(--font-text)", fontSize: 17, fontWeight: 600,
        color: "var(--text-on-accent)", textDecoration: "none",
        padding: "16px 24px", borderRadius: 980, background: "var(--accent)"
      }}>Hier zum Erstgespräch&nbsp;<span style={{ opacity: 0.6 }}>→</span></a>
    </div>);
}

/* ---------- Hamburger-Button ---------- */
function BurgerButton({ onClick, dark = false, className }) {
  return (
    <button onClick={onClick} aria-label="Menü öffnen" className={className} style={{
      appearance: "none", border: "none", background: "transparent", cursor: "pointer",
      width: 44, height: 44, alignItems: "center", justifyContent: "center",
      color: dark ? "#fff" : "var(--text-primary)", margin: "0 -10px 0 0"
    }}><i data-lucide="menu" style={{ width: 26, height: 26 }}></i></button>);
}

/* ---------- Helle, sticky, blurred Navigation für Unterseiten ---------- */
function SubNav({ active }) {
  const [open, setOpen] = React.useState(false);
  React.useEffect(() => { if (window.lucide) window.lucide.createIcons(); }, [open]);
  return (
    <header style={{
      position: "sticky", top: 0, zIndex: 50, height: 56,
      display: "flex", alignItems: "center",
      background: "rgba(255,255,255,0.72)",
      backdropFilter: "saturate(180%) blur(20px)",
      WebkitBackdropFilter: "saturate(180%) blur(20px)",
      borderBottom: "1px solid var(--border-subtle)"
    }}>
      <nav style={{
        position: "relative", width: "100%", maxWidth: 1200, margin: "0 auto", padding: "0 28px",
        display: "flex", alignItems: "center", justifyContent: "space-between", gap: 20
      }}>
        <a href={RAILO_HOME} style={{ display: "inline-flex", alignItems: "center", textDecoration: "none", flexShrink: 0 }}>
          <RailoLogo size={22} />
        </a>
        <ul className="subnav-links" style={{ display: "flex", alignItems: "center", gap: 4, listStyle: "none", margin: 0, padding: 0, position: "absolute", left: "50%", top: "50%", transform: "translate(-50%,-50%)" }}>
          {RAILO_NAV.map((l) => {
            const on = l.key === active;
            return (
              <li key={l.key}>
                <a href={l.href} style={{
                  fontFamily: "var(--font-text)", fontSize: 14, fontWeight: on ? 600 : 500,
                  color: on ? "var(--text-primary)" : "var(--text-secondary)",
                  textDecoration: "none", padding: "8px 14px", borderRadius: 980,
                  background: on ? "var(--surface-section)" : "transparent",
                  whiteSpace: "nowrap", transition: "color var(--dur-fast) var(--ease-standard)"
                }}>{l.label}</a>
              </li>);
          })}
        </ul>
        <a href="Railo%20Lokfuehrer.html" className="subnav-cta" style={{
          flexShrink: 0, display: "inline-flex", alignItems: "center", gap: 8,
          fontFamily: "var(--font-text)", fontSize: 14, fontWeight: 600,
          color: "var(--text-on-accent)", textDecoration: "none",
          padding: "9px 18px", borderRadius: 980, background: "var(--accent)"
        }}>Erstgespräch&nbsp;<span style={{ opacity: 0.6 }}>→</span></a>
        <BurgerButton className="nav-burger" onClick={() => setOpen(true)} />
      </nav>
      <MobileMenu active={active} open={open} onClose={() => setOpen(false)} />
    </header>);
}

/* ---------- Reveal (reines CSS, sichtbarer Fallback) ---------- */
function Reveal({ children, as = "div", className, style, ...rest }) {
  const Tag = as;
  return <Tag className={"reveal" + (className ? " " + className : "")} style={style} {...rest}>{children}</Tag>;
}

/* ---------- Section-Heading-Block (Eyebrow + Headline + Lede) ---------- */
function SectionHead({ eyebrow, head, sub, align = "center", maxWidth = 720, kicker }) {
  return (
    <div style={{ maxWidth, margin: align === "center" ? "0 auto" : 0, textAlign: align }}>
      {eyebrow && <Reveal><Eyebrow style={{ marginBottom: 16 }}>{eyebrow}</Eyebrow></Reveal>}
      <Reveal as="h2" style={{
        fontFamily: "var(--font-display)", fontWeight: 600,
        fontSize: "clamp(32px, 5vw, 56px)", lineHeight: 1.06,
        letterSpacing: "var(--tracking-display)", color: "var(--text-primary)",
        margin: 0, textWrap: "balance"
      }}>{head}</Reveal>
      {sub && <Reveal as="p" style={{
        fontFamily: "var(--font-text)", fontSize: "clamp(18px, 2.2vw, 22px)",
        lineHeight: 1.45, color: "var(--text-secondary)",
        maxWidth: 600, margin: align === "center" ? "20px auto 0" : "20px 0 0"
      }}>{sub}</Reveal>}
    </div>);
}

/* ---------- Heller Unterseiten-Hero ---------- */
function PageHero({ eyebrow, title, sub, primary, secondary, primaryHref = "#", secondaryHref = "#", image, imageId, imageH = 440, tone = "page" }) {
  const lines = Array.isArray(title) ? title : [title];
  if (tone === "immersive") {
    return (
      <section style={{ position: "relative", overflow: "hidden", textAlign: "center", background: "#05070f", color: "#fff", padding: "150px 22px 120px" }}>
        <div aria-hidden="true" style={{ position: "absolute", inset: 0, pointerEvents: "none", zIndex: 0,
          background:
            "radial-gradient(130% 85% at 50% 14%, rgba(10,92,255,0.55) 0%, rgba(10,92,255,0.16) 34%, transparent 62%)," +
            "radial-gradient(120% 120% at 50% 128%, rgba(36,120,255,0.42) 0%, transparent 52%)," +
            "radial-gradient(80% 60% at 50% 50%, rgba(10,92,255,0.14) 0%, transparent 70%)," +
            "#05070f" }}></div>
        <div aria-hidden="true" style={{ position: "absolute", inset: 0, pointerEvents: "none", zIndex: 0, opacity: 0.5,
          background:
            "repeating-linear-gradient(74deg, rgba(120,170,255,0.10) 0 1px, transparent 1px 46px)," +
            "repeating-linear-gradient(-74deg, rgba(120,170,255,0.08) 0 1px, transparent 1px 52px)",
          maskImage: "radial-gradient(75% 75% at 50% 42%, #000 0%, transparent 78%)",
          WebkitMaskImage: "radial-gradient(75% 75% at 50% 42%, #000 0%, transparent 78%)" }}></div>
        <div aria-hidden="true" style={{ position: "absolute", inset: 0, pointerEvents: "none", zIndex: 0,
          backgroundImage: railoRasterImage(RAILO_GOLD, "#4f93ff"), backgroundSize: "240px 140px", opacity: 0.4 }}></div>
        <div aria-hidden="true" style={{ position: "absolute", inset: 0, pointerEvents: "none", zIndex: 0,
          backdropFilter: "blur(9px)", WebkitBackdropFilter: "blur(9px)",
          background: "radial-gradient(48% 62% at 50% 46%, rgba(7,11,24,0.82) 0%, rgba(7,11,24,0.5) 50%, transparent 78%)",
          maskImage: "radial-gradient(50% 64% at 50% 46%, #000 0%, #000 56%, transparent 82%)",
          WebkitMaskImage: "radial-gradient(50% 64% at 50% 46%, #000 0%, #000 56%, transparent 82%)" }}></div>
        <div aria-hidden="true" style={{ position: "absolute", left: 0, right: 0, bottom: 0, height: 300, pointerEvents: "none", zIndex: 0,
          background: "linear-gradient(to bottom, rgba(5,7,15,0) 0%, rgba(8,12,26,0.5) 52%, rgba(150,180,230,0.4) 84%, var(--surface-page) 100%)" }}></div>

        <div className="reveal" style={{ maxWidth: 860, margin: "0 auto", position: "relative", zIndex: 1 }}>
          <div style={{ display: "flex", justifyContent: "center", marginBottom: 28 }}><RailoO size={64} color="#3a86ff" metal /></div>
          {eyebrow && <div style={{ fontFamily: "var(--font-text)", fontSize: 13, fontWeight: 600, letterSpacing: "0.16em", textTransform: "uppercase", color: "rgba(120,170,255,0.95)", marginBottom: 20 }}>{eyebrow}</div>}
          <h1 style={{
            fontFamily: "var(--font-display)", fontWeight: 600,
            fontSize: "clamp(44px, 7.6vw, 82px)", lineHeight: 1.03,
            letterSpacing: "var(--tracking-hero)", color: "#fff", margin: 0, textWrap: "balance"
          }}>{lines.map((l, i) => <span key={i} style={{ display: "block" }}>{l}</span>)}</h1>
          {sub && <p style={{
            fontFamily: "var(--font-text)", fontSize: "clamp(19px, 2.4vw, 23px)",
            lineHeight: 1.42, color: "rgba(255,255,255,0.74)", maxWidth: 600, margin: "24px auto 0"
          }}>{sub}</p>}
          {(primary || secondary) &&
          <div style={{ display: "flex", gap: 16, justifyContent: "center", marginTop: 36, flexWrap: "wrap", alignItems: "center" }}>
            {primary && <a href={primaryHref} style={{
              display: "inline-flex", alignItems: "center", gap: 10,
              fontFamily: "var(--font-text)", fontSize: 17, fontWeight: 600,
              color: "#05070f", textDecoration: "none", padding: "14px 28px", borderRadius: 980,
              background: "#fff", boxShadow: "0 0 0 1px rgba(255,255,255,0.6), 0 8px 40px rgba(10,92,255,0.5)"
            }}>{primary}</a>}
            {secondary && <a href={secondaryHref} style={{
              display: "inline-flex", alignItems: "center",
              fontFamily: "var(--font-text)", fontSize: 17, fontWeight: 500,
              color: "#fff", textDecoration: "none", padding: "14px 6px"
            }}>{secondary}&nbsp;›</a>}
          </div>}
        </div>
      </section>);
  }
  return (
    <section style={{
      position: "relative",
      background: tone === "section" ? "var(--surface-section)" : "var(--surface-page)",
      padding: image ? "84px 22px 0" : "104px 22px 72px"
    }}>
      <div className="reveal" style={{ maxWidth: 860, margin: "0 auto", textAlign: "center", position: "relative", zIndex: 1 }}>
        {eyebrow && <Eyebrow style={{ marginBottom: 20 }}>{eyebrow}</Eyebrow>}
        <h1 style={{
          fontFamily: "var(--font-display)", fontWeight: 600,
          fontSize: "clamp(44px, 7.6vw, 82px)", lineHeight: 1.03,
          letterSpacing: "var(--tracking-hero)", color: "var(--text-primary)",
          margin: 0, textWrap: "balance"
        }}>{lines.map((l, i) => <span key={i} style={{ display: "block" }}>{l}</span>)}</h1>
        {sub && <p style={{
          fontFamily: "var(--font-text)", fontSize: "clamp(19px, 2.4vw, 23px)",
          lineHeight: 1.42, color: "var(--text-secondary)", maxWidth: 600, margin: "24px auto 0"
        }}>{sub}</p>}
        {(primary || secondary) &&
        <div style={{ display: "flex", gap: 16, justifyContent: "center", marginTop: 36, flexWrap: "wrap", alignItems: "center" }}>
          {primary && <a href={primaryHref} style={btnPrimary}>{primary}</a>}
          {secondary && <a href={secondaryHref} style={btnText}>{secondary}&nbsp;›</a>}
        </div>}
      </div>
      {image &&
      <div className="reveal" style={{ maxWidth: 1120, margin: "56px auto 0" }}>
        <image-slot id={imageId} shape="rounded" radius="28" placeholder={image}
          style={{ display: "block", width: "100%", height: imageH, borderRadius: "var(--radius-xl)", overflow: "hidden" }}></image-slot>
      </div>}
    </section>);
}

const btnPrimary = {
  display: "inline-flex", alignItems: "center", gap: 8,
  fontFamily: "var(--font-text)", fontSize: 17, fontWeight: 600,
  color: "var(--text-on-accent)", textDecoration: "none",
  padding: "14px 26px", borderRadius: 980, background: "var(--accent)",
  boxShadow: "0 8px 28px rgba(10,92,255,0.28)"
};
const btnText = {
  display: "inline-flex", alignItems: "center",
  fontFamily: "var(--font-text)", fontSize: 17, fontWeight: 500,
  color: "var(--accent)", textDecoration: "none", padding: "14px 6px"
};

/* ---------- Zahlen-Platzhalter (echte Zahlen werden nachgereicht) ---------- */
function StatPlaceholder({ label, hint = "Platzhalter", value, align = "center" }) {
  const hasValue = value != null && value !== "";
  return (
    <div style={{ textAlign: align }}>
      <div style={{
        display: "inline-flex", alignItems: "baseline", gap: 4,
        fontFamily: "var(--font-display)", fontWeight: 600,
        fontSize: "clamp(40px, 6vw, 64px)", letterSpacing: "var(--tracking-display)",
        lineHeight: 1, color: "var(--accent)", whiteSpace: "nowrap",
        borderBottom: hasValue ? "none" : "2px dashed color-mix(in oklab, var(--accent) 38%, transparent)",
        paddingBottom: hasValue ? 0 : 6
      }}>
        {hasValue ? <span>{value}</span> : <span style={{ opacity: 0.34 }}>0,0</span>}
      </div>
      <div style={{ fontFamily: "var(--font-text)", fontSize: 15, color: "var(--text-tertiary)", marginTop: 12, maxWidth: 220, marginLeft: align === "center" ? "auto" : 0, marginRight: align === "center" ? "auto" : 0 }}>{label}</div>
      {!hasValue &&
      <div style={{
        display: "inline-flex", alignItems: "center", gap: 5, marginTop: 8,
        fontFamily: "var(--font-text)", fontSize: 11, fontWeight: 600, letterSpacing: "0.08em",
        textTransform: "uppercase", color: "var(--text-tertiary)",
        background: "var(--surface-section)", padding: "3px 8px", borderRadius: 980
      }}>
        <i data-lucide="pencil-line" style={{ width: 11, height: 11 }}></i>{hint}
      </div>}
    </div>);
}

function StatRow({ items, columns }) {
  return (
    <section style={{ padding: "72px 22px", background: "var(--surface-page)" }}>
      <div className="reveal" style={{
        maxWidth: 980, margin: "0 auto",
        display: "grid", gridTemplateColumns: `repeat(${columns || items.length}, 1fr)`,
        gap: 32, justifyItems: "center"
      }}>
        {items.map((it, i) => <StatPlaceholder key={i} label={it.label} hint={it.hint} value={it.value} />)}
      </div>
    </section>);
}

/* ---------- Argument-Band: zentriert ODER als Bild/Text-Split ---------- */
function ArgumentBand({ eyebrow, head, sub, mode = "center", image, imageId, flip = false, tinted = false, statLabel }) {
  const bg = tinted ? "var(--surface-section)" : "var(--surface-page)";
  if (mode === "split") {
    const text = (
      <div style={{ flex: "1 1 380px", minWidth: 280 }}>
        <Reveal><Eyebrow style={{ marginBottom: 14 }}>{eyebrow}</Eyebrow></Reveal>
        <Reveal as="h2" style={{
          fontFamily: "var(--font-display)", fontWeight: 600,
          fontSize: "clamp(28px, 3.8vw, 44px)", lineHeight: 1.08,
          letterSpacing: "var(--tracking-display)", color: "var(--text-primary)", margin: 0, textWrap: "balance"
        }}>{head}</Reveal>
        <Reveal as="p" style={{
          fontFamily: "var(--font-text)", fontSize: "clamp(17px, 2vw, 20px)",
          lineHeight: 1.5, color: "var(--text-secondary)", margin: "18px 0 0", maxWidth: 440
        }}>{sub}</Reveal>
        {statLabel && <Reveal style={{ marginTop: 28 }}><StatPlaceholder label={statLabel} align="left" /></Reveal>}
      </div>);
    const pic = (
      <Reveal style={{ flex: "1 1 380px", minWidth: 280 }}>
        <image-slot id={imageId} shape="rounded" radius="28" placeholder={image}
          style={{ display: "block", width: "100%", height: 380, borderRadius: "var(--radius-xl)", overflow: "hidden" }}></image-slot>
      </Reveal>);
    return (
      <section style={{ padding: "84px 22px", background: bg }}>
        <div className="split-band" style={{ maxWidth: 1120, margin: "0 auto", display: "flex", gap: "clamp(32px, 5vw, 72px)", alignItems: "center", flexDirection: flip ? "row-reverse" : "row" }}>
          {pic}{text}
        </div>
      </section>);
  }
  // center
  return (
    <section style={{ padding: "104px 22px", background: bg }}>
      <div style={{ maxWidth: 760, margin: "0 auto", textAlign: "center" }}>
        <Reveal><Eyebrow style={{ marginBottom: 16 }}>{eyebrow}</Eyebrow></Reveal>
        <Reveal as="h2" style={{
          fontFamily: "var(--font-display)", fontWeight: 600,
          fontSize: "clamp(34px, 5.4vw, 60px)", lineHeight: 1.06,
          letterSpacing: "var(--tracking-display)", color: "var(--text-primary)", margin: 0, textWrap: "balance"
        }}>{head}</Reveal>
        <Reveal as="p" style={{
          fontFamily: "var(--font-text)", fontSize: "clamp(18px, 2.2vw, 22px)",
          lineHeight: 1.45, color: "var(--text-secondary)", maxWidth: 560, margin: "20px auto 0"
        }}>{sub}</Reveal>
        {statLabel && <Reveal style={{ marginTop: 40 }}><StatPlaceholder label={statLabel} /></Reveal>}
      </div>
    </section>);
}

/* ---------- Prozessschritte ---------- */
function ProcessSteps({ eyebrow, head, sub, steps, tinted = true }) {
  return (
    <section style={{ padding: "104px 22px", background: tinted ? "var(--surface-section)" : "var(--surface-page)" }}>
      <div style={{ maxWidth: 1080, margin: "0 auto" }}>
        <SectionHead eyebrow={eyebrow} head={head} sub={sub} />
        <div className="step-grid" style={{ marginTop: 56, display: "grid", gridTemplateColumns: `repeat(${steps.length}, 1fr)`, gap: 24 }}>
          {steps.map((s, i) => (
            <Reveal key={i}>
              <div style={{ display: "flex", flexDirection: "column", gap: 14 }}>
                <div style={{ display: "flex", alignItems: "center", gap: 12 }}>
                  <span style={{
                    flexShrink: 0, width: 38, height: 38, borderRadius: 980,
                    background: "var(--surface-card)", border: "1px solid var(--border-subtle)",
                    display: "inline-flex", alignItems: "center", justifyContent: "center",
                    fontFamily: "var(--font-display)", fontWeight: 600, fontSize: 16, color: "var(--accent)"
                  }}>{i + 1}</span>
                  <span style={{ flex: 1, height: 1, background: "var(--border-subtle)" }}></span>
                </div>
                <h3 style={{ fontFamily: "var(--font-display)", fontWeight: 600, fontSize: 21, letterSpacing: "var(--tracking-title)", color: "var(--text-primary)", margin: 0 }}>{s.t}</h3>
                <p style={{ fontFamily: "var(--font-text)", fontSize: 16, lineHeight: 1.5, color: "var(--text-secondary)", margin: 0 }}>{s.d}</p>
              </div>
            </Reveal>))}
        </div>
      </div>
    </section>);
}

/* ---------- Vorteile/Leistungen-Raster ---------- */
function FeatureGrid({ eyebrow, head, sub, items, columns = 3, tinted = false }) {
  return (
    <section style={{ padding: "104px 22px", background: tinted ? "var(--surface-section)" : "var(--surface-page)" }}>
      <div style={{ maxWidth: 1080, margin: "0 auto" }}>
        <SectionHead eyebrow={eyebrow} head={head} sub={sub} />
        <div className="feature-grid" style={{ marginTop: 56, display: "grid", gridTemplateColumns: `repeat(${columns}, 1fr)`, gap: 20 }}>
          {items.map((it, i) => (
            <Reveal key={i}>
              <div style={{
                height: "100%", background: "var(--surface-card)", border: "1px solid var(--border-subtle)",
                borderRadius: "var(--radius-lg)", padding: 28, boxShadow: "var(--shadow-card)"
              }}>
                <div style={{ width: 44, height: 44, borderRadius: 12, background: "var(--surface-section)", display: "inline-flex", alignItems: "center", justifyContent: "center", color: "var(--accent)" }}>
                  <i data-lucide={it.icon} style={{ width: 22, height: 22 }}></i>
                </div>
                <h3 style={{ fontFamily: "var(--font-display)", fontWeight: 600, fontSize: 19, letterSpacing: "var(--tracking-title)", color: "var(--text-primary)", margin: "18px 0 8px" }}>{it.t}</h3>
                <p style={{ fontFamily: "var(--font-text)", fontSize: 15, lineHeight: 1.5, color: "var(--text-secondary)", margin: 0 }}>{it.d}</p>
              </div>
            </Reveal>))}
        </div>
      </div>
    </section>);
}

/* ---------- Abschluss-CTA-Band — dunkler, markanter Header ---------- */
function CTABand({ eyebrow, head, sub, primary, secondary, primaryHref = "Railo%20Lokfuehrer.html", secondaryHref = "#" }) {
  return (
    <section style={{
      padding: "clamp(96px, 13vw, 160px) 22px", background: "#05070f",
      textAlign: "center", position: "relative", overflow: "hidden", isolation: "isolate"
    }}>
      {/* dezenter Glow hinter dem o, nur für Tiefe – kein Deko-Verlauf */}
      <div aria-hidden="true" style={{
        position: "absolute", left: "50%", top: "30%", width: 720, height: 720,
        transform: "translate(-50%,-50%)", zIndex: -1, pointerEvents: "none",
        background: "radial-gradient(circle, color-mix(in srgb, var(--accent) 34%, transparent) 0%, transparent 62%)",
        filter: "blur(20px)", opacity: 0.7
      }}></div>
      <div className="reveal" style={{ maxWidth: 880, margin: "0 auto" }}>
        <div style={{ display: "flex", justifyContent: "center", marginBottom: 30 }}><RailoO size={56} color="var(--accent)" metal /></div>
        {eyebrow && <div style={{
          fontFamily: "var(--font-text)", fontSize: 13, fontWeight: 600,
          letterSpacing: "0.08em", textTransform: "uppercase",
          color: "color-mix(in srgb, var(--accent) 72%, white)", marginBottom: 20
        }}>{eyebrow}</div>}
        <h2 style={{
          fontFamily: "var(--font-display)", fontWeight: 600,
          fontSize: "clamp(40px, 7vw, 80px)", lineHeight: 1.02,
          letterSpacing: "var(--tracking-display)", color: "#fff", margin: 0, textWrap: "balance"
        }}>{head}</h2>
        {sub && <p style={{ fontFamily: "var(--font-text)", fontSize: "clamp(18px, 2.2vw, 22px)", lineHeight: 1.45, color: "rgba(255,255,255,0.66)", maxWidth: 560, margin: "22px auto 0" }}>{sub}</p>}
        <div style={{ display: "flex", gap: 16, justifyContent: "center", marginTop: 44, flexWrap: "wrap", alignItems: "center" }}>
          {primary && <a href={primaryHref} style={{ ...btnPrimary, background: "#fff", color: "#05070f" }}>{primary}</a>}
          {secondary && <a href={secondaryHref} style={{ ...btnText, color: "#fff" }}>{secondary}&nbsp;›</a>}
        </div>
      </div>
    </section>);
}

/* ---------- Footer ---------- */
function RailoFooter() {
  const cols = [
    { h: "Lokführer:innen", items: [["Stellen", "Railo%20Lokfuehrer.html"], ["Bewerben", "Railo%20Lokfuehrer.html"], ["Weiterbildung", "Railo%20Lokfuehrer.html"]] },
    { h: "Unternehmen", items: [["Personal anfragen", "Railo%20Unternehmen.html"], ["So funktioniert's", "Railo%20Unternehmen.html"], ["Branchen", "Railo%20Unternehmen.html"]] },
    { h: "Railo", items: [["Über uns", "Railo%20Ueber%20Uns.html"], ["Kontakt", "#"], ["Karriere", "Railo%20Ueber%20Uns.html"]] },
  ];
  return (
    <footer style={{ borderTop: "1px solid var(--border-subtle)", background: "var(--surface-page)", position: "relative", zIndex: 1 }}>
      <div style={{ maxWidth: 1024, margin: "0 auto", padding: "56px 22px 40px" }}>
        <div className="footer-grid" style={{ display: "grid", gridTemplateColumns: "1.4fr repeat(3, 1fr)", gap: 32 }}>
          <div>
            <a href={RAILO_HOME} style={{ textDecoration: "none" }}><RailoLogo size={24} /></a>
            <p style={{ fontFamily: "var(--font-text)", fontSize: 14, color: "var(--text-tertiary)", lineHeight: 1.5, marginTop: 16, maxWidth: 220 }}>
              Menschen, die Züge bewegen.
            </p>
          </div>
          {cols.map((c) =>
          <div key={c.h}>
            <div style={{ fontFamily: "var(--font-text)", fontSize: 13, fontWeight: 600, color: "var(--text-primary)", marginBottom: 14 }}>{c.h}</div>
            <ul style={{ listStyle: "none", margin: 0, padding: 0, display: "flex", flexDirection: "column", gap: 11 }}>
              {c.items.map(([it, href]) =>
              <li key={it}><a href={href} style={{ fontFamily: "var(--font-text)", fontSize: 14, color: "var(--text-secondary)", textDecoration: "none" }}>{it}</a></li>)}
            </ul>
          </div>)}
        </div>
        <div style={{ marginTop: 40, paddingTop: 22, borderTop: "1px solid var(--border-subtle)", fontFamily: "var(--font-text)", fontSize: 13, color: "var(--text-tertiary)" }}>
          © 2026 Railo. Alle Rechte vorbehalten. ·{" "}
          <a href="Impressum.html" style={{ color: "inherit", textDecoration: "none" }}>Impressum</a> ·{" "}
          <a href="Datenschutz.html" style={{ color: "inherit", textDecoration: "none" }}>Datenschutz</a>
        </div>
      </div>
    </footer>);
}

/* ---------- Akzent/Raster-Tweak-Effekt (gemeinsam) ---------- */
function useRailoTheme(t) {
  React.useEffect(() => { if (window.lucide) window.lucide.createIcons(); });
  React.useEffect(() => {
    const root = document.documentElement;
    const pal = Array.isArray(t.akzent) ? t.akzent : ["#0a5cff", "#0048d6", "#0036a3"];
    root.style.setProperty("--accent", pal[0]);
    root.style.setProperty("--accent-hover", pal[1] || pal[0]);
    root.style.setProperty("--accent-pressed", pal[2] || pal[0]);
    root.style.setProperty("--text-link", pal[0]);
    root.style.setProperty("--railo-blue-500", pal[0]);
    const op = t.raster === "Aus" ? 0 : t.raster === "Markant" ? 0.16 : 0.07;
    root.style.setProperty("--raster-opacity", String(op));
    root.style.setProperty("--raster-image", railoRasterImage(pal[0], RAILO_GOLD));
  }, [t.akzent, t.raster]);
}

/* ---------- gemeinsamer Tweak-Block (Akzent + Raster) ---------- */
function RailoBaseTweaks({ t, setTweak, children }) {
  return (
    <TweaksPanel title="Tweaks">
      {children}
      <TweakSection label="Stimmung" />
      <TweakColor label="Akzent" value={t.akzent}
        options={[["#0a5cff", "#0048d6", "#0036a3"], ["#1e3a8f", "#16306f", "#0f2350"], ["#1f8a5b", "#19744c", "#13573a"], ["#c2531f", "#a8471a", "#863914"]]}
        onChange={(v) => setTweak("akzent", v)} />
      <TweakRadio label="o-Raster" value={t.raster} options={["Aus", "Dezent", "Markant"]} onChange={(v) => setTweak("raster", v)} />
    </TweaksPanel>);
}

Object.assign(window, {
  RAILO_NAV, RAILO_HOME, RAILO_GOLD, railoRasterImage,
  RailoO, RailoLogo, SubNav, Reveal, SectionHead, PageHero,
  StatPlaceholder, StatRow, ArgumentBand, ProcessSteps, FeatureGrid,
  CTABand, RailoFooter, useRailoTheme, RailoBaseTweaks,
  railoBtnPrimary: btnPrimary, railoBtnText: btnText,
});
