/* ─────────────────────────────────────────────────────────────────
   CorpSol — home page sections (part 2)
   TeamTeaser · Numbers · Products · Process
   ───────────────────────────────────────────────────────────────── */

// ── TEAM TEASER ────────────────────────────────────────────────────────────
function TeamTeaser() {
  const t = useT();
  const leads = [
    { name: 'Zhakipbekov Iliyas',  role: 'CEO Insightlab',   img: '/images/leader-iliyas.jpeg',    quote: 'всегда докапывается до истины' },
    { name: 'Abdugani Zhasulan',  role: 'CEO Quanta',       img: '/images/leader-zhasulan.jpeg',  quote: 'Всегда в курсе статусов по задачам' },
    { name: 'Alimkulova Anara',   role: 'Head of Sales',    img: '/images/leader-anara.jpeg',     quote: 'У нее всегда и все под контролем' },
    { name: 'Shakelekov Tamerlan', role: 'HR',              img: '/images/leader-tamerlan.jpeg',  quote: 'охотник за головами' },
  ];
  const brands = ['PepsiCo', 'Nestle', 'Bosch', 'KPMG', 'Sandoz', 'P&G', 'Magnum', 'Kaspi'];
  return (
    <section className="cs-section">
      <div className="cs-container cs-container--wide">
        <div className="cs-tt-grid">
          <div className="cs-tt-photos cs-reveal">
            {leads.map((l, i) => (
              <div key={i} className="cs-tt-card">
                <div className="cs-tt-photo">
                  <img src={l.img} alt={l.name} className="cs-tt-photo-img" />
                </div>
                <div className="cs-tt-meta">
                  <div className="cs-tt-name">{l.name}</div>
                  <div className="cs-tt-role">{l.role}</div>
                  <div className="cs-tt-quote">"{l.quote}"</div>
                </div>
              </div>
            ))}
          </div>

          <div className="cs-tt-copy cs-reveal">
            <span className="cs-eyebrow">{t('team.eyebrow')}</span>
            <h2 className="cs-h2" style={{ marginTop: 16, maxWidth: '14ch' }}>{t('team.h2')}</h2>
            <p className="cs-lead" style={{ marginTop: 24 }}>{t('team.body')}</p>
            <div className="cs-tt-brands">
              {brands.map((b) => <span key={b} className="cs-chip">{b}</span>)}
            </div>
            <a href="/team" className="cs-btn cs-btn--primary" style={{ marginTop: 28 }}>
              {t('team.cta')}
              <svg width="14" height="14" viewBox="0 0 16 16"><path d="M3 8h10M8 3l5 5-5 5" stroke="currentColor" strokeWidth="1.5" fill="none" strokeLinecap="round" strokeLinejoin="round" /></svg>
            </a>
          </div>
        </div>
      </div>
      <style>{`
        .cs-tt-grid { display: grid; grid-template-columns: 1.05fr 1fr; gap: 64px; align-items: center; }
        @media (max-width: 1000px) { .cs-tt-grid { grid-template-columns: 1fr; gap: 40px; } }
        @media (max-width: 600px)  { .cs-tt-grid { gap: 28px; } }
        .cs-tt-photos { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
        @media (max-width: 400px)  { .cs-tt-photos { gap: 8px; } }
        .cs-tt-photo { aspect-ratio: 0.82; width: 100%; border-radius: 16px; overflow: hidden; background: var(--c-bg-muted); }
        @media (max-width: 600px)  { .cs-tt-photo { border-radius: 12px; } }
        .cs-tt-photo-img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
        .cs-tt-meta { padding: 10px 2px 0; }
        .cs-tt-name { font-family: var(--font-display); font-weight: 600; font-size: 15px; }
        .cs-tt-role { font-size: 12px; color: var(--c-mute); margin-top: 2px; }
        .cs-tt-quote { font-size: 12px; color: var(--c-faint); margin-top: 5px; font-style: italic; line-height: 1.4; }
        @media (max-width: 500px) {
          .cs-tt-name { font-size: 12px; }
          .cs-tt-role, .cs-tt-quote { font-size: 11px; }
        }
        .cs-tt-brands { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 24px; }
      `}</style>
    </section>
  );
}

