// homepage-extra.jsx — extension sections shared by mobile + desktop wrappers.
// Components are device-agnostic; mobile/desktop wrappers tune padding via props.

// ─────────────────────────────────────────────────────────────
// Section header (consistent across all extras)
// ─────────────────────────────────────────────────────────────
function XSH({ s, dark = false, dense = false }) {
  if (dense) {
    return (
      <div style={{ marginBottom: 26 }}>
        <div style={{ ...TX.mono, fontSize: 10, color: T.gold, marginBottom: 8 }}>§ {s.num} · {s.kicker}</div>
        <Reveal>
          <h2 style={{ ...TX.display, fontSize: 34, margin: '4px 0 14px', color: dark ? T.white : T.ink, textWrap: 'balance', lineHeight: 1.04 }}>{s.title}</h2>
        </Reveal>
        <Reveal delay={120}>
          <p style={{ fontSize: 15, color: dark ? 'rgba(255,255,255,0.7)' : T.body, lineHeight: 1.6, margin: 0 }}>{s.intro}</p>
        </Reveal>
      </div>
    );
  }
  return (
    <div style={{ display: 'grid', gridTemplateColumns: '110px 1fr 1.4fr', gap: 40, marginBottom: 56, alignItems: 'start' }}>
      <div style={{ ...TX.mono, fontSize: 11, color: T.gold, paddingTop: 8 }}>§ {s.num}</div>
      <div>
        <Kicker>{s.kicker}</Kicker>
        <Reveal>
          <h2 style={{ ...TX.display, fontSize: 56, margin: '18px 0 0', color: dark ? T.white : T.ink, textWrap: 'balance' }}>{s.title}</h2>
        </Reveal>
      </div>
      <Reveal delay={120}>
        <div style={{ paddingTop: 30, fontSize: 17, lineHeight: 1.55, color: dark ? 'rgba(255,255,255,0.72)' : T.body }}>{s.intro}</div>
      </Reveal>
    </div>
  );
}

// ─────────────────────────────────────────────────────────────
// 02 · ABOUT — paper background, ledger of facts + 3 pillars
// ─────────────────────────────────────────────────────────────
function XAbout({ dense = false }) {
  const { t } = useLang();
  const s = t.secX.about;
  return (
    <section style={{
      padding: dense ? '72px 18px' : '120px 0',
      background: T.paper, position: 'relative', overflow: 'hidden',
    }}>
      <Diamond size={dense ? 180 : 320} top="-60px" right="-100px" color={T.gold} opacity={0.12} dur={24} />
      <Diamond size={dense ? 70 : 130} bottom="12%" left={dense ? '-40px' : '4%'} color={T.steel} opacity={0.22} fill dur={18} delay={1} />

      <div style={dense ? null : { maxWidth: 1320, margin: '0 auto', padding: '0 56px' }}>
        <XSH s={s} dense={dense} />

        {/* Pillars */}
        <div style={{
          display: 'grid', gap: dense ? 0 : 24,
          gridTemplateColumns: dense ? '1fr' : 'repeat(3, 1fr)',
          marginBottom: dense ? 36 : 56,
        }}>
          {t.about.pillars.map(([k, v], i) => (
            <Reveal key={k} delay={i * 100}>
              <div style={{
                background: T.white, border: `1px solid ${T.hair}`, padding: dense ? '22px 20px' : '32px 28px 36px',
                position: 'relative', minHeight: dense ? 0 : 220,
                marginBottom: dense ? 12 : 0,
              }}>
                <div style={{ ...TX.mono, fontSize: 10, color: T.gold, marginBottom: 12 }}>0{i + 1}</div>
                <div style={{ fontSize: dense ? 19 : 24, fontWeight: 600, letterSpacing: '-0.02em', marginBottom: 8, color: T.ink }}>{k}</div>
                <div style={{ fontSize: dense ? 14 : 15, color: T.body, lineHeight: 1.6 }}>{v}</div>
              </div>
            </Reveal>
          ))}
        </div>

        {/* Registration ledger */}
        <Reveal>
          <div style={{ background: T.ink, color: T.white, padding: dense ? '24px 20px 28px' : '40px 36px 44px', position: 'relative', overflow: 'hidden' }}>
            <Diamond size={dense ? 100 : 200} top="-40px" right="-40px" color={T.gold} opacity={0.16} dur={20} fill />
            <div style={{ ...TX.mono, fontSize: 10, color: T.gold, marginBottom: dense ? 14 : 18 }}>РЕГИСТРАЦИОННАЯ ВЫПИСКА · KVK</div>
            <div style={{
              display: 'grid',
              gridTemplateColumns: dense ? '1fr' : 'repeat(2, 1fr)',
              borderTop: '1px solid rgba(255,255,255,0.18)',
            }}>
              {t.about.ledger.map(([k, v], i) => (
                <div key={k} style={{
                  display: 'grid', gridTemplateColumns: dense ? '130px 1fr' : '180px 1fr', gap: 16,
                  padding: dense ? '12px 0' : '16px 8px',
                  borderBottom: '1px solid rgba(255,255,255,0.14)',
                  borderRight: !dense && i % 2 === 0 ? '1px solid rgba(255,255,255,0.14)' : 'none',
                  paddingRight: !dense && i % 2 === 0 ? 24 : 8,
                  fontSize: dense ? 13 : 14,
                }}>
                  <span style={{ ...TX.mono, fontSize: 9, color: 'rgba(255,255,255,0.55)', alignSelf: 'center' }}>{k}</span>
                  <span style={{ color: T.white, fontWeight: 500 }}>{v}</span>
                </div>
              ))}
            </div>
          </div>
        </Reveal>
      </div>
    </section>
  );
}

