/* Burg Leuk, Maison 13 · das Restaurant vor der Burg Leuk
  Contemporary Alpine Social Club. Built on the bound design system
  (window.BurgLeukDesignSystem_07db60). The castle is the backdrop /
  the view, NOT our venue. We run the restaurant & terrace in front of it. */
const { Button, IconButton, Badge, Tag, Input, Card, EventCard, Avatar } = window.BurgLeukDesignSystem_07db60;
const h = React.createElement;
const Ic = (n, props = {}) => h('i', { 'data-lucide': n, ...props });

/* Burg Leuk Illustrationssystem, render an approved sujet by id.
  opts: { neg, className }. Wraps the data-source inner SVG markup. */
function Illus(id, opts) {
 opts = opts || {};
 const lib = window.BURG_ILLUS || [];
 const d = lib.find((s) => s.id === id);
 if (!d) return null;
 return h('svg', {
  className: 'ill ' + (opts.neg ? 'neg ' : '') + (opts.className || ''),
  viewBox: d.viewBox, role: 'img', 'aria-label': d.who || d.name,
  dangerouslySetInnerHTML: { __html: d.svg },
 });
}

function InstagramIcon() {
 return h('svg', { width: 18, height: 18, viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: 1.8, strokeLinecap: 'round', strokeLinejoin: 'round' },
  h('rect', { x: 2, y: 2, width: 20, height: 20, rx: 5 }),
  h('circle', { cx: 12, cy: 12, r: 4 }),
  h('line', { x1: 17.5, y1: 6.5, x2: 17.5, y2: 6.5 }));
}

/* thin hand-drawn contour line for the elevation sightline */
function SightlineRule() {
 return h('svg', { viewBox: '0 0 600 22', preserveAspectRatio: 'none', fill: 'none' },
  h('path', { d: 'M0 16 C 70 16, 110 6, 170 7 S 270 17, 330 12 S 440 2, 510 8 S 580 15, 600 12', stroke: 'var(--site-accent)', strokeWidth: 1.2, strokeLinecap: 'round', opacity: 0.7 }),
  h('path', { d: 'M0 20 C 90 19, 150 13, 230 14 S 360 21, 430 17 S 540 11, 600 17', stroke: 'var(--text-subtle)', strokeWidth: 1, strokeLinecap: 'round', opacity: 0.4 }));
}

const PAT_DARK = 'pattern-contour-ondark.svg';

const EVENTS = [
 { id: 'apero', category: 'Apéro', title: 'Afterwork Apéro', description: 'Ein Glas Wein, kleine Häppchen und gute Gesellschaft, wenn der Abend beginnt.', day: '11', month: 'Juni', time: 'ab 17:00', location: 'Terrasse', price: 'Eintritt frei', badge: 'Heute' },
 { id: 'wein', category: 'Degustation', title: 'Walliser Weinabend', description: 'Fünf Weine, fünf Geschichten, und der beste Sonnenuntergang weit und breit.', day: '14', month: 'Juni', time: 'ab 18:00', location: 'Terrasse', price: 'CHF 45', badge: 'Fast ausverkauft' },
 { id: 'musik', category: 'Live-Musik', title: 'Sundowner Sessions', description: 'Warme Klänge, während die Sonne hinter dem Tal verschwindet.', day: '20', month: 'Juni', time: 'ab 19:30', location: 'Terrasse', price: 'CHF 20' },
];

/* ---------------- Programm (gemeinsame Quelle window.BURG_CAL) ----------------
   Die Startseite zeigt das ganze Programm aus dem CAL (WM-Spiele + Spezialabende)
   plus die Sommer-Events. Chronologisch, vergangene Termine ausgeblendet,
   Progressive Disclosure ("mehr anzeigen"). Startzeiten der Fan Zone je Wochentag
   (Mo–Fr ab 16:00, Sa/So ab 14:00); die Anstosszeiten der Spiele bleiben wie im CAL.
   Walliser Tag: folgt nach Datenfreigabe (dann einfach im CAL ergaenzen). */
function blOpenTime(wd) { return (wd === 'Sa' || wd === 'So') ? '14:00' : '16:00'; }
function blIsTimeNote(s) { return !!s && /(^bis |^ab |\d{1,2}:\d{2}|^\d)/.test(s); }
function blThumb(e) {
 if (e.summer) return e.name.indexOf('Hofmarkt') >= 0 ? 'platz-strasse.webp'
   : (e.name.indexOf('Sunset') >= 0 ? 'platz-leben.webp' : 'terrasse-portrait.webp');
 if (e.cat === 'Spezial') return 'terrasse-wein.webp';
 return 'burg-summer.jpg';
}
function blTag(e) {
 if (e.badge) return e.badge;
 if (e.summer) return 'Sommer';
 if (e.ch) return 'Schweiz';
 if (e.ko) return 'K.o.-Phase';
 if (e.cat === 'Spezial') return 'Spezial';
 return 'Public Viewing';
}
function blMeta(e) {
 if (e.cat === 'Spiel') return 'ab ' + blOpenTime(e.wd) + ' · Anstoss ' + e.t;
 if (e.special && blIsTimeNote(e.special)) return e.t + ' ' + e.special;
 return 'ab ' + e.t;
}
/* Heutiges Datum als YYYYMMDD — gleiche Past-Hiding-Logik wie das CAL in der Fan Zone. */
const AGENDA_TODAY = (function () { var d = new Date(); return '' + d.getFullYear() + String(d.getMonth() + 1).padStart(2, '0') + String(d.getDate()).padStart(2, '0'); })();
function blAgendaRows() {
 var cal = (typeof window !== 'undefined' && window.BURG_CAL) ? window.BURG_CAL : [];
 return cal
  .filter(function (e) { return !e.d || e.d >= AGENDA_TODAY; })
  .slice()
  .sort(function (a, b) { return a.d === b.d ? (a.t < b.t ? -1 : 1) : (a.d < b.d ? -1 : 1); })
  .map(function (e) {
   var parts = (e.dl || '').split('. ');
   return {
    d: e.d, day: parts[0] || '', mo: parts[1] || '', wd: e.wd, name: e.name,
    sub: (e.special && !blIsTimeNote(e.special)) ? e.special : ((e.ko && e.name.indexOf('–') === -1) ? 'Paarung folgt' : ''),
    meta: blMeta(e), tag: blTag(e), img: blThumb(e),
    href: e.summer ? null : 'fan-zone-2026.html#spiele', fan: !e.summer
   };
  });
}

