/* ===========================================================================
   SolutionsSales -- 仕組み (FRAGMENT:loop). Layout + FINAL state.
   A true circle: 発掘 (W) -> アプローチ (N) -> 商談 (E) -> フォロー (S) -> 発掘,
   AI core in the centre (solid product purple #805496), 営業データ feeding
   発掘 from outside. The lines (ring, rail, feed) use a lighter purple so the
   core stays the one solid purple mass.
   Each step is a rounded "button" docked on the ring: numbered badge at its
   head, role marks after its name (AI = .sa-ai from sales-ui.css, 人 = flat
   grey chip). 商談 is the person's step: no AI mark, and it lights grey/navy
   instead of the AI tint. Two exits leave the ring (dashed, paler than the
   ring): 商談 -> 受注・失注, フォロー -> ナーチャリング. They are outcomes of
   the process, drawn static (nothing travels along them).
   - >= 1200px: data column left + ring.  768-1199px: data row on top + ring.
   - < 768px: vertical stack, connector through the badges, bracket back from
     4 to 1, exits hang under 商談 / フォロー in their own grid rows (--xh).
   Everything in this file is the resting state (no JS / reduced motion):
   ring fully drawn, 4 steps equal, no moving dot. sales-loop-2.css scrubs it.
   Ring geometry lives in vars on .sa-loop-board: --cw/--ch card, --g card
   offset from the ring (negative = the card overlaps the ring = docked),
   --r ring radius, --core AI core diameter.
   Contrast: #FFF on #805496 5.79:1, #F1E6F6 on it 4.80:1; ring #9E7BB2 on
   #FFF 3.54:1; --muted on #F1F3F5 4.93:1, --navy on it 13.2:1.
   =========================================================================== */
