// Service page — Position, 3 strengths, service overview, pricing
const { useState: useStateSv } = React;

function ServiceHero() {
  return (
    <section style={{ padding: "120px 0 80px", position: "relative", overflow: "hidden" }}>
      <div className="rail-right" />
      <div className="container">
        <span className="eyebrow">Service</span>
        <h1 className="h-section" style={{ marginTop: 18, fontSize: "clamp(56px, 10vw, 180px)" }}>
          <Kinetic text="最適な「形」を、" />
          <br />
          <span style={{ color: "var(--navy)" }}>
            <Kinetic text="選べる自由。" />
          </span>
        </h1>
        <p style={{ marginTop: 40, maxWidth: 720, fontSize: 17, lineHeight: 2.0, color: "var(--ink-2)" }}>
          任せることも、特定の領域だけを共創することも。<br />
          貴社のリソース状況に合わせた、最も効率的な体制を構築します。
        </p>
      </div>
    </section>
  );
}

function PositionMap() {
  // Skill scores out of 5 — used for the meters.
  const players = [
    {
      id: "create",
      label: "制作会社",
      tag: "Q2 · CREATIVE-LED",
      bg: "var(--navy)",
      fg: "#fff",
      desc: "クリエイティブの品質は高いが、運用実行に弱く広告成果に直結しづらい。",
      shortDesc: "制作に強み、運用に弱み",
      meters: [
        { k: "戦略", v: 2 },
        { k: "制作", v: 5 },
        { k: "運用", v: 1 },
      ],
      pos: { row: 1, col: 1 },
      x: 22, y: 24, size: 130,
      icon: "▲",
    },
    {
      id: "frevia",
      label: "frevia",
      tag: "Q1 · IDEAL ZONE ★",
      bg: "var(--terra)",
      fg: "#fff",
      desc: "戦略・制作・運用を一気通貫で。代理店より実行力、制作会社より戦略。",
      shortDesc: "戦略・制作・運用を一気通貫",
      meters: [
        { k: "戦略", v: 5 },
        { k: "制作", v: 5 },
        { k: "運用", v: 5 },
      ],
      pos: { row: 1, col: 2 },
      x: 76, y: 26, size: 130,
      icon: "★",
      featured: true,
    },
    {
      id: "selfops",
      label: "自社運用",
      tag: "Q3 · IN-HOUSE",
      bg: "transparent",
      fg: "var(--ink-2)",
      ghost: true,
      desc: "低コストだが、専門人材・ナレッジの不足で頭打ちになりやすい。",
      shortDesc: "低コスト、専門性に限界",
      meters: [
        { k: "戦略", v: 2 },
        { k: "制作", v: 1 },
        { k: "運用", v: 2 },
      ],
      pos: { row: 2, col: 1 },
      x: 28, y: 70, size: 130,
      icon: "○",
    },
    {
      id: "agency",
      label: "Web広告代理店",
      tag: "Q4 · OPS-LED",
      bg: "var(--sky)",
      fg: "var(--ink)",
      desc: "運用は強いが、戦略設計や制作との分業で部分最適になりがち。",
      shortDesc: "運用に強み、部分最適に陥りやすい",
      meters: [
        { k: "戦略", v: 3 },
        { k: "制作", v: 2 },
        { k: "運用", v: 5 },
      ],
      pos: { row: 2, col: 2 },
      x: 76, y: 68, size: 130,
      icon: "●",
    },
  ];

  return (
    <section style={{ padding: "64px 0", background: "var(--bg)", color: "var(--ink)", position: "relative", overflow: "hidden" }}>
      <div className="rail-right" />

      {/* decorative orbit */}
      <div style={{ position: "absolute", top: -120, left: -120, width: 360, height: 360, pointerEvents: "none", opacity: 0.5 }}>
        <svg viewBox="0 0 360 360" style={{ animation: "spin-slow 70s linear infinite" }}>
          <defs>
            <path id="pos-circ" d="M 180 180 m -150 0 a 150 150 0 1 1 300 0 a 150 150 0 1 1 -300 0" />
          </defs>
          <text fontFamily="var(--f-en)" fontSize="12" fontWeight="600" letterSpacing="6" fill="var(--navy)" opacity="0.35">
            <textPath href="#pos-circ">POSITIONING · STRATEGY · CREATIVE · OPERATIONS · </textPath>
          </text>
        </svg>
      </div>

      {/* Decorative dots removed per user request */}

      <div className="container" style={{ position: "relative", zIndex: 2 }}>
        <div style={{ display: "flex", alignItems: "baseline", gap: 16, flexWrap: "wrap" }}>
          <span className="eyebrow">Positioning</span>
        </div>
        <h2 className="h-section" style={{ marginTop: 14, marginBottom: 12, fontSize: "clamp(32px, 4.8vw, 64px)" }}>
          <Kinetic text="freviaの立ち位置" dotAt={4} />
        </h2>
        <p style={{ marginTop: 8, marginBottom: 24, maxWidth: 720, fontSize: 15, lineHeight: 1.8, color: "var(--ink-2)" }}>
          代理店より<span style={{ color: "var(--navy)", fontWeight: 700 }}>実行力</span>、制作会社より<span style={{ color: "var(--terra)", fontWeight: 700 }}>戦略</span>。戦略・制作・運用を一気通貫で担える、業界でも稀有なポジションを取っています。
        </p>

        {/* ============================================
            POSITIONING MAP — full-width 2D scatter plot
            ============================================ */}
        <div data-position-map style={{
          position: "relative",
          aspectRatio: "16/9",
          marginTop: 8,
          background: "linear-gradient(135deg, #FFFFFF 0%, #F8FAFC 100%)",
          borderRadius: 22,
          border: "1px solid var(--line)",
          boxShadow: "0 20px 60px rgba(31, 61, 99, 0.06)",
          overflow: "hidden",
        }}>
          {/* Quadrant background tints */}
          <div style={{ position: "absolute", top: 0, left: 0, width: "50%", height: "50%", background: "linear-gradient(135deg, rgba(0,0,0,0.015) 0%, transparent 60%)" }} />
          <div style={{ position: "absolute", top: 0, right: 0, width: "50%", height: "50%", background: "radial-gradient(ellipse at 70% 30%, rgba(200,70,50,0.16) 0%, rgba(200,70,50,0.04) 50%, transparent 100%)" }} />
          <div style={{ position: "absolute", bottom: 0, left: 0, width: "50%", height: "50%", background: "linear-gradient(315deg, rgba(0,0,0,0.015) 0%, transparent 60%)" }} />
          <div style={{ position: "absolute", bottom: 0, right: 0, width: "50%", height: "50%", background: "radial-gradient(ellipse at 70% 70%, rgba(123,199,226,0.14) 0%, transparent 70%)" }} />

          {/* Background grid (10x10 faint) */}
          <div style={{
            position: "absolute", inset: "80px 80px 100px 100px",
            backgroundImage:
              "linear-gradient(to right, rgba(26,26,26,0.06) 1px, transparent 1px), " +
              "linear-gradient(to bottom, rgba(26,26,26,0.06) 1px, transparent 1px)",
            backgroundSize: "10% 10%",
            pointerEvents: "none",
          }} />

          {/* Crosshair axes — dashed, span the inner chart */}
          <div style={{ position: "absolute", top: "9%", bottom: "13%", left: "50%", width: 0, borderLeft: "1.5px dashed rgba(26,26,26,0.28)" }} />
          <div style={{ position: "absolute", left: "10%", right: "8%", top: "50%", height: 0, borderTop: "1.5px dashed rgba(26,26,26,0.28)" }} />

          {/* Center origin dot */}
          <div style={{
            position: "absolute", top: "50%", left: "50%",
            transform: "translate(-50%, -50%)",
            width: 10, height: 10, borderRadius: "50%",
            background: "var(--ink)", opacity: 0.35,
          }} />
          <div style={{
            position: "absolute", top: "50%", left: "50%",
            transform: "translate(-50%, -50%)",
            width: 28, height: 28, borderRadius: "50%",
            border: "1px solid rgba(26,26,26,0.18)",
            pointerEvents: "none",
          }} />

          {/* Quadrant codes (corner overlays) */}
          <div style={{ position: "absolute", top: 28, left: 110, fontFamily: "var(--f-en)", fontSize: 12, fontWeight: 700, letterSpacing: "0.22em", color: "var(--ink-3)", opacity: 0.8 }}>Q2 · CREATIVE-LED</div>
          <div style={{ position: "absolute", top: 28, right: 32, fontFamily: "var(--f-en)", fontSize: 12, fontWeight: 700, letterSpacing: "0.22em", color: "var(--terra)", display: "flex", alignItems: "center", gap: 6 }}>
            <span style={{ fontSize: 14 }}>★</span> Q1 · IDEAL ZONE
          </div>
          <div style={{ position: "absolute", bottom: 80, left: 110, fontFamily: "var(--f-en)", fontSize: 12, fontWeight: 700, letterSpacing: "0.22em", color: "var(--ink-3)", opacity: 0.8 }}>Q3 · IN-HOUSE</div>
          <div style={{ position: "absolute", bottom: 80, right: 32, fontFamily: "var(--f-en)", fontSize: 12, fontWeight: 700, letterSpacing: "0.22em", color: "var(--ink-3)", opacity: 0.8 }}>Q4 · OPS-LED</div>

          {/* Y-axis: vertical label on left edge with scale arrows */}
          <div style={{
            position: "absolute",
            left: 18,
            top: "9%",
            bottom: "13%",
            display: "flex",
            flexDirection: "column",
            alignItems: "center",
            justifyContent: "space-between",
            fontFamily: "var(--f-en)",
            fontSize: 11,
            fontWeight: 700,
            letterSpacing: "0.16em",
            color: "var(--navy)",
            pointerEvents: "none",
          }}>
            <span style={{ display: "flex", alignItems: "center", gap: 4, fontSize: 13 }}>
              <span style={{ fontSize: 16 }}>↑</span> 高
            </span>
            <span style={{
              writingMode: "vertical-rl",
              fontFamily: "var(--f-body)",
              fontSize: 16,
              fontWeight: 700,
              letterSpacing: "0.22em",
              color: "var(--navy)",
              whiteSpace: "nowrap",
            }}>
              クリエイティブの量と質
            </span>
            <span style={{ display: "flex", alignItems: "center", gap: 4, color: "var(--ink-3)", fontSize: 13 }}>
              低 <span style={{ fontSize: 16 }}>↓</span>
            </span>
          </div>

          {/* X-axis: horizontal label at bottom with scale arrows */}
          <div style={{
            position: "absolute",
            bottom: 28,
            left: "10%",
            right: "8%",
            display: "flex",
            alignItems: "center",
            justifyContent: "space-between",
            fontFamily: "var(--f-en)",
            fontSize: 11,
            fontWeight: 700,
            letterSpacing: "0.16em",
            color: "var(--terra)",
            pointerEvents: "none",
          }}>
            <span style={{ display: "flex", alignItems: "center", gap: 4, color: "var(--ink-3)", fontSize: 13 }}>
              <span style={{ fontSize: 16 }}>←</span> 低
            </span>
            <span style={{
              fontFamily: "var(--f-body)",
              fontSize: 16,
              fontWeight: 700,
              letterSpacing: "0.22em",
              color: "var(--terra)",
            }}>
              運用の実行力
            </span>
            <span style={{ display: "flex", alignItems: "center", gap: 4, fontSize: 13 }}>
              高 <span style={{ fontSize: 16 }}>→</span>
            </span>
          </div>

          {/* Player bubbles plotted at (x, y) */}
          {players.map((p) => (
            <div
              key={p.id}
              data-position-bubble
              data-cursor="hover"
              style={{
                position: "absolute",
                left: `${p.x}%`,
                top: `${p.y}%`,
                transform: "translate(-50%, -50%)",
                textAlign: "center",
                cursor: "none",
                zIndex: p.featured ? 5 : 3,
              }}
            >
              {/* Star burst behind featured */}
              {p.featured ? (
                <div style={{
                  position: "absolute",
                  top: "50%", left: "50%",
                  transform: "translate(-50%, -50%)",
                  width: p.size + 80,
                  height: p.size + 80,
                  borderRadius: "50%",
                  background: "radial-gradient(circle, rgba(200,70,50,0.30) 0%, rgba(200,70,50,0.04) 60%, transparent 80%)",
                  animation: "pulse 2.6s ease-in-out infinite",
                  pointerEvents: "none",
                }} />
              ) : null}

              {/* The bubble */}
              <div style={{
                position: "relative",
                width: p.size,
                height: p.size,
                borderRadius: "50%",
                background: p.bg,
                color: p.fg,
                border: p.ghost ? "2px dashed rgba(26,26,26,0.35)" : "none",
                display: "grid",
                placeItems: "center",
                boxShadow: p.featured
                  ? "0 24px 60px rgba(200,70,50,0.45), inset 0 0 0 4px rgba(255,255,255,0.18)"
                  : p.ghost
                    ? "none"
                    : "0 12px 30px rgba(31,61,99,0.12)",
                fontFamily: "var(--f-display)",
                fontWeight: 900,
                lineHeight: 1,
                transition: "transform 0.5s var(--easing)",
              }}
              onMouseEnter={(e) => { e.currentTarget.style.transform = "scale(1.06)"; }}
              onMouseLeave={(e) => { e.currentTarget.style.transform = "scale(1)"; }}
              >
                {p.featured ? (
                  <span style={{ fontSize: "clamp(20px, 2.0vw, 32px)", letterSpacing: "-0.04em" }}>
                    {p.label}
                  </span>
                ) : (
                  <span style={{ fontSize: "clamp(13px, 1.3vw, 17px)", letterSpacing: "-0.02em", lineHeight: 1.15, padding: "0 10px", textWrap: "balance" }}>
                    {p.label}
                  </span>
                )}
              </div>

              {/* Brief description below every bubble */}
              <div style={{
                marginTop: 12,
                fontFamily: "var(--f-body)",
                fontWeight: 600,
                fontSize: 12,
                lineHeight: 1.5,
                color: p.featured ? "var(--terra)" : "var(--ink-2)",
                letterSpacing: "0.02em",
                textAlign: "center",
                whiteSpace: "nowrap",
              }}>
                {p.shortDesc}
              </div>

              {/* "HERE WE ARE" callout pinned to the LEFT of frevia */}
              {p.featured ? (
                <div style={{
                  position: "absolute",
                  top: -22,
                  right: "100%",
                  marginRight: 8,
                  fontFamily: "var(--f-en)",
                  fontSize: 11,
                  fontWeight: 700,
                  letterSpacing: "0.20em",
                  color: "var(--terra)",
                  whiteSpace: "nowrap",
                  transform: "rotate(-6deg)",
                  display: "flex",
                  alignItems: "center",
                  gap: 6,
                  pointerEvents: "none",
                }}>
                  HERE WE ARE
                  <span style={{ fontSize: 16 }}>↘</span>
                </div>
              ) : null}
            </div>
          ))}
        </div>

        {/* ============================================
            (Legend tiles removed — each bubble carries its own label + brief description.)
            ============================================ */}
      </div>
    </section>
  );
}