/* ---------------- Nav (burger menu) ---------------- */
function Nav({ onReserve }) {
 const [open, setOpen] = React.useState(false);
 React.useEffect(() => {
  document.body.style.overflow = open ? 'hidden' : '';
  if (open && window.lucide) window.lucide.createIcons();
 }, [open]);
 const nav = (target) => { setOpen(false); if (target) setTimeout(() => go(target), 60); };
 const items = [
  { label: 'Programm', go: 'agenda' },
  { label: 'Restaurant', go: 'tische' },
  { label: 'Der Ort', go: 'ort' },
  { label: 'Besuch', go: 'visit' },
  { label: 'Fan Zone Leuk 2026', href: 'fan-zone-2026.html', fan: true },
  { label: 'Über uns', href: 'ueber-uns.html' },
 ];
 return h(React.Fragment, null,
  h('header', { className: 'nav', id: 'nav', 'data-over': 'hero' },
   h('div', { className: 'nav__in' },
    h('button', { className: 'nav__brand', onClick: () => window.scrollTo({ top: 0, behavior: 'smooth' }) },
     h('img', { src: 'logo-mark-white.svg', alt: '', id: 'navMark' }),
     h('span', { className: 'bw' }, h('b', null, 'Burg Leuk'), h('span', null, 'Maison 13'))),
    h('div', { className: 'nav__right' },
     h('a', { className: 'nav__fanbtn', href: 'fan-zone-2026.html' }, 'Fan Zone'),
     h(Button, { variant: 'accent', size: 'sm', onClick: onReserve, iconRight: Ic('arrow-right') }, 'Reservieren'),
     h('button', { className: 'burger' + (open ? ' is-open' : ''), 'aria-label': 'Menü', 'aria-expanded': open ? 'true' : 'false', onClick: () => setOpen((v) => !v) },
      h('span', null), h('span', null), h('span', null))))),
  open ? h('div', { className: 'menu-ov', onClick: () => setOpen(false) },
   h('nav', { className: 'menu-ov__in', onClick: (e) => e.stopPropagation() },
    h('button', { className: 'menu-ov__close', 'aria-label': 'Menü schliessen', onClick: () => setOpen(false) },
     h('span', { style: { transform: 'rotate(45deg)' } }), h('span', { style: { transform: 'rotate(-45deg)' } })),
    h('span', { className: 'menu-ov__eyebrow' }, 'Burg Leuk · Maison 13'),
    h('ul', { className: 'menu-ov__list' },
     items.map((it, i) => h('li', { key: it.label, style: { '--mi': i } },
      it.href
       ? h('a', { href: it.href, className: it.fan ? 'is-fan' : '' }, it.label, h('i', { 'data-lucide': it.fan ? 'arrow-up-right' : 'arrow-right' }))
       : h('button', { onClick: () => nav(it.go) }, it.label, h('i', { 'data-lucide': 'arrow-right' }))))),
    h('div', { className: 'menu-ov__foot' },
     h('a', { href: 'https://www.instagram.com/burgleuk/', target: '_blank', rel: 'noopener' }, '@burgleuk'),
     h('a', { href: 'mailto:hallo@burgleuk.ch' }, 'hallo@burgleuk.ch'),
     h('span', null, 'Rathausplatz 10 · 3953 Leuk')))) : null);
}

function go(id) {
 const el = document.getElementById(id);
 if (el) window.scrollTo({ top: el.getBoundingClientRect().top + window.scrollY - 64, behavior: 'smooth' });
}

/* ---------------- Hero, full-bleed (v1 device), castle as backdrop ---------------- */
function Hero({ onReserve }) {
 return h('section', { className: 'hero', id: 'top', 'data-screen-label': 'Hero' },
  h('img', { className: 'hero__bg', src: 'hero-panorama.webp', alt: 'Die Burg Leuk mit dem Rhonetal und den Walliser Bergen' }),
  h('div', { className: 'hero__scrim' }),
  h('img', { className: 'hero__pat', src: PAT_DARK, alt: '' }),
  h('span', { className: 'hero__cross tl' }), h('span', { className: 'hero__cross tr' }),
  h('span', { className: 'hero__coord cl' }, '46°19′N'), h('span', { className: 'hero__coord cr' }, '07°38′E'),
  h('div', { className: 'hero__in' },
   h('div', { className: 'hero__copy' },
    h('p', { className: 'eyebrow on-dark line' }, 'Der Treffpunkt von Leuk.'),
    h('h1', { className: 'hero__title display' }, 'Schön, dass\ndu ', h('span', { className: 'a' }, 'da'), ' bist.'))),
  h('div', { className: 'hero__scroll' }, h('i', null), h('span', null, 'Scrollen')));
}

