/* The stage map and the stage flowcharts (plan docs/plan/20261002-v2-stage-flowchart §4, §5). The
   picture is server-rendered SVG; this file only paints it. Tokens only (D14/D18/D19/D61): colours,
   type, radii and spacing come from tokens.css, and sizes outside the SVG are in rem. Inside the SVG
   the geometry is in diagram units set by Go and the type sizes come from the font tokens, so they
   scale with the reader's text size. Light and dark both work because every colour is a token. */

.fc{display:flex;flex-direction:column;flex:1;min-height:0;margin:0}
.fc-tools{flex:none;display:flex;align-items:center;flex-wrap:wrap;gap:var(--space-2);margin-bottom:var(--space-2);min-height:var(--ctl-h)}
#fc-hint{color:var(--muted);font-size:var(--fs-sm)}
#fc-fit{width:auto;padding:0 var(--space-2)}

/* The mode tabs: "Stages · All processes", beside the page tabs (plan §4.1, §10 default 9). */
.fc-modes{display:flex;flex:none}
.fc-modes a{display:inline-flex;align-items:center;height:var(--ctl-h);padding:0 var(--space-3);font-size:var(--fs-md);font-weight:var(--fw-strong);color:var(--muted);background:var(--surface-2);border:1px solid var(--line);text-decoration:none;white-space:nowrap}
.fc-modes a + a{border-left:0}
.fc-modes a:first-child{border-radius:var(--control-radius) 0 0 var(--control-radius)}
.fc-modes a:last-child{border-radius:0 var(--control-radius) var(--control-radius) 0}
.fc-modes a:hover,.fc-modes a[aria-current]{color:var(--ink)}
.fc-modes a[aria-current="page"]{background:var(--accent-wash);border-color:var(--accent)}
.fc-stage-step{display:inline-flex;align-items:center;gap:var(--space-1)}
.fc-stage-name{font-size:var(--fs-sm);font-weight:var(--fw-strong);color:var(--ink-2);white-space:nowrap}

/* The key: line weights, arrowheads, designed and designed-only, connector circles, the band and the
   compare keys (plan §4.6, §4.9–§4.10). Shapes are made of tokens, never literal colours. */
.fc-legend{display:flex;flex-wrap:wrap;align-items:center;gap:var(--space-1) var(--space-3);margin-left:auto;font-size:var(--fs-xs);color:var(--muted)}
.fc-legend > span{display:inline-flex;align-items:center;gap:var(--space-1)}
.fc-key{display:inline-block;font-style:normal;line-height:1;vertical-align:middle}
.fc-key-line{width:1.25rem;height:0;border-top:2px solid var(--ink-2)}
.fc-key-w2{border-top-width:3px}
.fc-key-w3{border-top-width:4px}
.fc-key-arrow{color:var(--ink-2);font-weight:var(--fw-bold)}
.fc-key-designed{width:1.25rem;border-top:2px solid var(--ink)}
.fc-key-designed-only{width:1.25rem;border-top:2px dotted var(--muted)}
.fc-key-conn{display:inline-flex;align-items:center;justify-content:center;width:1rem;height:1rem;border:1.5px solid var(--ink-2);border-radius:var(--radius-round);font-size:var(--fs-2xs);color:var(--ink)}
.fc-key-band{width:1.75rem;height:.75rem;background:var(--surface);border:1px solid var(--line);border-radius:var(--radius-xs)}
.fc-key-add{color:var(--chg-add);font-weight:var(--fw-bold)}
.fc-key-del{color:var(--chg-del);font-weight:var(--fw-bold)}
.fc-key-edit{color:var(--chg-edit);font-weight:var(--fw-bold)}

/* The canvas fills the view like .dg-scroll (plan §4.4). */
.fc-scroll{position:relative;flex:1;min-height:0;overflow:hidden;touch-action:none;cursor:grab;overscroll-behavior:contain;border:var(--card-border);border-bottom:var(--card-border-b);border-radius:var(--card-radius);background:var(--card-bg)}
.fc-scroll.is-panning{cursor:grabbing}
.fc-scroll:focus-visible{outline:2px solid var(--focus);outline-offset:-2px}
.fc-svg{display:block;width:100%;height:100%;user-select:none}
.fc-placeholder{margin:0;padding:var(--space-4);color:var(--muted);font-size:var(--fs-sm)}
.fc-noscript{margin:var(--space-2) 0 0;font-size:var(--fs-sm)}

