/* Leveraged buyouts, explained: charts-b (fig-team, fig-checklist, fig-ai, fig-sentiment).
   Every rule is scoped under its figure id. Colors come only from the variables in assets/style.css, so dark mode
   follows the page. Without script every panel, line and face is visible; script adds the collapse and the toggles. */

/* An author display rule beats the browser's [hidden] rule, so say it again here. */
#fig-team [hidden], #fig-checklist [hidden], #fig-ai [hidden] { display: none !important; }
/* The "tap to ..." hints are hidden in the markup and shown by script. */
#fig-team .fig-team-hint, #fig-checklist .fig-checklist-hint, #fig-ai .fig-ai-hint-line {
  margin: 0 0 10px; font-size: 14px; font-weight: 600; line-height: 1.4; color: var(--muted);
}

/* ---------- fig-team ---------- */
#fig-team .fig-team-key { margin: 0 0 10px; font-size: 14px; line-height: 1.45; color: var(--muted); }
#fig-team .fig-team-board { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
#fig-team .fig-team-side-h {
  margin: 0 0 8px; font: 600 13px/1.3 var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
}
#fig-team .fig-team-side-h::before {
  content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 8px; border-radius: 50%; background: var(--people);
}
#fig-team .fig-team-sellers .fig-team-side-h::before { background: var(--seller); }
#fig-team .fig-team-buyers .fig-team-side-h::before { background: var(--cash); }
#fig-team .fig-team-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
#fig-team .fig-team-person {
  --c: var(--people); --cw: var(--people-wash);
  margin: 0; padding: 0; border: 1px solid var(--line); border-left: 4px solid var(--c); border-radius: 8px; background: var(--cw);
}
#fig-team .fig-team-founder { --c: var(--seller); --cw: var(--seller-wash); }
#fig-team .fig-team-me { --c: var(--cash); --cw: var(--cash-wash); }
#fig-team .fig-team-lender { --c: var(--loan); --cw: var(--loan-wash); }
#fig-team .fig-team-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; min-height: 44px; margin: 0; padding: 8px 12px; border: 0; border-radius: 8px;
  background: none; color: var(--ink); font: 600 15px/1.3 var(--sans); text-align: left; cursor: default;
}
#fig-team .fig-team-name { display: block; }
#fig-team.is-interactive .fig-team-btn { cursor: pointer; }
#fig-team.is-interactive .fig-team-btn::after { content: "+"; flex: none; font-size: 22px; font-weight: 400; line-height: 1; color: var(--muted); }
#fig-team.is-interactive .fig-team-btn[aria-expanded="true"]::after { content: "\2212"; }
#fig-team .fig-team-what { margin: 0; padding: 0 12px 10px; font-size: 14px; line-height: 1.45; }
#fig-team .fig-team-cost { margin: 0 12px; padding: 8px 0 10px; border-top: 1px dashed var(--line); font-size: 14px; line-height: 1.4; }
#fig-team .fig-team-cost-h { display: block; font-size: 13px; font-weight: 600; color: var(--muted); }
#fig-team .fig-team-middle {
  display: grid; grid-template-columns: 36px minmax(0, 1fr); align-items: center; gap: 12px;
  padding: 12px 14px; border: 2px solid var(--ink); border-radius: var(--radius); background: var(--wash);
}
#fig-team .fig-team-doc { width: 30px; height: 34px; overflow: visible; }
#fig-team .fig-team-doc-page { fill: var(--surface); stroke: var(--ink); stroke-width: 1.6; stroke-linejoin: round; }
#fig-team .fig-team-doc-fold { fill: none; stroke: var(--ink); stroke-width: 1.6; stroke-linejoin: round; }
#fig-team .fig-team-doc-line { fill: none; stroke: var(--muted); stroke-width: 1.6; stroke-linecap: round; }
#fig-team .fig-team-mid-name { margin: 0; font: 600 17px/1.25 var(--serif); }
#fig-team .fig-team-mid-what { margin: 2px 0 0; font-size: 14px; line-height: 1.4; color: var(--muted); }
@media (min-width: 720px) {
  #fig-team .fig-team-board { grid-template-columns: minmax(0, 1fr) 176px minmax(0, 1fr); gap: 18px; align-items: start; }
  #fig-team .fig-team-middle { align-self: center; grid-template-columns: minmax(0, 1fr); justify-items: center; gap: 8px; padding: 16px 12px; text-align: center; }
}