// Legacy Node — kept for backwards compatibility but no longer rendered.
function Node() { return null; }

function StrengthsDetail() {
  const items = [
    {
      n: "01",
      title: "クリエイティブの量×質。",
      lead: "運用の最適化だけでは成果に限界がある時代。いかに多くのクリエイティブを検証し、勝ちパターンを早期発見できるか。",
      stats: [{ k: "バナー検証", v: "無制限" }, { k: "制作コスト", v: "手数料内" }, { k: "勝ちパターン", v: "早期発見" }],
      visual: "banners",
      color: "var(--navy)",
      bg: "var(--sky-soft)",
    },
    {
      n: "02",
      title: "LP量産・改善でCVR向上。",
      lead: "ノーコードビルダー「Without」を活用。制作・修正は無制限、最短1日で公開。CVR最大化に向け、A/Bテストを高速で回し続ける。",
      stats: [{ k: "制作コスト", v: "1/10以下" }, { k: "公開速度", v: "最短1日" }, { k: "修正", v: "何度でも" }],
      visual: "lp",
      color: "var(--navy)",
      bg: "var(--bg-soft)",
    },
    {
      n: "03",
      title: "市場・ユーザー行動の解像度。",
      lead: "消費者モニターとWebユーザーの行動ログを覆う有料の分析ツールを導入。データに裏付けられたユーザー行動・競合動向を元に、感覚ではない施策を設計。",
      stats: [{ cat: "顧客視点", k: "潜在ニーズ", v: "行動ログ解析" }, { cat: "競争環境", k: "市場・競合", v: "勝率の最大化" }, { cat: "論理思考", k: "データ駆動", v: "根拠ある戦略" }],
      visual: "data",
      color: "var(--terra)",
      bg: "var(--bg-soft)",
    },
  ];

  return (
    <section style={{ padding: "120px 0" }}>
      <div className="container">
        <span className="eyebrow">Strengths</span>
        <h2 className="h-section" style={{ marginTop: 18, marginBottom: 80 }}>
          <Kinetic text="freviaの" dotAt={4} /><br />強み、ぜんぶ
        </h2>

        <div style={{ display: "flex", flexDirection: "column", gap: 24 }}>
          {items.map((it, i) => (
            <div key={it.n} data-strength-card style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: 0, borderRadius: 16, overflow: "hidden", background: "var(--paper)", border: "1px solid var(--line)" }}>
              <div style={{ padding: 48 }}>
                <div style={{ display: "flex", alignItems: "center", gap: 16, marginBottom: 32 }}>
                  <span style={{ fontFamily: "var(--f-display)", fontSize: 80, fontWeight: 900, letterSpacing: "-0.04em", color: it.color, lineHeight: 1 }}>
                    {it.n}
                  </span>
                  <span className={i === 2 ? "sticker sticker--terra" : "sticker"}>Strength</span>
                </div>
                <h3 style={{ fontFamily: "var(--f-display)", fontWeight: 900, fontSize: "clamp(28px, 2.6vw, 36px)", lineHeight: 1.3, letterSpacing: "-0.03em", marginBottom: 24, color: "var(--ink)", textWrap: "balance" }}>
                  {it.title}
                </h3>
                <p style={{ fontSize: 15, lineHeight: 1.95, color: "var(--ink-2)", marginBottom: 32 }}>{it.lead}</p>
                <div style={{ display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: 16 }}>
                  {it.stats.map((s) => (
                    <div key={s.k} style={{ padding: "16px 0", borderTop: "1px solid var(--line)" }}>
                      {s.cat ? (
                        <div style={{ fontSize: 11, fontWeight: 700, letterSpacing: "0.08em", color: it.color, marginBottom: 6 }}>{s.cat}</div>
                      ) : null}
                      <div className="eyebrow" style={{ marginBottom: 8 }}>{s.k}</div>
                      <div style={{ fontFamily: "var(--f-display)", fontWeight: 900, fontSize: 22, letterSpacing: "-0.02em", color: "var(--ink)" }}>{s.v}</div>
                    </div>
                  ))}
                </div>
              </div>
              <div data-strength-visual style={{ background: it.bg, padding: 48, display: "grid", placeItems: "center", position: "relative", overflow: "hidden" }}>
                <StrengthVisual kind={it.visual} accent={it.color} />
              </div>
            </div>
          ))}
        </div>
      </div>
    </section>
  );
}