/* Gridlines stay 1 px at every zoom (vector-effect on the path) and read quieter than the lines.
   On phones the 16 u minor pitch is under 12 px at fit, so it fades in from mid zoom (plan §4.8). */
.fc-grid-minor{fill:none;stroke:var(--grid);stroke-width:1;opacity:.55}
.fc-grid-major{fill:none;stroke:var(--line);stroke-width:1;opacity:.75}
.fc-grid-dots{fill:none;stroke:var(--grid);stroke-width:1;opacity:.8}

/* Cards. The phase tint is the one rule to switch off (Q1, D133); the label and data-phase stay. */
.fc-card{cursor:pointer}
.fc-card-rect{fill:var(--surface-2);stroke:var(--line);stroke-width:1;rx:var(--radius-xs)}
.fc-card[data-phase] .fc-card-rect{fill:color-mix(in oklab, var(--fc-phase, var(--h1)) 12%, var(--surface-2))}
.fc-card[data-phase="win"]{--fc-phase:var(--h1)}
.fc-card[data-phase="setup"]{--fc-phase:var(--h2)}
.fc-card[data-phase="serve"]{--fc-phase:var(--h3)}
.fc-card[data-phase="exit"]{--fc-phase:var(--h4)}
.fc-card:hover .fc-card-rect,.fc-card.is-hover .fc-card-rect{stroke:var(--ink-2);stroke-width:2}
.fc-card:focus-visible{outline:none}
.fc-card:focus-visible .fc-card-rect{stroke:var(--focus);stroke-width:3}
.fc-card[data-change="added"] .fc-card-rect{stroke:var(--chg-add);stroke-width:2}
.fc-card[data-change="deleted"] .fc-card-rect{stroke:var(--chg-del);stroke-width:2;stroke-dasharray:6 4}
.fc-card[data-change="deleted"] .fc-name{text-decoration:line-through}
.fc-phase{fill:var(--muted);font-size:var(--fs-xs);font-weight:var(--fw-semibold);letter-spacing:.04em}
.fc-name{fill:var(--ink);font-size:var(--fs-base);font-weight:var(--fw-strong)}
.fc-summary{fill:var(--muted);font-size:var(--fs-sm)}
.fc-counts{fill:var(--muted);font-size:var(--fs-xs);font-variant-numeric:tabular-nums}
.fc-chg{fill:var(--chg-edit);font-size:var(--fs-xs);font-weight:var(--fw-bold)}

/* The business-wide bands (D125). */
.fc-band{cursor:pointer}
.fc-band-rect{fill:var(--surface);stroke:var(--line);stroke-width:1;rx:var(--radius-xs)}
.fc-band:hover .fc-band-rect,.fc-band.is-hover .fc-band-rect{stroke:var(--ink-2);stroke-width:2}
.fc-band:focus-visible{outline:none}
.fc-band:focus-visible .fc-band-rect{stroke:var(--focus);stroke-width:3}
.fc-band-name{fill:var(--ink);font-size:var(--fs-lg);font-weight:var(--fw-semibold)}
.fc-band-summary{fill:var(--muted);font-size:var(--fs-sm)}
.fc-band-counts{fill:var(--muted);font-size:var(--fs-xs);font-variant-numeric:tabular-nums}
.fc-band-chg{fill:var(--chg-edit);font-size:var(--fs-xs);font-weight:var(--fw-bold);font-variant-numeric:tabular-nums}

