// V6 — Mix of V4 (i18n, theme, scenes, prima/dopo, climax, 8 verticals)
// with Mockup C editorial DNA (diary spine, bolder weights, warm paper,
// clock-timeline hero, closing "— fine giornata —" centered coda).

function V6Nav({ lang, setLang, mode, setMode, onReroll, variantN }) {
  const T = useTheme();
  const t = useT();
  const { isMobile } = useViewport();
  return (
    <nav style={{
      display: 'flex', alignItems: 'center', justifyContent: 'space-between',
      padding: isMobile ? '16px 20px' : '22px 48px',
      position: 'sticky', top: 0, zIndex: 50,
      background: T.mode === 'dark' ? 'rgba(11,10,16,0.78)' : 'rgba(246,241,232,0.82)',
      backdropFilter: 'blur(14px)',
      borderBottom: `1px solid ${T.line}`,
    }}>
      <HelloWordmark size={isMobile ? 17 : 20} />
      {!isMobile && (
        <div style={{ display: 'flex', gap: 28, fontSize: 13, color: T.muted, fontWeight: 500 }}>
          <a href="#day" style={{ color: 'inherit', textDecoration: 'none' }}>{t.nav.day}</a>
          <a href="#features" style={{ color: 'inherit', textDecoration: 'none' }}>{t.nav.features}</a>
          <a href="#channels" style={{ color: 'inherit', textDecoration: 'none' }}>{t.nav.channels}</a>
          <a href="#pricing" style={{ color: 'inherit', textDecoration: 'none' }}>{t.nav.pricing}</a>
        </div>
      )}
      <div style={{ display: 'flex', gap: 10, alignItems: 'center' }}>
        <button onClick={onReroll} title={lang === 'en' ? 'New angle' : 'Nuova versione'} style={{
          background: 'transparent', border: `1px solid ${T.line2}`, color: T.muted,
          fontSize: 11, fontFamily: T.mono, letterSpacing: 1, padding: '6px 10px',
          borderRadius: 6, cursor: 'pointer', display: 'flex', alignItems: 'center', gap: 5,
        }}>↻ v{variantN + 1}</button>
        <button onClick={() => setLang(lang === 'it' ? 'en' : 'it')} style={{
          background: 'transparent', border: `1px solid ${T.line2}`, color: T.muted,
          fontSize: 11, fontFamily: T.mono, letterSpacing: 1, padding: '6px 10px',
          borderRadius: 6, cursor: 'pointer',
        }}>{lang === 'it' ? 'EN' : 'IT'}</button>
        <button onClick={() => setMode(mode === 'dark' ? 'light' : 'dark')} style={{
          background: 'transparent', border: `1px solid ${T.line2}`, color: T.muted,
          width: 30, height: 28, borderRadius: 6, cursor: 'pointer',
          display: 'flex', alignItems: 'center', justifyContent: 'center',
        }}>{mode === 'dark' ? '☾' : '☀'}</button>
        {!isMobile && (
          <a href="https://schedy-sales.aidevops1.workers.dev/#pricing" style={{ textDecoration: 'none' }}>
            <CTAPrimary>{t.cta.primary} →</CTAPrimary>
          </a>
        )}
      </div>
    </nav>
  );
}