// ─────────────────────────────────────────────────────────────
// 04 · WHY — graphite section, vertical timeline of 6
// ─────────────────────────────────────────────────────────────
function XWhy({ dense = false }) {
  const { t } = useLang();
  return (
    <section style={{
      padding: dense ? '72px 18px' : '120px 0',
      background: T.graphite, color: T.white, position: 'relative', overflow: 'hidden',
    }}>
      <Diamond size={dense ? 220 : 360} top="-100px" right="-120px" color={T.gold} opacity={0.1} dur={26} />
      <Diamond size={dense ? 80 : 140} bottom="10%" left={dense ? '-30px' : '4%'} color={T.gold} opacity={0.4} fill dur={16} delay={1} />

      <div style={dense ? null : { maxWidth: 1320, margin: '0 auto', padding: '0 56px' }}>
        <XSH s={t.secX.why} dark dense={dense} />

        <div style={{ position: 'relative' }}>
          {dense ? (
            <>
              <div aria-hidden style={{ position: 'absolute', left: 24, top: 28, bottom: 28, width: 1, background: T.gold, opacity: 0.5 }} />
              {t.why.map(([n, k, v], i) => (
                <Reveal key={k} delay={i * 60}>
                  <div style={{ display: 'grid', gridTemplateColumns: '48px 1fr', gap: 14, alignItems: 'start', padding: '14px 0' }}>
                    <div style={{
                      width: 48, height: 48, border: `1px solid ${T.gold}`, transform: 'rotate(45deg)',
                      display: 'flex', alignItems: 'center', justifyContent: 'center', background: T.graphite,
                    }}>
                      <span style={{ ...TX.mono, color: T.gold, fontSize: 12, transform: 'rotate(-45deg)' }}>{n}</span>
                    </div>
                    <div>
                      <div style={{ fontSize: 18, fontWeight: 600, letterSpacing: '-0.015em', color: T.white, marginBottom: 4 }}>{k}</div>
                      <div style={{ fontSize: 14, color: 'rgba(255,255,255,0.7)', lineHeight: 1.55 }}>{v}</div>
                    </div>
                  </div>
                </Reveal>
              ))}
            </>
          ) : (
            <div style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 0, borderTop: '1px solid rgba(255,255,255,0.4)' }}>
              {t.why.map(([n, k, v], i) => (
                <Reveal key={k} delay={i * 80}>
                  <div style={{
                    padding: '32px 28px 36px',
                    borderRight: (i + 1) % 3 !== 0 ? '1px solid rgba(255,255,255,0.14)' : 'none',
                    borderBottom: '1px solid rgba(255,255,255,0.14)',
                    minHeight: 240,
                  }}>
                    <div style={{ display: 'flex', alignItems: 'center', gap: 12, marginBottom: 16 }}>
                      <span style={{ width: 36, height: 36, border: `1px solid ${T.gold}`, transform: 'rotate(45deg)', display: 'inline-flex', alignItems: 'center', justifyContent: 'center' }}>
                        <span style={{ ...TX.mono, fontSize: 11, color: T.gold, transform: 'rotate(-45deg)' }}>{n}</span>
                      </span>
                      <span style={{ ...TX.mono, fontSize: 10, color: 'rgba(255,255,255,0.5)' }}>0{i + 1} / 06</span>
                    </div>
                    <div style={{ fontSize: 22, fontWeight: 600, letterSpacing: '-0.018em', color: T.white, marginBottom: 8 }}>{k}</div>
                    <div style={{ fontSize: 14, color: 'rgba(255,255,255,0.7)', lineHeight: 1.6 }}>{v}</div>
                  </div>
                </Reveal>
              ))}
            </div>
          )}
        </div>
      </div>
    </section>
  );
}

