/* The flow chart canvas (#348 part A, flow.js). The dark workbench of the #345 mockup: a dotted grid, cards per kind, gold for paths and the pick.
   Uses app.css's variables when they are there, with the same values as fallbacks so the canvas also stands alone (flow-demo.html). */
.fv {
  --fv-bg: var(--bg, #0e1115);
  --fv-dot: #252c35;
  --fv-card: #1a1f26;
  --fv-card-line: #2f3843;
  --fv-quest: #14211a;
  --fv-quest-line: #355b40;
  --fv-mark: #1d1a13;
  --fv-mark-line: #4a3c22;
  --fv-reward: #221d12;
  --fv-reward-line: #5c4a22;
  --fv-note: #1c2027;
  --fv-gold: var(--gold, #e6b450);
  --fv-gold-hi: var(--gold-hi, #f3cd7d);
  --fv-text: var(--text, #e7e9ec);
  --fv-text-2: var(--text-2, #c4cad1);
  --fv-muted: var(--muted, #9aa3ae);
  --fv-wire: #56616e;
  --fv-bad: #ef8a80;
  --fv-ui: var(--ui, Inter, "Segoe UI", system-ui, -apple-system, Roboto, sans-serif);
  --fv-story: var(--story, Spectral, Georgia, "Times New Roman", serif);
  --fv-mono: var(--mono, "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace);
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 320px;
  overflow: hidden;
  background: var(--fv-bg);
  color: var(--fv-text);
  font: 13px/1.4 var(--fv-ui);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.fv:focus { outline: none; }
.fv:focus-visible { box-shadow: inset 0 0 0 2px var(--fv-gold-hi); }

.fv-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  cursor: default;
  background-image: radial-gradient(circle, var(--fv-dot) 1.2px, transparent 1.4px);
  background-size: 24px 24px;
}
.fv.is-space .fv-stage, .fv-readonly .fv-stage { cursor: grab; }
.fv.is-panning .fv-stage { cursor: grabbing; }
.fv-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.fv-cards { position: absolute; left: 0; top: 0; }
.fv-wires { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }

/* ---- wires */
.fv-wire { fill: none; stroke: var(--fv-wire); stroke-width: 2; stroke-linecap: round; }
.fv-wire.is-back { stroke-dasharray: 2 6; }
.fv-wire-choice { stroke: var(--fv-gold); stroke-dasharray: 7 5; opacity: 0.85; }
.fv-wire-mark { stroke: #8a744a; }
.fv-wire.is-near { stroke-width: 2.6; opacity: 1; }
.fv-wire-next.is-near, .fv-wire-mark.is-near { stroke: #7d8a99; }
.fv-wire.is-selected { stroke: var(--fv-gold-hi); stroke-width: 3; }
.fv-wire-drag { stroke: var(--fv-gold-hi); stroke-dasharray: 4 4; stroke-width: 2; }
.fv-wire-hit { fill: none; stroke: transparent; stroke-width: 14; pointer-events: stroke; cursor: pointer; }
.fv-readonly .fv-wire-hit { pointer-events: none; }

/* ---- cards */
.fv-card {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  box-sizing: border-box;
  margin: 0;
  padding: 10px 14px 12px;
  text-align: left;
  font: inherit;
  color: var(--fv-text);
  background: var(--fv-card);
  border: 1px solid var(--fv-card-line);
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}
.fv-card:hover { border-color: #46515e; }
.fv-card:focus { outline: none; }
.fv-card:focus-visible { box-shadow: 0 0 0 2px var(--fv-bg), 0 0 0 4px #7aa2d6, 0 6px 18px rgba(0, 0, 0, 0.35); }
.fv-card.is-selected {
  outline: 2px solid var(--fv-gold);
  outline-offset: 0;
  box-shadow: 0 0 0 5px rgba(230, 180, 80, 0.16), 0 0 26px rgba(230, 180, 80, 0.22), 0 6px 18px rgba(0, 0, 0, 0.35);
}
.fv-card.is-dragging { cursor: grabbing; opacity: 0.94; z-index: 2; }
.fv-card.is-drop { border-color: var(--fv-gold-hi); box-shadow: 0 0 0 3px rgba(243, 205, 125, 0.35); }
.fv-card.has-errors { border-left: 3px solid var(--fv-bad); }
.fv-readonly .fv-card { cursor: default; }

.fv-kind-quest { background: var(--fv-quest); border-color: var(--fv-quest-line); }
.fv-kind-mark { background: var(--fv-mark); border-color: var(--fv-mark-line); border-style: dashed; }
.fv-kind-rewards { background: var(--fv-reward); border-color: var(--fv-reward-line); }
.fv-kind-note { background: var(--fv-note); border-color: #39414c; border-radius: 4px; overflow: hidden; box-shadow: none; }

.fv-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-height: 18px; }
.fv-kicker { color: var(--fv-gold); font-weight: 600; font-size: 11px; letter-spacing: 0.07em; text-transform: uppercase; }
.fv-kind-quest .fv-kicker { color: #a9e0b4; }
.fv-kind-note .fv-kicker { color: var(--fv-muted); }
.fv-id { font-family: var(--fv-mono); font-size: 11px; color: var(--fv-muted); }
.fv-prob { margin-left: auto; font-size: 11px; font-weight: 600; border-radius: 999px; padding: 0 7px; line-height: 18px; }
.fv-prob + .fv-prob { margin-left: 0; }
.fv-prob-bad { color: var(--fv-bad); background: #2c1716; border: 1px solid #6a3430; }
.fv-prob-warn { color: var(--fv-gold-hi); background: #2a2210; border: 1px solid #5c4a22; }

.fv-title { font-weight: 600; font-size: 14px; color: var(--fv-text); }
.fv-story { font-family: var(--fv-story); font-weight: 500; font-size: 17px; line-height: 1.25; }
.fv-sub { color: var(--fv-muted); font-size: 12px; }
.fv-lines { display: flex; flex-direction: column; gap: 3px; }
.fv-line {
  color: var(--fv-text-2);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}
.fv-line-goal::before { content: ""; display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: var(--fv-gold); margin: 0 7px 2px 0; }
.fv-line-story { font-family: var(--fv-story); color: var(--fv-text-2); font-size: 13.5px; }
.fv-line-turnin { color: var(--fv-muted); font-size: 12px; }
.fv-line-flag { font-family: var(--fv-mono); font-size: 12px; color: var(--fv-gold-hi); }
.fv-line-reward::before { content: "+"; color: var(--fv-gold); font-weight: 700; margin-right: 6px; }
.fv-note-text { white-space: pre-wrap; color: var(--fv-text-2); overflow: hidden; }

.fv-chips { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 2px; }
.fv-chip { font-size: 11px; border-radius: 999px; padding: 0 7px; line-height: 18px; border: 1px solid #36404c; color: var(--fv-text-2); }
.fv-chip-info { color: #b9d3f0; border-color: #33475e; background: #172230; }
.fv-chip-warn { color: var(--fv-gold-hi); border-color: #5c4a22; background: #231d10; }
.fv-chip-bad { color: var(--fv-bad); border-color: #6a3430; background: #2c1716; }
.fv-chip-good { color: #a9e0b4; border-color: #2f4a35; background: #142019; }

.fv-path {
  position: relative;
  display: block;
  margin: 4px -14px 0 0;
  padding: 5px 22px 5px 9px;
  border-top: 1px solid #3b3220;
  background: rgba(230, 180, 80, 0.05);
  border-radius: 6px 0 0 6px;
}
.fv-path-text {
  font-family: var(--fv-story);
  color: var(--fv-text);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

/* ---- ports: the in dot on the left edge by the head, out dots on the right */
.fv-port {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--fv-bg);
  border: 2px solid var(--fv-wire);
  box-sizing: border-box;
}
.fv-port-in { left: -7px; top: 16px; }
.fv-port-out { right: -7px; top: 16px; cursor: crosshair; }
.fv-path .fv-port-out { top: 50%; margin-top: -6px; right: -7px; border-color: var(--fv-gold); }
.fv-port-out:hover { background: var(--fv-gold); border-color: var(--fv-gold-hi); transform: scale(1.25); }
.fv-readonly .fv-port-out { cursor: default; }
.fv-readonly .fv-port-out:hover { background: var(--fv-bg); transform: none; }
.fv-kind-quest .fv-port-out { border-color: #5f9a6d; }

/* ---- the tool palette */
.fv-tools {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  background: rgba(19, 22, 27, 0.92);
  border: 1px solid var(--fv-card-line);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 3;
}
.fv-tool, .fv-zoom-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  margin: 0;
  color: var(--fv-text-2);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
}
.fv-tool svg, .fv-zoom-btn svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.fv-tool:hover, .fv-zoom-btn:hover { background: #222831; color: var(--fv-text); border-color: transparent; }
.fv-tool[aria-pressed="true"] { color: var(--fv-gold-hi); background: #2a2210; border-color: #5c4a22; }
.fv-tool:disabled { opacity: 0.35; cursor: not-allowed; background: transparent; }
.fv-tool:focus-visible, .fv-zoom-btn:focus-visible { outline: 2px solid var(--fv-gold-hi); outline-offset: 1px; }

/* ---- zoom and minimap */
.fv-corner { position: absolute; right: 12px; bottom: 12px; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; z-index: 3; }
.fv-zoom {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: rgba(19, 22, 27, 0.92);
  border: 1px solid var(--fv-card-line);
  border-radius: 10px;
}
.fv-zoom-btn { width: 30px; height: 30px; }
.fv-zoom-text { min-width: 44px; text-align: center; font-family: var(--fv-mono); font-size: 12px; color: var(--fv-text-2); }
.fv-minimap { display: block; background: rgba(19, 22, 27, 0.92); border: 1px solid var(--fv-card-line); border-radius: 10px; cursor: pointer; }
.fv-mini-node { fill: #3a4450; }
.fv-mini-quest { fill: #355b40; }
.fv-mini-mark { fill: #4a3c22; }
.fv-mini-rewards { fill: #5c4a22; }
.fv-mini-note { fill: #2c323b; }
.fv-mini-node.is-selected { fill: var(--fv-gold); }
.fv-mini-view { fill: rgba(230, 180, 80, 0.06); stroke: var(--fv-gold); stroke-width: 1; }

/* ---- the notice for a refused edit */
.fv-toast {
  position: absolute;
  left: 50%;
  top: 14px;
  transform: translateX(-50%);
  max-width: min(560px, calc(100% - 32px));
  padding: 8px 14px;
  background: #1f1a12;
  border: 1px solid #5c4a22;
  border-radius: 8px;
  color: var(--fv-text);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  z-index: 4;
  opacity: 0;
  pointer-events: none;
}
.fv-toast.is-on { opacity: 1; }

@media (prefers-reduced-motion: no-preference) {
  .fv-card { transition: border-color 120ms ease, box-shadow 160ms ease; }
  .fv-port-out { transition: transform 100ms ease, background 100ms ease; }
  .fv-toast { transition: opacity 180ms ease; }
}

@media (max-width: 640px) {
  .fv-minimap { display: none; }
  .fv-tools { top: auto; bottom: 12px; transform: none; flex-direction: row; }
}

/* ---- the dev demo page only (flow-demo.html) */
.fv-demo { display: flex; flex-direction: column; height: 100vh; margin: 0; }
.fv-demo-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 8px 16px; background: #13161b; border-bottom: 1px solid #2a313b; }
.fv-demo-bar .fv-demo-log { margin-left: auto; color: #9aa3ae; font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 12px; }
.fv-demo-host { flex: 1; min-height: 0; }