function V6ClockHero({ vertical, lang }) {
  const T = useTheme();
  const { isMobile } = useViewport();
  const hours = [8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18];
  const events = {
    9:  { k: 'booking', l: lang === 'en' ? 'Booking' : 'Prenotazione' },
    11: { k: 'voice',   l: lang === 'en' ? 'Voice WA' : 'Vocale WA' },
    13: { k: 'break',   l: lang === 'en' ? 'Lunch'    : 'Pranzo' },
    15: { k: 'reminder',l: lang === 'en' ? 'Reminder -1h' : 'Reminder -1h' },
    17: { k: 'booking', l: lang === 'en' ? 'Cancel handled' : 'Cancellazione gestita' },
  };
  return (
    <div style={{
      background: T.ink2, border: `1px solid ${T.paperLine}`,
      borderRadius: 18, padding: isMobile ? 20 : 26, position: 'relative',
      boxShadow: T.mode === 'light' ? '0 24px 50px rgba(20,15,30,0.07)' : '0 24px 50px rgba(0,0,0,0.3)',
    }}>
      <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'baseline', marginBottom: 16 }}>
        <div style={{ fontSize: 14, fontWeight: 700, color: T.text }}>
          {lang === 'en' ? 'Today — Tuesday' : 'Oggi — martedì'}
        </div>
        <div style={{ fontSize: 10, color: T.muted, fontFamily: T.mono, letterSpacing: 1.5 }}>
          11 · AUTO
        </div>
      </div>

      <div style={{ position: 'relative', padding: '36px 0 12px' }}>
        <div style={{ position: 'absolute', left: 0, right: 0, top: 56, height: 2, background: T.paperLine, borderRadius: 1 }} />
        <div style={{
          position: 'absolute', left: 0, top: 56, height: 2, width: '64%',
          background: `linear-gradient(90deg, ${T.viola}, ${T.corallo})`, borderRadius: 1,
        }} />
        <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-end', position: 'relative' }}>
          {hours.map((h) => {
            const ev = events[h];
            return (
              <div key={h} style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 4, width: isMobile ? 24 : 30 }}>
                <div style={{
                  fontSize: 8, fontFamily: T.mono, color: ev ? T.corallo : 'transparent',
                  letterSpacing: 0.5, height: 22, textAlign: 'center', lineHeight: 1.15,
                  fontWeight: 600,
                }}>{ev ? ev.l : '·'}</div>
                <div style={{
                  width: ev ? 12 : 5, height: ev ? 12 : 5, borderRadius: 8,
                  background: ev ? T.ink2 : T.paperLine,
                  border: ev ? `2px solid ${ev.k === 'voice' ? T.corallo : T.viola}` : 'none',
                  boxShadow: ev ? '0 2px 6px rgba(139,92,246,0.3)' : 'none',
                  marginBottom: ev ? -2 : 2,
                }} />
                <div style={{ fontSize: 10, color: T.muted, fontFamily: T.mono, marginTop: 6, fontVariantNumeric: 'tabular-nums' }}>
                  {String(h).padStart(2, '0')}
                </div>
              </div>
            );
          })}
        </div>
      </div>

      <div style={{
        display: 'flex', alignItems: 'center', gap: 8,
        padding: '11px 14px', background: T.violaSoft,
        border: `1px solid ${T.violaBorder}`, borderRadius: 10, marginTop: 12,
      }}>
        <span style={{ width: 8, height: 8, borderRadius: 4, background: T.corallo }} />
        <span style={{ fontSize: 12, fontWeight: 500, color: T.text }}>
          {lang === 'en' ? 'Now — 15:12 · Reminders sent (3)' : 'Ora — 15:12 · Reminder inviati (3)'}
        </span>
        <span style={{ flex: 1 }} />
        <span style={{ fontSize: 10, fontFamily: T.mono, color: T.muted, letterSpacing: 1 }}>AUTO</span>
      </div>
    </div>
  );
}

function V6Hero({ vertical, onRotate, lang, variant }) {
  const T = useTheme();
  const t = useT();
  const { isMobile, isTablet } = useViewport();
  const H = variant.hero;
  return (
    <section style={{
      padding: isMobile ? '28px 20px 44px' : isTablet ? '40px 40px 56px' : '48px 48px 72px',
      position: 'relative',
    }}>
      <div style={{
        display: 'grid',
        gridTemplateColumns: isMobile ? '1fr' : '1.1fr 1fr',
        gap: isMobile ? 32 : 48, alignItems: 'center',
      }}>
        <div>
          <div style={{ fontFamily: T.mono, fontSize: 11, color: T.corallo, letterSpacing: 2, marginBottom: 18, fontWeight: 600 }}>
            {H.kicker}
          </div>
          <h1 style={{
            fontSize: isMobile ? 48 : isTablet ? 64 : 84,
            lineHeight: 0.96, letterSpacing: isMobile ? -1.8 : -3,
            fontWeight: T.hBold, margin: 0, color: T.text,
          }}>
            {H.h1.l1}<br/>
            {H.h1.l2}<br/>
            <span style={{ color: T.corallo, fontStyle: 'italic' }}>{H.h1.l3}</span>
          </h1>
          <p style={{ fontSize: isMobile ? 16 : 19, color: T.muted, lineHeight: 1.5, marginTop: 24, maxWidth: 520 }}>
            {H.bodyPre} <strong style={{ color: T.text }}>{H.bodyStrong}</strong>
          </p>
          <p style={{ fontSize: 14, color: T.muted, lineHeight: 1.5, marginTop: 14 }}>
            {lang === 'en' ? 'Today, a' : 'Oggi, un'}{' '}
            <button onClick={onRotate} style={{
              background: 'transparent', border: 'none', color: T.text, fontWeight: 700,
              textDecoration: 'underline', textDecorationColor: T.corallo,
              textDecorationThickness: 2, textUnderlineOffset: 4,
              cursor: 'pointer', padding: 0, font: 'inherit',
            }}>{verticalName(vertical, lang).toLowerCase()}</button>
            {' '}{lang === 'en' ? 'in' : 'a'} {vertical.place}.
          </p>
          <div style={{ display: 'flex', gap: 12, marginTop: 28, flexWrap: 'wrap' }}>
            <a href="https://schedy-sales.aidevops1.workers.dev/#pricing" style={{ textDecoration: 'none' }}>
              <CTAPrimary size="lg">{t.cta.start} →</CTAPrimary>
            </a>
            <a href="#day" style={{ textDecoration: 'none' }}>
              <CTASecondary size="lg">{t.cta.scrollDay}</CTASecondary>
            </a>
          </div>
        </div>
        <V6ClockHero vertical={vertical} lang={lang} />
      </div>

      {/* Stats strip — editorial: small italic lowercase, then huge bold number */}
      <div style={{
        display: 'grid',
        gridTemplateColumns: isMobile ? '1fr 1fr' : 'repeat(4, 1fr)',
        gap: isMobile ? 16 : 28,
        marginTop: isMobile ? 40 : 64,
        paddingTop: 24, borderTop: `1px solid ${T.paperLine}`,
      }}>
        {t.stats.map(([n, l]) => (
          <div key={l}>
            <div style={{ fontSize: 11, color: T.faint, marginBottom: 6, textTransform: 'lowercase', letterSpacing: 0.1, fontStyle: 'italic', fontWeight: 400 }}>{l.toLowerCase()}</div>
            <div style={{ fontSize: isMobile ? 40 : 56, fontWeight: T.hBold, letterSpacing: -2, color: T.text, lineHeight: 0.95, fontVariantNumeric: 'tabular-nums' }}>{n}</div>
          </div>
        ))}
      </div>
    </section>
  );
}

