/* diagrams-a.css: the capital stack family (fig-house, fig-stack, fig-funds).
   One visual language, always bottom to top: SBA loan (--loan), seller note (--seller), investors (--investor),
   buyer cash (--cash). Every rule is scoped under a figure id. Colours come only from the CSS variables in style.css,
   so dark mode follows the page tokens. SVG is drawn close to 1 unit = 1 CSS px, so the font sizes below are close to
   the rendered sizes (never under 13px at a 360px phone). */

/* ===================== fig-house ===================== */
#fig-house .fig-house-svg{max-width:420px;margin:0 auto}
#fig-house .fig-house-t{font-size:15px}
#fig-house .fig-house-b{font-weight:600}
#fig-house .fig-house-m{font-size:14px;fill:var(--muted)}
#fig-house .fig-house-mid{text-anchor:middle}
#fig-house .fig-house-big{font:600 26px var(--serif)}
#fig-house .fig-house-say{font:600 17px var(--serif)}
#fig-house [class*="fig-house-k-"],#fig-house [class*="fig-house-w-"]{stroke:var(--surface);stroke-width:2}
#fig-house .fig-house-k-loan{fill:var(--loan)}
#fig-house .fig-house-k-note{fill:var(--seller)}
#fig-house .fig-house-k-cash{fill:var(--cash)}
#fig-house .fig-house-w-loan{fill:var(--loan-wash)}
#fig-house .fig-house-w-note{fill:var(--seller-wash)}
#fig-house .fig-house-w-cash{fill:var(--cash-wash)}
#fig-house .fig-house-roof,#fig-house .fig-house-wall{fill:var(--paper);stroke:var(--ink);stroke-width:2.5;stroke-linejoin:round}
#fig-house .fig-house-door{fill:var(--ink)}
#fig-house .fig-house-win{fill:var(--surface);stroke:var(--ink);stroke-width:1.5}
#fig-house .fig-house-ground{stroke:var(--line);stroke-width:1.5}
#fig-house .fig-house-flow{stroke:var(--cash);stroke-width:4;stroke-linecap:round}
#fig-house .fig-house-pulse{stroke:var(--surface);stroke-width:2;stroke-linecap:round;stroke-dasharray:2 10}
#fig-house .fig-house-head{fill:var(--cash)}
#fig-house .fig-house-pay{fill:var(--loan)}
#fig-house .fig-house-left{fill:var(--cash)}
#fig-house .fig-house-rule{fill:var(--ink)}
@media (prefers-reduced-motion:no-preference){
  @keyframes fig-house-flow{to{stroke-dashoffset:-24}}
  #fig-house .fig-house-pulse{animation:fig-house-flow 1.4s linear infinite}
}

/* ===================== fig-funds ===================== */
#fig-funds .fig-funds-svg{max-width:420px;margin:0 auto}
#fig-funds .fig-funds-wide{display:none;max-width:780px}
@media (min-width:720px){
  #fig-funds .fig-funds-tall{display:none}
  #fig-funds .fig-funds-wide{display:block}
}
/* text styles sit on groups and are inherited; the muted fill is set on the text itself because the page rule
   ".fig svg text" would otherwise win over an inherited fill */
