// dpo-middle.jsx — DPOTriggers + DPOIncluded
// All copy comes from window.DPO (dpo-content.jsx).
// Only SVG icons are defined here.

// Icons for the 6 trigger cards (order matches DPO.triggers.cards)
const TRIGGER_ICONS = [
  <svg width="20" height="20" viewBox="0 0 24 24" fill="none"><path d="M14 3H6a2 2 0 00-2 2v14a2 2 0 002 2h12a2 2 0 002-2V9l-6-6z" stroke="currentColor" strokeWidth="1.6" strokeLinejoin="round"/><path d="M14 3v6h6M8 13h8M8 17h5" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round"/></svg>,
  <svg width="20" height="20" viewBox="0 0 24 24" fill="none"><rect x="4" y="3" width="16" height="18" rx="2" stroke="currentColor" strokeWidth="1.6"/><path d="M8 8h8M8 12h8M8 16h5" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round"/></svg>,
  <svg width="20" height="20" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="12" r="9" stroke="currentColor" strokeWidth="1.6"/><path d="M3 12h18M12 3a13 13 0 010 18M12 3a13 13 0 000 18" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round"/></svg>,
  <svg width="20" height="20" viewBox="0 0 24 24" fill="none"><path d="M3 12l3 3 7-7M14 17l3 3 4-4" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round"/><circle cx="9" cy="11" r="0.5" fill="currentColor"/></svg>,
  <svg width="20" height="20" viewBox="0 0 24 24" fill="none"><path d="M12 3l8 4v5c0 5-3.5 8-8 9-4.5-1-8-4-8-9V7l8-4z" stroke="currentColor" strokeWidth="1.6" strokeLinejoin="round"/><path d="M12 8v4M12 16h.01" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round"/></svg>,
  <svg width="20" height="20" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="12" r="9" stroke="currentColor" strokeWidth="1.6"/><path d="M12 7v5l3.5 2" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round"/></svg>,
];

// ── DPOTriggers ───────────────────────────────────────────────────────────────

function DPOTriggers() {
  const t = DPO.triggers;
  return (
    <section id="triggers" className="section" style={{ background: 'var(--bg-2)' }}>
      <div className="container">
        <div style={{ maxWidth: 720, marginBottom: 56 }}>
          <div className="eyebrow">{t.eyebrow}</div>
          <h2 style={{ fontSize: 'clamp(32px, 3.4vw, 44px)', marginBottom: 16, letterSpacing: '-0.03em' }}>
            {t.title}
          </h2>
          <p style={{ fontSize: 18, color: 'var(--muted)', lineHeight: 1.55 }}>
            {t.sub}
          </p>
        </div>

        <div style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 20 }}
             className="triggers-grid">
          {t.cards.map((card, i) => (
            <div key={i} className="trigger-card" style={{
              background: 'white', borderRadius: 16,
              border: '1px solid var(--border)', padding: 28,
              position: 'relative',
            }}>
              <div style={{ display: 'flex', alignItems: 'center', gap: 12, marginBottom: 18 }}>
                <div style={{
                  width: 40, height: 40, borderRadius: 10,
                  background: card.accent ? 'var(--orange-50)' : 'var(--turquoise-50)',
                  color: card.accent ? 'var(--orange)' : 'var(--turquoise-700)',
                  display: 'flex', alignItems: 'center', justifyContent: 'center',
                }}>{TRIGGER_ICONS[i]}</div>
                <span className="en num" style={{ fontSize: 13, fontWeight: 500, color: 'var(--muted-2)', letterSpacing: '0.02em' }}>
                  {`0${i + 1}`}
                </span>
              </div>
              <h3 style={{ fontSize: 18, fontWeight: 500, letterSpacing: '-0.01em', marginBottom: 10, lineHeight: 1.3 }}>
                {card.title}
              </h3>
              <p style={{ fontSize: 14.5, color: 'var(--muted)', lineHeight: 1.6 }}>{card.desc}</p>
            </div>
          ))}
        </div>
      </div>
      <style>{`
        .trigger-card {
          transition: all 0.22s cubic-bezier(.4,0,.2,1);
        }
        .trigger-card:hover {
          border-color: #47CBCB !important;
          transform: translateY(-3px);
          box-shadow: 0 8px 28px rgba(15,17,21,0.09);
        }
        @media (max-width: 900px) {
          .triggers-grid { grid-template-columns: 1fr 1fr !important; }
        }
        @media (max-width: 600px) {
          .triggers-grid { grid-template-columns: 1fr !important; }
        }
      `}</style>
    </section>
  );
}

// ── DPOIncluded ───────────────────────────────────────────────────────────────