/* Edges: a hit area, a halo and the visible line; stroke weight by handoff count (D134). */
.fc-hit,.fc-halo,.fc-line{fill:none;stroke-linecap:round;stroke-linejoin:round}
.fc-hit{stroke:transparent;stroke-width:14}
.fc-halo{stroke:var(--surface-2);stroke-width:4}
.fc-line{stroke:var(--ink-2);stroke-width:1.5}
.fc-line.w2{stroke-width:2.5}
.fc-line.w3{stroke-width:3.5}
.fc-line.is-designed{stroke:var(--ink)}
.fc-line.is-designed-only{stroke:var(--muted);stroke-dasharray:2 4}
.fc-line.chg-added{stroke:var(--chg-add)}
.fc-line.chg-deleted{stroke:var(--chg-del);stroke-dasharray:6 4}
.fc-edge{cursor:pointer}
.fc-edge:focus-visible{outline:none}
.fc-edge.is-hover .fc-line,.fc-edge:focus-visible .fc-line{stroke:var(--accent-ink);stroke-width:3}
.fc-edge.is-hover .fc-halo,.fc-edge:focus-visible .fc-halo{stroke-width:6}
.fc-marker{fill:var(--ink-2)}
.fc-marker.chg-added{fill:var(--chg-add)}
.fc-marker.chg-deleted{fill:var(--chg-del)}
.fc-label{fill:var(--muted);font-size:var(--fs-xs);font-variant-numeric:tabular-nums;paint-order:stroke;stroke:var(--surface-2);stroke-width:3;stroke-linejoin:round}
.fc-label-designed{fill:var(--ink-2);font-style:italic}

/* On-page connectors (D121, D145): a circle with a letter in each row's connector cell. */
.fc-conn{cursor:pointer}
.fc-conn-circle{fill:var(--surface-2);stroke:var(--ink-2);stroke-width:1.5}
.fc-conn:hover .fc-conn-circle,.fc-conn:focus-visible .fc-conn-circle{stroke:var(--accent);stroke-width:2.5}
.fc-conn:focus-visible{outline:none}
.fc-conn.is-flash .fc-conn-circle,.fc-card.is-flash .fc-card-rect{stroke:var(--accent);stroke-width:3}
.fc-conn-label{fill:var(--ink);font-size:var(--fs-xs);font-weight:var(--fw-bold);text-anchor:middle;dominant-baseline:central}

/* Popovers: the look of every other panel; click-only wiring lives in fc-pop.js (D122). */
.fc-pops[hidden]{display:none}
#fc-pop-layer{position:fixed;inset:0;z-index:var(--z-pop);pointer-events:none}
.fc-pop{position:fixed;z-index:var(--z-pop);width:min(var(--w-pop),calc(100vw - 2rem));max-height:70vh;overflow:auto;pointer-events:auto;text-align:left}
.fc-pop-head{margin:0 0 var(--space-1);font-size:var(--fs-md)}
.fc-pop-bw{color:var(--muted);font-weight:var(--fw-medium)}
.fc-pop-links{margin:var(--space-2) 0 0}
.fc-pop-list{margin:var(--space-1) 0;padding-left:1.1rem}

/* The stage list: the screen-reader reading and the no-JS content (plan §4.15). It is visually
   hidden on desktop and becomes the phone List view below 45 em. */
.fc-list{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0;margin:0;padding:0;list-style:none}
.fc-list-item{margin:0}
.fc-list-head{margin:0}

/* Phones (plan §4.13): a Map | List toggle, shown below 45 em only, remembered in localStorage. */
#fc-phone-view{display:none}
@media (max-width:45em){
  .fc-scroll{height:75dvh;flex:none}
  #fc-phone-view{display:inline-flex}
  #view-flowchart > .toolbar{flex:none}
  #view-flowchart[data-phone="list"]{height:auto;min-height:0}
  #view-flowchart[data-phone="list"] > figure.fc{flex:none;min-height:0}
  #view-flowchart[data-phone="list"] .fc-scroll,
  #view-flowchart[data-phone="list"] #fc-zoom-in,
  #view-flowchart[data-phone="list"] #fc-zoom-out,
  #view-flowchart[data-phone="list"] #fc-fit,
  #view-flowchart[data-phone="list"] #fc-hint{display:none}
  #view-flowchart[data-phone="list"] .fc-list,
  #view-flowchart[data-phone="list"] .fc-proc-list{position:static;width:auto;height:auto;overflow:visible;clip:auto;white-space:normal;display:block;padding:0;margin:0}
  #view-flowchart[data-phone="list"] .fc-list-item,
  #view-flowchart[data-phone="list"] .fc-proc-item{padding:var(--space-2) var(--space-3);margin:0 0 var(--space-2);background:var(--surface-2);border:var(--card-border);border-bottom:var(--card-border-b);border-radius:var(--card-radius)}
  .fc-path{flex-wrap:wrap;max-width:100%}
  .fc-path-form{position:static;flex-wrap:wrap;white-space:normal;background:none;border:0;box-shadow:none;padding:var(--space-1) 0 0}
  .fc-path-form select{max-width:100%}
  .fc[data-zband="far"] .fc-grid-minor{opacity:0}
}