// ─────────────────────────────────────────────────────────────
// 06 · PROCESS EXTENDED — paper, 7-step structured ledger
// ─────────────────────────────────────────────────────────────
function XProcessExt({ dense = false }) {
  const { t } = useLang();
  return (
    <section style={{
      padding: dense ? '72px 18px' : '120px 0',
      background: T.paper, position: 'relative', overflow: 'hidden',
    }}>
      <Diamond size={dense ? 160 : 260} top="60px" right={dense ? '-50px' : '-80px'} color={T.gold} opacity={0.14} dur={22} />
      <Diamond size={dense ? 70 : 110} bottom="14%" left={dense ? '-30px' : '6%'} color={T.steel} opacity={0.18} fill dur={18} delay={1.5} />

      <div style={dense ? null : { maxWidth: 1320, margin: '0 auto', padding: '0 56px' }}>
        <XSH s={t.secX.processX} dense={dense} />

        <div style={{ borderTop: `1px solid ${T.ink}` }}>
          {t.processX.map(([n, k, v], i) => (
            <Reveal key={k} delay={i * 50}>
              <div style={{
                display: 'grid',
                gridTemplateColumns: dense ? '52px 1fr' : '80px 280px 1fr 80px',
                gap: dense ? 14 : 32,
                alignItems: dense ? 'start' : 'center',
                padding: dense ? '18px 0' : '24px 4px',
                borderBottom: `1px solid ${T.hair2}`,
              }}>
                <div style={{
                  width: dense ? 44 : 56, height: dense ? 44 : 56, border: `1px solid ${T.gold}`,
                  display: 'flex', alignItems: 'center', justifyContent: 'center', transform: 'rotate(45deg)',
                  background: T.paper,
                }}>
                  <span style={{ fontFamily: '"JetBrains Mono", monospace', fontSize: dense ? 12 : 14, color: T.gold, transform: 'rotate(-45deg)' }}>{n}</span>
                </div>
                {!dense && (
                  <div style={{ fontSize: 22, fontWeight: 600, letterSpacing: '-0.018em', color: T.ink }}>{k}</div>
                )}
                <div>
                  {dense && (
                    <div style={{ fontSize: 17, fontWeight: 600, letterSpacing: '-0.015em', color: T.ink, marginBottom: 4 }}>{k}</div>
                  )}
                  <div style={{ fontSize: dense ? 14 : 15, color: T.body, lineHeight: 1.6 }}>{v}</div>
                </div>
                {!dense && (
                  <div style={{ ...TX.mono, fontSize: 10, color: T.mute, textAlign: 'right' }}>ШАГ {String(i + 1).padStart(2, '0')}</div>
                )}
              </div>
            </Reveal>
          ))}
        </div>
      </div>
    </section>
  );
}