// Diary-spine moment (mockup C grammar) — time column | axis | content
function DayEntry({ n, time, kicker, children, first, last }) {
  const T = useTheme();
  const { isMobile } = useViewport();
  if (isMobile) {
    return (
      <div style={{ padding: '28px 0', borderTop: first ? 'none' : `1px solid ${T.paperLine}` }}>
        <div style={{ display: 'flex', alignItems: 'baseline', gap: 10, marginBottom: 14 }}>
          <div style={{ fontSize: 28, fontWeight: T.hBold, letterSpacing: -1, color: T.text, fontVariantNumeric: 'tabular-nums', lineHeight: 1 }}>{time}</div>
          <div style={{ fontSize: 10, color: T.corallo, fontFamily: T.mono, letterSpacing: 1.5, fontWeight: 600 }}>№{n} · {kicker.toUpperCase()}</div>
        </div>
        {children}
      </div>
    );
  }
  return (
    <div style={{
      display: 'grid', gridTemplateColumns: '120px 1px 1fr', gap: 36,
      padding: '40px 0', borderTop: first ? 'none' : `1px solid ${T.paperLine}`,
      alignItems: 'start',
    }}>
      <div>
        <div style={{ fontSize: 44, fontWeight: T.hBold, letterSpacing: -1.8, color: T.text, fontVariantNumeric: 'tabular-nums', lineHeight: 0.95 }}>{time}</div>
        <div style={{ fontSize: 10, color: T.corallo, fontFamily: T.mono, letterSpacing: 1.5, marginTop: 8, fontWeight: 600 }}>№{n}</div>
        <div style={{ fontSize: 11, color: T.muted, marginTop: 4, fontStyle: 'italic' }}>— {kicker.toLowerCase()}</div>
      </div>
      <div style={{ width: 1, background: T.paperLine, height: '100%', position: 'relative', minHeight: 80 }}>
        <div style={{
          position: 'absolute', top: 10, left: -6, width: 13, height: 13, borderRadius: 7,
          background: T.ink2, border: `2.5px solid ${T.viola}`,
        }} />
        {last && <div style={{
          position: 'absolute', bottom: 10, left: -6, width: 13, height: 13, borderRadius: 7,
          background: T.corallo, border: `2.5px solid ${T.corallo}`,
        }} />}
      </div>
      <div>{children}</div>
    </div>
  );
}