/* --- the stage flowchart (S56) ------------------------------------------------------------------
   The process box, the outside stage box, the department chip, the column headers and the process
   list. Geometry is Go's; here only paint and the far/near level of detail (plan §4.11). */
.fc-proc{cursor:pointer}
.fc-proc-rect{fill:var(--surface-2);stroke:var(--line);stroke-width:1;rx:var(--radius-xs)}
.fc-proc:hover .fc-proc-rect,.fc-proc.is-hover .fc-proc-rect{stroke:var(--ink-2);stroke-width:2}
.fc-proc:focus-visible{outline:none}
.fc-proc:focus-visible .fc-proc-rect{stroke:var(--focus);stroke-width:3}
.fc-proc[data-change="added"] .fc-proc-rect{stroke:var(--chg-add);stroke-width:2}
.fc-proc[data-change="edited"] .fc-proc-rect{stroke:var(--chg-edit);stroke-width:2}
.fc-proc.is-ghost .fc-proc-rect,.fc-proc[data-change="deleted"] .fc-proc-rect{stroke:var(--chg-del);stroke-width:2;stroke-dasharray:6 4}
.fc-proc.is-ghost .fc-name{text-decoration:line-through}
.fc-proc-seq{fill:var(--muted);font-size:var(--fs-2xs);font-weight:var(--fw-semibold);font-variant-numeric:tabular-nums}
.fc-proc-id{fill:var(--ink);font-size:var(--fs-sm);font-weight:var(--fw-bold);letter-spacing:.02em}
.fc-proc-steps{fill:var(--muted);font-size:var(--fs-2xs);font-variant-numeric:tabular-nums}
.fc-proc-chg{fill:var(--chg-edit);font-size:var(--fs-sm);font-weight:var(--fw-bold)}
.fc-proc[data-change="added"] .fc-proc-chg{fill:var(--chg-add)}
.fc-proc[data-change="deleted"] .fc-proc-chg{fill:var(--chg-del)}
.fc-dept-rect{fill:var(--surface);stroke:var(--line);stroke-width:1}
.fc-dept-text{fill:var(--ink-2);font-size:var(--fs-2xs);font-weight:var(--fw-semibold);letter-spacing:.03em}

.fc-ref{cursor:pointer}
.fc-ref-rect{fill:var(--surface);stroke:var(--line);stroke-width:1;rx:var(--radius-xs)}
.fc-ref:hover .fc-ref-rect,.fc-ref.is-hover .fc-ref-rect{stroke:var(--ink-2);stroke-width:2}
.fc-ref:focus-visible{outline:none}
.fc-ref:focus-visible .fc-ref-rect{stroke:var(--focus);stroke-width:3}
.fc-ref-name{fill:var(--ink);font-size:var(--fs-sm);font-weight:var(--fw-strong)}
.fc-ref-procs{fill:var(--muted);font-size:var(--fs-2xs);font-variant-numeric:tabular-nums}
.fc-col-head{fill:var(--muted);font-size:var(--fs-xs);font-weight:var(--fw-semibold);letter-spacing:.04em;text-transform:uppercase}
.fc-band-note{fill:var(--muted);font-size:var(--fs-sm)}
.fc-conn-edge{cursor:pointer}

/* Far detail (RUN at fit, plan §4.11): process names are hidden and the ids and chips grow, so the
   ids stay readable; the near level (the default) shows the names. */
.fc[data-lod="far"] .fc-name{display:none}
.fc[data-lod="far"] .fc-proc-id{font-size:var(--fs-base)}
.fc[data-lod="far"] .fc-dept-text{font-size:var(--fs-xs)}
.fc[data-lod="far"] .fc-ref-name{font-size:var(--fs-xs)}

/* The stage flowchart's header and stage stepper (plan §4.11). */
.fc-stage-head{margin:0;font-size:var(--fs-sm);color:var(--ink-2)}
.fc-stage-head-name{font-size:var(--fs-md)}
.fc-stage-head-sum{color:var(--muted)}
.fc-stage-map-link{margin-left:var(--space-2);font-size:var(--fs-sm);white-space:nowrap}