/* ---------------- Sightline ---------------- */
function Sightline() {
 return h('section', { className: 'sightline' },
  h('div', { className: 'sightline__in' },
   h('span', null, 'Oberwallis'),
   h('span', { className: 'sightline__rule' }, h(SightlineRule)),
   h('span', { className: 'sightline__c' }, 'Burg Leuk'),
   h('span', { className: 'sightline__rule' }, h(SightlineRule)),
   h('span', null, 'Unterwallis')));
}

/* ---------------- Angebot, full-width editorial text block (on white) ---------------- */
function Angebot() {
 const offers = ['Dein Event', 'Deine Generalversammlung', 'Dein Seminar', 'Deine Feier', 'Deine Hochzeit im Schloss'];
 return h('section', { className: 'angebot', id: 'angebot' },
  h('div', { className: 'wrap' },
   h('p', { className: 'angebot__lead reveal' },
    'Der Treffpunkt von Leuk. ', h('em', null, 'Walliser Wein'), ', gutes Essen und Menschen, die gerne zusammenkommen. Direkt neben dem Schloss. Mit Blick ins Rhonetal. ', h('em', null, 'Ein Ort, an dem man gerne bleibt.')),
   h('div', { className: 'angebot__offer reveal' },
    h('div', { className: 'angebot__offer-head' },
     h('span', { className: 'angebot__plus' }, '+'),
     h('span', { className: 'angebot__offer-label' }, 'Und wenn du mehr brauchst')),
    h('ul', { className: 'angebot__list' },
     offers.map((o) => h('li', { key: o }, h('span', { className: 'angebot__listplus' }, '+'), o))),
    h('p', { className: 'angebot__offer-text' }, 'Restaurant, Terrasse und Vorplatz, exklusiv für deinen Anlass. Und wenn ihr das Schloss mietet, koordinieren wir den ganzen Anlass: Deko, Catering, Eventtechnik. Alles aus einer Hand.'))));
}

/* ---------------- Marquee (cultural ticker) ---------------- */
function Marquee() {
 const words = ['Walliser Wein', 'Live-Musik', 'Apéro', 'Sunset Sessions', 'Walliser Markt', 'Summer-Vibes'];
 const seq = words.concat(words);
 return h('section', { className: 'marquee', 'aria-hidden': 'true' },
  h('div', { className: 'marquee__track' }, seq.map((w, i) => h('span', { key: i }, w))));
}

/* ---------------- Section header ---------------- */
function SecHead({ idx, eyebrow, title, action, lead }) {
 return h('div', { className: 'sechead' },
  h('span', { className: 'sechead__idx' }, idx),
  h('div', { className: 'sechead__main' },
   h('span', { className: 'eyebrow' }, eyebrow),
   h('h2', { className: 'sechead__title' }, title),
   lead ? h('p', { className: 'lead', style: { marginTop: '6px', maxWidth: '46ch' } }, lead) : null),
  action ? h('div', { className: 'sechead__action' }, action) : null);
}

/* ---------------- This week (cards) ---------------- */
function ThisWeek({ onReserve }) {
 const feat = EVENTS[0];
 const rest = EVENTS.slice(1);
 return h('section', { className: 'sec', id: 'programm' },
  h('div', { className: 'wrap' },
   h(SecHead, { idx: '01', eyebrow: 'Diese Woche', title: 'Was bei uns passiert',
    action: h(Button, { variant: 'ghost', iconRight: Ic('arrow-right'), onClick: () => go('agenda') }, 'Ganzes Programm') }),
   h('a', { className: 'promo', href: 'fan-zone-2026.html#spiele' },
    h('span', { className: 'promo__l' },
     h('span', { className: 'promo__eyebrow' }, 'Fan Zone Leuk 2026 · Public Viewing'),
     h('span', { className: 'promo__title' }, 'Der ganze Fussball-Sommer auf dem Rathausplatz')),
    h('span', { className: 'promo__cta' }, 'Spielkalender WM 2026', Ic('arrow-up-right'))),
   h('div', { className: 'evgrid reveal' },
    h('article', { className: 'evfeat', onClick: onReserve },
     h('figure', { className: 'evfeat__media' },
      h('img', { src: 'terrasse-wein.webp', alt: feat.title }),
      h('span', { className: 'evfeat__date' }, h('b', null, feat.day), h('em', null, feat.month)),
      feat.badge ? h('span', { className: 'evfeat__badge' }, feat.badge) : null),
     h('div', { className: 'evfeat__body' },
      h('span', { className: 'evfeat__cat' }, feat.category),
      h('h3', { className: 'evfeat__title' }, feat.title),
      h('p', { className: 'evfeat__desc' }, feat.description),
      h('div', { className: 'evfeat__meta' },
       h('span', null, Ic('clock'), ' ', feat.time),
       h('span', null, Ic('map-pin'), ' ', feat.location),
       h('span', null, Ic('ticket'), ' ', feat.price)),
      h('span', { className: 'evfeat__go' }, 'Reservieren ', Ic('arrow-right')))),
    h('div', { className: 'evside' },
     rest.map((e) => h('button', { key: e.id, className: 'evrow', onClick: onReserve },
      h('span', { className: 'evrow__date' }, h('b', null, e.day), h('em', null, e.month)),
      h('span', { className: 'evrow__main' },
       h('span', { className: 'evrow__cat' }, e.category),
       h('span', { className: 'evrow__name' }, e.title),
       h('span', { className: 'evrow__meta' }, e.time + ' · ' + e.location + ' · ' + e.price)),
      h('span', { className: 'evrow__go' }, Ic('arrow-right')))),
     h('div', { className: 'evside__foot' },
      h('span', { className: 'evside__coord' }, 'Juni 2026 · Burg Leuk'),
      h('button', { className: 'evside__all', onClick: () => go('agenda') }, 'Alle Termine ', Ic('arrow-right')))))));
}