#fig-funds .fig-funds-t{font-size:15px}
#fig-funds .fig-funds-bd{font-size:15px;font-weight:600}
#fig-funds .fig-funds-m{font-size:14px}
#fig-funds .fig-funds-m text,#fig-funds text.fig-funds-m{fill:var(--muted)}
#fig-funds .fig-funds-s-loan{fill:var(--loan)}
#fig-funds .fig-funds-s-note,#fig-funds .fig-funds-s-seller{fill:var(--seller)}
#fig-funds .fig-funds-s-cash{fill:var(--cash)}
#fig-funds .fig-funds-s-fees{fill:var(--people)}
#fig-funds .fig-funds-s-notepart{fill:var(--seller-wash);stroke:var(--seller);stroke-width:1.5;stroke-dasharray:3 2}
#fig-funds .fig-funds-src rect,#fig-funds .fig-funds-use rect{stroke:var(--surface);stroke-width:1.5;stroke-dasharray:none}
#fig-funds .fig-funds-use .fig-funds-s-notepart{stroke:var(--seller);stroke-dasharray:3 2}
#fig-funds .fig-funds-r-loan{fill:var(--loan);fill-opacity:.28}
#fig-funds .fig-funds-r-note,#fig-funds .fig-funds-r-seller{fill:var(--seller);fill-opacity:.28}
#fig-funds .fig-funds-r-notepart{fill:var(--seller);fill-opacity:.16}
#fig-funds .fig-funds-r-cash{fill:var(--cash);fill-opacity:.28}
#fig-funds .fig-funds-r-fees{fill:var(--people);fill-opacity:.32}
#fig-funds .fig-funds-potbox{fill:var(--paper);stroke:var(--line);stroke-width:1.5}

/* ===================== fig-stack ===================== */
#fig-stack [hidden]{display:none !important}
#fig-stack .chart{min-height:0}
#fig-stack .fig-stack-nojs{margin:0 0 12px;padding:8px 12px;border-left:4px solid var(--ink);border-radius:0 8px 8px 0;background:var(--wash);font-size:14px;line-height:1.45}
#fig-stack.fig-stack-js .fig-stack-nojs{display:none}
#fig-stack:not(.fig-stack-js) .fig-stack-controls{display:none}

/* controls: price slider with a pass / fail track, then the investor switch */
#fig-stack .fig-stack-range{display:grid;grid-template-columns:minmax(0,1fr) auto;grid-template-areas:"lab out" "trk trk";gap:0 12px;align-items:end;margin:0 0 6px}
#fig-stack .fig-stack-range label{grid-area:lab;padding-bottom:6px;font-size:15px;font-weight:600;line-height:1.3}
#fig-stack .fig-stack-range output{grid-area:out;display:block;min-width:0;padding-bottom:2px;text-align:right;line-height:1.1}
#fig-stack .fig-stack-ox{display:block;font:600 26px/1.1 var(--serif);font-variant-numeric:tabular-nums}
#fig-stack .fig-stack-op{display:block;margin-top:2px;font-size:14px;font-weight:400;color:var(--muted);font-variant-numeric:tabular-nums}
#fig-stack .fig-stack-track{grid-area:trk;position:relative;height:44px;margin:0 0 24px}
#fig-stack .fig-stack-zone{position:absolute;top:18px;height:8px;opacity:.38;pointer-events:none}
#fig-stack .fig-stack-zone-ok{left:14px;width:calc((100% - 28px) * var(--d,.39));border-radius:4px 0 0 4px;background:var(--pass)}
#fig-stack .fig-stack-zone-no{left:calc(14px + (100% - 28px) * var(--d,.39));right:14px;border-radius:0 4px 4px 0;background:var(--fail)}
#fig-stack.is-inv .fig-stack-zone-no{background:var(--investor)}
#fig-stack .fig-stack-track input[type="range"]{position:absolute;left:0;top:0;width:100%;height:44px;margin:0;padding:0;background:transparent;-webkit-appearance:none;appearance:none;cursor:pointer}
#fig-stack input[type="range"]::-webkit-slider-runnable-track{height:8px;background:transparent;border:0}
#fig-stack input[type="range"]::-moz-range-track{height:8px;background:transparent;border:0}
#fig-stack input[type="range"]::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:28px;height:28px;margin-top:-10px;border-radius:50%;border:4px solid var(--surface);background:var(--ink);box-sizing:border-box}
#fig-stack input[type="range"]::-moz-range-thumb{width:28px;height:28px;border-radius:50%;border:4px solid var(--surface);background:var(--ink);box-sizing:border-box}
#fig-stack .fig-stack-tick{position:absolute;top:36px;left:calc(14px + (100% - 28px) * var(--d,.39));width:2px;height:12px;margin-left:-1px;background:var(--ink);pointer-events:none}
#fig-stack .fig-stack-tickl{position:absolute;top:49px;left:calc(14px + (100% - 28px) * var(--d,.39));transform:translateX(-50%);white-space:nowrap;font-size:13px;line-height:1.3;color:var(--muted);pointer-events:none}
#fig-stack .fig-stack-seg{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin:0 0 8px}
#fig-stack .fig-stack-seg button{min-height:48px;padding:8px 10px;border-radius:12px;font-size:14px;line-height:1.2;text-align:center}
#fig-stack .fig-stack-seg button[data-mode="on"][aria-pressed="true"]{background:var(--investor);border-color:var(--investor);color:var(--on-color)}
#fig-stack .fig-stack-hint{margin:0 0 8px;font-size:14px;line-height:1.4}
#fig-stack .fig-stack-sba{margin:0 0 14px;font-size:13px;line-height:1.4;color:var(--muted)}

