/* global React */
/* UC365 — Subpage components (depends on components.jsx loaded first) */

const { useState: useSubState } = React;

// =========================================================
//  PAGE HERO — for all subpages
// =========================================================
function PageHero({ eyebrow, title, lead, image, breadcrumb }) {
  return (
    <section className={'uc-page-hero' + (image ? '' : ' uc-page-hero-no-img')}>
      <div className="uc-container uc-page-hero-inner">
        <div>
          {breadcrumb &&
          <div className="uc-breadcrumb">
              <a href="UC365 Website.html">Start</a>
              {breadcrumb.map((b, i) =>
            <React.Fragment key={i}>
                  <span className="uc-breadcrumb-sep">/</span>
                  {b.href ?
              <a href={b.href}>{b.label}</a> :

              <span className="uc-breadcrumb-now">{b.label}</span>
              }
                </React.Fragment>
            )}
            </div>
          }
          {eyebrow && <span className="uc-eyebrow">{eyebrow}</span>}
          <h1 className="uc-page-title">{title}</h1>
          {lead && <p className="uc-page-lead">{lead}</p>}
        </div>
        {image &&
        <div className="uc-page-hero-img" style={{ backgroundImage: `url(${image})` }} data-comment-anchor="b99469115c-div-34-11" />
        }
      </div>
    </section>);

}

// =========================================================
//  STEP PROCESS — 3-step "Weg in die Community"
// =========================================================
function StepProcess({ steps }) {
  return (
    <div className="uc-steps">
      {steps.map((s, i) =>
      <div key={s.title} className="uc-step">
          <div className="uc-step-num">0{i + 1}</div>
          <h4>{s.title}</h4>
          <p>{s.body}</p>
        </div>
      )}
    </div>);

}

// =========================================================
//  PROGRAM TIMELINE
// =========================================================
function Timeline({ items }) {
  return (
    <div className="uc-timeline">
      {items.map((it, i) =>
      <div key={i} className="uc-timeline-item">
          <div className="uc-timeline-time">{it.time}</div>
          <h4 className="uc-timeline-title">{it.title}</h4>
          {it.body && <p className="uc-timeline-body">{it.body}</p>}
        </div>
      )}
    </div>);

}

// =========================================================
//  GALLERY
// =========================================================
function Gallery({ images }) {
  // images: array of { src, span?, alt? } — span: 'wide' | 'tall'
  const [openIdx, setOpenIdx] = useSubState(-1);
  const isOpen = openIdx >= 0;

  React.useEffect(() => {
    if (!isOpen) return;
    const onKey = (e) => {
      if (e.key === 'Escape') setOpenIdx(-1);else
      if (e.key === 'ArrowRight') setOpenIdx((i) => (i + 1) % images.length);else
      if (e.key === 'ArrowLeft') setOpenIdx((i) => (i - 1 + images.length) % images.length);
    };
    window.addEventListener('keydown', onKey);
    const prevOverflow = document.body.style.overflow;
    document.body.style.overflow = 'hidden';
    return () => {
      window.removeEventListener('keydown', onKey);
      document.body.style.overflow = prevOverflow;
    };
  }, [isOpen, images.length]);

  return (
    <>
      <div className="uc-gallery">
        {images.map((img, i) =>
        <div
          key={i}
          className={'uc-gallery-item' + (img.span === 'wide' ? ' uc-gallery-item-wide' : img.span === 'tall' ? ' uc-gallery-item-tall' : '')}
          style={{ backgroundImage: `url(${img.src})`, cursor: 'pointer' }}
          role="button"
          tabIndex={0}
          aria-label={img.alt || `Bild ${i + 1} von ${images.length} ansehen`}
          onClick={() => setOpenIdx(i)}
          onKeyDown={(e) => {if (e.key === 'Enter' || e.key === ' ') {e.preventDefault();setOpenIdx(i);}}} />

        )}
      </div>

      {isOpen &&
      <div className="uc-lightbox" onClick={() => setOpenIdx(-1)} role="dialog" aria-modal="true">
          <button
          className="uc-lightbox-close"
          onClick={(e) => {e.stopPropagation();setOpenIdx(-1);}}
          aria-label="Schließen">
          
            <svg width="24" height="24" viewBox="0 0 24 24" fill="none">
              <path d="M6 6l12 12M18 6L6 18" stroke="currentColor" strokeWidth="2" strokeLinecap="round" />
            </svg>
          </button>
          <button
          className="uc-lightbox-nav uc-lightbox-nav-prev"
          onClick={(e) => {e.stopPropagation();setOpenIdx((i) => (i - 1 + images.length) % images.length);}}
          aria-label="Vorheriges Bild">
          
            <svg width="32" height="32" viewBox="0 0 24 24" fill="none">
              <path d="M15 6l-6 6 6 6" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" />
            </svg>
          </button>
          <button
          className="uc-lightbox-nav uc-lightbox-nav-next"
          onClick={(e) => {e.stopPropagation();setOpenIdx((i) => (i + 1) % images.length);}}
          aria-label="Nächstes Bild">
          
            <svg width="32" height="32" viewBox="0 0 24 24" fill="none">
              <path d="M9 6l6 6-6 6" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" />
            </svg>
          </button>
          <figure className="uc-lightbox-figure" onClick={(e) => e.stopPropagation()}>
            <img className="uc-lightbox-img" src={images[openIdx].src} alt={images[openIdx].alt || ''} />
            {images[openIdx].alt &&
          <figcaption className="uc-lightbox-caption">{images[openIdx].alt}</figcaption>
          }
            <div className="uc-lightbox-counter">{openIdx + 1} / {images.length}</div>
          </figure>
        </div>
      }
    </>);

}