/* ---------- fig-checklist ---------- */
#fig-checklist .seg[hidden] { display: none; }
#fig-checklist .seg button { flex: 1 1 150px; }
#fig-checklist .fig-checklist-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
#fig-checklist .fig-checklist-row { margin: 0; border: 1.5px solid var(--line); border-radius: 10px; background: var(--paper); }
#fig-checklist .fig-checklist-row.is-open { border-color: var(--muted); }
#fig-checklist .fig-checklist-head {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; align-items: center;
  width: 100%; min-height: 44px; margin: 0; padding: 10px 12px; border: 0; border-radius: 10px;
  background: none; color: var(--ink); font: inherit; text-align: left; cursor: default;
}
#fig-checklist .fig-checklist-head > * { grid-column: 1; }
#fig-checklist .fig-checklist-tag {
  display: none; justify-self: start; margin: 0 0 4px; padding: 2px 10px; border-radius: 999px;
  background: var(--ink); color: var(--paper); font-size: 13px; font-weight: 600; line-height: 1.4;
}
#fig-checklist .fig-checklist-name { font: 600 17px/1.25 var(--serif); }
#fig-checklist .fig-checklist-q { margin-top: 2px; font-size: 15px; line-height: 1.4; color: var(--muted); }
#fig-checklist.is-interactive .fig-checklist-head { cursor: pointer; }
#fig-checklist.is-interactive .fig-checklist-head::after {
  content: ""; grid-column: 2; grid-row: 1 / span 3; align-self: center; width: 9px; height: 9px; margin: 0 4px 4px 0;
  border: solid var(--muted); border-width: 0 2px 2px 0; transform: rotate(45deg);
}
#fig-checklist.is-interactive .fig-checklist-head[aria-expanded="true"]::after { margin: 4px 4px 0 0; transform: rotate(-135deg); }
#fig-checklist .fig-checklist-row.is-done .fig-checklist-name::before {
  content: ""; display: inline-block; width: 6px; height: 11px; margin: 0 10px 2px 2px;
  border: solid var(--ink); border-width: 0 2px 2px 0; transform: rotate(45deg); vertical-align: middle;
}
#fig-checklist .fig-checklist-panel { padding: 0 12px 6px; }
#fig-checklist .fig-checklist-why {
  display: none; margin: 0 0 8px; padding: 8px 10px; border-left: 3px solid var(--ink); border-radius: 0 8px 8px 0;
  background: var(--surface); font-size: 14px; line-height: 1.45;
}
#fig-checklist .fig-checklist-why strong { font-weight: 600; }
#fig-checklist .fig-checklist-items { list-style: none; margin: 0; padding: 0; }
#fig-checklist .fig-checklist-items li { margin: 0; border-top: 1px solid var(--line); }
#fig-checklist .fig-checklist-items label { display: flex; align-items: flex-start; gap: 12px; min-height: 44px; padding: 10px 2px; font-size: 15px; line-height: 1.4; cursor: pointer; }
#fig-checklist .fig-checklist-items input { flex: none; width: 22px; height: 22px; margin: 0; accent-color: var(--ink); }
#fig-checklist .fig-checklist-items input:checked + span { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; }
/* The three to check first: highlighted with no script at all, and when the toggle asks for them. */
#fig-checklist:not(.is-interactive) .fig-checklist-row[data-first],
#fig-checklist.is-first .fig-checklist-row[data-first] { border-color: var(--ink); background: var(--wash); }
#fig-checklist:not(.is-interactive) [data-first] .fig-checklist-tag,
#fig-checklist.is-first [data-first] .fig-checklist-tag { display: inline-block; }
#fig-checklist:not(.is-interactive) [data-first] .fig-checklist-why,
#fig-checklist.is-first [data-first] .fig-checklist-why { display: block; }
#fig-checklist.is-first .fig-checklist-row:not([data-first]) .fig-checklist-name { color: var(--muted); }
#fig-checklist .fig-checklist-note { margin: 12px 0 0; font-size: 14px; line-height: 1.45; color: var(--muted); }