/* the board: bank test first on a phone, so the verdict sits right under the slider; bar on the left from 720px */
#fig-stack .fig-stack-board{display:grid;grid-template-columns:minmax(0,1fr);gap:16px}
@media (min-width:720px){
  #fig-stack .fig-stack-board{grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:24px;align-items:start}
  #fig-stack .fig-stack-bargrp{order:-1}
}
#fig-stack .fig-stack-h{margin:0;font:600 17px/1.3 var(--serif)}

/* bank test panel */
#fig-stack .fig-stack-test{min-width:0;padding:12px;border:1px solid var(--line);border-radius:12px;background:var(--paper)}
#fig-stack .fig-stack-thead{display:flex;align-items:center;justify-content:space-between;gap:12px;margin:0 0 6px}
#fig-stack .fig-stack-badge{display:inline-flex;align-items:center;gap:6px;margin:0;padding:7px 14px 7px 10px;border-radius:999px;background:var(--pass);color:var(--on-color);font:600 17px/1 var(--sans)}
#fig-stack .fig-stack-badge.is-fail{background:var(--fail)}
#fig-stack .fig-stack-ic{display:block;flex:0 0 auto;width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:2.5;stroke-linecap:round;stroke-linejoin:round}
#fig-stack .fig-stack-badge.is-pass .fig-stack-ic-no,#fig-stack .fig-stack-badge.is-fail .fig-stack-ic-ok{display:none}
#fig-stack .fig-stack-dscr{display:flex;flex-wrap:wrap;align-items:baseline;gap:0 10px;margin:4px 0 0}
#fig-stack .fig-stack-dk{font-size:14px;font-weight:600;color:var(--muted)}
#fig-stack .fig-stack-dv{font:600 34px/1.15 var(--serif);font-variant-numeric:tabular-nums}
#fig-stack .fig-stack-test.is-fail .fig-stack-dv{color:var(--fail)}
#fig-stack .fig-stack-df{font-size:14px;color:var(--muted)}
#fig-stack .fig-stack-def{margin:2px 0 4px;font-size:13px;line-height:1.4;color:var(--muted)}
#fig-stack .fig-stack-brow{margin:10px 0 0}
#fig-stack .fig-stack-bh{display:flex;justify-content:space-between;gap:8px;margin:0;font-size:14px;line-height:1.3}
#fig-stack .fig-stack-bh b{font-weight:600;font-variant-numeric:tabular-nums}
#fig-stack .fig-stack-bt{position:relative;display:block;height:18px;margin-top:4px;border-radius:4px;background:var(--line);overflow:hidden}
#fig-stack .fig-stack-bf{position:absolute;top:0;bottom:0;left:0;width:calc(var(--w,0) * 1%)}
#fig-stack .fig-stack-bf-cash{background:var(--cash)}
#fig-stack .fig-stack-bf-pay{background:var(--loan)}
#fig-stack .fig-stack-bf-cush{left:calc(var(--x,0) * 1%);box-sizing:border-box;border:2px dashed var(--loan);background:transparent}
#fig-stack .fig-stack-bf-gap{left:calc(var(--x,0) * 1%)}
#fig-stack .fig-stack-bf-gap.is-room{background:var(--pass);opacity:.4}
#fig-stack .fig-stack-bf-gap.is-short{background:var(--fail)}
#fig-stack .fig-stack-gl{margin:6px 0 0;font-size:14px;font-weight:600;line-height:1.35;color:var(--pass)}
#fig-stack .fig-stack-gl.is-short{color:var(--fail)}
#fig-stack .fig-stack-key{margin:4px 0 0;font-size:13px;line-height:1.4;color:var(--muted)}
#fig-stack .fig-stack-capmsg{margin:10px 0 0;padding:8px 10px;border:2px solid var(--fail);border-radius:8px;font-size:14px;font-weight:600;line-height:1.4}