function Moment0842({ vertical, variant }) {
  const T = useTheme();
  const t = useT();
  const m = t.moments.m1;
  const { isMobile } = useViewport();
  return (
    <DayEntry n="01" time="08:42" kicker={m.kicker} first>
      <h2 style={{ fontSize: isMobile ? 26 : 40, lineHeight: 1.05, letterSpacing: -1.2, fontWeight: T.hMid, margin: 0, color: T.text }}>
        {variant.m1H.pre}{vertical.firstName}{variant.m1H.post}{' '}
        <em style={{ fontStyle: 'italic', color: T.corallo, fontWeight: T.hBold }}>{variant.m1HAccent}</em>
      </h2>
      <p style={{ fontSize: isMobile ? 14 : 16, color: T.muted, lineHeight: 1.6, marginTop: 14, maxWidth: 560 }}>{variant.m1Body}</p>
      <div style={{ display: 'flex', gap: 8, marginTop: 16, flexWrap: 'wrap' }}>
        {m.chips.map((c) => <ChipPill key={c}>{c}</ChipPill>)}
      </div>
      <div style={{
        marginTop: 20, padding: 16, background: T.ink2, border: `1px solid ${T.paperLine}`, borderRadius: 12,
      }}>
        <div style={{ fontFamily: T.mono, fontSize: 10, color: T.faint, letterSpacing: 1.5, marginBottom: 10, fontWeight: 600 }}>
          {m.agenda.title.replace('{staff}', vertical.staffName.toUpperCase())}
        </div>
        {vertical.agenda.slice(0, 3).map((r, i) => (
          <div key={i} style={{ display: 'grid', gridTemplateColumns: '56px 1fr', gap: 12, padding: '8px 0', borderTop: i ? `1px solid ${T.paperLine}` : 'none' }}>
            <div style={{ fontSize: 12, fontWeight: 700, color: T.text, fontFamily: T.mono, fontVariantNumeric: 'tabular-nums' }}>{r.t}</div>
            <div>
              <div style={{ fontSize: 13, fontWeight: 600, color: T.text }}>{r.who}</div>
              <div style={{ fontSize: 11, color: T.muted }}>{r.svc}</div>
            </div>
          </div>
        ))}
        <div style={{ padding: '8px 0 0', borderTop: `1px solid ${T.paperLine}`, display: 'flex', alignItems: 'center', gap: 8, fontSize: 10, color: T.muted, fontFamily: T.mono, letterSpacing: 0.5, marginTop: 4 }}>
          <span style={{ width: 6, height: 6, borderRadius: 3, background: '#10b981' }} />
          {m.agenda.sync}
        </div>
      </div>
    </DayEntry>
  );
}

function Moment1130({ vertical, variant }) {
  const T = useTheme();
  const t = useT();
  const m = t.moments.m2;
  const { isMobile } = useViewport();
  return (
    <DayEntry n="02" time="11:30" kicker={m.kicker}>
      <h2 style={{ fontSize: isMobile ? 26 : 40, lineHeight: 1.05, letterSpacing: -1.2, fontWeight: T.hMid, margin: 0, color: T.text }}>
        {variant.m2H} <em style={{ fontStyle: 'italic', color: T.corallo, fontWeight: T.hBold }}>{variant.m2HAccent}</em>
      </h2>
      <p style={{ fontSize: isMobile ? 14 : 16, color: T.muted, lineHeight: 1.6, marginTop: 14, maxWidth: 620 }}>{variant.m2Body}</p>
      <div style={{ marginTop: 20 }}>
        <VoiceScene vertical={vertical} />
      </div>
    </DayEntry>
  );
}

function Moment1400({ vertical, variant }) {
  const T = useTheme();
  const t = useT();
  const m = t.moments.m3;
  const { isMobile } = useViewport();
  return (
    <DayEntry n="03" time="14:00" kicker={m.kicker}>
      <div style={{ display: 'grid', gridTemplateColumns: isMobile ? '1fr' : '1fr auto', gap: isMobile ? 20 : 36, alignItems: 'start' }}>
        <div>
          <h2 style={{ fontSize: isMobile ? 26 : 40, lineHeight: 1.05, letterSpacing: -1.2, fontWeight: T.hMid, margin: 0, color: T.text }}>
            {variant.m3H} <em style={{ fontStyle: 'italic', color: T.corallo, fontWeight: T.hBold }}>{variant.m3HAccent}</em>
          </h2>
          <p style={{ fontSize: isMobile ? 14 : 16, color: T.muted, lineHeight: 1.6, marginTop: 14, maxWidth: 420 }}>{variant.m3Body}</p>
          <div style={{ display: 'flex', gap: 8, marginTop: 16, flexWrap: 'wrap' }}>
            {m.chips.map((c) => <ChipPill key={c}>{c}</ChipPill>)}
          </div>
        </div>
        <ReminderScene vertical={vertical} />
      </div>
    </DayEntry>
  );
}