// =========================================================
//  TEAM GRID
// =========================================================
function TeamGrid({ members }) {
  return (
    <div className="uc-team-grid">
      {members.map((m) =>
      <div key={m.name} className="uc-team-card">
          <div className="uc-team-photo" style={{ backgroundImage: `url(${m.photo})` }} />
          <h4 className="uc-team-name">{m.name}</h4>
          <p className="uc-team-role">{m.role}</p>
          {m.link && <a href={m.link} className="uc-team-link">LinkedIn →</a>}
        </div>
      )}
    </div>);

}

// =========================================================
//  TRIP DETAIL CARD (Reisen)
// =========================================================
function TripCard({ image, title, body, date, location, seats, price, id, href, ctaLabel }) {
  return (
    <article className="uc-trip-card" id={id}>
      <div className="uc-trip-card-img" style={{ backgroundImage: `url(${image})` }} />
      <div className="uc-trip-card-body">
        <h3>{title}</h3>
        <p>{body}</p>
        <div className="uc-trip-card-meta">
          <div className="uc-trip-card-meta-item">
            <div className="uc-sm-lbl">Termin</div>
            <div className="uc-sm-val">{date}</div>
          </div>
          <div className="uc-trip-card-meta-item">
            <div className="uc-sm-lbl">Location</div>
            <div className="uc-sm-val">{location}</div>
          </div>
          {seats &&
          <div className="uc-trip-card-meta-item">
              <div className="uc-sm-lbl">Verfügbar</div>
              <div className="uc-sm-val" style={{ color: 'var(--uc-orange)' }}>{seats}</div>
            </div>
          }
          {price &&
          <div className="uc-trip-card-meta-item">
              <div className="uc-sm-lbl">Ab</div>
              <div className="uc-sm-val">{price}</div>
            </div>
          }
        </div>
        <div>
          <a className="uc-btn uc-btn-primary" href={href || 'Kontakt.html'}>
            {ctaLabel || 'Mehr Infos'}
            <Icon.ArrowUpRight />
          </a>
        </div>
      </div>
    </article>);

}

