/* ══════════════════════════════════════════════════════════════════════════
 * ⚠⚠ ROLE CHANGED BEFORE THIS FILE EVER SHIPPED — READ THIS FIRST.
 *
 * This was written as THE FIX (option B4-a). RB then granted the frozen-file
 * exception (#438), so the SOURCE fix went in at `js/bid-ui.js:6433/:6545/:6551`
 * and every card body now carries `collapsed`. **THIS FILE IS THEREFORE A
 * REGRESSION GUARD, NOT THE FIX**, and both rules below are written so they
 * match NOTHING while the source invariant holds.
 *
 * ⚠ THAT IS NOT A CHECK THAT CANNOT FIRE. It fires on exactly one condition —
 * a qa/ca card body emitted WITHOUT `collapsed` — which is the only shape this
 * defect can return in. `tests/qa-collapse-fix.test.js` Suite A proves the source
 * fix is complete WITHOUT this file (styles.css alone), and Suite B drives the
 * pre-fix markup on purpose to prove the guard still catches it.
 *
 * The description below is kept VERBATIM as written pre-#438, because it is the
 * record of the defect and of why the `ca-` rule carries its marker exclusion.
 * ──────────────────────────────────────────────────────────────────────────
 *
 * qa-collapse-fix.css — E1-9. "ARCHITECTURAL will not collapse."
 * Built 2026-08-03 (RB #432, option B4-a). ADDITIVE ONLY.
 *
 * DOES NOT TOUCH THE FROZEN TRIO. `css/styles.css`, `js/bid-ui.js` and
 * `js/plan-markup-viewer.js` are unmodified; this file plus one <link> in
 * index.html is the whole change.
 *
 * ── THE DEFECT — CLAUDE.md Rule 25, exactly: two nodes, two classes, one state
 *
 * The QA "Client Questions" and "Contractor Actions" tabs render one collapsible
 * card per question/action CATEGORY. `bid-ui.js` writes the collapse state to
 * TWO DIFFERENT PLACES and only ever reads one of them:
 *
 *   INITIAL STATE  ->  `collapsed` on the BODY   (bid-ui.js:6433, :6551)
 *   CLICK          ->  `qa-open` / `ca-open` on the CARD (bid-ui.js:6427, :6546)
 *
 * and `css/styles.css:500-503` / `:556-559` drives visibility ENTIRELY from the
 * body's `collapsed`:
 *
 *     .qa-card-body.collapsed              { display:none  }
 *     .qa-card.qa-open .qa-card-body.collapsed { display:block }
 *
 * There is NO rule that hides a body which lacks `collapsed`. `bid-ui.js` opens
 * the first group by default (`var isOpen = gi === 0`) and therefore emits that
 * body WITHOUT `collapsed` — so nothing can ever hide it. Clicking toggles
 * `qa-open`/`ca-open` and produces NO visible change at all.
 *
 * ⚠ THE DEFECT IS `gi === 0`, NOT `ARCHITECTURAL`. Every other category collapses
 * correctly; ARCHITECTURAL was simply the category that sorted first on the bid
 * that was looked at. Two earlier hypotheses (a non-unique element id; a handler
 * bound before the section renders) are both REFUTED — `id="results-section"`
 * appears once, and the controls are inline `onclick` attributes emitted with the
 * markup, so they cannot bind early.
 *
 * ── THE CONTROL, and it is already deployed
 *
 * `js/answered-citations.js` renders the SAME `ca-card` markup against the SAME
 * CSS and collapses correctly — because it never renders an initially-open card,
 * so every one of its bodies carries `collapsed`. Same CSS, same handler, no
 * defect: the `isOpen` branch is the isolated variable.
 *
 * ── ⚠ WHY THE `ca-` RULE CARRIES A `:not([data-answered-citations])`
 *
 * `answered-citations.js:130` deliberately emits a `ca-card-body` WITHOUT
 * `collapsed` so its "N questions were not cross-referenced" disclosure stays
 * visible while the panel is closed. That is the same shape as the defect, used
 * on purpose. Without the marker exclusion, this fix would HIDE that disclosure
 * as soon as a user expanded and re-collapsed the panel — a regression on a
 * surface that exists precisely to stop a number going unseen. The marker
 * (`data-answered-citations="1"`, declared at answered-citations.js:47/114) is
 * that module's own explicit opt-out, not an inference about structure.
 *
 * ── TRUTH TABLE (both rules), asserted in tests/qa-collapse-fix.test.js
 *
 *   card                       body            -> visible?   before / after
 *   .qa-card                   (no collapsed)      YES / YES   <- gi===0 initial
 *   .qa-card.qa-open           (no collapsed)      YES / no    <- gi===0 clicked  ** THE FIX **
 *   .qa-card                   .collapsed          no  / no    <- gi>=1 initial
 *   .qa-card.qa-open           .collapsed          YES / YES   <- gi>=1 expanded
 *   .ca-card.ca-open           (no collapsed)      YES / YES   <- gi===0 initial
 *   .ca-card                   (no collapsed)      YES / no    <- gi===0 clicked  ** THE FIX **
 *   .ca-card[data-answered-citations] (no collapsed) YES / YES <- the control, PROTECTED
 *
 * ══════════════════════════════════════════════════════════════════════════ */

/* Client Questions — `qa-open` is a FLIP flag, not an "is open" flag: it means
   "the opposite of what was rendered". So a card carrying it whose body was
   rendered open must now be closed. */
.qa-card.qa-open > .qa-card-body:not(.collapsed) {
  display: none;
}

/* Contractor Actions — same flip, opposite polarity: `ca-open` IS present at
   render for gi===0 (bid-ui.js:6426), so the closed state is its ABSENCE.
   The marker exclusion protects answered-citations.js's always-visible line. */
.ca-card:not(.ca-open):not([data-answered-citations]) > .ca-card-body:not(.collapsed) {
  display: none;
}