function StrengthVisual({ kind, accent }) {
  if (kind === "banners") {
    // 4×4 = 16 mini ad-banner mockups.
    // Each column shares a color (left→right: navy / sky / terra / navy-deep).
    // Each row carries its own A/B/C/D variant badge (top→bottom).
    // Staggered "breathe" animation with narrow peak — only 2–3 active at any moment.
    const columnThemes = ["navy", "sky", "terra", "navy-deep"];
    const rowBadges = ["A", "B", "C", "D"];
    const banners = [];
    for (let row = 0; row < 4; row++) {
      for (let col = 0; col < 4; col++) {
        banners.push({
          theme: columnThemes[col],
          badge: rowBadges[row],
          delay: (row * 4 + col) * 0.4,
        });
      }
    }
    const themeMap = {
      navy:       { bg: "var(--navy)",       fg: "#fff",       imgBg: "rgba(255,255,255,0.14)", accent: "var(--sky)" },
      "navy-deep":{ bg: "var(--navy-deep)",  fg: "#fff",       imgBg: "rgba(255,255,255,0.10)", accent: "var(--sky)" },
      sky:        { bg: "var(--sky)",        fg: "var(--ink)", imgBg: "rgba(255,255,255,0.50)", accent: "var(--navy)" },
      terra:      { bg: "var(--terra)",      fg: "#fff",       imgBg: "rgba(255,255,255,0.20)", accent: "#fff" },
    };

    return (
      <div data-strength-banners style={{
        display: "grid",
        gridTemplateColumns: "repeat(4, 1fr)",
        gridAutoRows: "1fr",
        gap: 8,
        width: "100%",
        position: "relative",
      }}>
        <style>{`
          @keyframes bannerBreathe {
            0%, 100% { transform: scale(1) translateY(0); }
            12%      { transform: scale(1.06) translateY(-3px); }
            28%      { transform: scale(1) translateY(0); }
          }
        `}</style>

        {banners.map((b, i) => {
          const t = themeMap[b.theme];
          return (
            <div key={i} style={{
              aspectRatio: "1",
              background: t.bg,
              color: t.fg,
              borderRadius: 8,
              padding: 8,
              display: "flex",
              flexDirection: "column",
              gap: 5,
              position: "relative",
              overflow: "hidden",
              boxShadow: "0 4px 12px rgba(0,0,0,0.06)",
              willChange: "transform",
              animation: `bannerBreathe 8s cubic-bezier(0.4, 0, 0.2, 1) infinite ${b.delay}s`,
            }}>
              {/* Hero image area */}
              <div style={{
                flex: 1,
                background: t.imgBg,
                borderRadius: 4,
                position: "relative",
                display: "grid",
                placeItems: "center",
                minHeight: 0,
                overflow: "hidden",
              }}>
                <div style={{
                  width: "55%",
                  aspectRatio: "1",
                  borderRadius: "50%",
                  background: t.accent,
                  opacity: 0.6,
                }} />
              </div>

              {/* Text bars */}
              <div style={{ display: "flex", flexDirection: "column", gap: 2 }}>
                <div style={{ height: 3, borderRadius: 2, background: t.fg, opacity: 0.85, width: "75%" }} />
                <div style={{ height: 2, borderRadius: 1, background: t.fg, opacity: 0.5, width: "55%" }} />
              </div>

              {/* A / B badge */}
              <div style={{
                position: "absolute",
                top: 5, left: 5,
                padding: "1px 5px",
                background: "rgba(0,0,0,0.55)",
                color: "#fff",
                borderRadius: 999,
                fontFamily: "var(--f-en)",
                fontSize: 7,
                fontWeight: 700,
                letterSpacing: "0.1em",
                backdropFilter: "blur(4px)",
                WebkitBackdropFilter: "blur(4px)",
              }}>{b.badge}</div>
            </div>
          );
        })}
      </div>
    );
  }
  if (kind === "lp") {
    // Animated LP mockups — auto-scroll content, rotate "current page" indicator,
    // and pulse the CTA. Feels like real LPs being optimized in real time.
    return (
      <div style={{ display: "flex", gap: 14, alignItems: "stretch", width: "100%", perspective: "800px" }}>
        <style>{`
          @keyframes lp-scroll-${"a"} {
            0%   { transform: translateY(0); }
            45%  { transform: translateY(-12px); }
            55%  { transform: translateY(-12px); }
            100% { transform: translateY(0); }
          }
          @keyframes lp-cta-pulse {
            0%, 100% { transform: scaleX(1); opacity: 1; }
            50%      { transform: scaleX(0.85); opacity: 0.6; }
          }
          @keyframes lp-headline-flicker {
            0%, 100% { width: 60%; background: var(--terra); }
            50%      { width: 75%; background: var(--navy); }
          }
          @keyframes lp-card-bob {
            0%, 100% { transform: translateY(var(--y0)) rotate(var(--r0)); }
            50%      { transform: translateY(calc(var(--y0) - 8px)) rotate(var(--r0)); }
          }
          @keyframes lp-badge-blink {
            0%, 70%, 100% { opacity: 0; transform: scale(0.6); }
            10%, 60%      { opacity: 1; transform: scale(1); }
          }
          @keyframes lp-cursor-move {
            0%   { transform: translate(0, 0); opacity: 0; }
            10%  { opacity: 1; }
            40%  { transform: translate(0, 80px); }
            60%  { transform: translate(0, 80px); }
            90%  { opacity: 1; }
            100% { transform: translate(0, 0); opacity: 0; }
          }
        `}</style>
        {[0, 1, 2].map((i) => {
          const y0 = `${i * 8}px`;
          const r0 = `${(i - 1) * -3}deg`;
          return (
            <div key={i} style={{
              flex: 1,
              background: "#fff",
              borderRadius: 12,
              padding: 12,
              color: "var(--ink)",
              aspectRatio: "9/16",
              display: "flex",
              flexDirection: "column",
              gap: 6,
              border: "1px solid var(--line)",
              position: "relative",
              boxShadow: "0 12px 30px rgba(31,61,99,0.08)",
              "--y0": y0,
              "--r0": r0,
              animation: `lp-card-bob 5.5s ease-in-out infinite ${i * 0.4}s`,
              overflow: "hidden",
            }}>
              {/* Page content (animated scroll) */}
              <div style={{
                display: "flex", flexDirection: "column", gap: 6,
                animation: `lp-scroll-a 6s ease-in-out infinite ${i * 0.6}s`,
              }}>
                {/* Headline bar — color/width flickers (A/B test) */}
                <div style={{
                  height: 6,
                  borderRadius: 3,
                  animation: `lp-headline-flicker 4s ease-in-out infinite ${i * 0.8}s`,
                  width: "60%",
                }} />
                {/* Hero block */}
                <div style={{ height: 22, background: "var(--navy)", borderRadius: 5 }} />
                {/* Text lines */}
                <div style={{ height: 5, background: "var(--sky-soft)", borderRadius: 3 }} />
                <div style={{ height: 5, background: "var(--sky-soft)", borderRadius: 3, width: "80%" }} />
                {/* Image placeholder with grid */}
                <div style={{ flex: 1, background: "var(--sky-soft)", borderRadius: 6, minHeight: 50, position: "relative", overflow: "hidden" }}>
                  <div style={{
                    position: "absolute", inset: 0,
                    background: "linear-gradient(45deg, transparent 48%, rgba(123,199,226,0.4) 50%, transparent 52%)",
                    backgroundSize: "10px 10px",
                  }} />
                </div>
                {/* CTA */}
                <div style={{
                  height: 14,
                  background: "var(--terra)",
                  borderRadius: 5,
                  transformOrigin: "left center",
                  animation: `lp-cta-pulse 1.6s ease-in-out infinite ${i * 0.3}s`,
                }} />
              </div>

              {/* "improving" badge */}
              <div style={{
                position: "absolute",
                top: 10,
                right: 10,
                background: "var(--terra)",
                color: "#fff",
                fontFamily: "var(--f-en)",
                fontSize: 8,
                fontWeight: 700,
                letterSpacing: "0.08em",
                padding: "2px 6px",
                borderRadius: 999,
                animation: `lp-badge-blink 4s ease-in-out infinite ${i * 1.2 + 1}s`,
              }}>
                A/B
              </div>

              {/* moving cursor */}
              {i === 1 ? (
                <div style={{
                  position: "absolute",
                  top: "20%",
                  left: "55%",
                  width: 10, height: 10,
                  animation: "lp-cursor-move 4.5s ease-in-out infinite 0.3s",
                  pointerEvents: "none",
                }}>
                  <svg viewBox="0 0 12 12" width="12" height="12">
                    <path d="M1 1 L1 9 L4 7 L6 11 L8 10 L6 6 L10 6 Z" fill="var(--ink)" stroke="#fff" strokeWidth="0.6" />
                  </svg>
                </div>
              ) : null}
            </div>
          );
        })}
      </div>
    );
  }
  // data
  return (
    <div style={{ width: "100%" }}>
      <svg viewBox="0 0 300 200" style={{ width: "100%", height: "auto" }}>
        <defs>
          <pattern id="grid" width="20" height="20" patternUnits="userSpaceOnUse">
            <path d="M 20 0 L 0 0 0 20" fill="none" stroke="rgba(26,26,26,0.12)" strokeWidth="0.5" />
          </pattern>
        </defs>
        <rect width="300" height="200" fill="url(#grid)" />
        {Array.from({ length: 80 }).map((_, i) => {
          const x = 20 + (i * 47) % 270;
          const y = 20 + (i * 31) % 160;
          const r = (i % 5) + 2;
          return <circle key={i} cx={x} cy={y} r={r} fill={i % 7 === 0 ? "var(--terra)" : "var(--navy)"} opacity={i % 7 === 0 ? 0.9 : 0.4} />;
        })}
        <circle cx="180" cy="80" r="48" fill="none" stroke="var(--terra)" strokeWidth="2" strokeDasharray="4 4">
          <animate attributeName="r" values="44;52;44" dur="3s" repeatCount="indefinite" />
        </circle>
      </svg>
    </div>
  );
}