function Moment1754Climax({ vertical, variant }) {
  const T = useTheme();
  const t = useT();
  const m = t.moments.m4;
  const { isMobile } = useViewport();
  return (
    <DayEntry n="04" time="17:54" kicker={m.kicker} last>
      <div style={{
        padding: isMobile ? '24px 22px' : '32px 36px',
        background: `linear-gradient(135deg, ${T.corallo}, ${T.coralloDeep})`,
        color: '#fff', borderRadius: 16,
        boxShadow: '0 20px 50px rgba(244,63,94,0.3)',
      }}>
        <h2 style={{ margin: 0, fontSize: isMobile ? 30 : 48, lineHeight: 1, letterSpacing: -1.8, fontWeight: T.hBold }}>
          {variant.m4H.pre}<span>+{vertical.stats.bookings}</span> {variant.m4H.post}
        </h2>
        <div style={{ marginTop: 10, fontSize: isMobile ? 18 : 24, fontStyle: 'italic', fontWeight: T.hMid, opacity: 0.95 }}>
          {variant.m4HAccent}
        </div>

        <div style={{
          display: 'grid',
          gridTemplateColumns: isMobile ? '1fr 1fr' : 'repeat(3, 1fr)',
          gap: isMobile ? 16 : 28, marginTop: 28, paddingTop: 24,
          borderTop: '1px solid rgba(255,255,255,0.28)',
        }}>
          {[
            [`+${vertical.stats.bookings}`, m.stats[0][0]],
            [`${vertical.stats.voices}`,    m.stats[1][0]],
            [`~${vertical.stats.saved} ${m.tag}`, m.stats[2][0]],
          ].map(([n, l]) => (
            <div key={l}>
              <div style={{ fontSize: 10, marginBottom: 4, textTransform: 'lowercase', fontStyle: 'italic', opacity: 0.85 }}>{l.toLowerCase()}</div>
              <div style={{ fontSize: isMobile ? 28 : 40, fontWeight: T.hBold, letterSpacing: -1.5, lineHeight: 1, fontVariantNumeric: 'tabular-nums' }}>{n}</div>
            </div>
          ))}
        </div>

        <div style={{ marginTop: 28, fontSize: isMobile ? 15 : 17, lineHeight: 1.45, opacity: 0.95 }}>
          {variant.m4Outro.l1}<br/><strong>{variant.m4Outro.l2}</strong>
        </div>
        <div style={{ display: 'flex', gap: 12, marginTop: 24, flexWrap: 'wrap' }}>
          <a href="https://schedy-sales.aidevops1.workers.dev/#pricing" style={{ textDecoration: 'none' }}>
            <button style={{
              padding: '15px 26px', fontSize: 14, fontWeight: 700,
              background: '#fff', color: T.corallo, border: 'none', borderRadius: 10,
              fontFamily: T.font, cursor: 'pointer',
              boxShadow: '0 8px 20px rgba(0,0,0,0.18)',
            }}>{t.cta.start} →</button>
          </a>
          <button style={{
            padding: '15px 22px', fontSize: 14, fontWeight: 500,
            background: 'transparent', color: '#fff', border: '1px solid rgba(255,255,255,0.5)',
            borderRadius: 10, fontFamily: T.font, cursor: 'pointer',
          }}>{t.cta.see}</button>
        </div>
      </div>
    </DayEntry>
  );
}

function DaySection({ vertical, variant }) {
  const T = useTheme();
  const t = useT();
  const { isMobile, isTablet } = useViewport();
  return (
    <section id="day" style={{
      padding: isMobile ? '32px 20px 20px' : isTablet ? '48px 40px 32px' : '64px 48px 40px',
      borderTop: `1px solid ${T.paperLine}`,
    }}>
      <div style={{ maxWidth: 1040, margin: '0 auto' }}>
        <div style={{ marginBottom: isMobile ? 24 : 40, display: 'flex', alignItems: 'baseline', gap: 14, flexWrap: 'wrap' }}>
          <span style={{ fontFamily: T.mono, fontSize: 11, color: T.corallo, letterSpacing: 2, fontWeight: 600 }}>
            {t.dayLabel || (t === I18N?.en ? 'THE DAY' : 'LA GIORNATA')}
          </span>
          <h2 style={{ margin: 0, fontSize: isMobile ? 28 : 44, fontWeight: T.hBold, letterSpacing: -1.5, lineHeight: 1.05, color: T.text, maxWidth: 720 }}>
            {t.dayH || (t === I18N?.en ? 'Features enter when they matter.' : 'Le feature entrano in scena quando servono.')}
          </h2>
        </div>
        <Moment0842 vertical={vertical} variant={variant} />
        <Moment1130 vertical={vertical} variant={variant} />
        <Moment1400 vertical={vertical} variant={variant} />
        <Moment1754Climax vertical={vertical} variant={variant} />

        <div style={{ paddingTop: 40, textAlign: 'center', borderTop: `1px solid ${T.paperLine}` }}>
          <div style={{ fontSize: 12, fontFamily: T.mono, color: T.muted, letterSpacing: 2, marginBottom: 14, fontWeight: 600 }}>
            — {t.endOfDay || 'FINE GIORNATA'} —
          </div>
          <div style={{ fontSize: isMobile ? 22 : 32, fontWeight: T.hMid, letterSpacing: -0.8, maxWidth: 640, margin: '0 auto', lineHeight: 1.25, color: T.text }}>
            {variant.endBody} <span style={{ color: T.corallo, fontStyle: 'italic', fontWeight: T.hBold }}>
              {variant.endAccent}
            </span>
          </div>
        </div>
      </div>
    </section>
  );
}