/* ---------------- Statement band ---------------- */
function Band() {
 return h('section', { className: 'band' },
  h('img', { className: 'band__pat', src: PAT_DARK, alt: '' }),
  h('div', { className: 'band__in reveal' },
   h('span', { className: 'band__illus' }, Illus('vibes', { neg: true })),
   h('span', { className: 'eyebrow on-dark' }, 'Maison 13'),
   h('p', { className: 'band__q' }, 'Der Ort, an dem man sich trifft, feiert und den ', h('span', { className: 'a' }, 'Sommerabend'), ' nicht enden lassen will.')));
}

/* ---------------- Agenda, editorial list (v1 device) ---------------- */
function Agenda({ onReserve }) {
 const rows = blAgendaRows();
 const STEP = 6;
 const [shown, setShown] = React.useState(STEP);
 const visible = rows.slice(0, shown);
 return h('section', { className: 'sec agenda', id: 'agenda' },
  h('div', { className: 'wrap' },
   h('div', { className: 'agenda__head' },
    h('div', { className: 'agenda__head-l' },
     h('p', { className: 'eyebrow' }, 'Programm')),
    h('div', { className: 'agenda__cal' },
     h('span', { className: 'agenda__month' }, 'Sommer'),
     h('span', { className: 'agenda__year' }, '2026'))),
   h('div', { className: 'agenda__list reveal' },
    visible.map((e, i) => h('button', { key: i, className: 'arow' + (e.fan ? ' arow--fan' : ''),
      onClick: () => { if (e.href) window.location.href = e.href; else onReserve(); } },
     h('span', { className: 'arow__date' }, h('em', null, e.wd), h('b', null, e.day), h('em', null, e.mo)),
     h('span', { className: 'arow__name' }, e.name, e.sub ? h('small', null, e.sub) : null),
     h('span', { className: 'arow__tag' }, h(Tag, null, e.tag)),
     h('span', { className: 'arow__meta' }, e.meta),
     h('span', { className: 'arow__go' }, Ic(e.href ? 'arrow-up-right' : 'arrow-right')))),
   shown < rows.length
    ? h('button', { className: 'agenda__more', onClick: () => setShown(shown + STEP) },
       'Mehr anzeigen', h('span', { className: 'agenda__more-n' }, '+' + Math.min(STEP, rows.length - shown)))
    : null)));
}

/* ---------------- Der Ort, castle as backdrop, offset frame (v1 device) ---------------- */
function Ort() {
 return h('section', { className: 'sec ort', id: 'ort' },
  h('div', { className: 'wrap reveal' },
   h('div', { className: 'ort__media' },
    h('img', { src: 'terrasse-portrait.webp', alt: 'Die Terrasse vor der Burg Leuk mit Blick aufs Tal', 'data-parallax': '0.5' }),
    h('span', { className: 'ort__cnr tl' }, '46°19′01″N'),
    h('span', { className: 'ort__cnr br' }, 'Schloss Leuk')),
   h('div', { className: 'ort__body' },
    h('div', { className: 'ort__illus' }, Illus('the-traveller-variante-a-im-gehen', {})),
    h('p', { className: 'eyebrow line' }, 'Der Ort'),
    h('h2', { className: 'display' }, 'Mitten in\nLeuk.'),
    h('p', { className: 'lead' }, 'Direkt neben dem Schloss. Über dem Rhonetal. Mitten im alten Dorfkern von Leuk. Hier wird gekocht, gegessen, angestossen und gefeiert. Ein Ort mit Aussicht. Und vor allem mit Ruhe.'),
    h('div', { className: 'ort__facts' },
     h('div', null, Ic('map-pin'), h('span', null, 'Rathausplatz 10 · 3953 Leuk · Wallis')),
     h('div', null, Ic('clock'), h('span', null, 'Mo–Fr ab 16:00 · Sa & So ab 14:00')),
     h('div', null, Ic('bus'), h('span', null, 'Bus ab Bahnhof Leuk · rund 20 Minuten'))),
    h('div', { className: 'ort__host' },
     h(Avatar, { src: 'niko-head.png', name: 'Niko Solidoro', size: 'md' }),
     h('div', { className: 'ort__host-t' }, h('b', null, 'Niko Solidoro'), h('span', null, 'Gastgeber & Team'))),
    h(Button, { variant: 'primary', iconRight: Ic('arrow-up-right') }, 'Auf der Karte öffnen'))));
}