// ─────────────────────────────────────────────────────────────
// 08 · EVIDENCE — black, 8-cell document grid
// ─────────────────────────────────────────────────────────────
function XEvidence({ dense = false }) {
  const { t } = useLang();
  return (
    <section style={{
      padding: dense ? '72px 18px' : '120px 0',
      background: T.ink, color: T.white, position: 'relative', overflow: 'hidden',
    }}>
      <Diamond size={dense ? 200 : 360} top="-100px" left={dense ? '-80px' : '-120px'} color={T.gold} opacity={0.1} dur={26} />
      <Diamond size={dense ? 80 : 140} bottom="10%" right={dense ? '-30px' : '6%'} color={T.gold} opacity={0.45} fill dur={16} delay={1} />

      <div style={dense ? null : { maxWidth: 1320, margin: '0 auto', padding: '0 56px' }}>
        <XSH s={t.secX.evidence} dark dense={dense} />

        <div style={{
          display: 'grid',
          gridTemplateColumns: dense ? '1fr 1fr' : 'repeat(4, 1fr)',
          borderTop: '1px solid rgba(255,255,255,0.4)',
          borderLeft: '1px solid rgba(255,255,255,0.14)',
        }}>
          {t.evidence.map(([k, v], i) => (
            <Reveal key={k} delay={i * 50}>
              <div style={{
                padding: dense ? '18px 14px 22px' : '28px 24px 32px',
                borderRight: '1px solid rgba(255,255,255,0.14)',
                borderBottom: '1px solid rgba(255,255,255,0.14)',
                position: 'relative',
                minHeight: dense ? 130 : 200,
              }}>
                <div style={{ display: 'flex', alignItems: 'center', gap: 10, marginBottom: dense ? 10 : 14 }}>
                  <span style={{ ...TX.mono, fontSize: 10, color: T.gold }}>{String(i + 1).padStart(2, '0')}</span>
                  <span style={{ flex: 1, height: 1, background: 'rgba(255,255,255,0.18)' }} />
                  <span style={{ width: 7, height: 7, background: T.gold, transform: 'rotate(45deg)' }} />
                </div>
                <div style={{ fontSize: dense ? 16 : 18, fontWeight: 600, letterSpacing: '-0.015em', color: T.white, marginBottom: dense ? 6 : 8 }}>{k}</div>
                <div style={{ fontSize: dense ? 13 : 14, color: 'rgba(255,255,255,0.7)', lineHeight: 1.55 }}>{v}</div>
              </div>
            </Reveal>
          ))}
        </div>
      </div>
    </section>
  );
}

// ─────────────────────────────────────────────────────────────
// 11 · STATS — white background, animated counters
// ─────────────────────────────────────────────────────────────
function XStats({ dense = false }) {
  const { t } = useLang();
  return (
    <section style={{
      padding: dense ? '72px 18px' : '120px 0',
      background: T.white, position: 'relative', overflow: 'hidden',
    }}>
      <Diamond size={dense ? 160 : 240} top="40px" right={dense ? '-40px' : '6%'} color={T.gold} opacity={0.14} dur={22} />
      <Diamond size={dense ? 60 : 100} bottom="14%" left={dense ? '-20px' : '6%'} color={T.steel} opacity={0.18} fill dur={18} delay={1} />

      <div style={dense ? null : { maxWidth: 1320, margin: '0 auto', padding: '0 56px' }}>
        <XSH s={t.secX.stats} dense={dense} />

        <div style={{
          display: 'grid',
          gridTemplateColumns: dense ? '1fr 1fr' : 'repeat(3, 1fr)',
          borderTop: `1px solid ${T.ink}`,
          borderLeft: `1px solid ${T.hair2}`,
        }}>
          {t.stats.map(([n, l, sub], i) => (
            <Reveal key={l} delay={i * 80}>
              <div style={{
                padding: dense ? '20px 16px 22px' : '32px 28px 36px',
                borderRight: `1px solid ${T.hair2}`,
                borderBottom: `1px solid ${T.hair2}`,
                minHeight: dense ? 120 : 180,
                position: 'relative',
              }}>
                <div style={{ ...TX.mono, fontSize: 10, color: T.gold, marginBottom: dense ? 8 : 12 }}>{String(i + 1).padStart(2, '0')}</div>
                <div style={{ fontSize: dense ? 38 : 56, fontWeight: 600, color: T.ink, letterSpacing: '-0.03em', lineHeight: 1, marginBottom: dense ? 6 : 10 }}>
                  <Counter value={n} />
                </div>
                <div style={{ fontSize: dense ? 13 : 14, color: T.ink, fontWeight: 500, marginBottom: 4 }}>{l}</div>
                <div style={{ fontSize: dense ? 11 : 12, color: T.mute }}>{sub}</div>
              </div>
            </Reveal>
          ))}
        </div>
      </div>
    </section>
  );
}