function PrePost() {
  const T = useTheme();
  const t = useT();
  const p = t.prePost;
  const { isMobile, isTablet } = useViewport();
  return (
    <section style={{
      padding: isMobile ? '40px 20px 44px' : isTablet ? '56px 40px 60px' : '72px 48px 80px',
      borderTop: `1px solid ${T.paperLine}`, background: T.ink3,
    }}>
      <div style={{ maxWidth: 1040, margin: '0 auto' }}>
        <div style={{ display: 'flex', alignItems: 'baseline', gap: 14, flexWrap: 'wrap', marginBottom: isMobile ? 24 : 36 }}>
          <span style={{ fontFamily: T.mono, fontSize: 11, color: T.corallo, letterSpacing: 2, fontWeight: 600 }}>{p.label}</span>
          <h2 style={{ margin: 0, fontSize: isMobile ? 28 : 44, fontWeight: T.hBold, letterSpacing: -1.5, lineHeight: 1.05, color: T.text, maxWidth: 720 }}>
            {p.h.pre}<em style={{ fontStyle: 'italic', color: T.corallo, fontWeight: T.hBold }}>{p.hAccent}</em>{p.h.post}
          </h2>
        </div>
        <div style={{ display: 'grid', gridTemplateColumns: isMobile ? '1fr' : '1fr 1fr', gap: 4, border: `1px solid ${T.paperLine}`, borderRadius: 14, overflow: 'hidden', background: T.paperLine }}>
          <PrePostCol side="before" label={p.beforeLabel} items={p.before} />
          <PrePostCol side="after"  label={p.afterLabel}  items={p.after} />
        </div>
      </div>
    </section>
  );
}

function PrePostCol({ side, label, items }) {
  const T = useTheme();
  const isAfter = side === 'after';
  return (
    <div style={{
      background: isAfter ? 'linear-gradient(180deg, rgba(244,63,94,0.08), transparent)' : T.ink2,
      padding: '28px 24px', position: 'relative',
    }}>
      <div style={{ display: 'flex', alignItems: 'center', gap: 10, marginBottom: 20 }}>
        <div style={{
          width: 26, height: 26, borderRadius: 13,
          background: isAfter ? T.corallo : T.ink3,
          border: `1px solid ${isAfter ? T.corallo : T.line2}`,
          display: 'flex', alignItems: 'center', justifyContent: 'center',
        }}>
          {isAfter
            ? <svg width="13" height="9" viewBox="0 0 10 8" fill="none" stroke="#fff" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round"><path d="M1 4l3 3 5-6"/></svg>
            : <svg width="11" height="11" viewBox="0 0 12 12" fill="none" stroke={T.muted} strokeWidth="2" strokeLinecap="round"><path d="M2 2l8 8M10 2L2 10"/></svg>}
        </div>
        <div style={{ fontFamily: T.mono, fontSize: 11, letterSpacing: 2, color: isAfter ? T.corallo : T.muted, fontWeight: 600 }}>{label}</div>
      </div>
      <ul style={{ listStyle: 'none', padding: 0, margin: 0, display: 'flex', flexDirection: 'column', gap: 12 }}>
        {items.map((it, i) => (
          <li key={i} style={{
            fontSize: 14, lineHeight: 1.5, color: isAfter ? T.text : T.muted,
            fontWeight: isAfter ? 600 : 400,
            textDecoration: isAfter ? 'none' : 'line-through',
            paddingLeft: 14, borderLeft: `2px solid ${isAfter ? T.corallo : T.line}`,
          }}>{it}</li>
        ))}
      </ul>
    </div>
  );
}