// =========================================================
//  CONTACT FORM
// =========================================================
function ContactForm() {
  const [submitted, setSubmitted] = useSubState(false);
  const [form, setForm] = useSubState({ name: '', email: '', company: '', topic: 'membership', message: '' });
  const update = (k) => (e) => setForm((f) => ({ ...f, [k]: e.target.value }));

  if (submitted) {
    return (
      <div className="uc-form-success">
        <strong>Danke, {form.name.split(' ')[0] || 'wir haben deine Nachricht'}.</strong>
        <br />
        Wir melden uns innerhalb eines Werktags zurück. In dringenden Fällen erreichst du Christian
        direkt unter mail@uc365.community.
      </div>);

  }

  return (
    <form className="uc-form" onSubmit={(e) => {e.preventDefault();setSubmitted(true);}}>
      <div className="uc-field-row">
        <div className="uc-field">
          <label htmlFor="cf-name">Dein Name</label>
          <input id="cf-name" type="text" value={form.name} onChange={update('name')} required />
        </div>
        <div className="uc-field">
          <label htmlFor="cf-email">E-Mail</label>
          <input id="cf-email" type="email" value={form.email} onChange={update('email')} required />
        </div>
      </div>
      <div className="uc-field">
        <label htmlFor="cf-company">Unternehmen</label>
        <input id="cf-company" type="text" value={form.company} onChange={update('company')} />
      </div>
      <div className="uc-field">
        <label htmlFor="cf-topic">Worum geht's?</label>
        <select id="cf-topic" value={form.topic} onChange={update('topic')}>
          <option value="membership">Ich möchte Mitglied werden</option>
          <option value="event">Ich habe Fragen zu einem Event</option>
          <option value="speaker">Speaker / Workshop-Anfrage</option>
          <option value="press">Presse / Medien</option>
          <option value="other">Etwas anderes</option>
        </select>
      </div>
      <div className="uc-field">
        <label htmlFor="cf-msg">Deine Nachricht</label>
        <textarea id="cf-msg" value={form.message} onChange={update('message')} required
        placeholder="Erzähl uns kurz, was du machst und was du dir von der Community erhoffst." />
      </div>
      <div>
        <button type="submit" className="uc-btn uc-btn-primary">
          Nachricht senden
          <Icon.ArrowUpRight />
        </button>
      </div>
    </form>);

}

// =========================================================
//  CONTACT ASIDE (sidebar with mail / hours / linkedin)
// =========================================================
function ContactAside() {
  return (
    <aside className="uc-contact-aside">
      <h3>Lieber direkt sprechen?</h3>
      <div className="uc-contact-row">
        <span className="uc-contact-row-ico">
          <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6">
            <rect x="3" y="5" width="18" height="14" rx="2" />
            <path d="M3 7l9 6 9-6" />
          </svg>
        </span>
        <div>
          <div className="uc-contact-row-lbl">E-Mail</div>
          <div className="uc-contact-row-val">
            <a href="mailto:mail@uc365.community">mail@uc365.community</a>
          </div>
        </div>
      </div>
      <div className="uc-contact-row">
        <span className="uc-contact-row-ico">
          <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6">
            <circle cx="12" cy="12" r="9" />
            <path d="M12 7v5l3 2" />
          </svg>
        </span>
        <div>
          <div className="uc-contact-row-lbl">Öffnungszeiten</div>
          <div className="uc-contact-row-val">Mo – Fr · 9:00 – 16:00</div>
        </div>
      </div>
      <div className="uc-contact-row">
        <span className="uc-contact-row-ico"><Icon.LinkedIn /></span>
        <div>
          <div className="uc-contact-row-lbl">LinkedIn</div>
          <div className="uc-contact-row-val">
            <a href="#">UC&nbsp;365 — Unternehmer Community</a>
          </div>
        </div>
      </div>
      <div className="uc-contact-row">
        <span className="uc-contact-row-ico">
          <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6">
            <rect x="3" y="5" width="18" height="16" rx="2" />
            <path d="M3 9h18M8 3v4M16 3v4" />
          </svg>
        </span>
        <div>
          <div className="uc-contact-row-lbl">Termin buchen</div>
          <div className="uc-contact-row-val">
            <a href="#">30 Min Kennenlerncall mit Christian →</a>
          </div>
        </div>
      </div>
    </aside>);

}