/* ---------------- Was dich erwartet ---------------- */
function Erleben() {
 const cell = (num, icon, title, text) => h('div', { className: 'modcell' },
  h('span', { className: 'modcell__icon' }, Ic(icon)),
  h('span', { className: 'modcell__num' }, num),
  h('h3', { className: 'modcell__title' }, title),
  h('p', { className: 'modcell__text' }, text));
 return h('section', { className: 'sec' },
  h('div', { className: 'wrap' },
   h(SecHead, { idx: '03', eyebrow: 'Erleben', title: 'Was dich erwartet' }),
   h('div', { className: 'modgrid reveal' },
    cell('01', 'grape', 'Wein &\nDegustation', 'Walliser Gewächse, kuratiert und erzählt, Glas für Glas.'),
    cell('02', 'music', 'Live-\nMusik', 'Sundowner Sessions auf der Terrasse, wenn die Sonne sinkt.'),
    cell('03', 'utensils', 'Küche &\nMarkt', 'Saisonales aus dem Wallis und Produzenten aus der Region zu Gast.'))));
}

/* ---------------- Restaurant & Terrasse (what we actually have) ---------------- */
function Tische() {
 const rows = [
  ['01', 'Restaurant', 'Die warme Stube im Herzen von Leuk. Saisonale Gerichte, ausgewählte Weine und eine Atmosphäre, die zum Bleiben einlädt.', 'bis 40 Plätze'],
  ['02', 'Terrasse', 'Direkt neben dem Schloss. Mit freiem Blick ins Rhonetal. Ein Ort für Sommerabende, Apéros und lange Gespräche.', 'bis 80 Plätze'],
  ['03', 'Privat & Feiern', 'Für Geburtstage, Hochzeiten, Firmenanlässe und besondere Abende. Restaurant und Terrasse können exklusiv genutzt werden.', 'auf Anfrage'],
 ];
 return h('section', { className: 'sec', id: 'tische' },
  h('div', { className: 'wrap' },
   h(SecHead, { idx: '04', eyebrow: 'Bei uns', title: 'Restaurant & Terrasse',
    lead: 'Drinnen oder draussen. Beide haben ihren Reiz. Die warme Stube für gemütliche Abende. Die Terrasse mit Blick über Leuk und das Rhonetal.' }),
   h('div', { className: 'trows reveal' },
    rows.map((r) => h('div', { key: r[0], className: 'trow' },
     h('span', { className: 'trow__num' }, r[0]),
     h('div', { className: 'trow__body' },
      h('h3', { className: 'trow__title' }, r[1]),
      h('p', { className: 'trow__text' }, r[2])),
     h('span', { className: 'trow__cap' }, r[3]))))));
}

/* ---------------- Atmosphere ---------------- */
function Atmos() {
 return h('section', { className: 'atmos', 'data-screen-label': 'Atmosphäre' },
  h('image-slot', { id: 'atmos-abend', src: 'terrasse-wein.webp', shape: 'rect', placeholder: 'Sommerabend mit Gästen, Bild ablegen' }),
  h('div', { className: 'atmos__grad' }),
  h('div', { className: 'atmos__in reveal' },
   h('p', { className: 'atmos__q' }, 'Komm vorbei,\nbleib länger.'),
   h('span', { className: 'atmos__cap' }, Ic('camera'), ' Sommerabend auf der Terrasse')));
}

/* ---------------- Editorial feature block (urbane vibes: bold burgundy + overlapping photo) ---------------- */
function Feature({ onReserve }) {
 return h('section', { className: 'feature' },
  h('div', { className: 'feature__block' },
   h('img', { className: 'feature__pat', src: PAT_DARK, alt: '' }),
   h('span', { className: 'feature__coord' }, '46°19′N · 07°38′E'),
   h('div', { className: 'feature__copy' },
    h('div', { className: 'feature__illus' }, Illus('the-vintner-variante-a-die-ernte', { neg: true })),
    h('span', { className: 'eyebrow on-dark' }, 'Aperitivo'),
    h('h2', { className: 'feature__title display' }, 'Ein gutes Glas Wein. Der Rest ergibt sich meist ', h('span', { className: 'u' }, 'von selbst'), '.'),
    h('p', null, 'Walliser Wein, passende Gerichte und das Rhonetal im Abendlicht. Manchmal reicht ein Tisch, ein Glas Wein und die richtigen Menschen. Komm vorbei. Bleib, solange es schön ist.'),
    h('div', { className: 'feature__cta' },
     h(Button, { variant: 'secondary', size: 'lg', onDark: true, onClick: () => go('agenda'), iconRight: Ic('arrow-right') }, 'Sunset Sessions')))),
  h('figure', { className: 'feature__media' },
   h('img', { src: 'platz-leben.webp', alt: 'Apéro auf dem Schlossplatz vor der Burg Leuk', 'data-parallax': '0.45' }),
   h('figcaption', null, Ic('camera'), ' Schlossplatz · Sommer')));
}

/* ---------------- Photo mosaic (dense, asymmetric, magazine grid) ---------------- */
function Mosaik() {
 const tiles = [
  { src: 'terrasse-wein.webp', cap: 'Apéro mit Aussicht', cls: 'm1', plx: '1.3' },
  { src: 'platz-strasse.webp', cap: 'Altstadt Leuk', cls: 'm2', plx: '-0.9' },
  { src: 'terrasse-portrait.webp', cap: 'Auf der Terrasse', cls: 'm3', plx: '1.7' },
  { src: 'hero-panorama.webp', cap: 'Das Rhonetal', cls: 'm4', plx: '-1.2' },
 ];
 return h('section', { className: 'sec mosaik2', id: 'momente' },
  h('div', { className: 'wrap' },
   h(SecHead, { idx: '05', eyebrow: 'Momente', title: 'Aus dem Sommer vor der Burg' }),
   h('div', { className: 'mosaik2__grid' },
    tiles.map((t, i) => h('figure', { key: i, className: 'm2tile ' + t.cls + ' reveal' },
     h('div', { className: 'm2tile__media' }, h('img', { src: t.src, alt: t.cap, 'data-parallax': t.plx, loading: 'lazy' })),
     h('figcaption', null, h('span', { className: 'm2tile__num' }, '0' + (i + 1)), ' ', t.cap))))));
}

