/* ==========================================================================
   Scan flow: a static port of the CoreSpec dashboard Workflow Lab canvas
   (n8n style node graph) for the /no-floor-plan marketing page.
   Nodes are real HTML so i18n.js translates them; edges are drawn by
   src/js/scan-flow.js. The graph itself stays LTR in every language.
   ========================================================================== */
.sfl {
  --wfc-trigger: #FCBF20;
  --wfc-agent: #4E9E7E;
  --wfc-action: #4E9E7E;
  --wfc-service: #2F6E97;
  --wfc-tool: #A1A1AA;
  --wfc-human: #6B4FCF;
  --wfc-end: #8A8A8A;
  --wfc-edge: rgba(110, 110, 115, 0.55);
  --wfc-live: #3E8A6B;
  --sfl-line: rgba(13, 10, 2, 0.1);
  --sfl-muted: #6E6E73;
  --sfl-ink: #0d0a02;
  --sfl-surface: #fff;
  --sfl-canvas: #F6F4EE;
  max-width: 1180px; margin: 0 auto; font-family: 'Fustat', Arial, sans-serif;
}

/* ---- Tiles ---------------------------------------------------------------- */
.sfl-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 1000px) and (min-width: 701px) { .sfl-tile__badge > span { display: none; } }
@media (max-width: 700px) { .sfl-tiles { grid-template-columns: minmax(0, 1fr); } }
.sfl-tile {
  display: flex; align-items: flex-start; gap: 12px; padding: 16px 18px; text-align: start;
  font: inherit; color: var(--sfl-ink); cursor: pointer; min-width: 0;
  background: var(--sfl-surface); border: 1px solid var(--sfl-line); border-radius: 12px;
  transition: border-color .15s ease, background .15s ease;
}
.sfl-tile:hover { border-color: rgba(252, 191, 32, 0.6); }
.sfl-tile.is-on { border-color: #FCBF20; background: rgba(252, 191, 32, 0.08); box-shadow: 0 0 0 1px #FCBF20 inset; }
.sfl-tile__icon { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 8px; background: rgba(252, 191, 32, 0.18); color: #B88600; }
.sfl-tile__body { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.sfl-tile__name { font-size: 15px; font-weight: 700; line-height: 1.25; }
.sfl-tile__trig { font-size: 13px; color: var(--sfl-muted); line-height: 1.35; }
.sfl-tile__meta { font-size: 12px; color: var(--sfl-muted); margin-top: 4px; }
.sfl-tile__badge { display: inline-flex; align-items: center; gap: 5px; flex: none; font-size: 11px; color: var(--sfl-muted); }
.sfl-tile__badge i { width: 7px; height: 7px; border-radius: 50%; background: #4E9E7E; display: block; }

/* ---- Contract strip ------------------------------------------------------- */
.sfl-contract { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; margin: 14px 0 0; border: 1px solid var(--sfl-line); border-radius: 10px; background: var(--sfl-surface); }
.sfl-contract[hidden] { display: none; }
.sfl-contract > div { padding: 12px 16px; min-width: 0; border-inline-start: 1px solid var(--sfl-line); }
.sfl-contract > div:first-child { border-inline-start: 0; }
.sfl-contract dt { font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--sfl-muted); margin-bottom: 4px; }
.sfl-contract dd { margin: 0; font-size: 14px; line-height: 1.4; color: var(--sfl-ink); overflow-wrap: anywhere; }
@media (max-width: 700px) {
  .sfl-contract { grid-template-columns: minmax(0, 1fr); }
  .sfl-contract > div { border-inline-start: 0; border-top: 1px solid var(--sfl-line); }
  .sfl-contract > div:first-child { border-top: 0; }
}

/* ---- Flowchart / Steps switch -------------------------------------------- */
.sfl-switch { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 20px 0 0; }
.sfl-switch__label { font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--sfl-muted); }
.sfl-tabs { display: inline-flex; gap: 6px; }
.sfl-tab { font: inherit; font-size: 13px; font-weight: 500; padding: 6px 14px; border: 1px solid var(--sfl-line); border-radius: 6px; background: var(--sfl-surface); color: var(--sfl-ink); cursor: pointer; }
.sfl-tab.is-on { background: #FCBF20; border-color: #FCBF20; }

/* ---- Canvas --------------------------------------------------------------- */
.wfc { border: 1px solid var(--sfl-line); border-radius: 10px; overflow: hidden; background: var(--sfl-surface); margin-top: 12px; }
.wfc[hidden] { display: none; }
.wfc-bar { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--sfl-line); flex-wrap: wrap; }
.wfc-note { font-size: 12.5px; color: var(--sfl-muted); flex: 1; min-width: 0; }
.wfc-tools { margin-inline-start: auto; display: flex; align-items: center; gap: 6px; }
.wfc-run { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 12.5px; font-weight: 600; padding: 7px 14px; border-radius: 7px; border: 0; background: #FCBF20; color: #0d0a02; cursor: pointer; }
.wfc-run:disabled { opacity: .55; cursor: default; }
.wfc-run [hidden] { display: none; }
.wfc-key { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 7px 12px; border-bottom: 1px solid var(--sfl-line); font-size: 11px; color: var(--sfl-muted); }
.wfc-key-item { display: inline-flex; align-items: center; gap: 6px; }
.wfc-swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

.wfc-view {
  position: relative; height: 380px; overflow: hidden;
  background-color: var(--sfl-canvas);
  background-image: radial-gradient(rgba(110, 110, 115, 0.3) 1px, transparent 1px);
  background-size: 18px 18px;
}
.wfc-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.wfc-world[hidden] { display: none; }
.wfc-edges { position: absolute; inset: 0; overflow: visible; pointer-events: none; }
.wfc-edges g { color: var(--wfc-edge); }
.wfc-edges g.e-tool { color: rgba(161, 161, 170, 0.75); }
.wfc-edges g.e-loop { color: rgba(107, 79, 207, 0.75); }
.wfc-edges g.is-live { color: var(--wfc-live); }
.wfc-edges g.is-live.e-human { color: var(--wfc-human); }
.wfc-edges path { fill: none; stroke: currentColor; stroke-width: 2; transition: stroke .25s ease; }
.wfc-edges g.e-tool path { stroke-width: 1.5; stroke-dasharray: 4 4; }
.wfc-edges g.e-loop path { stroke-dasharray: 6 5; }
.wfc-edges circle { fill: currentColor; transition: fill .25s ease; }
.wfc-edge-label { position: absolute; transform: translate(-50%, -100%); font-size: 11px; white-space: nowrap; color: rgba(107, 79, 207, 0.95); background: var(--sfl-canvas); padding: 0 4px; pointer-events: none; }

.wfc-node-wrap { position: absolute; }
.wfc-node {
  position: relative; width: 100%; display: flex; align-items: flex-start; gap: 9px;
  padding: 11px 12px; text-align: left; font: inherit; color: var(--sfl-ink); cursor: pointer;
  background: var(--sfl-surface); border: 2px solid color-mix(in srgb, var(--tone) 55%, rgba(13,10,2,0.12));
  border-radius: 10px; box-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 6px 18px rgba(0, 0, 0, .07);
  transition: border-color .2s ease, box-shadow .2s ease;
}
.wfc-node:hover { border-color: var(--tone); }
.wfc-node.wfc-on { box-shadow: 0 0 0 3px rgba(252, 191, 32, 0.45); }
.wfc-node.wfc-k-trigger { border-radius: 26px 10px 10px 26px; padding-left: 16px; }
.wfc-node.wfc-k-service { border-radius: 14px; }
.wfc-node.wfc-k-human { background: color-mix(in srgb, var(--wfc-human) 9%, #fff); border-color: var(--wfc-human); }
.wfc-node.wfc-k-end { border-radius: 10px 26px 26px 10px; }
.wfc-node.wfc-k-tool { padding: 7px 9px; gap: 7px; border-style: dashed; border-width: 1.5px; border-radius: 8px; }
.wfc-ran > .wfc-node { border-color: var(--wfc-live); }
.wfc-ran > .wfc-node.wfc-k-human { border-color: var(--wfc-human); }
.wfc-glyph { display: grid; place-items: center; flex: none; width: 28px; height: 28px; border-radius: 7px; color: var(--tone); background: color-mix(in srgb, var(--tone) 16%, transparent); }
.wfc-k-trigger .wfc-glyph { color: #B88600; }
.wfc-node.wfc-k-tool .wfc-glyph { width: 20px; height: 20px; border-radius: 5px; }
.wfc-text { min-width: 0; flex: 1; display: block; }
.wfc-title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 12.5px; font-weight: 700; line-height: 1.25; text-align: start; }
.wfc-sub { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 2px; font-size: 10.5px; line-height: 1.3; color: var(--sfl-muted); text-align: start; }
.wfc-node.wfc-k-tool .wfc-title { font-size: 11px; }
.wfc-node.wfc-k-tool .wfc-sub { font-size: 9.5px; -webkit-line-clamp: 1; }
.wfc-chip { position: absolute; top: -9px; right: 8px; padding: 1px 6px; border-radius: 3px; font-size: 9px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; background: var(--tone); color: #fff; }
.wfc-done { position: absolute; right: 8px; bottom: 6px; color: var(--wfc-live); display: none; }
.wfc-ran .wfc-done { display: grid; }
.wfc-k-human .wfc-done { color: var(--wfc-human); }
.wfc-in { position: absolute; left: -6px; top: calc(50% - 5px); width: 9px; height: 9px; border-radius: 2px; background: #8A8A8A; }
.wfc-port-out { position: absolute; display: flex; align-items: center; gap: 4px; pointer-events: none; font-size: 9.5px; white-space: nowrap; color: var(--sfl-muted); }
.wfc-port-out i { width: 10px; height: 10px; border-radius: 50%; background: #8A8A8A; display: block; border: 2px solid var(--sfl-canvas); box-sizing: content-box; margin: -2px; }
.wfc-port-out.wfc-go { color: var(--wfc-live); }
.wfc-port-out.wfc-go i { background: var(--wfc-live); }
.wfc-port-out.wfc-back { color: var(--wfc-human); }
.wfc-port-out.wfc-back i { background: var(--wfc-human); }
.wfc-tools-cap { display: table; margin: 5px auto 0; padding: 0 5px; background: var(--sfl-canvas); font-size: 9px; letter-spacing: .12em; text-transform: uppercase; color: var(--sfl-muted); position: relative; }
.wfc-mnote { display: none; }
.wfc-info { display: none; }

.wfc-drawer {
  position: absolute; top: 10px; right: 10px; width: 290px; max-height: calc(100% - 20px); overflow: auto; z-index: 5;
  padding: 14px; background: var(--sfl-surface); border: 1px solid var(--sfl-line); border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .18);
}
.wfc-drawer[hidden] { display: none; }
.wfc-drawer-head { display: flex; align-items: flex-start; gap: 10px; }
.wfc-drawer-glyph .wfc-glyph { width: 30px; height: 30px; }
.wfc-drawer-text { flex: 1; min-width: 0; }
.wfc-drawer-title { display: block; font-size: 14px; line-height: 1.3; color: var(--sfl-ink); }
.wfc-drawer-sub { font-size: 12px; color: var(--sfl-muted); margin: 2px 0 0; }
.wfc-drawer-x { background: none; border: 0; padding: 2px; cursor: pointer; color: var(--sfl-muted); }
.wfc-drawer-body .wfc-info { display: block; }
.wfc-facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 12px 0 0; font-size: 12.5px; }
.wfc-facts dt { color: var(--sfl-muted); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; padding-top: 2px; }
.wfc-facts dd { margin: 0; overflow-wrap: anywhere; color: var(--sfl-ink); }
.wfc-explain { margin: 10px 0 0; font-size: 12.5px; color: var(--sfl-muted); line-height: 1.55; }
[dir="rtl"] .wfc-drawer { direction: rtl; }

/* ---- Steps list ----------------------------------------------------------- */
.sfl-stepsbox { margin-top: 12px; border: 1px solid var(--sfl-line); border-radius: 10px; background: var(--sfl-surface); padding: 4px 18px; }
.sfl-stepsbox[hidden], .sfl-steps[hidden] { display: none; }
.sfl-steps { list-style: none; padding: 0; margin: 0; counter-reset: wf; }
.sfl-steps li { counter-increment: wf; display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 14px 0; border-top: 1px solid var(--sfl-line); }
.sfl-steps li:first-child { border-top: 0; }
.sfl-steps li::before { content: counter(wf); width: 26px; height: 26px; border-radius: 50%; background: #FCBF20; color: #0d0a02; display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.sfl-steps li.human::before { background: var(--wfc-human); color: #fff; }
.sfl-steps b { display: block; font-size: 15px; color: var(--sfl-ink); }
.sfl-steps span { display: block; font-size: 13px; color: var(--sfl-muted); margin-top: 2px; line-height: 1.45; }
.sfl-badge { font-style: normal; font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: rgba(13,10,2,0.07); color: var(--sfl-ink); white-space: nowrap; }
.sfl-badge--svc { background: rgba(47, 110, 151, 0.12); color: #2F6E97; }
.sfl-badge--ai { background: rgba(78, 158, 126, 0.14); color: #3E8A6B; }
.sfl-badge--human { background: rgba(107, 79, 207, 0.13); color: #6B4FCF; }
.sfl-badge--you { background: rgba(252, 191, 32, 0.22); color: #7A5A00; }

/* ---- Mobile: the same node cards, stacked, with straight connectors ------ */
@media (max-width: 767px) {
  .wfc-note { flex-basis: 100%; }
  .wfc-view { height: auto !important; background-size: 18px 18px !important; padding: 22px 16px 26px; }
  .wfc-world { position: relative; transform: none !important; width: auto !important; height: auto !important; display: flex; flex-direction: column; gap: 30px; }
  .wfc-world[hidden] { display: none; }
  .wfc-edges, .wfc-edge-label, .wfc-port-out, .wfc-in { display: none; }
  .wfc-node-wrap { position: relative; left: auto !important; top: auto !important; width: 100% !important; }
  .wfc-node { height: auto !important; min-height: 64px; }
  .wfc-node-wrap[data-kind="tool"] { width: calc(100% - 36px) !important; margin-inline-start: 36px; margin-top: -14px; }
  .wfc-node-wrap::before { content: ""; position: absolute; left: 50%; top: -30px; height: 30px; border-left: 2px solid var(--wfc-edge); }
  .wfc-node-wrap:first-of-type::before { display: none; }
  .wfc-node-wrap[data-kind="tool"]::before { left: -18px; top: -16px; height: calc(100% / 2 + 16px); border-left: 1.5px dashed rgba(161,161,170,0.9); width: 16px; border-bottom: 1.5px dashed rgba(161,161,170,0.9); }
  .wfc-node-wrap.wfc-ran::before { border-color: var(--wfc-live); }
  .wfc-tools-cap { margin-top: 8px; }
  .wfc-mnote { display: block; margin-top: 8px; font-size: 11.5px; color: var(--wfc-human); text-align: center; }
  .wfc-drawer { position: fixed; top: auto; bottom: 0; right: 0; left: 0; width: auto; max-height: 60vh; border-radius: 12px 12px 0 0; z-index: 150; }
}
@media (prefers-reduced-motion: reduce) { .wfc-node, .wfc-edges path, .wfc-edges circle { transition: none; } }
/* The approved label sits above its line so the outgoing edge does not run through it. */
.wfc-port-out.wfc-go > span { transform: translate(2px, -10px); }
.wfc-port-out.wfc-back > span { transform: translate(2px, 9px); }
.wfc-port-out > span { background: var(--sfl-canvas); padding: 0 2px; border-radius: 2px; }