// =========================================================
//  CTA STRIP
// =========================================================
function CTAStrip({ title, primaryLabel, primaryHref, secondaryLabel, secondaryHref }) {
  return (
    <section className="uc-cta-strip">
      <div className="uc-container uc-cta-strip-inner">
        <h2>{title}</h2>
        <div className="uc-cta-strip-body">
          <a className="uc-btn uc-btn-on-orange" href={primaryHref || 'Kontakt.html'}>
            {primaryLabel || 'Sei dabei'}
            <Icon.ArrowUpRight />
          </a>
          {secondaryLabel &&
          <a href={secondaryHref || 'Kontakt.html'} className="uc-btn uc-btn-dark">{secondaryLabel}</a>
          }
        </div>
      </div>
    </section>);

}

// =========================================================
//  VIDEO TESTIMONIALS — inline-playing video gallery
// =========================================================
const TESTIMONIAL_VIDEOS = [
{ name: 'Alexander Eggers', role: 'CEO · NextVideo GmbH', poster: 'https://cdn.prod.website-files.com/64786325af69e9b944c9ec89/66698623e6544dd04987f721_Alexander.webp', video: 'https://video.gumlet.io/657ffce0483270175945e8d0/6580059c48327017594627ba/download.mp4' },
{ name: 'Andreas Hähnel', role: 'CEO · Black Magic Cloud', poster: 'https://cdn.prod.website-files.com/64786325af69e9b944c9ec89/668fabd21d6c58367c376bfb_Andreas%20Ha%CC%88hnel.webp', video: 'https://video.gumlet.io/657ffce0483270175945e8d0/658004d7d92ca1c1b5dd1537/download.mp4' },
{ name: 'Antonio Treglia', role: 'CEO · Pack of 7', poster: 'https://cdn.prod.website-files.com/64786325af69e9b944c9ec89/668fa82d77741f9b4755afd9_Antonio%20Treglia.webp', video: 'https://video.gumlet.io/657ffce0483270175945e8d0/658004d748327017594615e1/download.mp4' },
{ name: 'Artur Strzalkowski', role: 'Teamleitung · Digital Touch GmbH', poster: 'https://cdn.prod.website-files.com/64786325af69e9b944c9ec89/6667328d2efc46fd1b8ccda3_Artur.webp', video: 'https://video.gumlet.io/657ffce0483270175945e8d0/6580021ad92ca1c1b5dd0223/download.mp4' },
{ name: 'Bastian John', role: 'CTO · Solutions2Share', poster: 'https://cdn.prod.website-files.com/64786325af69e9b944c9ec89/668fb40c3325376d78fd894d_Bastian%20John.webp', video: 'https://video.gumlet.io/657ffce0483270175945e8d0/65800456d92ca1c1b5dd0d9e/download.mp4' },
{ name: 'Dennis Hoffstaedte', role: 'CEO · Datenpioniere GmbH', poster: 'https://cdn.prod.website-files.com/64786325af69e9b944c9ec89/668fad8d1de8f2c8170270f2_Dennis%20Hoffstaedte.webp', video: 'https://video.gumlet.io/657ffce0483270175945e8d0/658004564832701759460e8b/download.mp4' },
{ name: 'Dominik Stange', role: 'Co-Founder · addhucate GmbH', poster: 'https://cdn.prod.website-files.com/64786325af69e9b944c9ec89/668fb5f62d0090ff9467d46d_Dominik%20Stange.webp', video: 'https://video.gumlet.io/657ffce0483270175945e8d0/658004d748327017594615d7/download.mp4' },
{ name: 'Fabian Weber', role: 'Head of Compliance · PCG Germany', poster: 'https://cdn.prod.website-files.com/64786325af69e9b944c9ec89/666994e94580d6939987d24f_Fabian.webp', video: 'https://video.gumlet.io/657ffce0483270175945e8d0/65800543d92ca1c1b5dd1f03/download.mp4' },
{ name: 'Florian Pflanz', role: 'CCO · Solutions2Share GmbH', poster: 'https://cdn.prod.website-files.com/64786325af69e9b944c9ec89/6669844243c514ea90e66666_Florian.webp', video: 'https://video.gumlet.io/657ffce0483270175945e8d0/65a4e340573d69cc670685ea/download.mp4' },
{ name: 'Hannes Schröck', role: 'CEO · itacs GmbH', poster: 'https://cdn.prod.website-files.com/64786325af69e9b944c9ec89/668fb5056c773ff995e5430b_Hannes%20Schro%CC%88ck.webp', video: 'https://video.gumlet.io/657ffce0483270175945e8d0/65800456d92ca1c1b5dd0da0/download.mp4' },
{ name: 'Julian Lindner', role: 'Managing Partner · Hanso Group', poster: 'https://cdn.prod.website-files.com/64786325af69e9b944c9ec89/668fa93d1de8f2c817ff6f41_Julian%20Lindner.webp', video: 'https://video.gumlet.io/657ffce0483270175945e8d0/65800458d92ca1c1b5dd0dcb/download.mp4' },
{ name: 'Marcus Feimer', role: 'Senior Partner · Hanso Group', poster: 'https://cdn.prod.website-files.com/64786325af69e9b944c9ec89/666989a14e9df72ce136b9c1_Marcus.webp', video: 'https://video.gumlet.io/657ffce0483270175945e8d0/6580059b48327017594627a3/download.mp4' },
{ name: 'Matthias Hupe', role: 'Geschäftsführender Gesellschafter · Layer 2 GmbH', poster: 'https://cdn.prod.website-files.com/64786325af69e9b944c9ec89/66699ae369a992dd398e1930_Matthias.webp', video: 'https://video.gumlet.io/657ffce0483270175945e8d0/658005424832701759461f6a/download.mp4' },
{ name: 'Michael Asshauer', role: 'CEO · XHAUER', poster: 'https://cdn.prod.website-files.com/64786325af69e9b944c9ec89/6669930044772ac69c2f4af4_Michael%20A.webp', video: 'https://video.gumlet.io/657ffce0483270175945e8d0/6580059b483270175946279b/download.mp4' },
{ name: 'Michael Wohlfart', role: 'Partner · kwpartners StBerG mbH', poster: 'https://cdn.prod.website-files.com/64786325af69e9b944c9ec89/668fb2ad0a093f8968e0e30c_Michael%20Wohlfart.webp', video: 'https://video.gumlet.io/657ffce0483270175945e8d0/658004564832701759460e8e/download.mp4' },
{ name: 'Niklas Segbers', role: 'Co-Founder · Addhucate GmbH', poster: 'https://cdn.prod.website-files.com/64786325af69e9b944c9ec89/668facec530b1ed2f2a4064d_Niklas%20Segbers.webp', video: 'https://video.gumlet.io/657ffce0483270175945e8d0/6580021a48327017594602ff/download.mp4' },
{ name: 'Robert Kaiser', role: 'Geschäftsführender Gesellschafter · Wolkenwerft GmbH', poster: 'https://cdn.prod.website-files.com/64786325af69e9b944c9ec89/668fb3878ca86b567e7bc5c4_Robert%20Kaiser.webp', video: 'https://video.gumlet.io/657ffce0483270175945e8d0/65800456d92ca1c1b5dd0d8f/download.mp4' },
{ name: 'Thomas Maier', role: 'Geschäftsführer · 365 Akademie', poster: 'https://cdn.prod.website-files.com/64786325af69e9b944c9ec89/66673377fa72a85a2d31f65f_Thomas.webp', video: 'https://video.gumlet.io/657ffce0483270175945e8d0/6580021a4832701759460302/download.mp4' },
{ name: 'Thorsten Hufsky', role: 'CEO · Aithoria GmbH', poster: 'https://cdn.prod.website-files.com/64786325af69e9b944c9ec89/668fa9e5ad31a3e2bf83fb93_Thorsten%20Hufsky.webp', video: 'https://video.gumlet.io/657ffce0483270175945e8d0/658004d8d92ca1c1b5dd1557/download.mp4' },
{ name: 'Wolfgang Groß', role: 'CEO · Solutions2Share', poster: 'https://cdn.prod.website-files.com/64786325af69e9b944c9ec89/668faad73195cc9b0d6fc7fa_Wolfgang%20Gro%C3%9F.webp', video: 'https://video.gumlet.io/657ffce0483270175945e8d0/65800535d92ca1c1b5dd1da5/download.mp4' }];