/* ---------------- Visit + map plate (v1 cartographic device) ---------------- */
function Plate() {
 return h('div', { className: 'plate' },
  h('svg', { width: 0, height: 0, style: { position: 'absolute' } },
   h('defs', null,
    h('filter', { id: 'wobble' },
     h('feTurbulence', { type: 'fractalNoise', baseFrequency: '0.012 0.016', numOctaves: 2, seed: 4, result: 'noise' },
      h('animate', { attributeName: 'baseFrequency', dur: '14s', values: '0.012 0.016;0.016 0.012;0.012 0.016', repeatCount: 'indefinite' })),
     h('feDisplacementMap', { in: 'SourceGraphic', in2: 'noise', scale: 9, xChannelSelector: 'R', yChannelSelector: 'G' })))),
  h('img', { className: 'plate__topo', src: 'pattern-contour-kalk.svg', alt: '' }),
  h('span', { className: 'plate__cross a' }), h('span', { className: 'plate__cross b' }),
  h('span', { className: 'plate__pin' }, h('img', { src: 'logo-mark-anthracite.svg', alt: 'Burg Leuk' })),
  h('span', { className: 'plate__cnr tl' }, '46°19′N'),
  h('span', { className: 'plate__cnr tr' }, '07°38′E'),
  h('span', { className: 'plate__cnr bl' }, 'Rathausplatz 10 · Leuk'),
  h('span', { className: 'plate__cnr br' }, 'Leuk · Wallis'));
}

function Visit({ onReserve }) {
 return h('section', { className: 'sec visit', id: 'visit' },
  h('div', { className: 'wrap reveal' },
   h('div', null,
    h('div', { className: 'visit__illus' }, Illus('the-keeper-variante-a-laterne', {})),
    h('p', { className: 'eyebrow line' }, 'Besuch'),
    h('h2', null, 'Ein Tisch für dich.'),
    h('p', { className: 'lead' }, 'Reservation empfohlen, besonders, wenn die Sonne über dem Tal untergeht.'),
    h('div', { className: 'visit__facts' },
     h('div', { className: 'r' }, h('span', null, 'Öffnung'), h('b', null, 'Montag bis Freitag', h('small', null, 'ab 16:00 · Sa & So ab 14:00'))),
     h('div', { className: 'r' }, h('span', null, 'Adresse'), h('b', null, 'Rathausplatz 10', h('small', null, '3953 Leuk · Wallis'))),
     h('div', { className: 'r' }, h('span', null, 'Kontakt'), h('b', null, '027 473 39 53', h('small', null, 'hallo@burgleuk.ch')))),
    h('div', { className: 'visit__cta' },
     h(Button, { variant: 'accent', size: 'lg', onClick: onReserve, iconRight: Ic('arrow-right') }, 'Reservieren'),
     h(Button, { variant: 'secondary', size: 'lg', onClick: onReserve }, 'Anlass anfragen'))),
   h('div', { className: 'visit__plate' }, h(Plate))));
}

/* ---------------- Newsletter ---------------- */
function News() {
 return h('section', { className: 'sec sec--tight' },
  h('div', { className: 'wrap' },
   h('div', { className: 'news reveal' },
    h('img', { className: 'news__pat', src: PAT_DARK, alt: '' }),
    h('div', { className: 'news__copy' },
     h('span', { className: 'eyebrow on-dark' }, 'Burglerinnen und Burgler'),
     h('h3', null, 'Für Menschen, die gerne wissen, was bei uns passiert.'),
     h('p', null, 'Neue Veranstaltungen, besondere Abende und Geschichten aus Burg Leuk. Einige Male im Jahr. Nicht öfter.')),
    h('form', { className: 'news__form', onSubmit: (e) => e.preventDefault() },
     h(Input, { label: 'E-Mail', type: 'email', placeholder: 'du@beispiel.ch', icon: Ic('mail') }),
     h(Button, { variant: 'accent', block: true, iconRight: Ic('arrow-right') }, 'Anmelden')))));
}