function ServiceFlow() {
  const steps = [
    { n: "STEP 01", title: "戦略設計の土台策定", body: "弊社の分析データと貴社のCRM・MAデータを掛け合わせ、データドリブンにペルソナを立案。市場・ユーザー行動をとらえた戦略設計。", color: "var(--navy)" },
    { n: "STEP 02", title: "施策成果の最大化", body: "クリエイティブPDCAとLP最適化（LPO）で施策成果を最大化。バナー量産とWithoutによるLP生成で、無制限に検証。", color: "var(--sky)" },
    { n: "STEP 03", title: "事業売上・利益の最大化", body: "インハウス化支援を通じて、事業売上のさらなる拡大。OJT形式の伴走・社内勉強会で、ノウハウを組織の資産に。", color: "var(--terra)" },
  ];

  return (
    <section style={{ padding: "120px 0", background: "var(--bg-soft)", position: "relative" }}>
      <div className="rail-right" />
      <div className="container">
        <span className="eyebrow">Service Flow</span>
        <h2 className="h-section" style={{ marginTop: 18, marginBottom: 80 }}>
          委託 → 並走 → <span style={{ color: "var(--terra)" }}>自走</span>
        </h2>

        <div style={{ display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: 24, position: "relative" }}>
          {steps.map((s, i) => (
            <div key={s.n} style={{ padding: 32, borderRadius: 16, background: "var(--paper)", position: "relative", border: "1px solid var(--line)" }}>
              <div style={{ position: "absolute", top: -14, left: 24, background: s.color, padding: "5px 14px", borderRadius: 999, color: s.color === "var(--sky)" ? "var(--ink)" : "#fff", fontFamily: "var(--f-en)", fontSize: 11, fontWeight: 700, letterSpacing: "0.12em" }}>
                {s.n}
              </div>
              <div style={{ fontFamily: "var(--f-display)", fontSize: 100, fontWeight: 900, letterSpacing: "-0.05em", lineHeight: 1, color: s.color, marginTop: 16 }}>
                0{i + 1}
              </div>
              <h3 style={{ fontFamily: "var(--f-display)", fontWeight: 900, fontSize: 26, marginTop: 16, letterSpacing: "-0.02em", color: "var(--ink)" }}>{s.title}</h3>
              <p style={{ marginTop: 16, color: "var(--ink-2)", fontSize: 14, lineHeight: 1.85 }}>{s.body}</p>
            </div>
          ))}
        </div>

        <div style={{ marginTop: 48, padding: 40, background: "var(--navy-deep)", color: "#fff", borderRadius: 16, display: "grid", gridTemplateColumns: "1fr 1.4fr", gap: 40, alignItems: "center" }}>
          <div>
            <span className="sticker sticker--terra">GOAL</span>
            <h3 style={{ fontFamily: "var(--f-display)", fontWeight: 900, fontSize: "clamp(30px, 3.2vw, 42px)", marginTop: 24, letterSpacing: "-0.03em", color: "#fff", lineHeight: 1.3 }}>
              自分たちで、<br />未来をハンドリング<br />できる強さを。
            </h3>
          </div>
          <div style={{ fontSize: 17, lineHeight: 1.95, color: "#fff" }}>
            <p style={{ margin: 0, fontSize: 19, fontWeight: 600, lineHeight: 1.75, letterSpacing: "0.01em" }}>
              支援のゴールは、貴社がマーケティングを<br />
              「自らの意志で自由に動かせる」状態になることです。
            </p>
            <p style={{ margin: "20px 0 0 0", color: "rgba(255,255,255,0.88)", letterSpacing: "0.01em", lineHeight: 1.9 }}>
              マーケティング基盤の権限は最初から貴社に帰属。<br />
              蓄積されたデータもノウハウも、すべて貴社の資産として残ります。
            </p>
            <div style={{ height: 1, background: "rgba(255,255,255,0.18)", margin: "26px 0" }} />
            <p style={{ margin: 0, color: "rgba(255,255,255,0.88)", letterSpacing: "0.01em", lineHeight: 1.9 }}>
              「任せる」のも「自分たちでやる」のも、<wbr />常に貴社が最適に選べるように。
            </p>
            <p style={{ margin: "14px 0 0 0", color: "#fff", fontWeight: 600, letterSpacing: "0.01em", lineHeight: 1.85 }}>
              freviaは、ブラックボックスを排除し、貴社チームの自立的な成長にどこまでも伴走します。
            </p>
          </div>
        </div>
      </div>
    </section>
  );
}