/* The process list: the screen-reader reading, the no-JS content and the phone List view. */
.fc-proc-list{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0;margin:0;padding:0}
.fc-proc-seq{margin:0;padding-left:1.4rem;list-style:none}
.fc-proc-item{margin:0}
.fc-proc-item-head{margin:0}
.fc-proc-list-side{margin:var(--space-2) 0 0;font-size:var(--fs-sm)}
.fc-step-list{margin:var(--space-1) 0 var(--space-2);padding-left:1.6rem;list-style:none}
.fc-step-seq{color:var(--muted);font-size:var(--fs-xs);font-variant-numeric:tabular-nums;margin-right:var(--space-1)}
.fc-step-name{color:var(--ink-2)}
.fc-step-mode{font-size:var(--fs-2xs);text-transform:uppercase;letter-spacing:.03em}
.fc-pop-steps-head{margin:var(--space-2) 0 var(--space-1);font-size:var(--fs-sm);font-weight:var(--fw-strong)}
.fc-pop-pills{margin:var(--space-1) 0}

/* Path calculation (S57, plan §4.12): the toolbar control, the route's highlight and the chain list
   under the figure. Colours, type and spacing come from tokens, so light and dark both work. */
.fc-path{position:relative;display:inline-flex;align-items:center;gap:var(--space-1)}
.fc-path details{position:relative}
.fc-path-btn{display:inline-flex;align-items:center;height:var(--ctl-h);padding:0 var(--space-3);font-size:var(--fs-md);font-weight:var(--fw-strong);color:var(--muted);background:var(--surface-2);border:1px solid var(--line);border-radius:var(--control-radius);cursor:pointer;list-style:none;white-space:nowrap}
.fc-path-btn::-webkit-details-marker{display:none}
.fc-path details[open] > .fc-path-btn,.fc-path-btn:hover{color:var(--ink);border-color:var(--ink-2)}
.fc-path-form{position:absolute;top:calc(100% + var(--space-1));left:0;z-index:var(--z-pop);display:flex;align-items:center;gap:var(--space-1);padding:var(--space-2);background:var(--card-bg);border:var(--card-border);border-radius:var(--card-radius);box-shadow:var(--shadow);white-space:nowrap}
.fc-path-lbl{font-size:var(--fs-sm);color:var(--muted)}
.fc-path-form select{height:var(--ctl-h);padding:0 var(--space-1);font:inherit;font-size:var(--fs-sm);color:var(--ink);background:var(--surface-2);border:1px solid var(--line);border-radius:var(--field-radius)}
.fc-path-show{width:auto;padding:0 var(--space-3)}
.fc-path-clear{width:auto;padding:0 var(--space-2);text-decoration:none;font-size:var(--fs-sm)}

/* The route's cards and links stand out; everything else fades but stays readable. */
.fc-card.dim,.fc-band.dim,.fc-conn.dim{opacity:.5}
.fc-edge.dim{opacity:.35}
.fc-card.on-path .fc-card-rect{fill:var(--accent-wash);stroke:var(--accent);stroke-width:2}
.fc-band.on-path .fc-band-rect{stroke:var(--accent);stroke-width:2}
.fc-edge.on-path .fc-line{stroke:var(--accent-ink);stroke-width:3}
.fc-edge.on-path .fc-halo{stroke-width:6}
.fc-conn.on-path .fc-conn-circle{stroke:var(--accent);stroke-width:2.5}

/* The route, the chain list and the note under the figure. */
/* The chain list under the figure is one compact line (it must not squeeze the canvas, whose height
   decides the stage-map layout). The figure keeps the height it would have without a path. */
#view-flowchart[data-path] > figure.fc{min-height:calc(100dvh - 7.75rem)}
.fc-path-result{margin-top:var(--space-1);font-size:var(--fs-sm);line-height:1.5;color:var(--ink-2)}
.fc-path-line{margin:0}
.fc-path-lbl{color:var(--muted);font-weight:var(--fw-strong);margin-right:var(--space-1)}
.fc-path-sep{color:var(--muted)}
.fc-chain a{font-variant-numeric:tabular-nums}
.fc-chain-arrow{color:var(--muted)}
.fc-path-note{margin:0;font-size:var(--fs-sm);color:var(--muted)}

@media print{
  .fc-tools,.fc-noscript,.fc-legend{display:none}
}