function DPOIncluded() {
  const s = DPO.tiers;
  return (
    <section className="section">
      <div className="container">

        {/* Section header */}
        <div style={{ maxWidth: 720, marginBottom: 48 }}>
          <div className="eyebrow">{s.eyebrow}</div>
          <h2 style={{ fontSize: 'clamp(32px, 3.4vw, 44px)', marginBottom: 16, letterSpacing: '-0.03em' }}>
            {s.title}
          </h2>
          <p style={{ fontSize: 18, color: 'var(--muted)', lineHeight: 1.55 }}>
            {s.sub}
          </p>
        </div>

        {/* ── Tier cards ── */}
        <div style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 20 }}
             className="dpo-tiers-grid">
          {s.cards.map((card, i) => (
            <div
              key={i}
              className={`dpo-tier-card${card.highlight ? ' dpo-tier-highlight' : ''}`}
              style={{
                background: card.highlight ? 'var(--turquoise-50)' : 'white',
                border: `${card.highlight ? '2px' : '1px'} solid ${card.highlight ? 'var(--turquoise)' : 'var(--border)'}`,
                borderRadius: 16,
                padding: card.highlight ? 27 : 28,
                display: 'flex', flexDirection: 'column',
                position: 'relative',
              }}
            >
              {/* "הנפוץ ביותר" badge */}
              {card.highlight && (
                <div style={{
                  position: 'absolute', top: -13, insetInlineStart: 24,
                  background: 'var(--turquoise)', color: '#0A2A2A',
                  fontSize: 11, fontWeight: 700, letterSpacing: '0.04em',
                  padding: '3px 12px', borderRadius: 999,
                }}>הנפוץ ביותר</div>
              )}

              {/* Mode badge */}
              <div style={{
                display: 'inline-flex', alignItems: 'center', gap: 5,
                padding: '4px 10px', borderRadius: 999, marginBottom: 20,
                alignSelf: 'flex-start',
                background: card.mode === 'retainer' ? '#F1F1EE' : '#FAECE7',
                border: `1px solid ${card.mode === 'retainer' ? '#E2E2DD' : '#F0D6C8'}`,
                color: card.mode === 'retainer' ? '#5C5C58' : '#993C1D',
                fontSize: 11.5, fontWeight: 500,
              }}>
                <span style={{
                  width: 5, height: 5, borderRadius: '50%',
                  background: card.mode === 'retainer' ? '#8C8C86' : '#C2532E',
                }} />
                {card.modeLabel}
              </div>

              <h3 style={{ fontSize: 20, fontWeight: 700, letterSpacing: '-0.02em', marginBottom: 4, color: 'var(--ink)' }}>
                {card.title}
              </h3>
              <div className="en" style={{ fontSize: 12, color: 'var(--muted-2)', marginBottom: 14 }}>
                {card.sub}
              </div>
              <p style={{ fontSize: 14.5, lineHeight: 1.6, marginBottom: 22, color: 'var(--muted)' }}>
                {card.desc}
              </p>

              <ul style={{ listStyle: 'none', padding: 0, margin: 0, display: 'flex', flexDirection: 'column', gap: 10, marginTop: 'auto' }}>
                {card.items.map((item, ii) => (
                  <li key={ii} style={{ display: 'flex', alignItems: 'flex-start', gap: 10, fontSize: 14, lineHeight: 1.45, color: 'var(--ink-2)' }}>
                    <div style={{
                      width: 17, height: 17, borderRadius: 4, flexShrink: 0, marginTop: 2,
                      background: 'var(--turquoise-50)', color: 'var(--turquoise-700)',
                      display: 'flex', alignItems: 'center', justifyContent: 'center',
                    }}>
                      <svg width="10" height="10" viewBox="0 0 10 10"><path d="M2 5.5 L4 7.5 L8 3" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" fill="none"/></svg>
                    </div>
                    {item}
                  </li>
                ))}
              </ul>
            </div>
          ))}
        </div>

        {/* Notes */}
        <div style={{ marginTop: 24, padding: '18px 24px', background: 'var(--bg-2)', borderRadius: 12, fontSize: 15, color: 'var(--muted)', lineHeight: 1.6, borderInlineStart: '3px solid var(--turquoise)' }}>
          {s.note1}
        </div>
        <div style={{ marginTop: 14, padding: '16px 24px', background: 'white', borderRadius: 12, border: '1px solid var(--border)', fontSize: 14, color: 'var(--muted)', lineHeight: 1.65 }}>
          <span style={{ fontWeight: 600, color: 'var(--ink-2)' }}>{s.note2label}</span>
          {s.note2}
        </div>
      </div>

      <style>{`
        @media (max-width: 900px) {
          .dpo-tiers-grid { grid-template-columns: 1fr 1fr !important; }
        }
        @media (max-width: 600px) {
          .dpo-tiers-grid { grid-template-columns: 1fr !important; }
          .dpo-connector-line { display: none !important; }
        }
        .dpo-tier-card {
          transition:
            transform 0.22s cubic-bezier(.4,0,.2,1),
            box-shadow 0.22s cubic-bezier(.4,0,.2,1),
            border-color 0.22s cubic-bezier(.4,0,.2,1);
        }
        .dpo-tier-card:hover {
          transform: translateY(-3px);
          box-shadow: 0 8px 28px rgba(15,17,21,0.09);
        }
        .dpo-tier-card:not(.dpo-tier-highlight):hover {
          border-color: #47CBCB !important;
        }
        .dpo-tier-card.dpo-tier-highlight:hover {
          box-shadow: 0 10px 32px rgba(71,203,203,0.26);
        }
      `}</style>
    </section>
  );
}

Object.assign(window, { DPOTriggers, DPOIncluded });