/* ---------------- Footer ---------------- */
function Footer() {
 return h('footer', { className: 'foot' },
  h('img', { className: 'foot__pat', src: PAT_DARK, alt: '' }),
  h('div', { className: 'wrap' },
   h('p', { className: 'foot__big display' }, 'Da will ich heute ', h('span', { className: 'a' }, 'Abend'), ' sein.'),
   h('div', { className: 'foot__grid' },
    h('div', { className: 'foot__brand' },
     h('img', { src: 'logo-mark-kalkstein.svg', alt: 'Burg Leuk' }),
     h('p', null, 'Burg Leuk, das Restaurant vor der Burg. Ein Projekt von Maison 13. Der Treffpunkt von Leuk.')),
    h('div', { className: 'foot__col' }, h('h5', null, 'Besuch'),
     h('a', { onClick: () => go('visit') }, 'Öffnungszeiten'), h('a', { onClick: () => go('ort') }, 'Anfahrt'), h('a', { onClick: () => go('visit') }, 'Reservieren')),
    h('div', { className: 'foot__col' }, h('h5', null, 'Entdecken'),
     h('a', { href: 'fan-zone-2026.html' }, 'Fan Zone Leuk 2026'), h('a', { href: 'ueber-uns.html' }, 'Über uns'), h('a', { onClick: () => go('agenda') }, 'Programm'), h('a', { onClick: () => go('tische') }, 'Restaurant & Terrasse')),
    h('div', { className: 'foot__col' }, h('h5', null, 'Folgen'),
     h('a', { href: 'https://www.instagram.com/burgleuk/', target: '_blank', rel: 'noopener' }, h(InstagramIcon), ' Instagram'))),
   h('div', { className: 'foot__bot' },
    h('span', null, 'Rathausplatz 10 · 3953 Leuk · Wallis'),
    h('span', null,
     h('a', { className: 'foot__link', href: 'datenschutz.html' }, 'Datenschutz'), ' · ',
     h('a', { className: 'foot__link', href: 'impressum.html' }, 'Impressum'), ' · ',
     h('a', { className: 'foot__link', href: '#', id: 'cookie-settings' }, 'Cookie-Einstellungen'),
     ' · Ein Projekt von ', h('span', { className: 'a' }, 'Maison 13'), ' · © 2026'))));
}

/* ---------------- Fan Zone teaser ---------------- */
function FanTeaser() {
 return h('section', { className: 'fanteaser', id: 'fanzone' },
  h('a', { className: 'fanteaser__in', href: 'fan-zone-2026.html' },
   h('img', { className: 'fanteaser__pat', src: PAT_DARK, alt: '' }),
   h('div', { className: 'fanteaser__logo' },
    h('img', { className: 'fanteaser__mark', src: 'logo-mark-white.svg', alt: 'Burg Leuk' }),
    h('div', { className: 'fanteaser__type' }, h('span', { className: 'fz1' }, 'FAN'), h('span', { className: 'fz2' }, 'ZONE'))),
   h('div', { className: 'fanteaser__r' },
    h('p', { className: 'fanteaser__sig' }, 'Gemeinsam. Emotionen. Gänsehaut.'),
    h('p', { className: 'fanteaser__sub' }, 'Public Viewing auf dem Rathausplatz. Die Spiele, Spezialabende und Walliser Küche. Eintritt frei.'),
    h('span', { className: 'fanteaser__date' }, '11. Juni bis 19. Juli 2026'),
    h('span', { className: 'fanteaser__cta' }, 'Zur Fan Zone ', Ic('arrow-up-right')))));
}

/* ---------------- Reservation modal ---------------- */
function Reserve({ open, onClose }) {
 const [done, setDone] = React.useState(false);
 React.useEffect(() => { if (open) { setDone(false); window.lucide && window.lucide.createIcons(); } }, [open]);
 if (!open) return null;
 return h('div', { className: 'modal', onClick: onClose },
  h('div', { className: 'modal__box', onClick: (e) => e.stopPropagation() },
   h(IconButton, { label: 'Schliessen', variant: 'ghost', className: 'modal__x', onClick: onClose }, Ic('x')),
   done
    ? h('div', { className: 'modal__done' },
      h('div', { className: 'modal__check' }, Ic('check')),
      h('h3', null, 'Bis bald auf der Terrasse!'),
      h('p', null, 'Wir haben deine Anfrage erhalten und melden uns kurz zur Bestätigung.'),
      h(Button, { variant: 'primary', onClick: onClose }, 'Schön'))
    : h('div', null,
      h('span', { className: 'eyebrow' }, 'Reservieren'),
      h('h3', { className: 'modal__title' }, 'Ein Tisch für dich.'),
      h('div', { className: 'modal__grid' },
       h(Input, { label: 'Name', placeholder: 'Dein Name', icon: Ic('user') }),
       h(Input, { label: 'Personen', placeholder: 'z. B. 4', icon: Ic('users') }),
       h(Input, { label: 'Datum', type: 'date', icon: Ic('calendar') }),
       h(Input, { label: 'Uhrzeit', placeholder: 'ab 18:00', icon: Ic('clock') })),
      h('div', { style: { marginTop: '14px' } }, h(Input, { label: 'Anmerkung', optional: true, multiline: true, placeholder: 'Worauf hast du Lust?' })),
      h('div', { style: { marginTop: '18px' } }, h(Button, { variant: 'accent', block: true, onClick: () => setDone(true), iconRight: Ic('arrow-right') }, 'Anfrage senden')))));
}

