/* Portfolio builder (pipeline/pages/portfolio.py, js/portfolio.js).
   Builds on style.css (.card, .sentence + .dd, .result, .chips/.seg, .stats, .btn)
   and on the Time Machine's form and chart classes (css/timemachine.css). */

/* colors: the portfolio's own line is ink; assets without a site-wide color get
   a calm one here (the site's asset colors stay with the assets that own them) */
:root { --pf: var(--ink); --bills: #e58a7a; --silver: #9aa5b1; --platinum: #6f8196; --coin: var(--ink-2); }
.ln.a-pf { stroke: var(--pf); }
.dot.a-pf, .bar.a-pf:not(.neg) { fill: var(--pf); }

/* the form: presets, one row per asset, the money sentence, the link */
.pb-form { gap: 16px; }
.pb-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.pb-rows { display: grid; gap: 8px; }
.pb-row { display: grid; grid-template-columns: 44px minmax(0, 1.25fr) minmax(90px, 1fr) auto 32px; align-items: center; gap: 10px; }
.pb-row .dd { margin: 0; padding: 7px 12px; min-width: 0; }
.ico.pb-i { width: auto; min-width: 28px; height: 28px; padding: 0 5px; border-radius: 8px; font-size: 10px; justify-self: start; }
.ico.pb-i.xs { min-width: 20px; height: 20px; padding: 0 3px; border-radius: 6px; font-size: 7px; box-shadow: none; }
th .ico.pb-i.xs { margin-right: 8px; vertical-align: -5px; }
.pb-asset select { font: 600 15px var(--font); color: var(--ink); background: transparent; border: 0; padding: 2px 0; margin: 0; width: 100%; min-width: 0; cursor: pointer; text-overflow: ellipsis; }
.pb-asset select:focus, .pb-w input:focus, .pb-name input:focus { outline: none; }
.pb-row .dd:focus-within, .pb-name:focus-within { box-shadow: 0 0 0 2px var(--accent); }
.pb-asset option, .pb-asset optgroup { font: 500 15px var(--font); color: var(--ink); background: var(--surface); }
.pb-w input { width: 4.4ch; text-align: right; font: 600 15px var(--mono); letter-spacing: -0.03em; color: var(--ink); background: transparent; border: 0; padding: 2px 0; margin: 0; }
.pb-w span { color: var(--muted); font-weight: 600; }
.pb-range { -webkit-appearance: none; appearance: none; width: 100%; min-width: 0; height: 6px; margin: 0; border-radius: 999px; cursor: pointer;
  background: linear-gradient(to right, var(--c) 0, var(--c) var(--p), var(--track) var(--p), var(--track) 100%); }
.pb-range::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%; background: var(--surface); border: 0; box-shadow: 0 0 0 2.5px var(--c), 0 2px 6px rgba(0, 0, 0, 0.18); }
.pb-range::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: var(--surface); border: 0; box-shadow: 0 0 0 2.5px var(--c), 0 2px 6px rgba(0, 0, 0, 0.18); }
.pb-range::-moz-range-track { background: transparent; }
.pb-range:focus-visible { outline: 2px solid var(--accent); outline-offset: 6px; }
.pb-x { width: 32px; height: 32px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); font: 400 20px/1 var(--font); cursor: pointer; }
.pb-x:hover { background: var(--track); color: var(--ink); }
.pb-x[hidden] { display: block; visibility: hidden; }
.pb-rowtools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pb-tool { font: 600 13px/1 var(--font); color: var(--ink); background: var(--track); border: 0; border-radius: 999px; padding: 10px 14px; cursor: pointer; }
.pb-tool:hover { filter: brightness(0.97); }
.pb-tool:disabled { opacity: 0.45; cursor: default; }
.pb-tool[hidden] { display: none; }
.pb-total { margin-left: auto; font-variant-numeric: tabular-nums; }
.pb-total.is-off { color: var(--bad); font-weight: 600; }
.pb-sentence .pb-short { width: 5ch; }
.pb-clamp { margin: 0; }
.pb-clamp[hidden] { display: none; }
.pb-share { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding-top: 16px; border-top: 1px solid var(--border); }
.pb-share[hidden] { display: none; }
.pb-name { flex: 1 1 280px; margin: 0; padding: 9px 14px; gap: 10px; }
.pb-name input { flex: 1; min-width: 0; font: 500 15px var(--font); color: var(--ink); background: transparent; border: 0; padding: 2px 0; }
.pb-name input::placeholder { color: var(--muted); }
.pb-x:focus-visible, .pb-tool:focus-visible, .pb-share .btn:focus-visible, #pb-presets .chip:focus-visible, #pb-vs .chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* the result: its name, the mix as one bar, numbers, charts */
.pb-out { margin: 44px 0 0; }
.pb-out h2 { margin: 0 0 14px; overflow-wrap: anywhere; }
.pb-segs { display: flex; gap: 3px; height: 12px; }
.pb-seg { flex: 1 1 0; min-width: 3px; border-radius: 4px; background: var(--c); }
.pb-seg:first-child { border-radius: 999px 4px 4px 999px; }
.pb-seg:last-child { border-radius: 4px 999px 999px 4px; }
.pb-seg:only-child { border-radius: 999px; }
.pb-keys { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 10px 0 0; font-size: 14px; color: var(--ink-2); }
.pb-keys span { display: inline-flex; align-items: center; gap: 6px; }
.pb-keys b { color: var(--ink); font-weight: 600; }
.pb-dot { width: 10px; height: 10px; border-radius: 3px; background: var(--c); flex: none; }
.pb-out .tm-headline { margin: 14px 0 0; }
.pb-out .tm-chart-head { padding-right: 40px; } /* room for the full-screen button */
.pb-out .findings { margin-top: 16px; }
.pb-yearbars { min-height: 260px; }
.pb-years { margin: 16px 0 0; max-height: 520px; overflow: auto; }
.pb-years thead th { position: sticky; top: 0; background: var(--surface); z-index: 1; }

@media (max-width: 720px) {
  .pb-row { grid-template-columns: 44px minmax(0, 1fr) auto 32px; grid-template-areas: "ico asset asset x" "range range w w"; row-gap: 6px; padding: 4px 0 8px; }
  .pb-row .ico { grid-area: ico; }
  .pb-row .pb-asset { grid-area: asset; }
  .pb-row .pb-x { grid-area: x; justify-self: end; }
  .pb-row .pb-range { grid-area: range; }
  .pb-row .pb-w { grid-area: w; justify-self: end; }
  .pb-total { margin-left: 0; flex-basis: 100%; }
  .pb-out .findings { grid-template-columns: 1fr; }
}