function VideoCard({ name, role, poster, video }) {
  const [open, setOpen] = useSubState(false);
  // Support gumlet.tv watch URLs as embed iframes (for videos without direct mp4 URL)
  const ytMatch = video && video.match(/youtube\.com\/watch\?v=([\w-]+)|youtu\.be\/([\w-]+)/);
  const gumletMatch = video && video.match(/gumlet\.tv\/watch\/([\w-]+)/);
  const isEmbed = !!(ytMatch || gumletMatch);
  let embedSrc = null;
  let derivedPoster = poster;
  if (gumletMatch) {
    embedSrc = `https://play.gumlet.io/embed/${gumletMatch[1]}?autoplay=true`;
    if (!derivedPoster) derivedPoster = `https://video.gumlet.io/657ffce0483270175945e8d0/${gumletMatch[1]}/thumbnail-1-0.png`;
  } else if (ytMatch) {
    const id = ytMatch[1] || ytMatch[2];
    embedSrc = `https://www.youtube-nocookie.com/embed/${id}?autoplay=1&rel=0&modestbranding=1&playsinline=1`;
  }

  React.useEffect(() => {
    if (!open) return;
    const onKey = (e) => {if (e.key === 'Escape') setOpen(false);};
    window.addEventListener('keydown', onKey);
    const prev = document.body.style.overflow;
    document.body.style.overflow = 'hidden';
    return () => {
      window.removeEventListener('keydown', onKey);
      document.body.style.overflow = prev;
    };
  }, [open]);

  return (
    <>
      <div className="uc-video-card">
        <div className="uc-video-frame">
          <img
            className="uc-video-poster"
            src={derivedPoster || ''}
            alt={name || ''}
            loading="lazy"
            onClick={() => setOpen(true)}
            onError={(e) => {e.target.style.background = 'var(--uc-bg-dark)';}} />
          
          <button
            className="uc-video-play-btn"
            aria-label={`Video${name ? ' von ' + name : ''} abspielen`}
            onClick={() => setOpen(true)}
            tabIndex={-1}>
            
            <svg width="20" height="22" viewBox="0 0 20 22" fill="currentColor">
              <path d="M1.5 1.866a1 1 0 0 1 1.5-.866l16 9.464a1 1 0 0 1 0 1.732l-16 9.464a1 1 0 0 1-1.5-.866V1.866z" />
            </svg>
          </button>
        </div>
        {(name || role) &&
        <div className="uc-video-card-body">
            {name && <h4>{name}</h4>}
            {role && <p>{role}</p>}
          </div>
        }
      </div>

      {open &&
      <div className="uc-video-lightbox" onClick={() => setOpen(false)} role="dialog" aria-modal="true">
          <button
          className="uc-lightbox-close"
          onClick={(e) => {e.stopPropagation();setOpen(false);}}
          aria-label="Schließen">
          
            <svg width="24" height="24" viewBox="0 0 24 24" fill="none">
              <path d="M6 6l12 12M18 6L6 18" stroke="currentColor" strokeWidth="2" strokeLinecap="round" />
            </svg>
          </button>
          <div className="uc-video-lightbox-frame" onClick={(e) => e.stopPropagation()}>
            {isEmbed ?
          <iframe
            className="uc-video-lightbox-el"
            src={embedSrc}
            title={name || 'Video'}
            frameBorder="0"
            allow="accelerometer; autoplay; encrypted-media; fullscreen; picture-in-picture"
            allowFullScreen /> :


          <video
            className="uc-video-lightbox-el"
            src={video}
            poster={derivedPoster}
            controls
            autoPlay
            playsInline />

          }
          </div>
          {(name || role) &&
        <div className="uc-video-lightbox-caption">
              {name && <strong>{name}</strong>}
              {name && role && <span> · </span>}
              {role && <span>{role}</span>}
            </div>
        }
        </div>
      }
    </>);

}