function Pricing() {
  const plans = [
    {
      name: "Standard",
      jp: "Standard Plan",
      price: "50",
      color: "var(--sky)",
      tag: "運用主軸",
      tagline: "運用とレポートを中心に、着実にPDCAを回すスタートプラン。",
      includes: [
        "週次改善MTG（週1回・60分）",
        "月次レポート（Looker Studio）",
        "広告オペレーション実務対応",
        "バナー制作 ～ 月 50本",
        "LP制作 ～ 月 1本（LPO対応）",
      ],
    },
    {
      name: "Execution Add",
      jp: "Execution Add Plan",
      price: "80",
      color: "var(--sky)",
      tag: "クリエイティブ加速",
      tagline: "クリエイティブと分析を強化、成果を一気に押し上げる中間プラン。",
      includes: [
        "Standard の全内容を含む",
        "週次戦略MTG（週1回・2時間）",
        "制作ディレクターアサイン",
        "バナー制作 ～ 月 100本",
        "LP制作 ～ 月 2本（A/Bテスト対応）",
        "市場・競合分析レポート（月次）",
      ],
      featured: true,
    },
    {
      name: "Premium Full",
      jp: "Premium Full Plan",
      price: "100",
      color: "var(--terra)",
      tag: "インハウス支援",
      tagline: "戦略・運用・制作・インハウス化まで、フル伴走プラン。",
      includes: [
        "Execution Add の全内容を含む",
        "月次経営报告MTG（森田参加）",
        "専属デザイナー・ストラテジストアサイン",
        "バナー制作 無制限",
        "LP制作 無制限（キャンペーンLP対応）",
        "インハウス化支援（スキルトランスファー・社内勉強会）",
      ],
    },
  ];

  return (
    <section style={{ padding: "120px 0", position: "relative" }}>
      <div className="rail-right" />
      <div className="container">
        <div style={{ textAlign: "center", marginBottom: 80 }}>
          <span className="eyebrow" style={{ justifyContent: "center" }}>Pricing</span>
          <h2 className="h-section" style={{ marginTop: 18 }}>
            サービスプラン
          </h2>
        </div>

        <div style={{ display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: 24 }}>
          {plans.map((p) => (
            <div key={p.name} style={{
              borderRadius: 16,
              padding: 36,
              background: p.featured ? "var(--navy-deep)" : "var(--paper)",
              color: p.featured ? "#fff" : "var(--ink)",
              border: p.featured ? "none" : "1px solid var(--line)",
              transform: p.featured ? "translateY(-20px)" : "none",
              position: "relative",
              overflow: "hidden",
              boxShadow: p.featured ? "0 24px 60px rgba(31,61,99,0.25)" : "none",
            }}>
              {p.featured ? (
                <span className="sticker sticker--terra" style={{ position: "absolute", top: 24, right: 24 }}>POPULAR</span>
              ) : null}
              <span className="eyebrow" style={{ color: p.featured ? "var(--sky)" : "var(--ink-3)" }}>{p.name}</span>
              <h3 style={{ fontFamily: "var(--f-display)", fontWeight: 900, fontSize: 28, marginTop: 14, letterSpacing: "-0.02em", color: p.featured ? "#fff" : "var(--ink)" }}>{p.jp}</h3>
              <p style={{ marginTop: 12, fontSize: 13, lineHeight: 1.75, opacity: p.featured ? 0.85 : 1, color: p.featured ? "#fff" : "var(--ink-2)", minHeight: 56 }}>{p.tagline}</p>

              <div style={{ marginTop: 24, display: "flex", alignItems: "baseline", gap: 8 }}>
                <span style={{ fontFamily: "var(--f-en)", fontSize: 16, opacity: 0.6 }}>月額</span>
                <span style={{ fontFamily: "var(--f-display)", fontWeight: 900, fontSize: 88, lineHeight: 0.9, letterSpacing: "-0.05em", color: p.color }}>{p.price}</span>
                <span style={{ fontFamily: "var(--f-display)", fontSize: 22, fontWeight: 700 }}>万円</span>
              </div>
              <div style={{ fontSize: 12, opacity: 0.55, marginTop: 4 }}>（税別）</div>

              <div style={{ height: 1, background: p.featured ? "rgba(255,255,255,0.2)" : "var(--line)", margin: "28px 0 20px" }} />

              <div className="eyebrow" style={{ color: p.featured ? "var(--sky)" : "var(--ink-3)", marginBottom: 12 }}>{p.tag}</div>
              <ul style={{ listStyle: "none", padding: 0, fontSize: 13, lineHeight: 1.7 }}>
                {p.includes.map((line, i) => (
                  <li key={i} style={{ padding: "7px 0", paddingLeft: 22, position: "relative" }}>
                    <span style={{ position: "absolute", left: 0, top: 7, color: p.color, fontSize: 14, fontWeight: 700 }}>✓</span>
                    {line}
                  </li>
                ))}
              </ul>
            </div>
          ))}
        </div>

        <div style={{ marginTop: 48, padding: 24, background: "var(--bg-soft)", borderRadius: 12, fontSize: 13, color: "var(--ink-3)", textAlign: "center", lineHeight: 1.85 }}>
          ※初回契約期間：6ヶ月　/　契約更新：1ヶ月ごとの自動更新　/　締結書類：最初の契約書のみ
        </div>
      </div>
    </section>
  );
}

function ServicePage({ onNav }) {
  return (
    <div className="page-wrap">
      <ServiceHero />
      <PositionMap />
      <StrengthsDetail />
      <ServiceFlow />
      <Pricing />
      <CTASection onNav={onNav} />
    </div>
  );
}

window.ServicePage = ServicePage;