/* ---------- fig-ai ---------- */
#fig-ai .seg[hidden] { display: none; }
#fig-ai .seg button { flex: 1 1 150px; }
#fig-ai .fig-ai-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
#fig-ai .fig-ai-tile { position: relative; margin: 0; padding: 16px 12px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); overflow: hidden; }
#fig-ai .fig-ai-bar { position: absolute; top: 0; left: 0; right: 0; height: 4px; background: var(--ai); }
#fig-ai .fig-ai-dept { margin: 0 0 8px; font: 600 17px/1.25 var(--serif); }
#fig-ai .fig-ai-face { margin: 0 0 8px; padding: 8px 10px; border-radius: 8px; }
#fig-ai .fig-ai-today { border: 1px dashed var(--muted); }
#fig-ai .fig-ai-with { border-left: 3px solid var(--ai); background: var(--ai-wash); }
#fig-ai .fig-ai-k { margin: 0 0 2px; font-size: 13px; font-weight: 600; line-height: 1.3; color: var(--muted); }
#fig-ai .fig-ai-with .fig-ai-k { color: var(--ai); }
#fig-ai .fig-ai-v { margin: 0; font-size: 15px; line-height: 1.4; }
#fig-ai .fig-ai-measure { margin: 0; font-size: 14px; line-height: 1.4; }
#fig-ai .fig-ai-measure .fig-ai-k { display: inline; margin: 0 6px 0 0; }
#fig-ai.is-interactive .fig-ai-tile { padding-bottom: 40px; }
#fig-ai.is-interactive .fig-ai-tile:hover { border-color: var(--ai); }
#fig-ai.is-interactive .fig-ai-tile:not(.is-flipped) .fig-ai-with,
#fig-ai.is-interactive .fig-ai-tile.is-flipped .fig-ai-today { display: none; }
#fig-ai .fig-ai-flip {
  position: absolute; top: 0; right: 0; bottom: 0; left: 0; display: flex; align-items: flex-end; justify-content: flex-end;
  width: 100%; height: 100%; margin: 0; padding: 0 12px 10px; border: 0; border-radius: 10px;
  background: none; color: var(--ai); font: inherit; cursor: pointer;
}
#fig-ai .fig-ai-flip:focus-visible { outline-offset: -3px; }
#fig-ai .fig-ai-hint { font-size: 14px; font-weight: 600; line-height: 1.3; }
#fig-ai .fig-ai-hint::after { content: " +"; }
#fig-ai .fig-ai-human {
  display: flex; align-items: flex-start; gap: 10px; margin: 14px 0 0; padding: 10px 12px;
  border: 1.5px solid var(--ai); border-radius: 10px; background: var(--ai-wash); font-size: 15px; font-weight: 600; line-height: 1.45;
}
#fig-ai .fig-ai-icon { flex: none; width: 26px; height: 26px; fill: none; stroke: var(--ai); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
@media (min-width: 720px) {
  #fig-ai .fig-ai-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
}

/* ---------- fig-sentiment ---------- */
#fig-sentiment .chart:not(.is-ready), #fig-sentiment .chart.is-ready { min-height: 0; }
#fig-sentiment .fig-sentiment-axis { display: grid; grid-template-columns: minmax(0, 1fr); margin: 0 0 4px; }
#fig-sentiment .fig-sentiment-ax-in {
  position: relative; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 6px 10px; border-radius: 8px; overflow: hidden; font-size: 13px; font-weight: 600; line-height: 1.3;
}
#fig-sentiment .fig-sentiment-ax-in::before, #fig-sentiment .fig-sentiment-ax-in::after { content: ""; position: absolute; top: 0; bottom: 0; width: 50%; opacity: .12; }
#fig-sentiment .fig-sentiment-ax-in::before { left: 0; background: var(--fail); }
#fig-sentiment .fig-sentiment-ax-in::after { right: 0; background: var(--cash); }
#fig-sentiment .fig-sentiment-ax-in span { position: relative; z-index: 1; }
#fig-sentiment .fig-sentiment-ax-m { text-align: center; color: var(--muted); }
#fig-sentiment .fig-sentiment-ax-p { text-align: right; }
#fig-sentiment .fig-sentiment-rows { list-style: none; margin: 0; padding: 0; }
#fig-sentiment .fig-sentiment-row {
  display: grid; grid-template-columns: minmax(0, 1fr); grid-template-areas: "theme" "track" "meta" "count";
  gap: 4px 16px; margin: 0; padding: 12px 0; border-top: 1px solid var(--line);
}
#fig-sentiment .fig-sentiment-theme { grid-area: theme; margin: 0; font: 600 15px/1.35 var(--sans); }
#fig-sentiment .fig-sentiment-track { grid-area: track; display: block; width: 100%; height: 34px; margin: 4px 0; border-radius: 8px; overflow: hidden; }
#fig-sentiment .fig-sentiment-track svg { display: block; width: 100%; height: 34px; }
#fig-sentiment .fig-sentiment-meta { grid-area: meta; margin: 0; font-size: 13px; line-height: 1.4; color: var(--muted); }
#fig-sentiment .fig-sentiment-count { grid-area: count; margin: 0; font-size: 13px; line-height: 1.4; color: var(--muted); }
#fig-sentiment .fig-sentiment-tone { display: block; font-weight: 600; color: var(--ink); }
#fig-sentiment .fig-sentiment-wn { fill: var(--fail); fill-opacity: .12; }
#fig-sentiment .fig-sentiment-wp { fill: var(--cash); fill-opacity: .12; }
#fig-sentiment .fig-sentiment-mid { stroke: var(--line); stroke-width: 1; }
#fig-sentiment .fig-sentiment-stem { stroke: var(--ink); stroke-width: 2.5; stroke-linecap: round; }
#fig-sentiment .fig-sentiment-dot { fill: var(--ink); stroke: var(--surface); stroke-width: 2; }
#fig-sentiment .fig-sentiment-key { margin: 12px 0 0; font-size: 14px; line-height: 1.45; color: var(--muted); }
@media (min-width: 720px) {
  #fig-sentiment .fig-sentiment-axis { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); column-gap: 16px; }
  #fig-sentiment .fig-sentiment-ax-in { grid-column: 2; }
  #fig-sentiment .fig-sentiment-row {
    grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); grid-template-areas: "theme track" "meta track" "count track";
    align-items: center;
  }
}