// ── NUMBERS — primary 4 + secondary 5 ──────────────────────────────────────
function NumbersSection() {
  const t = useT();
  const primary = [1, 2, 3, 4].map((i) => ({ n: t(`nums.${i}.n`), l: t(`nums.${i}.l`) }));
  const secondary = [5, 6, 7, 8, 9].map((i) => ({ n: t(`nums.${i}.n`), l: t(`nums.${i}.l`) }));
  return (
    <section className="cs-section" style={{ background: 'var(--c-ink)', color: 'var(--c-bg)' }}>
      <div className="cs-container cs-container--wide">
        <div className="cs-sec-head cs-reveal">
          <span className="cs-eyebrow" style={{ color: 'rgba(255,255,255,0.6)' }}>{t('nums.eyebrow')}</span>
          <h2 className="cs-h2">{t('nums.h2')}</h2>
        </div>

        <div className="cs-nums-grid">
          {primary.map((p, i) => (
            <div key={i} className="cs-num cs-num--big cs-reveal">
              <div className="cs-num-n">{p.n}</div>
              <div className="cs-num-l">{p.l}</div>
            </div>
          ))}
        </div>

        <div className="cs-nums-grid cs-nums-grid--sec">
          {secondary.map((p, i) => (
            <div key={i} className="cs-num cs-num--sm cs-reveal">
              <div className="cs-num-n">{p.n}</div>
              <div className="cs-num-l">{p.l}</div>
            </div>
          ))}
        </div>
      </div>
      <style>{`
        .cs-nums-grid {
          display: grid; gap: 1px;
          grid-template-columns: repeat(4, 1fr);
          background: rgba(255,255,255,0.08);
          border: 1px solid rgba(255,255,255,0.08);
          margin-top: 0;
        }
        .cs-nums-grid--sec { grid-template-columns: repeat(5, 1fr); margin-top: 24px; }
        @media (max-width: 800px) {
          .cs-nums-grid { grid-template-columns: repeat(2, 1fr); }
          .cs-nums-grid--sec { grid-template-columns: repeat(2, 1fr); }
          .cs-nums-grid--sec .cs-num:last-child:nth-child(odd) { grid-column: 1 / -1; }
        }
        .cs-num {
          background: var(--c-ink);
          padding: 36px 24px;
        }
        @media (max-width: 600px) { .cs-num { padding: 24px 16px; } }
        .cs-num-n {
          font-family: var(--font-display);
          font-size: clamp(40px, 5vw, 72px);
          font-weight: 600;
          letter-spacing: -0.04em;
          line-height: 1;
          background: linear-gradient(180deg, #ffffff 0%, rgba(255,255,255,0.65) 100%);
          -webkit-background-clip: text;
          background-clip: text;
          color: transparent;
        }
        .cs-num--sm .cs-num-n { font-size: clamp(28px, 3vw, 44px); }
        .cs-num-l { margin-top: 12px; color: rgba(255,255,255,0.65); font-size: 14px; line-height: 1.4; max-width: 22ch; }
        .cs-num--sm .cs-num-l { font-size: 13px; }
      `}</style>
    </section>
  );
}