/* ---------------- App ---------------- */
function App() {
 const [reserve, setReserve] = React.useState(false);
 const onReserve = () => setReserve(true);

 React.useEffect(() => {
  if (window.lucide) window.lucide.createIcons();
  // custom cursor (desktop only)
  const cur = document.getElementById('__cursor');
  if (cur && window.matchMedia('(pointer:fine)').matches) {
   let x = innerWidth / 2, y = innerHeight / 2, cx = x, cy = y;
   window.addEventListener('mousemove', (e) => { x = e.clientX; y = e.clientY; cur.style.opacity = '1'; }, { passive: true });
   const tick = () => { cx += (x - cx) * 0.2; cy += (y - cy) * 0.2; cur.style.transform = 'translate(' + cx + 'px,' + cy + 'px)'; requestAnimationFrame(tick); };
   requestAnimationFrame(tick);
   window.addEventListener('mouseover', (e) => {
    cur.classList.toggle('is-hot', !!e.target.closest('button,a,.evrow,.evfeat,.mtile,.arow,input,.hero__navlink,[role=button]'));
   }, { passive: true });
  }
  const nav = document.getElementById('nav');
  const navMark = document.getElementById('navMark');
  const hero = document.querySelector('.hero');
  const update = () => {
   const trigger = (hero ? hero.offsetHeight : 600) - 90;
   const stuck = window.scrollY > trigger;
   nav.classList.toggle('is-stuck', stuck);
   if (stuck) nav.removeAttribute('data-over'); else nav.setAttribute('data-over', 'hero');
   if (navMark) {
    const tag = document.documentElement.dataset.stimmung === 'tag';
    navMark.src = (stuck && tag) ? 'logo-mark-anthracite.svg' : 'logo-mark-white.svg';
   }
  };
  update();
  window.__burgNavUpdate = update;

  // ---- unified rAF scroll layer: nav · progress · hero · parallax ----
  const motionOK = window.matchMedia('(prefers-reduced-motion: no-preference)').matches;
  const prog = document.getElementById('__progress');
  const heroBg = document.querySelector('.hero__bg');
  const heroCopy = document.querySelector('.hero__copy');
  const heroScroll = document.querySelector('.hero__scroll');
  const plx = Array.from(document.querySelectorAll('[data-parallax]'));
  let ticking = false;
  const onScroll = () => {
   if (ticking) return;
   ticking = true;
   requestAnimationFrame(() => {
    const y = window.scrollY || 0;
    update();
    // scroll progress
    if (prog) {
     const max = (document.documentElement.scrollHeight - innerHeight) || 1;
     prog.style.transform = 'scaleX(' + Math.min(1, y / max).toFixed(4) + ')';
    }
    if (motionOK) {
     const vh = innerHeight;
     // hero: bg drifts down slower, copy rises + fades
     const hh = hero ? hero.offsetHeight : vh;
     if (y < hh) {
      const p = y / hh;
      if (heroBg) heroBg.style.transform = 'translate3d(0,' + (y * 0.34).toFixed(1) + 'px,0) scale(' + (1.05 + p * 0.12).toFixed(3) + ')';
      if (heroCopy) { heroCopy.style.transform = 'translate3d(0,' + (y * 0.18).toFixed(1) + 'px,0)'; heroCopy.style.opacity = Math.max(0, 1 - p * 1.35).toFixed(3); }
      if (heroScroll) heroScroll.style.opacity = Math.max(0, 1 - p * 2.4).toFixed(3);
     }
     // generic parallax targets
     plx.forEach((el) => {
      const r = el.getBoundingClientRect();
      const c = (r.top + r.height / 2 - vh / 2) / vh;
      const ty = c * (parseFloat(el.dataset.parallax) || 0) * -30;
      el.style.transform = 'translate3d(0,' + ty.toFixed(1) + 'px,0) scale(1.16)';
     });
    }
    ticking = false;
   });
  };
  window.addEventListener('scroll', onScroll, { passive: true });
  window.addEventListener('resize', onScroll);
  onScroll();

  // ---- staggered line/child reveal ----
  document.querySelectorAll('.reveal-stagger').forEach((grp) => {
   Array.from(grp.children).forEach((c, i) => { c.style.setProperty('--si', i); });
  });
  const els = document.querySelectorAll('.reveal:not(.in)');
  let fired = false;
  const io = new IntersectionObserver((ents) => ents.forEach((e) => {
   if (e.isIntersecting) { fired = true; e.target.classList.add('in'); io.unobserve(e.target); }
  }), { threshold: 0.12, rootMargin: '0px 0px -6% 0px' });
  els.forEach((el) => io.observe(el));
  const fb = setTimeout(() => { if (!fired) document.querySelectorAll('.reveal:not(.in)').forEach((el) => { el.style.transition = 'none'; el.classList.add('in'); }); }, 1400);
  return () => { window.removeEventListener('scroll', onScroll); window.removeEventListener('resize', onScroll); io.disconnect(); clearTimeout(fb); };
 }, []);

 return h('div', { className: 'site' },
  h('div', { className: 'scrollprog', id: '__progress', 'aria-hidden': 'true' }),
  h(Nav, { onReserve }),
  h('main', null,
   h(Hero, { onReserve }),
   h(Sightline),
   h(Angebot),
   h(Agenda, { onReserve }),
   h(Marquee),
   /* ThisWeek (EVENTS: Apéro, Weinabend, Sundowner) vorerst ausgeblendet —
      Startseite kommuniziert aktuell nur Public Viewing. Zum Reaktivieren
      Zeile wieder einkommentieren und Nav-Item 'Programm' auf 'programm' zuruecksetzen. */
   /* h(ThisWeek, { onReserve }), */
   h(Band),
   h(FanTeaser),
   h(Ort),
   h(Erleben),
   h(Feature, { onReserve }),
   h(Tische),
   h(Mosaik),
   h(Visit, { onReserve }),
   h(News)),
  h(Footer),
  h(Reserve, { open: reserve, onClose: () => setReserve(false) }),
  h('div', { className: 'cursor', id: '__cursor', 'aria-hidden': 'true' }));
}

if (!window.__siteMounted) {
 window.__siteMounted = true;
 ReactDOM.createRoot(document.getElementById('root')).render(h(App));
}