// ─────────────────────────────────────────────────────────────
// 13 · CONTACT — graphite block (paired with footer)
// ─────────────────────────────────────────────────────────────
function XContact({ dense = false }) {
  const { t } = useLang();
  return (
    <section style={{
      padding: dense ? '72px 18px' : '120px 0',
      background: T.graphite, color: T.white, position: 'relative', overflow: 'hidden',
    }}>
      <Diamond size={dense ? 220 : 360} bottom="-120px" right={dense ? '-100px' : '-160px'} color={T.gold} opacity={0.12} dur={26} />
      <Diamond size={dense ? 90 : 140} top="14%" left={dense ? '-40px' : '4%'} color={T.gold} opacity={0.4} fill dur={16} delay={1} />

      <div style={dense ? null : { maxWidth: 1320, margin: '0 auto', padding: '0 56px' }}>
        <XSH s={t.secX.contact} dark dense={dense} />

        <div style={{
          display: 'grid',
          gridTemplateColumns: dense ? '1fr' : 'repeat(3, 1fr)',
          borderTop: '1px solid rgba(255,255,255,0.4)',
          marginBottom: dense ? 24 : 36,
        }}>
          {t.contact.blocks.map(([k, v], i) => (
            <Reveal key={k} delay={i * 100}>
              <div style={{
                padding: dense ? '22px 0' : '32px 28px 36px',
                borderBottom: '1px solid rgba(255,255,255,0.14)',
                borderRight: !dense && i < 2 ? '1px solid rgba(255,255,255,0.14)' : 'none',
                minHeight: dense ? 0 : 200,
              }}>
                <div style={{ ...TX.mono, fontSize: 10, color: T.gold, marginBottom: dense ? 10 : 14 }}>0{i + 1} · {k}</div>
                <div style={{ fontSize: dense ? 16 : 18, color: T.white, lineHeight: 1.6, whiteSpace: 'pre-line', fontWeight: 500, letterSpacing: '-0.005em' }}>{v}</div>
              </div>
            </Reveal>
          ))}
        </div>

        <Reveal>
          <div style={{
            display: 'grid', gridTemplateColumns: dense ? '1fr' : '1fr auto', gap: 16,
            alignItems: 'center', borderTop: '1px solid rgba(255,255,255,0.18)',
            paddingTop: dense ? 18 : 24,
          }}>
            <div style={{ display: 'flex', alignItems: 'center', gap: 14 }}>
              <span style={{ width: 8, height: 8, background: T.gold, transform: 'rotate(45deg)' }} />
              <span style={{ ...TX.mono, fontSize: 10, color: 'rgba(255,255,255,0.6)' }}>{t.contact.hoursLabel}</span>
              <span style={{ fontSize: dense ? 14 : 15, color: T.white, fontWeight: 500 }}>{t.contact.hours}</span>
            </div>
            <div style={{ ...TX.mono, fontSize: 10, color: 'rgba(255,255,255,0.5)' }}>KVK 27164831 · 13.01.2012</div>
          </div>
        </Reveal>
      </div>
    </section>
  );
}

Object.assign(window, { XAbout, XWhy, XProcessExt, XEvidence, XStats, XContact });