function V6Features() {
  const T = useTheme();
  const t = useT();
  const f = t.features;
  const { isMobile, isTablet } = useViewport();
  return (
    <section id="features" style={{
      padding: isMobile ? '40px 20px 44px' : isTablet ? '56px 40px 60px' : '72px 48px 80px',
      borderTop: `1px solid ${T.paperLine}`,
    }}>
      <div style={{ maxWidth: 1040, margin: '0 auto' }}>
        <div style={{ display: 'flex', alignItems: 'baseline', gap: 14, flexWrap: 'wrap', marginBottom: isMobile ? 28 : 40 }}>
          <span style={{ fontFamily: T.mono, fontSize: 11, color: T.corallo, letterSpacing: 2, fontWeight: 600 }}>{f.label}</span>
          <h2 style={{ margin: 0, fontSize: isMobile ? 28 : 44, fontWeight: T.hBold, letterSpacing: -1.5, lineHeight: 1.05, color: T.text }}>
            {f.h.l1}<em style={{ fontStyle: 'italic', color: T.muted, fontWeight: T.hMid }}>{f.h.l2}</em>
          </h2>
        </div>
        <div style={{ display: 'grid', gridTemplateColumns: isMobile ? '1fr' : '1fr 1fr', gap: '0 56px' }}>
          {f.items.map((it, i) => (
            <div key={it[0]} style={{
              display: 'grid', gridTemplateColumns: '76px 1fr', gap: 18,
              padding: '22px 0', borderTop: `1px solid ${T.paperLine}`,
              borderBottom: !isMobile && i >= f.items.length - 2 ? `1px solid ${T.paperLine}` : 'none',
            }}>
              <div style={{ fontSize: 52, fontWeight: T.hBold, lineHeight: 1, color: T.viola, letterSpacing: -2.2, fontVariantNumeric: 'tabular-nums' }}>{it[0]}</div>
              <div>
                <div style={{ fontFamily: T.font, fontSize: 11, color: T.corallo, textTransform: 'lowercase', fontStyle: 'italic', marginBottom: 4 }}>{it[2].toLowerCase()}</div>
                <div style={{ fontSize: 22, fontWeight: T.hMid, letterSpacing: -0.4, color: T.text }}>{it[1]}</div>
              </div>
            </div>
          ))}
        </div>
      </div>
    </section>
  );
}

function V6Channels() {
  const T = useTheme();
  const t = useT();
  const c = t.channels;
  const { isMobile, isTablet } = useViewport();
  return (
    <section id="channels" style={{
      padding: isMobile ? '40px 20px 44px' : isTablet ? '56px 40px 60px' : '72px 48px 80px',
      borderTop: `1px solid ${T.paperLine}`, background: T.ink3,
    }}>
      <div style={{ maxWidth: 1040, margin: '0 auto' }}>
        <div style={{ display: 'flex', alignItems: 'baseline', gap: 14, flexWrap: 'wrap', marginBottom: isMobile ? 24 : 32 }}>
          <span style={{ fontFamily: T.mono, fontSize: 11, color: T.corallo, letterSpacing: 2, fontWeight: 600 }}>{c.label}</span>
          <h2 style={{ margin: 0, fontSize: isMobile ? 28 : 44, fontWeight: T.hBold, letterSpacing: -1.5, lineHeight: 1.05, color: T.text }}>{c.h}</h2>
        </div>
        <div style={{ display: 'grid', gridTemplateColumns: isMobile ? '1fr' : 'repeat(3, 1fr)', gap: 16 }}>
          {c.items.map((ch) => (
            <div key={ch.name} style={{ padding: '24px 22px', border: `1px solid ${T.paperLine}`, borderRadius: 14, background: T.ink2 }}>
              <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: 12 }}>
                <div style={{ fontSize: 22, fontWeight: T.hBold, color: T.text, letterSpacing: -0.4 }}>{ch.name}</div>
                <span style={{ fontSize: 10, padding: '3px 8px', borderRadius: 4, background: 'rgba(16,185,129,0.15)', color: '#10b981', fontFamily: T.mono, letterSpacing: 1, fontWeight: 600 }}>{c.tag}</span>
              </div>
              <div style={{ fontSize: 14, color: T.muted, lineHeight: 1.5 }}>{ch.desc}</div>
            </div>
          ))}
        </div>
      </div>
    </section>
  );
}