// ── PRODUCTS — Quanta + Insight Lab plashki ────────────────────────────────
function ProductsSection() {
  const t = useT();
  return (
    <section className="cs-section" id="products">
      <div className="cs-container cs-container--wide">
        <div className="cs-sec-head cs-reveal">
          <span className="cs-eyebrow">{t('prod.eyebrow')}</span>
          <h2 className="cs-h2">{t('prod.h2')}</h2>
          <p className="cs-lead" style={{ marginTop: 16 }}>{t('prod.sub')}</p>
        </div>

        <div className="cs-prod-grid">
          {/* QUANTA */}
          <article className="cs-prod-card cs-prod-card--quanta cs-reveal" itemScope itemType="https://schema.org/Product">
            <div className="cs-prod-bg-art" aria-hidden="true">
              <QuantaArt />
            </div>
            <div className="cs-prod-card-h">
              <span className="cs-prod-eyebrow">{t('prod.q.eyebrow')}</span>
              <span className="cs-prod-logo">Quanta</span>
            </div>
            <h3 className="cs-prod-t" itemProp="name">{t('prod.q.t')}</h3>
            <p className="cs-prod-d" itemProp="description">{t('prod.q.d')}</p>
            <ul className="cs-prod-list">
              <li><BulletDot /> {t('prod.q.b1')}</li>
              <li><BulletDot /> {t('prod.q.b2')}</li>
              <li><BulletDot /> {t('prod.q.b3')}</li>
            </ul>
            <a href="https://omnivoice.tilda.ws/#rightsld" target="_blank" rel="noopener" className="cs-prod-cta">
              {t('prod.q.cta')}
              <svg width="16" height="16" viewBox="0 0 16 16"><path d="M3 8h10M8 3l5 5-5 5" stroke="currentColor" strokeWidth="1.6" fill="none" strokeLinecap="round" strokeLinejoin="round"/></svg>
            </a>
          </article>

          {/* INSIGHT LAB */}
          <article className="cs-prod-card cs-prod-card--insight cs-reveal" itemScope itemType="https://schema.org/Product">
            <div className="cs-prod-bg-art" aria-hidden="true">
              <InsightArt />
            </div>
            <div className="cs-prod-card-h">
              <span className="cs-prod-eyebrow">{t('prod.i.eyebrow')}</span>
              <span className="cs-prod-logo">Insight Lab</span>
            </div>
            <h3 className="cs-prod-t" itemProp="name">{t('prod.i.t')}</h3>
            <p className="cs-prod-d" itemProp="description">{t('prod.i.d')}</p>
            <ul className="cs-prod-list">
              <li><BulletDot /> {t('prod.i.b1')}</li>
              <li><BulletDot /> {t('prod.i.b2')}</li>
              <li><BulletDot /> {t('prod.i.b3')}</li>
            </ul>
            <a href="https://insightlab.kz" target="_blank" rel="noopener" className="cs-prod-cta">
              {t('prod.i.cta')}
              <svg width="16" height="16" viewBox="0 0 16 16"><path d="M3 8h10M8 3l5 5-5 5" stroke="currentColor" strokeWidth="1.6" fill="none" strokeLinecap="round" strokeLinejoin="round"/></svg>
            </a>
          </article>
        </div>

        <p className="cs-prod-foot cs-reveal">{t('prod.foot')}</p>
      </div>

      <style>{`
        .cs-prod-grid {
          display: grid; gap: 24px;
          grid-template-columns: 1fr 1fr;
        }
        @media (max-width: 900px) { .cs-prod-grid { grid-template-columns: 1fr; gap: 16px; } }

        .cs-prod-card {
          position: relative;
          padding: 36px;
          border-radius: 24px;
          color: #fff;
          display: flex; flex-direction: column;
          min-height: 540px;
          overflow: hidden;
          isolation: isolate;
          transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
          box-shadow: 0 4px 24px rgba(0,0,0,0.06);
        }
        @media (max-width: 600px) {
          .cs-prod-card { min-height: auto; padding: 28px 22px; }
        }
        [data-radius="sharp"] .cs-prod-card { border-radius: 8px; }
        [data-radius="pill"] .cs-prod-card { border-radius: 36px; }
        .cs-prod-card:hover { transform: translateY(-4px); box-shadow: 0 24px 60px -16px rgba(10,31,68,0.35); }
        @media (hover: none) { .cs-prod-card:hover { transform: none; box-shadow: 0 4px 24px rgba(0,0,0,0.06); } }
        .cs-prod-card--quanta { background: radial-gradient(ellipse at top right, #2563EB 0%, #1d3a82 50%, #0A1F44 100%); }
        .cs-prod-card--insight { background: radial-gradient(ellipse at top right, #06B6D4 0%, #0a5566 50%, #052e3a 100%); }

        .cs-prod-bg-art {
          position: absolute; inset: 0;
          opacity: 0.5; pointer-events: none;
          mix-blend-mode: screen;
        }
        .cs-prod-card-h {
          display: flex; align-items: center; justify-content: space-between;
          margin-bottom: 32px;
          position: relative; z-index: 2;
        }
        .cs-prod-eyebrow {
          font-size: 11px; font-weight: 700; letter-spacing: 0.12em;
          text-transform: uppercase; color: rgba(255,255,255,0.75);
        }
        .cs-prod-logo {
          font-family: var(--font-display);
          font-weight: 700; font-size: 17px; letter-spacing: -0.02em;
          padding: 6px 12px; border-radius: 999px;
          background: rgba(255,255,255,0.12);
          backdrop-filter: blur(8px);
        }
        .cs-prod-t {
          font-family: var(--font-display);
          font-size: clamp(26px, 2.6vw, 34px);
          font-weight: 600;
          letter-spacing: -0.025em;
          line-height: 1.1;
          max-width: 18ch;
          position: relative; z-index: 2;
        }
        .cs-prod-d {
          margin-top: 18px;
          color: rgba(255,255,255,0.82);
          line-height: 1.5;
          font-size: 15.5px;
          max-width: 48ch;
          position: relative; z-index: 2;
        }
        .cs-prod-list {
          margin-top: 28px;
          display: flex; flex-direction: column; gap: 10px;
          position: relative; z-index: 2;
        }
        .cs-prod-list li {
          display: flex; align-items: flex-start; gap: 10px;
          color: rgba(255,255,255,0.9);
          font-size: 14px;
        }
        .cs-prod-cta {
          margin-top: auto;
          padding-top: 28px;
          display: inline-flex; align-items: center; gap: 8px;
          align-self: flex-start;
          color: #fff;
          font-weight: 600; font-size: 15px;
          position: relative; z-index: 2;
        }
        .cs-prod-cta:hover { gap: 14px; }
        .cs-prod-cta::before {
          content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 32px;
          opacity: 0; transition: opacity 0.2s var(--ease);
        }

        .cs-prod-foot {
          margin-top: 32px;
          font-size: 13px; color: var(--c-faint);
          max-width: 80ch;
        }
      `}</style>
    </section>
  );
}