function VideoTestimonials({ limit, eyebrow, title, videos, countLabel }) {
  const source = videos || TESTIMONIAL_VIDEOS;
  const list = limit ? source.slice(0, limit) : source;
  return (
    <section className="uc-section uc-section-soft">
      <div className="uc-container">
        <div className="uc-section-head-row">
          <div>
            {eyebrow && <span className="uc-eyebrow">{eyebrow}</span>}
            {title && <h2 className="uc-section-title">{title}</h2>}
          </div>
          <div className="uc-video-count">
            <strong>{source.length}</strong>&nbsp;{countLabel || 'Video-Stimmen aus der Community'}
          </div>
        </div>
        <div className="uc-video-grid">
          {list.map((v) =>
          <VideoCard key={v.name} {...v} />
          )}
        </div>
      </div>
    </section>);

}

// =========================================================
//  AFTERMOVIE — big hero video player
// =========================================================
function Aftermovie({ poster, src, label, title, note }) {
  const [playing, setPlaying] = useSubState(false);
  // Convert gumlet.tv watch URLs to play.gumlet.io embed URLs for iframe playback
  const isGumletEmbed = /gumlet\.tv\/watch\/|play\.gumlet\.io\/embed\//.test(src);
  // YouTube support — convert watch URL to embed URL
  const ytMatch = src.match(/youtube\.com\/watch\?v=([\w-]+)|youtu\.be\/([\w-]+)/);
  const ytId = ytMatch ? ytMatch[1] || ytMatch[2] : null;
  const isYouTube = !!ytId;
  const isEmbed = isGumletEmbed || isYouTube;
  let embedSrc = null;
  if (isGumletEmbed) {
    embedSrc = src.replace(/^https?:\/\/gumlet\.tv\/watch\/([^/?#]+).*$/, 'https://play.gumlet.io/embed/$1?autoplay=true');
  } else if (isYouTube) {
    embedSrc = `https://www.youtube-nocookie.com/embed/${ytId}?autoplay=1&rel=0&modestbranding=1&playsinline=1`;
  }
  return (
    <>
      <div className="uc-aftermovie">
        {!playing &&
        <>
            <img className="uc-aftermovie-poster" src={poster} alt={title} onClick={() => setPlaying(true)} />
            <div className="uc-aftermovie-overlay">
              {label && <span className="uc-aftermovie-label">{label}</span>}
              {title && <h3 className="uc-aftermovie-title">{title}</h3>}
            </div>
            <button
            className="uc-aftermovie-play"
            aria-label="Aftermovie abspielen"
            onClick={() => setPlaying(true)}>
            
              <svg width="34" height="38" viewBox="0 0 20 22" fill="currentColor">
                <path d="M1.5 1.866a1 1 0 0 1 1.5-.866l16 9.464a1 1 0 0 1 0 1.732l-16 9.464a1 1 0 0 1-1.5-.866V1.866z" />
              </svg>
            </button>
          </>
        }
        {playing && (
        isEmbed ?
        <iframe
          className="uc-aftermovie-el"
          src={embedSrc}
          title={title}
          frameBorder="0"
          allow="accelerometer; autoplay; encrypted-media; fullscreen; picture-in-picture"
          allowFullScreen /> :


        <video
          className="uc-aftermovie-el"
          src={src}
          poster={poster}
          controls
          autoPlay
          playsInline
          preload="metadata" />)


        }
      </div>
      {note && <p className="uc-aftermovie-note">{note}</p>}
    </>);

}

// =========================================================
//  Export
// =========================================================
Object.assign(window.UC, {
  PageHero, StepProcess, Timeline, Gallery, TeamGrid,
  TripCard, ContactForm, ContactAside, CTAStrip,
  VideoTestimonials, VideoCard, TESTIMONIAL_VIDEOS,
  Aftermovie
});