/* Interactive workflow board + collapsible long-form block for template pages. */

/* ---------- shell ---------- */
.nd-flow {
  border: 1px solid var(--line, #e3e6f4);
  border-radius: 18px;
  background: #fff;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(11, 16, 48, .04), 0 18px 40px -30px rgba(11, 16, 48, .3);
}
.nd-flow-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line, #e3e6f4);
  background: #fafbfe;
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
}
.nd-flow-name { display: inline-flex; align-items: center; gap: 9px; min-width: 0; }
.nd-flow-name > i {
  width: 8px; height: 8px; border-radius: 50%; flex: none;
  background: #22a06b; box-shadow: 0 0 0 3px rgba(34, 160, 107, .16);
}
.nd-flow-note, .nd-flow-duration {
  font-weight: 500; font-size: 12px; color: #64748b;
}
.nd-flow-note { padding-left: 10px; margin-left: 2px; border-left: 1px solid #dfe3ee; }
.nd-flow-duration { display: inline-flex; align-items: center; gap: 6px; flex: none; }
.nd-flow-duration .mi { width: 14px; height: 14px; color: #64748b; }

.nd-flow-chapters {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line, #e3e6f4);
  background: #fff;
}
.nd-chapter {
  border: 1px solid var(--line, #e3e6f4);
  background: #fff; color: #475569;
  border-radius: 999px; padding: 7px 14px;
  font-size: 12.5px; font-weight: 600; cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.nd-chapter:hover { border-color: rgba(0, 51, 255, .35); color: #0033ff; }
.nd-chapter[aria-pressed="true"] { background: #0033ff; border-color: #0033ff; color: #fff; }

/* ---------- board ---------- */
.nd-flow-board {
  position: relative;
  height: 520px;
  overflow: hidden;
  touch-action: none;
  background-color: #fbfcff;
  background-image: radial-gradient(circle, rgba(173, 196, 222, .68) 1px, transparent 1.2px);
  background-size: 20px 20px;
  background-position: 10px 10px;
}
/* No will-change and no idle filter here: either one promotes the viewport to a
   cached layer, which the browser then stretches instead of re-rendering, and
   node text goes soft as soon as you zoom in. */
.nd-flow-board .viewport { position: absolute; inset: 0; transform-origin: 0 0; }
.nd-flow-board.is-pannable { cursor: grab; }
.nd-flow-board.is-pannable.grabbing { cursor: grabbing; }

.nd-flow-board .node {
  position: absolute; z-index: 2; box-sizing: border-box;
  background: #fff;
  border: 1px solid rgba(212, 222, 234, .95);
  border-radius: 20px;
  box-shadow: 0 14px 30px rgba(17, 24, 39, .09);
  padding: 12px 14px 11px;
  user-select: none; cursor: pointer; outline: none;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.nd-flow-board .node:hover { transform: translateY(-2px); border-color: rgba(0, 51, 255, .22); }
.nd-flow-board .node.is-focus,
.nd-flow-board .node:focus-visible {
  border-color: #0033ff;
  box-shadow: 0 0 0 3px rgba(0, 51, 255, .14), 0 12px 28px rgba(15, 23, 42, .12);
}
.nd-flow-board .node.is-dim { opacity: .3; }
.nd-flow-board .node .hdr { display: flex; align-items: center; gap: 7px; margin-bottom: 5px; }
.nd-flow-board .node .icon {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
}
.nd-flow-board .node .icon svg { width: 14px; height: 14px; }
.nd-flow-board .node.trigger .icon svg { width: 26px; height: 26px; }
.nd-flow-board .node .kind {
  font-size: 9.5px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase;
}
.nd-flow-board .node.task .kind, .nd-flow-board .node.task .icon { color: #0033ff; }
.nd-flow-board .node.task .icon { background: rgba(0, 51, 255, .1); }
.nd-flow-board .node.approval .kind, .nd-flow-board .node.approval .icon { color: #b45309; }
.nd-flow-board .node.approval .icon { background: rgba(180, 83, 9, .16); }
.nd-flow-board .node.rework .kind, .nd-flow-board .node.rework .icon { color: #0369a1; }
.nd-flow-board .node.rework .icon { background: rgba(3, 105, 161, .12); }
.nd-flow-board .node.trigger .kind, .nd-flow-board .node.trigger .icon { color: #6d28d9; background: transparent; }
.nd-flow-board .node .title {
  margin: 0 0 4px; font-size: 13.5px; font-weight: 700; line-height: 1.28;
  color: #0f172a; letter-spacing: -.02em;
}
.nd-flow-board .node .desc { margin: 0; font-size: 11.5px; line-height: 1.4; color: #64748b; font-weight: 500; }
.nd-flow-board .node .rework-to { margin: 2px 0 0; font-size: 11px; color: #64748b; font-weight: 500; }
.nd-flow-board .node .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 7px; }
.nd-flow-board .node .meta-item {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; color: #475569;
}
.nd-flow-board .node .meta-item .mi { width: 13px; height: 13px; flex: none; color: #64748b; }
.nd-flow-board .node .meta-item.person .mi { color: #2563eb; }

.nd-flow-board .port {
  position: absolute; width: 10px; height: 10px; border-radius: 50%;
  background: #fff; border: 2px solid #0033ff; box-shadow: 0 0 0 2px #fff;
}
.nd-flow-board .port.l { left: -5px; top: 50%; transform: translateY(-50%); }
.nd-flow-board .port.r { right: -5px; top: 50%; transform: translateY(-50%); }
.nd-flow-board .port.b { left: 50%; bottom: -5px; transform: translateX(-50%); }
.nd-flow-board .port.t { left: 50%; top: -5px; transform: translateX(-50%); }
.nd-flow-board .node.trigger .port { border-color: #6d28d9; }
.nd-flow-board .node.approval .port.r { border-color: #b45309; }
.nd-flow-board .node.approval .port.b, .nd-flow-board .node.approval .port.t { border-color: #ef6b6b; }
.nd-flow-board .node.rework .port { border-color: #0369a1; }

.nd-flow-board svg.wires {
  position: absolute; left: 0; top: 0;
  width: auto !important; height: auto !important; max-width: none !important;
  overflow: visible; pointer-events: none; z-index: 1;
}
.nd-flow-board .wire { fill: none; stroke-width: 2.75; stroke-linecap: round; stroke-linejoin: round; }
.nd-flow-board .wire.done { stroke: #22a06b; }
.nd-flow-board .wire.ok { stroke: #0033ff; }
.nd-flow-board .wire.decline { stroke: #ef6b6b; }
.nd-flow-board .wire.restart { stroke: #f59e0b; stroke-dasharray: 6 4; }

.nd-flow-board .hero-wire-labels {
  position: absolute; left: 0; top: 0; width: 0; height: 0;
  pointer-events: none; z-index: 4; overflow: visible;
}
.nd-flow-board .lbl {
  position: absolute; transform: translate(-50%, -50%); z-index: 4;
  font-size: 11px; font-weight: 700; line-height: 1.2;
  padding: 3px 9px; border-radius: 999px; white-space: nowrap;
  background: #fff; border: 1px solid #e5e7eb;
  box-shadow: 0 4px 10px rgba(17, 24, 39, .08);
}
.nd-flow-board .lbl.done { color: #22a06b; border-color: #bbf7d0; background: #f0fdf4; }
.nd-flow-board .lbl.ok { color: #0033ff; border-color: #c7d2fe; background: #eef2ff; }
.nd-flow-board .lbl.decline { color: #b91c1c; border-color: #fecaca; background: #fef2f2; }
.nd-flow-board .lbl.restart { color: #b45309; border-color: #fde68a; background: #fffbeb; }

/* ---------- controls ---------- */
.nd-flow-board .controls {
  position: absolute; left: 12px; bottom: 12px; z-index: 7;
  display: flex; flex-direction: column;
  background: rgba(255, 255, 255, .96);
  border: 1px solid #e2e8f0; border-radius: 12px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .1);
  overflow: visible;
}
.nd-flow-board .controls button {
  position: relative; width: 36px; height: 36px;
  border: 0; border-bottom: 1px solid #eef2f7; background: transparent;
  cursor: pointer; display: grid; place-items: center; color: #0f172a;
}
.nd-flow-board .controls button:first-child { border-radius: 12px 12px 0 0; }
.nd-flow-board .controls button:last-child { border-bottom: 0; border-radius: 0 0 12px 12px; }
.nd-flow-board .controls button:hover { background: #f1f5f9; }
.nd-flow-board .controls svg { width: 15px; height: 15px; }
.nd-flow-board .controls button::after {
  content: attr(data-tip); position: absolute; left: calc(100% + 10px); top: 50%;
  transform: translateY(-50%) scale(.96); transform-origin: left center;
  background: #0b1030; color: #fff; font-size: 11.5px; font-weight: 600;
  padding: 5px 9px; border-radius: 7px; white-space: nowrap;
  opacity: 0; pointer-events: none; z-index: 12;
  transition: opacity .13s ease, transform .13s ease;
}
.nd-flow-board .controls button:hover::after,
.nd-flow-board .controls button:focus-visible::after { opacity: 1; transform: translateY(-50%) scale(1); }

.nd-flow-board .minimap {
  position: absolute; right: 12px; bottom: 12px; z-index: 7;
  width: 118px; height: 58px; border-radius: 12px; overflow: hidden;
  background: rgba(255, 255, 255, .94); border: 1px solid #e2e8f0;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .1);
}
.nd-flow-board .minimap svg { width: 100%; height: 100%; }
.nd-flow-board .minimap .mini-node { fill: #c7d2fe; }
.nd-flow-board .minimap .mini-node.approval { fill: #fcd9a8; }
.nd-flow-board .minimap .mini-node.rework { fill: #bae0f5; }
.nd-flow-board .minimap .mini-node.trigger { fill: #d9c9fb; }
.nd-flow-board .minimap .view { fill: rgba(0, 51, 255, .12); stroke: #0033ff; stroke-width: 14; }
.nd-flow-hint {
  position: absolute; right: 12px; top: 12px; z-index: 7; margin: 0;
  font-size: 10px; letter-spacing: .02em; color: #64748b;
  background: rgba(255, 255, 255, .9); border: 1px solid #e2e8f0;
  border-radius: 999px; padding: 5px 11px; pointer-events: none;
}

/* ---------- locked / explore state ---------- */
.nd-flow-board.is-locked .viewport { pointer-events: none; filter: blur(2.5px); }
.nd-flow-board.is-locked::before {
  content: ""; position: absolute; inset: 0; z-index: 6;
  pointer-events: none; background: rgba(247, 248, 253, .45);
}
.nd-flow-board.is-locked .controls,
.nd-flow-board.is-locked .minimap,
.nd-flow-board.is-locked .nd-flow-hint { opacity: 0; pointer-events: none; }
.nd-flow-explore {
  position: absolute; inset: 0; z-index: 9; display: grid; place-items: center;
  margin: 0; padding: 0; border: 0; background: transparent; cursor: pointer; font: inherit;
}
.nd-flow-board:not(.is-locked) .nd-flow-explore { display: none; }
.nd-flow-explore span {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--blue, #0033ff); color: #fff;
  font-size: 15px; font-weight: 700; letter-spacing: -.01em;
  border-radius: 12px; padding: 14px 26px; white-space: nowrap;
  box-shadow: 0 10px 26px -10px rgba(0, 51, 255, .65), 0 0 0 6px rgba(0, 51, 255, .1);
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}
.nd-flow-explore span::after { content: "\2192"; }
.nd-flow-explore:hover span { background: #0026bf; transform: translateY(-1px); }
.nd-flow-explore:focus-visible span { outline: 3px solid rgba(0, 51, 255, .35); outline-offset: 3px; }

/* ---------- footer + text outline ---------- */
.nd-flow-foot {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 10px 20px; padding: 12px 16px;
  border-top: 1px solid var(--line, #e3e6f4); background: #fafbfe;
  font-size: 12px; color: #64748b; font-weight: 500;
}
.nd-flow-legend { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.nd-flow-legend i { width: 14px; height: 3px; border-radius: 2px; margin-left: 8px; }
.nd-flow-legend i:first-child { margin-left: 0; }
.nd-flow-legend .lg-done { background: #22a06b; }
.nd-flow-legend .lg-ok { background: #0033ff; }
.nd-flow-legend .lg-decline { background: #ef6b6b; }
.nd-flow-legend .lg-restart { background: #f59e0b; }

/* The text outline is the no-JS and screen-reader reading of the same graph. */
.nd-flow-outline { padding: 18px 16px 20px; border-top: 1px solid var(--line, #e3e6f4); }
.nd-flow-outline h3 { font-size: 14px; margin: 0 0 10px; }
.nd-flow-outline ol { margin: 0; padding-left: 20px; font-size: 13px; line-height: 1.7; color: #475569; }
.nd-flow-outline ol ol { padding-left: 18px; font-size: 12.5px; }
.js-on .nd-flow-outline {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

@media (max-width: 760px) {
  .nd-flow-board { height: 400px; }
  .nd-flow-bar { flex-wrap: wrap; }
  .nd-flow-board .minimap { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .nd-flow-board .node, .nd-flow-explore span, .nd-flow-board .viewport { transition: none; }
}

@media print {
  .nd-flow-board, .nd-flow-chapters { display: none; }
  .js-on .nd-flow-outline { position: static; width: auto; height: auto; clip: auto; margin: 0; white-space: normal; }
}

/* ---------- "why use this template": copy + one visual ---------- */
.nd-why {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px 64px;
  align-items: start;
}
.nd-why-copy { grid-column: 1; grid-row: 1; }
/* Matches the other section heads: the eyebrow keeps its flex dot. */
.nd-why-copy .template-eyebrow { display: inline-flex; }
/* This heading carries a full explainer sentence, not a two-word display
   line, so it sits a step below the other section headings. */
.nd-why-copy h2 {
  margin: 16px 0 18px;
  font-size: clamp(28px, 3vw, 40px);
  line-height: 1.12;
}
.nd-why-lead {
  font-size: 16px; line-height: 1.75; color: var(--muted, #565d7e); max-width: 540px;
}
.nd-why-lead p { margin: 18px 0 0; }

.nd-why-visual { grid-column: 2; grid-row: 1 / span 2; margin: 0; align-self: center; }
.nd-why-art {
  border: 1px solid var(--line, #e3e6f4);
  border-radius: 18px;
  background: #fafbfd;
  display: grid;
  place-items: center;
  padding: 26px;
}
.nd-why-art img { width: 100%; max-width: 420px; height: auto; display: block; }
.nd-why-visual figcaption {
  margin-top: 16px; font-size: 15px; line-height: 1.6;
  font-weight: 500; color: var(--ink, #0b1030);
}

/* ---------- collapsible long-form SEO block ---------- */
.nd-longform { grid-column: 1; grid-row: 2; }
.nd-longform[data-collapsed="false"] { grid-column: 1 / -1; grid-row: 3; margin-top: 10px; }
.nd-longform-body {
  font-size: 15px; line-height: 1.75; color: var(--muted, #565d7e);
  max-width: 820px;
}
.nd-longform-body h3 {
  font-size: 20px; line-height: 1.3; color: var(--ink, #0b1030);
  margin: 28px 0 10px;
}
.nd-longform-body h3:first-child { margin-top: 0; }
.nd-longform-body p { margin: 0 0 14px; }
.nd-longform-table-wrap { max-width: 100%; overflow-x: auto; margin: 0 0 18px; }
.nd-longform table {
  border-collapse: collapse; width: 100%; min-width: 620px;
  font-size: 13.5px; line-height: 1.6;
}
.nd-longform th, .nd-longform td {
  border: 1px solid var(--line, #e3e6f4); padding: 11px 13px;
  text-align: left; vertical-align: top;
}
.nd-longform th { background: #f7f8fd; color: var(--ink, #0b1030); font-weight: 600; }
.nd-longform caption { text-align: left; font-size: 12.5px; color: #8a92a8; padding-bottom: 8px; }

/* Collapsed keeps the copy in the document and simply clips it to nothing, so
   the lead paragraph above stays the teaser and the control sits right under it. */
.nd-longform[data-collapsed="true"] .nd-longform-body { max-height: 0; overflow: hidden; }
.nd-longform-toggle {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 22px;
  background: #fff; border: 1px solid var(--line, #e3e6f4); border-radius: 999px;
  padding: 11px 20px; font-size: 14px; font-weight: 600; color: var(--blue, #0033ff);
  cursor: pointer; transition: border-color .15s ease, background .15s ease;
}
.nd-longform-toggle:hover { border-color: rgba(0, 51, 255, .4); background: #f7f8fd; }
.nd-longform-toggle svg { width: 15px; height: 15px; transition: transform .2s ease; }
.nd-longform-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
.nd-longform-toggle[hidden] { display: none; }

/* Narrow screens: copy, then the long-form control, then the visual. */
@media (max-width: 860px) {
  .nd-why { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .nd-why-copy, .nd-why-visual, .nd-longform,
  .nd-longform[data-collapsed="false"] { grid-column: 1; grid-row: auto; margin-top: 0; }
  .nd-why-visual { order: 3; }
  .nd-why-lead { max-width: none; }
}

@media (max-width: 760px) {
  .nd-longform table { min-width: 520px; font-size: 13px; }
}