.sa-loop-fig { --sa-line: #9E7BB2; --sa-exit: #C3A9D1; margin: var(--sp-tight) 0 0; }
.sa-loop-board { position: relative; padding: 24px 16px 28px; border: 1px solid var(--line-strong); border-radius: 16px; background: var(--white); box-shadow: 0 12px 32px rgba(16, 42, 67, 0.08); }
.sa-loop-lbl { margin: 0 0 10px; font-size: 13px; font-weight: 700; line-height: 20px; letter-spacing: 0.12em; color: var(--muted); }
.sa-loop-cap { margin: 0 0 20px; font-family: 'Noto Sans JP', sans-serif; font-size: 14px; line-height: 1.9; color: var(--muted); text-wrap: pretty; }

/* ---- 営業データ ------------------------------------------------------------- */
.sa-loop-in { position: relative; }
.sa-loop-src { position: relative; display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.sa-loop-src li { position: relative; display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--white); font-size: 14px; line-height: 20px; color: var(--ink); }
.sa-loop-src svg { flex: none; width: 18px; height: 18px; fill: none; stroke: var(--sa-acc); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
/* feed arrow into 発掘 (vertical on mobile/tablet, horizontal on desktop) */
.sa-loop-feed { position: relative; display: block; width: 2px; height: 36px; margin: 8px auto 14px; background: var(--sa-line); }
.sa-loop-feed::after { content: ""; position: absolute; left: 50%; bottom: -3px; width: 12px; height: 9px; margin-left: -6px; background: var(--sa-line); clip-path: polygon(0 0, 100% 0, 50% 100%); }
.sa-loop-pkt { position: absolute; inset: 0; opacity: 0; }
.sa-loop-pkt::before { content: ""; position: absolute; left: 50%; top: 0; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; background: var(--sa-acc); box-shadow: 0 0 0 4px rgba(128, 84, 150, 0.22); }

/* ---- AI core (product purple) + legend --------------------------------------- */
.sa-loop-cyc { position: relative; }
.sa-loop-ring { display: none; }
.sa-loop-core { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 80px; margin: 0 0 12px; padding: 12px; border-radius: 16px; background: var(--sa-acc); text-align: center; line-height: 1.5; box-shadow: 0 0 0 6px rgba(128, 84, 150, 0.14), 0 14px 30px -14px rgba(74, 40, 94, 0.6); }
.sa-loop-core::before { content: ""; width: 12px; height: 12px; margin-bottom: 4px; background: #F1E6F6; clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%); }
.sa-loop-core b { font-family: 'Zen Kaku Gothic New', 'Noto Sans JP', sans-serif; font-size: 17px; letter-spacing: 0.05em; color: var(--white); }
.sa-loop-core span { font-size: 13px; color: #F1E6F6; }
.sa-loop-key { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; margin: 0 0 14px; padding: 0; list-style: none; font-size: 12px; line-height: 20px; color: var(--muted); }
.sa-loop-key li { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
/* 人 mark: flat grey chip, thin person icon, navy text (same box as .sa-ai) */
.sa-loop-hu { display: inline-flex; align-items: center; gap: 3px; padding: 1px 7px; border-radius: 999px; background: var(--sa-flat); font-size: 10.5px; font-weight: 700; line-height: 18px; color: var(--navy); white-space: nowrap; box-shadow: inset 0 0 0 1px var(--line-strong); }
.sa-loop-hu svg { flex: none; width: 10px; height: 10px; fill: none; stroke: currentColor; stroke-width: 1.2; stroke-linecap: round; }

/* ---- step buttons (mobile = vertical stack) ------------------------------- */
.sa-loop-list { --pl: 22px; --gap: 12px; --xh: 40px; position: relative; }
.sa-loop-steps { display: grid; grid-template-rows: 1fr 1fr 1fr var(--xh) 1fr var(--xh); row-gap: var(--gap); margin: 0; padding: 0 0 0 var(--pl); list-style: none; }
.sa-loop-step { position: relative; z-index: 1; }
.sa-loop-step--4 { grid-row: 5; }
.sa-loop-card { position: relative; isolation: isolate; box-sizing: border-box; display: grid; grid-template-columns: 26px minmax(0, 1fr); column-gap: 12px; align-content: center; height: 100%; min-height: 72px; padding: 10px 12px 10px 10px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--white); box-shadow: 0 2px 6px -2px rgba(16, 42, 67, 0.12); }
.sa-loop-num { grid-row: 1 / span 2; align-self: center; position: relative; box-sizing: border-box; display: grid; place-items: center; width: 26px; height: 26px; border: 2px solid var(--sa-acc); border-radius: 50%; background: var(--white); font-size: 12px; font-weight: 700; line-height: 1; color: var(--sa-acc-ink); font-variant-numeric: tabular-nums; }
.sa-loop-on { position: absolute; inset: -2px; display: grid; place-items: center; border-radius: 50%; background: var(--sa-acc); color: var(--white); opacity: 0; }
.sa-loop-hd { grid-column: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; min-width: 0; }
.sa-loop-role { display: inline-flex; gap: 4px; }
.sa-loop-role .sa-ai, .sa-loop-role .sa-loop-hu { padding: 1px 6px; }
.sa-loop-fig .sa-ai { box-shadow: inset 0 0 0 1px rgba(128, 84, 150, 0.3); }
.sa-loop-name { margin: 0; font-size: 16px; line-height: 24px; font-weight: 700; color: var(--navy); white-space: nowrap; }
.sa-loop-tx { grid-column: 2; margin: 2px 0 0; font-family: 'Noto Sans JP', sans-serif; font-size: 14px; line-height: 22px; color: var(--muted); text-wrap: balance; }
/* lit state: pale purple fill + outline ring. Behind the text (isolated card).
   --muted on --sa-tint = 4.64:1, --navy on it 13.2:1. 商談 = the person's
   step: navy outline on white, no AI tint. Role chips carry a hairline so
   they stay visible on the lit tint. */
.sa-loop-glow { position: absolute; z-index: -1; inset: -1px; border: 2px solid var(--sa-acc); border-radius: inherit; background: var(--sa-tint); box-shadow: 0 0 0 4px rgba(128, 84, 150, 0.16), 0 14px 26px -14px rgba(128, 84, 150, 0.6); opacity: 0; pointer-events: none; }
.sa-loop-step--3 .sa-loop-glow { border-color: var(--navy); background: var(--white); box-shadow: 0 0 0 4px rgba(16, 42, 67, 0.1), 0 14px 26px -14px rgba(16, 42, 67, 0.5); }
.sa-loop-step--3 .sa-loop-on { background: var(--navy); }
/* exits: outcome labels hanging off 商談 / フォロー, dashed and paler than the ring */
.sa-loop-exit { position: absolute; z-index: 1; top: 100%; left: 48px; margin: 0; padding: calc(var(--gap) + 1px) 0 0 22px; font-size: 12px; line-height: 18px; color: var(--muted); white-space: nowrap; }
.sa-loop-exit b { display: block; font-size: 13px; color: var(--navy); }
.sa-loop-exit span { display: block; }
.sa-loop-exit::before { content: ""; position: absolute; left: 0; top: 0; box-sizing: border-box; width: 13px; height: calc(var(--gap) + 11px); border: 0 dashed var(--sa-exit); border-width: 0 0 1.5px 1.5px; border-bottom-left-radius: 6px; }
.sa-loop-exit::after { content: ""; position: absolute; left: 12px; top: calc(var(--gap) + 6px); width: 7px; height: 8px; background: var(--sa-exit); clip-path: polygon(0 0, 100% 50%, 0 100%); }
/* connector through the badge centres (shows in the gaps, cards sit on top)
   + bracket back from 4 to 1 in the left gutter. --h2 = half a card row. */
.sa-loop-rail, .sa-loop-back { --h2: calc((100% - 2 * var(--xh) - 5 * var(--gap)) / 8); position: absolute; z-index: 0; top: var(--h2); bottom: calc(var(--xh) + var(--gap) + var(--h2)); }
.sa-loop-rail { left: calc(var(--pl) + 1px + 10px + 12px); width: 2px; background: #DCD2E3; }
.sa-loop-fill { position: absolute; inset: 0 -0.5px; background: var(--sa-line); transform-origin: 50% 0; }
.sa-loop-back { left: 2px; width: calc(var(--pl) + 6px); }
.sa-loop-back, .sa-loop-back-on { box-sizing: border-box; border: 2px solid #DCD2E3; border-right: 0; border-radius: 14px 0 0 14px; }
.sa-loop-back-on { position: absolute; inset: -2px 0 -2px -2px; border-color: var(--sa-line); }
.sa-loop-back-on::after { content: ""; position: absolute; left: -7px; top: 50%; width: 12px; height: 10px; margin-top: -6px; background: var(--sa-line); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.sa-loop-dot { position: absolute; left: 0; top: 0; box-sizing: border-box; width: 16px; height: 16px; margin: -8px 0 0 -8px; border: 3px solid var(--white); border-radius: 50%; background: var(--sa-acc); box-shadow: 0 0 0 5px rgba(128, 84, 150, 0.2), 0 2px 8px rgba(16, 42, 67, 0.3); }

/* ---- ring (tablet + desktop) ------------------------------------------------ */
@media (min-width: 768px) {
  .sa-loop-board { --cw: 236px; --ch: 92px; --g: -8px; --r: 98px; --core: 144px; --cyc-w: calc(2 * (var(--cw) + var(--g) + var(--r))); padding: 32px 16px 36px; }
  .sa-loop-src { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
  .sa-loop-src li { min-height: 52px; }
  /* stubs down from each source + bus, then the feed drops into 発掘's top edge */
  .sa-loop-src li::after { content: ""; position: absolute; left: 50%; top: 100%; width: 1.5px; height: 14px; background: var(--sa-rule); }
  .sa-loop-src::after { content: ""; position: absolute; top: calc(100% + 14px); left: calc((100% - 24px) / 6); right: calc((100% - 24px) / 6); height: 1.5px; background: var(--sa-rule); }
  .sa-loop-feed { position: absolute; top: calc(100% + 14px); left: calc((100% - var(--cyc-w)) / 2 + var(--cw) / 2 - 1px); height: calc(28px - 14px + var(--ch) / 2 + var(--g) + var(--r) - 4px); margin: 0; }
  .sa-loop-cyc { width: var(--cyc-w); height: calc(2 * (var(--ch) + var(--g) + var(--r))); margin: 28px auto 0; background: radial-gradient(closest-side, rgba(244, 234, 246, 0.95), rgba(244, 234, 246, 0)); }
  /* the core already names the cycle: label stays for the list's name only */
  .sa-loop-lbl--cyc { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .sa-loop-ring { display: block; position: absolute; left: calc(var(--cw) + var(--g)); top: calc(var(--ch) + var(--g)); width: calc(2 * var(--r)); height: calc(2 * var(--r)); }
  .sa-loop-ring svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
  .sa-loop-track { fill: none; stroke: #DCD2E3; stroke-width: 1; }
  .sa-loop-draw { fill: none; stroke: var(--sa-line); stroke-width: 1.3; stroke-dasharray: 100; stroke-dashoffset: 0; }
  .sa-loop-heads { fill: var(--sa-line); }
  .sa-loop-arm { position: absolute; inset: 0; opacity: 0; }
  .sa-loop-arm .sa-loop-dot { left: 50%; }
  .sa-loop-hand { position: absolute; left: 50%; top: 0; width: 2px; height: calc(var(--r) - var(--core) / 2); margin-left: -1px; background: linear-gradient(var(--sa-line), rgba(158, 123, 178, 0)); }
  .sa-loop-core { position: absolute; left: 50%; top: 50%; width: var(--core); height: var(--core); min-height: 0; margin: calc(var(--core) / -2) 0 0 calc(var(--core) / -2); padding: 0; box-sizing: border-box; border-radius: 50%; box-shadow: 0 0 0 8px rgba(128, 84, 150, 0.14), 0 16px 34px -12px rgba(74, 40, 94, 0.55); }
  .sa-loop-core b { font-size: 15px; }
  /* legend in the empty NE corner of the ring box */
  .sa-loop-key { position: absolute; top: 0; right: 0; display: grid; justify-content: start; gap: 6px; margin: 0; }
  .sa-loop-list, .sa-loop-steps { position: static; }
  .sa-loop-steps { display: block; padding: 0; }
  .sa-loop-step { position: absolute; width: var(--cw); height: var(--ch); }
  .sa-loop-step--1 { left: 0; top: calc(50% - var(--ch) / 2); }
  .sa-loop-step--2 { left: calc(50% - var(--cw) / 2); top: 0; }
  .sa-loop-step--3 { right: 0; top: calc(50% - var(--ch) / 2); }
  .sa-loop-step--4 { left: calc(50% - var(--cw) / 2); bottom: 0; }
  .sa-loop-card { min-height: 0; padding: 10px 16px 10px 14px; box-shadow: 0 6px 16px -8px rgba(16, 42, 67, 0.22); }
  .sa-loop-hd { flex-wrap: nowrap; gap: 6px; }
  .sa-loop-name { font-size: 15px; }
  .sa-loop-tx { font-size: 13px; line-height: 20px; }
  .sa-loop-rail, .sa-loop-back { display: none; }
  /* 商談 exit drops out of the ring below its button; フォロー exit leaves left */
  .sa-loop-exit { left: auto; padding: 0; }
  .sa-loop-step--3 .sa-loop-exit { right: 18px; padding-top: 30px; text-align: center; }
  .sa-loop-step--3 .sa-loop-exit::before { left: 50%; top: 5px; width: 1.5px; height: 20px; margin-left: -0.75px; border-width: 0 0 0 1.5px; border-radius: 0; }
  .sa-loop-step--3 .sa-loop-exit::after { left: 50%; top: 22px; width: 8px; height: 7px; margin-left: -4px; clip-path: polygon(0 0, 100% 0, 50% 100%); }
  .sa-loop-step--4 .sa-loop-exit { top: 50%; right: 100%; margin-top: -18px; padding-right: 34px; text-align: right; }
  .sa-loop-step--4 .sa-loop-exit::before { left: auto; right: 7px; top: 50%; width: 20px; height: 1.5px; border-width: 0 0 1.5px; border-radius: 0; }
  .sa-loop-step--4 .sa-loop-exit::after { left: auto; right: 25px; top: 50%; margin-top: -3.25px; clip-path: polygon(100% 0, 0 50%, 100% 100%); }
}

/* ---- desktop: data column on the left, feed goes straight into 発掘 -------- */
@media (min-width: 1200px) {
  .sa-loop-board { --cw: 240px; --ch: 92px; --r: 136px; --core: 188px; --dg: 56px; display: flex; align-items: center; justify-content: center; gap: var(--dg); padding: 40px 32px; }
  .sa-loop-in { flex: none; width: 232px; }
  .sa-loop-in > .sa-loop-lbl { position: absolute; left: 0; bottom: 100%; }
  .sa-loop-src { grid-template-columns: none; gap: 12px; }
  .sa-loop-src li { min-height: 60px; }
  .sa-loop-src li::after { left: 100%; top: 50%; width: 20px; height: 1.5px; }
  .sa-loop-src::after { top: 30px; bottom: 30px; left: calc(100% + 20px); right: auto; width: 1.5px; height: auto; }
  .sa-loop-feed { top: 50%; left: calc(100% + 20px); width: calc(var(--dg) - 20px - 4px); height: 2px; margin-top: -1px; }
  .sa-loop-feed::after { left: auto; right: -3px; top: 50%; bottom: auto; width: 9px; height: 12px; margin: -6px 0 0; clip-path: polygon(0 0, 100% 50%, 0 100%); }
  .sa-loop-pkt::before { left: 0; top: 50%; }
  .sa-loop-cyc { flex: none; margin: 0; }
  .sa-loop-core b { font-size: 17px; }
  .sa-loop-name { font-size: 16px; }
  .sa-loop-tx { font-size: 14px; line-height: 22px; }
}