function V6Footer() {
  const T = useTheme();
  const t = useT();
  const f = t.footer;
  const { isMobile } = useViewport();
  return (
    <footer style={{ padding: isMobile ? '36px 20px 24px' : '56px 48px 36px', borderTop: `1px solid ${T.paperLine}`, color: T.muted, fontSize: 13 }}>
      <div style={{ maxWidth: 1040, margin: '0 auto', display: 'grid', gridTemplateColumns: isMobile ? '1fr' : '2fr 1fr 1fr 1fr', gap: isMobile ? 24 : 40 }}>
        <div>
          <HelloWordmark size={18} />
          <div style={{ marginTop: 14, maxWidth: 280, lineHeight: 1.5 }}>{f.tagline}</div>
        </div>
        {f.cols.map(([h, items]) => (
          <div key={h}>
            <div style={{ fontFamily: T.mono, fontSize: 11, color: T.faint, letterSpacing: 1.5, marginBottom: 12, fontWeight: 600 }}>{h.toUpperCase()}</div>
            {items.map((x) => <div key={x} style={{ marginBottom: 6 }}>{x}</div>)}
          </div>
        ))}
      </div>
      <div style={{ maxWidth: 1040, margin: '32px auto 0', paddingTop: 20, borderTop: `1px solid ${T.paperLine}`, fontSize: 12, color: T.faint }}>{f.rights}</div>
    </footer>
  );
}

function VerticalSwitcher({ vertical, onRotate, lang }) {
  const T = useTheme();
  const t = useT();
  const { isMobile } = useViewport();
  return (
    <div style={{
      position: 'fixed',
      bottom: isMobile ? 12 : 20, left: isMobile ? 12 : 20,
      right: isMobile ? 12 : 'auto', zIndex: 100,
      background: T.mode === 'dark' ? 'rgba(18,17,26,0.94)' : 'rgba(255,255,255,0.95)',
      backdropFilter: 'blur(14px)',
      border: `1px solid ${T.line2}`, borderRadius: 12,
      padding: '10px 14px',
      display: 'flex', alignItems: 'center', gap: 12,
      fontFamily: T.font, fontSize: 12,
      boxShadow: '0 10px 30px rgba(0,0,0,0.15)',
    }}>
      <div style={{ width: 8, height: 8, borderRadius: 4, background: T.corallo }} />
      <div style={{ minWidth: 0, flex: isMobile ? 1 : 'none' }}>
        <div style={{ fontSize: 10, color: T.faint, fontFamily: T.mono, letterSpacing: 1, fontWeight: 600 }}>{t.switcher.label}</div>
        <div style={{ color: T.text, fontWeight: 700, marginTop: 1, whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' }}>
          {verticalName(vertical, lang)} · {vertical.place}
        </div>
      </div>
      <button onClick={onRotate} style={{
        marginLeft: 8, padding: '6px 10px', borderRadius: 6,
        background: T.violaSoft, border: `1px solid ${T.violaBorder}`,
        color: T.text, fontFamily: 'inherit', fontSize: 11, fontWeight: 600,
        cursor: 'pointer', flexShrink: 0,
      }}>{t.switcher.change}</button>
    </div>
  );
}

function V6App() {
  const [v, setV] = React.useState(() => pickVertical());
  const [lang, setLang] = React.useState(() => {
    try { return localStorage.getItem('hello_lang') || 'it'; } catch { return 'it'; }
  });
  const [mode, setMode] = React.useState(() => {
    try { return localStorage.getItem('hello_theme_v6') || 'light'; } catch { return 'light'; }
  });
  const [variantN, setVariantN] = React.useState(() => getVariantSeed());
  const theme = React.useMemo(() => makeTheme(mode), [mode]);
  const variant = React.useMemo(() => getVariant(lang, variantN), [lang, variantN]);

  React.useEffect(() => { try { localStorage.setItem('hello_lang', lang); } catch {} }, [lang]);
  React.useEffect(() => { try { localStorage.setItem('hello_theme_v6', mode); } catch {} }, [mode]);

  const rotate = React.useCallback(() => {
    rotateVertical();
    setV(pickVertical());
  }, []);

  const reroll = React.useCallback(() => {
    setVariantN(rotateVariantSeed());
  }, []);

  return (
    <ThemeCtx.Provider value={theme}>
      <LangCtx.Provider value={lang}>
        <div style={{
          background: theme.ink, color: theme.text, fontFamily: theme.font,
          minHeight: '100vh',
          transition: 'background .25s, color .25s',
        }}>
          <V6Nav lang={lang} setLang={setLang} mode={mode} setMode={setMode} onReroll={reroll} variantN={variantN} />
          <V6Hero vertical={v} onRotate={rotate} lang={lang} variant={variant} />
          <DaySection vertical={v} variant={variant} />
          <PrePost />
          <V6Features />
          <V6Channels />
          <V6Footer />
          <VerticalSwitcher vertical={v} onRotate={rotate} lang={lang} />
        </div>
      </LangCtx.Provider>
    </ThemeCtx.Provider>
  );
}

Object.assign(window, { V6App, V6Nav, V6ClockHero, V6Hero, DayEntry, Moment0842, Moment1130, Moment1400, Moment1754Climax, DaySection, PrePost, PrePostCol, V6Features, V6Channels, V6Footer, VerticalSwitcher });