function BulletDot() {
  return (
    <svg width="18" height="18" viewBox="0 0 18 18" fill="none" style={{ flexShrink: 0, marginTop: 1 }}>
      <circle cx="9" cy="9" r="9" fill="rgba(255,255,255,0.15)" />
      <path d="M5 9.2L7.6 11.8 13 6.5" stroke="#fff" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" fill="none" />
    </svg>
  );
}

// Decorative SVG art for product cards
function QuantaArt() {
  return (
    <svg width="100%" height="100%" viewBox="0 0 600 540" fill="none" preserveAspectRatio="xMaxYMin slice">
      <g opacity="0.55" stroke="#fff" strokeWidth="0.7" fill="none">
        {Array.from({ length: 12 }).map((_, i) => (
          <circle key={i} cx="500" cy="80" r={(i + 1) * 50} />
        ))}
      </g>
      <g opacity="0.65" stroke="#fff" strokeWidth="0.7" fill="none">
        {Array.from({ length: 24 }).map((_, i) => {
          const a = (i / 24) * Math.PI * 2;
          return <line key={i} x1="500" y1="80" x2={500 + Math.cos(a) * 620} y2={80 + Math.sin(a) * 620} strokeDasharray="2 6" />;
        })}
      </g>
      <circle cx="500" cy="80" r="40" fill="#fff" opacity="0.18" />
      <circle cx="500" cy="80" r="22" fill="#fff" opacity="0.4" />
    </svg>
  );
}

