HifiPlanet-Website/hifi-src/src/pages/public/Home.jsx
Max Olchov ad3d1b081d
Live-Bearbeiten-Modus: Texte direkt auf der Website ändern
Eingeloggte Admins schalten über den Stift in der Navbar (oder "Website live
bearbeiten" im Dashboard) einen Bearbeiten-Modus ein und ändern Texte direkt
auf der Seite. Gesammelte Änderungen gehen mit "Speichern" an PUT /live-edit,
das jede Änderung gegen Feld-Whitelist und Berechtigung prüft und alles in
einer Transaktion schreibt.

- Startseite: Vorspann, Überschriften, Texte, Buttons inkl. Ziel, FAQ, Partner
- Leistungen, Paketkacheln (Name, Preistext, Stichpunkte), Marken, Modelle,
  Galerie-Marken/-Projekte, Impressum/Datenschutz/AGB
- Feste Texte (Buttons, Menü, Beschriftungen) je Seite über eine Liste,
  gespeichert in der neuen Tabelle text_overrides (Auto-Migration)
- Bearbeitet wird jeweils die gerade angezeigte Sprache
- .schema-version wird nicht mehr versioniert und vom Self-Update geschont

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015Dgc8etkq7JkjyZgD2DEbv
2026-10-19 22:31:25 +00:00

572 lines
30 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { useEffect, useRef, useState } from 'react';
import { Link } from 'react-router-dom';
import { motion, useScroll, useTransform, useReducedMotion } from 'framer-motion';
import { api } from '../../api/client.js';
import usePageMeta from '../../hooks/usePageMeta.js';
import Reveal from '../../components/Reveal.jsx';
import Accordion from '../../components/Accordion.jsx';
import StarRating from '../../components/StarRating.jsx';
import TestimonialSlider from '../../components/TestimonialSlider.jsx';
import { useIsAreaHidden, useSiteSettings } from '../../context/SiteSettingsContext.jsx';
import { isPathHidden } from '../../utils/siteAreas.js';
import { useTextStyle } from '../../context/TextStylesContext.jsx';
import { useLanguage } from '../../context/LanguageContext.jsx';
import { dragAnchorStyle } from '../../utils/dragAnchorPosition.js';
import { useLiveEdit } from '../../context/LiveEditContext.jsx';
import { EditableArea, EditableHtml, EditableT, EditableText } from '../../components/live/Editable.jsx';
import defaultHeroImage from '../../assets/photos/gallery-dash2.webp';
import galleryAmp from '../../assets/photos/gallery-amp-purple.webp';
import gallerySpeaker from '../../assets/photos/gallery-speaker.webp';
import gallerySubs from '../../assets/photos/gallery-subs.webp';
import galleryDash from '../../assets/photos/gallery-dash.webp';
import galleryTrunk from '../../assets/photos/hero-trunk.webp';
import galleryRear from '../../assets/photos/gallery-rear.webp';
import heroHighlight from '../../assets/leistungen/hero-highlight.webp';
import youtubeVideo from '../../assets/videos/youtube-hintergrund.mp4';
// Kurze 480p-Schleife (< 1 MB) fuer Handys statt der vollen 8,9-MB-Fassung.
import youtubeVideoMobile from '../../assets/videos/youtube-hintergrund-mobil.mp4';
// Tailwinds Build-Zeit-Scanner braucht die vollstaendigen Klassennamen woertlich im
// Quellcode - ein dynamisch zusammengesetzter String wie `text-${align}` wuerde nicht
// erkannt und aus dem Production-CSS herausgefiltert. Deshalb feste Lookup-Tabellen statt
// Template-Strings, angesteuert ueber home_sections.text_align (siehe HomeSectionController).
const ALIGN_TEXT = { left: 'text-left', center: 'text-center', right: 'text-right' };
const ALIGN_MARGIN_X = { left: '', center: 'mx-auto', right: 'ml-auto' };
const EMPTY_SECTION = {
eyebrow_de: '', eyebrow_en: '', title_de: '', title_en: '', body_html_de: '', body_html_en: '',
text_align: 'center', text_align_x: 50, text_align_y: 50,
button_label_de: '', button_label_en: '', button_url: '', font_family: null,
};
/** Rendert nur, wenn sowohl Beschriftung als auch Ziel gesetzt sind - interne Ziele (mit "/")
* bleiben in der SPA, alles andere oeffnet extern in einem neuen Tab. Zeigt das Ziel auf eine
* im Dashboard ausgeblendete Seite, entfaellt der Button (er wuerde nur zur Startseite fuehren). */
function SectionButton({ slug, label, url, className, style }) {
const { hidden_areas: hiddenAreas } = useSiteSettings();
const live = useLiveEdit();
// Im Bearbeiten-Modus immer sichtbar (auch ohne Text/Ziel), damit man ihn befuellen kann.
if (slug && live.canEdit('home_sections')) {
return (
<span className="inline-flex flex-wrap items-center justify-center gap-2">
<EditableText entity="home_sections" id={slug} field="button_label" value={label} className={className} style={style} placeholder="Button-Text (leer = kein Button)" />
<EditableArea
entity="home_sections"
id={slug}
field="button_url"
lang="de"
value={url}
kind="input"
label="Button-Ziel"
hint="Interne Seite mit / am Anfang (z. B. /leistungen) oder volle Adresse (https://...)."
as="span"
className="rounded bg-black/60 px-2 py-1 text-xs font-medium text-white"
>
Ziel: {url || '–'}
</EditableArea>
</span>
);
}
if (!label || !url) return null;
if (isPathHidden(url, hiddenAreas)) return null;
if (url.startsWith('/')) {
return (
<Link to={url} className={className} style={style}>
{label}
</Link>
);
}
return (
<a href={url} target="_blank" rel="noopener noreferrer" className={className} style={style}>
{label}
</a>
);
}
// Native Pixelmasse der Bilder unten - nur fuer die width/height-Attribute auf <img>,
// damit der Browser vor dem Laden Platz reserviert (verhindert Layout-Sprung). Die
// tatsaechliche Anzeigegroesse wird weiterhin komplett per CSS (aspect-square etc.)
// bestimmt, diese Werte muessen also nicht exakt zum gerenderten Seitenverhaeltnis passen.
const galleryImages = [
{ src: gallerySubs, width: 900, height: 600 },
{ src: galleryAmp, width: 900, height: 600 },
{ src: gallerySpeaker, width: 900, height: 1200 },
{ src: galleryDash, width: 900, height: 814 },
{ src: galleryRear, width: 900, height: 1200 },
{ src: galleryTrunk, width: 1920, height: 1280 },
];
export default function Home() {
const { hero_image_path: heroImagePath } = useSiteSettings();
const heroImage = heroImagePath || defaultHeroImage;
const { t, language } = useLanguage();
const isHidden = useIsAreaHidden();
const live = useLiveEdit();
const editing = live.canEdit('home_sections');
const showVehicles = !isHidden('page.vehicles');
const stats = t('home.stats');
const galleryAlts = t('home.galleryAlts');
const gallery = galleryImages.map((img, i) => ({ ...img, alt: galleryAlts[i] }));
const [faqs, setFaqs] = useState([]);
const [homeSections, setHomeSections] = useState({});
// Faellt /home-sections aus, greifen die Standardtexte - sonst bliebe z. B. die <h1> leer.
const [homeSectionsFailed, setHomeSectionsFailed] = useState(false);
const [partners, setPartners] = useState([]);
// Kurzform, um pro Abschnitt Text/Ausrichtung/Button in der jeweils aktiven Sprache zu lesen.
const section = (slug) => {
const s = homeSections[slug] || EMPTY_SECTION;
const fallbackTitle = homeSectionsFailed ? { hero: t('home.heroTitle'), craft: t('home.craftTitle') }[slug] || '' : '';
const fallbackBody = homeSectionsFailed && slug === 'hero' ? `<p>${t('home.heroSubtitle')}</p>` : '';
return {
// Inkl. noch nicht gespeicherter Live-Aenderungen (Bearbeiten-Modus).
eyebrow: live.getValue('home_sections', slug, 'eyebrow', language, s[`eyebrow_${language}`] || ''),
title: live.getValue('home_sections', slug, 'title', language, s[`title_${language}`] || fallbackTitle),
bodyHtml: live.getValue('home_sections', slug, 'body_html', language, s[`body_html_${language}`] || fallbackBody),
align: s.text_align || 'center',
// Nur fuer hero/youtube genutzt (echter Hintergrund) - siehe dragAnchorStyle-Aufrufe unten.
alignX: s.text_align_x,
alignY: s.text_align_y,
buttonLabel: live.getValue('home_sections', slug, 'button_label', language, s[`button_label_${language}`] || ''),
buttonUrl: live.getValue('home_sections', slug, 'button_url', 'de', s.button_url || ''),
fontFamily: s.font_family || undefined,
};
};
// Pro-Feld-Stil (Schriftart/-groesse/Farbe je Vorspann/Überschrift/Button-Text), zusaetzlich
// zur bestehenden Schriftart pro ganzer Sektion (section(slug).fontFamily) - siehe
// TextStylesContext.jsx. Feste Anzahl Aufrufe (6 Sektionen x bis zu 3 Felder), keine Schleife,
// da React Hooks nicht bedingt/dynamisch aufgerufen werden duerfen.
const heroEyebrowStyle = useTextStyle('home_sections.hero.eyebrow');
const heroTitleStyle = useTextStyle('home_sections.hero.title');
const youtubeEyebrowStyle = useTextStyle('home_sections.youtube.eyebrow');
const youtubeTitleStyle = useTextStyle('home_sections.youtube.title');
const youtubeButtonStyle = useTextStyle('home_sections.youtube.button_label');
const craftEyebrowStyle = useTextStyle('home_sections.craft.eyebrow');
const craftTitleStyle = useTextStyle('home_sections.craft.title');
const adviceEyebrowStyle = useTextStyle('home_sections.advice.eyebrow');
const adviceTitleStyle = useTextStyle('home_sections.advice.title');
const insightsEyebrowStyle = useTextStyle('home_sections.insights.eyebrow');
const insightsTitleStyle = useTextStyle('home_sections.insights.title');
const moreEyebrowStyle = useTextStyle('home_sections.more.eyebrow');
const moreTitleStyle = useTextStyle('home_sections.more.title');
const moreButtonStyle = useTextStyle('home_sections.more.button_label');
useEffect(() => {
api.get('/home-sections').then(setHomeSections).catch(() => setHomeSectionsFailed(true));
}, []);
useEffect(() => {
api.get('/partners').then(setPartners).catch(() => {});
}, []);
// Solange noch keine Google-Rezensionen konfiguriert/erfolgreich abgerufen wurden
// (googleReviews === null), zeigt die Seite die festen Beispiel-Texte aus den
// Uebersetzungen - danach die echten, im Admin-Bereich zwischengespeicherten Rezensionen.
const [googleReviews, setGoogleReviews] = useState(null);
const testimonials = googleReviews
? googleReviews.reviews
// Manche Google-Rezensionen sind reine Sterne-Bewertungen ohne Text - als
// Zitat-Karte ohne Zitat waeren die nur eine leere Huelle.
.filter((r) => r.review_text)
.map((r) => ({ name: r.author_name, text: r.review_text, rating: r.rating, photo: r.profile_photo_url }))
: t('home.testimonials');
useEffect(() => {
api
.get('/faqs')
.then((rows) => {
setFaqs(
rows.map((f) => ({
id: f.id,
question: language === 'de' ? f.question_de : f.question_en,
answer: language === 'de' ? f.answer_de : f.answer_en,
}))
);
})
.catch(() => {});
}, [language]);
useEffect(() => {
api
.get('/google-reviews')
.then((res) => {
// Nur uebernehmen, wenn mindestens eine Rezension auch echten Text hat -
// sonst bliebe die Zitat-Karten-Liste leer (siehe testimonials-Filter oben).
if (res.rating != null && res.reviews.some((r) => r.review_text)) setGoogleReviews(res);
})
.catch(() => {});
}, []);
usePageMeta({
title: t('home.metaTitle'),
description: t('home.metaDescription'),
path: '/',
});
useEffect(() => {
if (faqs.length === 0 || isHidden('home.faq')) return;
const script = document.createElement('script');
script.type = 'application/ld+json';
script.text = JSON.stringify({
'@context': 'https://schema.org',
'@type': 'FAQPage',
mainEntity: faqs.map((f) => ({
'@type': 'Question',
name: f.question,
acceptedAnswer: { '@type': 'Answer', text: f.answer },
})),
});
document.head.appendChild(script);
return () => document.head.removeChild(script);
}, [faqs]);
// Link "/#faq" (z. B. aus dem Admin): die FAQ laden erst nach, daher erst danach hinscrollen.
useEffect(() => {
if (faqs.length > 0 && window.location.hash === '#faq') {
document.getElementById('faq')?.scrollIntoView();
}
}, [faqs]);
// Das Hintergrundvideo erst laden, wenn sein Abschnitt in die Naehe des Bildschirms
// kommt, und ausserhalb pausieren - vorher startete der Download (autoPlay) sofort beim
// Seitenaufruf und konkurrierte mit Hero-Bild, Schriften und Skripten um die Bandbreite.
const videoRef = useRef(null);
useEffect(() => {
const video = videoRef.current;
if (!video) return undefined;
// Bei "Bewegung reduzieren" oder Datensparmodus bleibt es beim Standbild (Poster).
const reduceMotion = window.matchMedia?.('(prefers-reduced-motion: reduce)').matches;
const saveData = navigator.connection?.saveData;
if (reduceMotion || saveData) return undefined;
const isSmallScreen = window.matchMedia?.('(max-width: 767px), (pointer: coarse)').matches;
const source = isSmallScreen ? youtubeVideoMobile : youtubeVideo;
const observer = new IntersectionObserver(
([entry]) => {
if (entry.isIntersecting) {
if (!video.getAttribute('src')) video.src = source;
// Kann an Energiespar-/Autoplay-Regeln scheitern - dann bleibt das Poster stehen.
video.play().catch(() => {});
} else if (!video.paused) {
video.pause();
}
},
{ rootMargin: '300px 0px' }
);
observer.observe(video);
return () => observer.disconnect();
}, []);
const heroRef = useRef(null);
const { scrollYProgress: heroProgress } = useScroll({ target: heroRef, offset: ['start start', 'end start'] });
// Parallax laeuft ueber Motion-Values im style - das deckt MotionConfig (App.jsx) nicht ab,
// deshalb bei "Bewegung reduzieren" hier selbst auf feste Werte schalten.
const reduceMotion = useReducedMotion();
const heroImageY = useTransform(heroProgress, [0, 1], reduceMotion ? ['0%', '0%'] : ['-6%', '6%']);
const heroTextY = useTransform(heroProgress, [0, 1], reduceMotion ? ['0%', '0%'] : ['0%', '60%']);
const heroOpacity = useTransform(heroProgress, [0, 0.8], [1, 0]);
const ctaOpacity = useTransform(heroProgress, [0.5, 1], [0, 1]);
const ctaPointerEvents = useTransform(ctaOpacity, (v) => (v > 0.05 ? 'auto' : 'none'));
const ctaY = useTransform(heroProgress, [0.5, 1], [16, 0]);
return (
<div>
<motion.div
style={{ opacity: ctaOpacity, pointerEvents: ctaPointerEvents, y: ctaY }}
className="fixed inset-x-0 bottom-0 z-20 border-t border-neutral-200 bg-white/95 px-4 py-3 shadow-[0_-8px_24px_rgba(0,0,0,0.08)] backdrop-blur dark:border-neutral-800 dark:bg-neutral-950/95 sm:px-6"
>
<div className="mx-auto flex max-w-6xl items-center justify-between gap-3">
<EditableT k="home.stickyCta" as="p" className="hidden text-sm font-medium text-neutral-600 dark:text-neutral-300 sm:block" />
<div className="flex w-full gap-3 sm:w-auto">
{showVehicles && (
<Link
to="/fahrzeuge"
className="flex-1 rounded-md bg-brand-500 px-5 py-2.5 text-center text-sm font-semibold text-white shadow-sm transition hover:-translate-y-0.5 hover:bg-brand-600 sm:flex-none"
>
<EditableT k="home.selectVehicle" />
</Link>
)}
<Link
to="/kontakt"
className="flex-1 rounded-md border border-neutral-300 px-5 py-2.5 text-center text-sm font-semibold text-neutral-700 transition hover:-translate-y-0.5 hover:bg-neutral-100 dark:border-neutral-700 dark:text-neutral-200 dark:hover:bg-neutral-800 sm:flex-none"
>
<EditableT k="home.getInTouch" />
</Link>
</div>
</div>
</motion.div>
{/* Hoehe in svh statt dvh: dvh waechst auf dem Handy, sobald die Browserleisten beim Runterscrollen
eingeklappt sind - der Hero wurde dann nachtraeglich um die Leistenhoehe groesser und schob
alles darunter (Statistik-Leiste usw.) ruckartig nach unten. svh bleibt fest (Hoehe bei
eingeblendeten Leisten) und fuellt beim Seitenaufruf trotzdem genau den ersten Bildschirm. */}
<section ref={heroRef} className="relative -mt-[89px] h-svh min-h-[560px] overflow-hidden sm:-mt-[97px]">
<motion.img
style={{ y: heroImageY, scale: 1.15 }}
src={heroImage}
alt={t('home.heroImageAlt')}
className="absolute inset-0 h-full w-full object-cover"
/>
<div className="absolute inset-0 bg-gradient-to-t from-neutral-950 via-neutral-950/80 to-neutral-950/40" />
<motion.div style={{ y: heroTextY, opacity: heroOpacity }} className="absolute inset-0">
{/* Reine Positionierungs-Ebene (kein motion.div - siehe Kommentar bei dragAnchorPosition.js:
das eigene Scroll-Transform von framer-motion oben und die Eintritts-Animation unten
sollen sich nicht mit dieser statischen, per Drag gesetzten Position ueberschneiden). */}
<div
className="absolute w-full max-w-2xl px-4 text-center sm:px-6"
style={{
...dragAnchorStyle(section('hero').alignX, section('hero').alignY, { x: 50, y: 50 }),
fontFamily: section('hero').fontFamily,
}}
>
<motion.div
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.7, ease: 'easeOut' }}
>
{(section('hero').eyebrow || editing) && (
<EditableText entity="home_sections" id="hero" field="eyebrow" value={section('hero').eyebrow} as="p" className="mb-3 text-sm font-semibold uppercase tracking-wide text-brand-400" style={heroEyebrowStyle} placeholder="Vorspann (optional)" />
)}
<EditableText entity="home_sections" id="hero" field="title" value={section('hero').title} as="h1" className="text-3xl font-extrabold tracking-tight text-white sm:text-5xl" style={heroTitleStyle} placeholder="Überschrift" />
<EditableHtml entity="home_sections" id="hero" field="body_html" value={section('hero').bodyHtml} label="Text" className="legal-content mx-auto mt-4 max-w-2xl text-base text-neutral-200 sm:text-lg" />
<div className="mt-8 flex flex-wrap items-center justify-center gap-3">
{showVehicles && (
<Link
to="/fahrzeuge"
className="rounded-md bg-brand-500 px-6 py-3 text-sm font-semibold text-white shadow-sm transition hover:-translate-y-0.5 hover:bg-brand-600 hover:shadow-lg"
>
<EditableT k="home.selectVehicle" />
</Link>
)}
<Link
to="/kontakt"
className="rounded-md border border-white/30 bg-white/10 px-6 py-3 text-sm font-semibold text-white backdrop-blur transition hover:-translate-y-0.5 hover:bg-white/20"
>
<EditableT k="home.getInTouch" />
</Link>
</div>
</motion.div>
</div>
</motion.div>
</section>
{!isHidden('home.stats') && (
<section className="border-b border-neutral-200 bg-neutral-950 py-8 dark:border-neutral-800">
<div className="mx-auto grid max-w-6xl grid-cols-2 gap-6 px-4 text-center sm:grid-cols-4 sm:px-6">
{stats.map((stat, i) => (
<Reveal key={stat.label} index={i}>
<p className="text-2xl font-extrabold text-brand-400 sm:text-3xl">{stat.value}</p>
<p className="text-sm text-neutral-400">{stat.label}</p>
</Reveal>
))}
</div>
</section>
)}
{!isHidden('home.partners') && (
<section className="border-b border-neutral-200 py-8 dark:border-neutral-800">
<div className="mx-auto max-w-6xl px-4 sm:px-6">
<EditableT k="home.brandsHeading" as="p" className="mb-4 block text-center text-xs font-semibold uppercase tracking-wide text-neutral-400" />
<div className="flex flex-wrap items-center justify-center gap-x-8 gap-y-3">
{partners.map((partner, i) => (
<Reveal key={partner.id} index={i}>
{partner.logo_path ? (
<img src={partner.logo_path} alt={partner.name} className="h-8 max-w-[8rem] object-contain opacity-70 grayscale transition hover:opacity-100 hover:grayscale-0" />
) : (
<EditableText entity="partners" id={partner.id} field="name" lang="de" value={partner.name} className="text-lg font-bold text-neutral-400 dark:text-neutral-600" />
)}
</Reveal>
))}
</div>
</div>
</section>
)}
{!isHidden('home.youtube') && (
<section className="relative min-h-[70vh] overflow-hidden sm:min-h-[85vh]">
<video
ref={videoRef}
loop
muted
playsInline
preload="none"
poster={galleryDash}
className="absolute inset-0 h-full w-full object-cover"
/>
<div className="absolute inset-0 bg-black/55" />
<div
className="absolute w-full max-w-3xl px-4 text-center sm:px-6"
style={{
...dragAnchorStyle(section('youtube').alignX, section('youtube').alignY, { x: 50, y: 50 }),
fontFamily: section('youtube').fontFamily,
}}
>
<Reveal>
{(section('youtube').eyebrow || editing) && (
<EditableText entity="home_sections" id="youtube" field="eyebrow" value={section('youtube').eyebrow} as="p" className="mb-4 text-xs font-semibold uppercase tracking-[0.2em] text-neutral-200 sm:text-sm" style={youtubeEyebrowStyle} placeholder="Vorspann (optional)" />
)}
<EditableText entity="home_sections" id="youtube" field="title" value={section('youtube').title} as="h2" className="text-3xl font-bold uppercase tracking-wide text-white sm:text-5xl" style={youtubeTitleStyle} placeholder="Überschrift" />
<EditableHtml entity="home_sections" id="youtube" field="body_html" value={section('youtube').bodyHtml} label="Text" className="legal-content mt-4 text-xs font-semibold uppercase tracking-wide text-neutral-200 sm:text-sm" />
<SectionButton
slug="youtube"
label={section('youtube').buttonLabel}
url={section('youtube').buttonUrl}
className="mt-8 inline-flex items-center justify-center rounded-full bg-white px-8 py-3 text-xs font-bold uppercase tracking-wide text-neutral-900 transition hover:-translate-y-0.5 hover:bg-neutral-100"
style={youtubeButtonStyle}
/>
</Reveal>
</div>
</section>
)}
{!isHidden('home.craft') && (
<section className="grain-band border-y border-neutral-200 bg-neutral-50 py-16 dark:border-neutral-800 dark:bg-neutral-900/40">
<div className="mx-auto max-w-6xl space-y-16 overflow-hidden px-4 sm:px-6">
<div className="grid items-center gap-8 md:grid-cols-2">
<Reveal direction="left" shine className="rounded-xl shadow-lg">
<img
src={gallerySubs}
alt={t('home.craftImageAlt')}
width={900}
height={600}
className="w-full rounded-xl object-cover"
style={{ maxHeight: 380 }}
/>
</Reveal>
<Reveal direction="right" index={1} className={ALIGN_TEXT[section('craft').align]} style={{ fontFamily: section('craft').fontFamily }}>
{(section('craft').eyebrow || editing) && (
<EditableText entity="home_sections" id="craft" field="eyebrow" value={section('craft').eyebrow} as="p" className="mb-2 text-sm font-semibold uppercase tracking-wide text-brand-600 dark:text-brand-400" style={craftEyebrowStyle} placeholder="Vorspann (optional)" />
)}
<EditableText entity="home_sections" id="craft" field="title" value={section('craft').title} as="h2" className="mb-3 text-2xl font-bold text-neutral-900 dark:text-white" style={craftTitleStyle} placeholder="Überschrift" />
<EditableHtml entity="home_sections" id="craft" field="body_html" value={section('craft').bodyHtml} label="Text" className="legal-content text-neutral-600 dark:text-neutral-300" />
</Reveal>
</div>
<div className="grid items-center gap-8 md:grid-cols-2">
<Reveal direction="left" className={`order-2 md:order-1 ${ALIGN_TEXT[section('advice').align]}`} style={{ fontFamily: section('advice').fontFamily }}>
{(section('advice').eyebrow || editing) && (
<EditableText entity="home_sections" id="advice" field="eyebrow" value={section('advice').eyebrow} as="p" className="mb-2 text-sm font-semibold uppercase tracking-wide text-brand-600 dark:text-brand-400" style={adviceEyebrowStyle} placeholder="Vorspann (optional)" />
)}
<EditableText entity="home_sections" id="advice" field="title" value={section('advice').title} as="h2" className="mb-3 text-2xl font-bold text-neutral-900 dark:text-white" style={adviceTitleStyle} placeholder="Überschrift" />
<EditableHtml entity="home_sections" id="advice" field="body_html" value={section('advice').bodyHtml} label="Text" className="legal-content text-neutral-600 dark:text-neutral-300" />
</Reveal>
<Reveal direction="right" index={1} shine className="order-1 md:order-2 rounded-xl shadow-lg">
<img
src={galleryAmp}
alt={t('home.adviceImageAlt')}
width={900}
height={600}
className="w-full rounded-xl object-cover"
style={{ maxHeight: 380 }}
/>
</Reveal>
</div>
</div>
</section>
)}
{!isHidden('home.insights') && (
<section className="mx-auto max-w-6xl px-4 py-16 sm:px-6">
<Reveal className={`mb-8 ${ALIGN_TEXT[section('insights').align]}`} style={{ fontFamily: section('insights').fontFamily }}>
{(section('insights').eyebrow || editing) && (
<EditableText entity="home_sections" id="insights" field="eyebrow" value={section('insights').eyebrow} as="p" className="mb-2 text-sm font-semibold uppercase tracking-wide text-brand-600 dark:text-brand-400" style={insightsEyebrowStyle} placeholder="Vorspann (optional)" />
)}
<EditableText entity="home_sections" id="insights" field="title" value={section('insights').title} as="h2" className="text-2xl font-bold text-neutral-900 dark:text-white" style={insightsTitleStyle} placeholder="Überschrift" />
<EditableHtml entity="home_sections" id="insights" field="body_html" value={section('insights').bodyHtml} label="Text" className="legal-content mt-2 text-neutral-600 dark:text-neutral-300" />
</Reveal>
<div className="grid grid-cols-2 gap-3 sm:grid-cols-3">
{gallery.map((img, i) => (
<Reveal key={img.src} index={i % 3} shine className="aspect-square overflow-hidden rounded-xl border border-neutral-200 dark:border-neutral-800">
<img
src={img.src}
alt={img.alt}
width={img.width}
height={img.height}
loading="lazy"
className="h-full w-full object-cover transition duration-300 hover:scale-105"
/>
</Reveal>
))}
</div>
</section>
)}
{!isHidden('home.reviews') && (
<section className="grain-band border-y border-neutral-200 bg-neutral-50 py-16 dark:border-neutral-800 dark:bg-neutral-900/40">
<div className="mx-auto max-w-6xl px-4 sm:px-6">
<Reveal className="mb-10 text-center">
<div className="mb-2 flex items-center justify-center gap-2">
<StarRating className="h-6 w-6" count={googleReviews ? Math.round(googleReviews.rating) : 5} />
</div>
<h2 className="text-2xl font-bold text-neutral-900 dark:text-white">
{googleReviews ? t('home.reviewsRatingDynamic')(googleReviews.rating, googleReviews.rating_count) : t('home.reviewsRating')}
</h2>
<EditableT k="home.reviewsText" as="p" className="mt-1 text-neutral-600 dark:text-neutral-300" />
<a
href="https://www.google.com/maps/search/?api=1&query=Hifi+Planet+Amorbach+Boxbrunner+Stra%C3%9Fe+20a"
target="_blank"
rel="noopener noreferrer"
className="mt-2 inline-block text-sm font-medium text-brand-600 hover:underline dark:text-brand-400"
>
<EditableT k="home.reviewsLink" />
</a>
</Reveal>
<Reveal>
<TestimonialSlider testimonials={testimonials} />
</Reveal>
</div>
</section>
)}
{!isHidden('home.more') && (
<section className="mx-auto max-w-6xl overflow-hidden px-4 py-16 sm:px-6">
<div className="grid items-center gap-10 md:grid-cols-2">
<Reveal direction="left" shine className="overflow-hidden rounded-xl shadow-lg">
<img
src={heroHighlight}
alt={t('home.moreImageAlt')}
width={1600}
height={905}
className="h-full w-full object-cover"
loading="lazy"
/>
</Reveal>
<Reveal
direction="right"
index={1}
className={`rounded-xl border border-neutral-200 bg-white p-8 shadow-sm dark:border-neutral-800 dark:bg-neutral-900 ${ALIGN_TEXT[section('more').align]}`}
style={{ fontFamily: section('more').fontFamily }}
>
{(section('more').eyebrow || editing) && (
<EditableText entity="home_sections" id="more" field="eyebrow" value={section('more').eyebrow} as="p" className="mb-2 text-sm font-semibold uppercase tracking-wide text-brand-600 dark:text-brand-400" style={moreEyebrowStyle} placeholder="Vorspann (optional)" />
)}
<EditableText entity="home_sections" id="more" field="title" value={section('more').title} as="h2" className="mb-3 text-2xl font-bold text-neutral-900 dark:text-white" style={moreTitleStyle} placeholder="Überschrift" />
<EditableHtml entity="home_sections" id="more" field="body_html" value={section('more').bodyHtml} label="Text" className={`legal-content mb-8 max-w-2xl text-neutral-600 dark:text-neutral-300 ${ALIGN_MARGIN_X[section('more').align]}`} />
<SectionButton
slug="more"
label={section('more').buttonLabel}
url={section('more').buttonUrl}
className="inline-block rounded-md border border-neutral-300 px-6 py-3 text-sm font-semibold text-neutral-700 transition hover:-translate-y-0.5 hover:bg-neutral-100 dark:border-neutral-700 dark:text-neutral-200 dark:hover:bg-neutral-800"
style={moreButtonStyle}
/>
</Reveal>
</div>
</section>
)}
{!isHidden('home.faq') && (
<section id="faq" className="scroll-mt-20 border-t border-neutral-300 py-16 dark:border-neutral-700">
<div className="mx-auto max-w-3xl px-4 sm:px-6">
<Reveal className="mb-8 text-center">
<EditableT k="home.faqHeading" as="h2" className="text-2xl font-bold text-neutral-900 dark:text-white" />
</Reveal>
<Reveal index={1}>
<Accordion items={faqs} />
</Reveal>
</div>
</section>
)}
</div>
);
}