/* the stack: layer heights are proportional to dollars (28px floor); the label sits beside its layer */
#fig-stack .fig-stack-bargrp{--bar:240px;min-width:0}
@media (min-width:720px){#fig-stack .fig-stack-bargrp{--bar:300px}}
#fig-stack .fig-stack-hs{margin:2px 0 10px;font-size:14px;line-height:1.4;color:var(--muted)}
#fig-stack .fig-stack-layers{display:flex;flex-direction:column-reverse;margin:0;padding:0;list-style:none;border-radius:12px;overflow:hidden}
#fig-stack .fig-stack-layer{--c:var(--muted);--cw:var(--paper);display:grid;grid-template-columns:minmax(48px,26%) minmax(0,1fr);height:calc(var(--f,0) * var(--bar));min-height:28px;margin:0;padding:0;overflow:hidden}
#fig-stack .fig-stack-layer.is-off{height:0;min-height:0}
#fig-stack .fig-stack-l-loan{--c:var(--loan);--cw:var(--loan-wash)}
#fig-stack .fig-stack-l-note{--c:var(--seller);--cw:var(--seller-wash)}
#fig-stack .fig-stack-l-inv{--c:var(--investor);--cw:var(--investor-wash)}
#fig-stack .fig-stack-l-cash{--c:var(--cash);--cw:var(--cash-wash)}
#fig-stack .fig-stack-blk{display:block;border-top:2px solid var(--surface);background:var(--c)}
#fig-stack .fig-stack-lab{display:flex;flex-wrap:wrap;align-items:center;align-content:center;padding:0 10px;border-top:2px solid var(--surface);background:var(--cw);font-size:15px;line-height:1.25;font-variant-numeric:tabular-nums}
#fig-stack .fig-stack-l-note .fig-stack-lab,#fig-stack .fig-stack-l-inv .fig-stack-lab,#fig-stack .fig-stack-l-cash .fig-stack-lab{flex-wrap:nowrap;white-space:nowrap}
#fig-stack .fig-stack-nm{margin-right:6px;font-weight:600}
#fig-stack .fig-stack-shr{margin-left:5px}
#fig-stack .fig-stack-own{margin:10px 0 0;padding:8px 12px;border-radius:8px;background:var(--investor-wash)}
#fig-stack .fig-stack-own p{margin:0}
#fig-stack .fig-stack-own1{font-size:15px;line-height:1.4}
#fig-stack .fig-stack-own1 b{font-weight:600;font-variant-numeric:tabular-nums}
#fig-stack .fig-stack-own2{margin-top:2px;font-size:13px;line-height:1.4;color:var(--muted)}
#fig-stack .fig-stack-gloss{margin:14px 0 0;font-size:14px;line-height:1.5;color:var(--muted)}

/* calm motion: layer heights and bars glide for 0.4 s; the badge pops once when the verdict flips */
@media (prefers-reduced-motion:no-preference){
  #fig-stack .fig-stack-layer{transition:height .4s ease,min-height .4s ease}
  #fig-stack .fig-stack-bf{transition:width .4s ease,left .4s ease}
  @keyframes fig-stack-pop{0%{transform:scale(.88)}60%{transform:scale(1.07)}100%{transform:scale(1)}}
  #fig-stack .fig-stack-badge.pop{animation:fig-stack-pop .35s ease-out}
}