function InsightArt() {
  return (
    <svg width="100%" height="100%" viewBox="0 0 600 540" fill="none" preserveAspectRatio="xMaxYMin slice">
      <g opacity="0.6" stroke="#fff" strokeWidth="0.7" fill="none">
        {Array.from({ length: 14 }).map((_, i) => (
          <rect key={i} x={420 - i * 14} y={-i * 8} width={180 + i * 28} height={120 + i * 16} rx="20" />
        ))}
      </g>
      <g opacity="0.5">
        {[0, 1, 2, 3, 4].map((i) => (
          <circle key={i} cx={460 + i * 26} cy={220 + (i % 2) * 16} r={6 + (i % 3) * 2} fill="#fff" />
        ))}
      </g>
    </svg>
  );
}

// ── PROCESS — 5 steps horizontal ────────────────────────────────────────────
function ProcessSection() {
  const t = useT();
  const steps = [1, 2, 3, 4, 5].map((i) => ({
    k: t(`proc.${i}.k`), title: t(`proc.${i}.t`), d: t(`proc.${i}.d`),
  }));
  return (
    <section className="cs-section" style={{ background: 'var(--c-bg-soft)' }}>
      <div className="cs-container cs-container--wide">
        <div className="cs-sec-head cs-reveal">
          <span className="cs-eyebrow">{t('proc.eyebrow')}</span>
          <h2 className="cs-h2">{t('proc.h2')}</h2>
        </div>

        <div className="cs-proc-grid">
          {steps.map((s, i) => (
            <div key={i} className="cs-proc-step cs-reveal">
              <div className="cs-proc-num">
                <span>{String(i + 1).padStart(2, '0')}</span>
              </div>
              <div className="cs-proc-meta">
                <span className="cs-proc-k">{s.k}</span>
                <h3 className="cs-proc-t">{s.title}</h3>
                <p className="cs-mute" style={{ fontSize: 14, marginTop: 6 }}>{s.d}</p>
              </div>
            </div>
          ))}
        </div>
      </div>

      <style>{`
        .cs-proc-grid {
          display: grid; grid-template-columns: repeat(5, 1fr);
          gap: 0;
          position: relative;
        }
        .cs-proc-grid::before {
          content: ""; position: absolute;
          left: 36px; right: calc(20% - 36px); top: 36px; height: 2px;
          background: repeating-linear-gradient(90deg, var(--c-line-strong) 0 4px, transparent 4px 10px);
        }
        @media (max-width: 1000px) {
          .cs-proc-grid { grid-template-columns: repeat(2, 1fr); gap: 24px; }
          .cs-proc-grid::before { display: none; }
        }
        @media (max-width: 540px) {
          .cs-proc-grid { grid-template-columns: 1fr; gap: 0; }
          .cs-proc-step {
            flex-direction: row !important;
            gap: 16px !important;
            align-items: flex-start;
            padding: 20px 0 !important;
            border-bottom: 1px solid var(--c-line);
          }
          .cs-proc-step:last-child { border-bottom: 0; }
          .cs-proc-num { width: 44px !important; height: 44px !important; font-size: 15px !important; flex-shrink: 0; }
        }
        .cs-proc-step {
          display: flex; flex-direction: column; gap: 20px;
          padding-right: 20px;
          position: relative; z-index: 1;
        }
        .cs-proc-num {
          width: 72px; height: 72px;
          border-radius: 999px;
          background: var(--c-bg); color: var(--c-ink);
          display: inline-flex; align-items: center; justify-content: center;
          font-family: var(--font-display); font-weight: 600; font-size: 22px; letter-spacing: -0.02em;
          box-shadow: var(--shadow-sm);
        }
        [data-radius="sharp"] .cs-proc-num { border-radius: 8px; }
        .cs-proc-step:hover .cs-proc-num { background: var(--c-accent); color: #fff; }
        .cs-proc-k { font-size: 12px; font-weight: 600; color: var(--c-accent); letter-spacing: 0.04em; text-transform: uppercase; }
        .cs-proc-t { font-family: var(--font-display); font-size: 18px; font-weight: 600; letter-spacing: -0.015em; line-height: 1.2; margin-top: 6px; }
      `}</style>
    </section>
  );
}

Object.assign(window, { TeamTeaser, NumbersSection, ProductsSection, ProcessSection });
