/* ▣ tip cards (tip_cards.js) — the hover box painted as a small card when the tip is more
   than a line. One file for all three sites (byte-identical copies): the box is #tipbox on
   the Cockpit, #tip on Bonds & Credit, #tc-box on the Nation Tracker. Colours come from
   each site's own tokens through the --tc-* aliases below (the Cockpit's names first, the
   siblings' as fallbacks), so every skin and both themes carry it. The run-status card's
   language: tinted title strip, verdict pill, tiles, chips, a → action line. */
:is(#tipbox, #tip, #tc-box, .tcb-grid, .tcb-sub) {
  --tc-line: var(--border, var(--line, #d0d7de));
  --tc-wash: var(--accent-soft, color-mix(in srgb, var(--accent) 11%, var(--panel)));
  --tc-chip: var(--grey-chip-bg, var(--panel2, rgba(127, 127, 127, 0.14)));
  --tc-up: var(--bull, var(--green, #1a7f37));
  --tc-dn: var(--bear, var(--red, #cf222e));
  --tc-warn: var(--amber, #9a6700);
}

/* the Nation Tracker has no tooltip of its own — this is it (plain one-liners use it too) */
#tc-box {
  position: fixed; z-index: 300; max-width: 340px;
  background: var(--panel); color: var(--text); border: 1px solid var(--tc-line);
  font: 12px/1.5 var(--sans, system-ui, -apple-system, "Segoe UI", sans-serif);
  padding: 8px 11px; border-radius: 7px; box-shadow: 0 6px 22px rgba(0, 0, 0, 0.2);
  pointer-events: none; white-space: normal; text-align: left; overflow: hidden;
}

:is(#tipbox, #tip, #tc-box).tc-card {
  padding: 0;
  width: max-content;
  max-width: min(390px, calc(100vw - 16px));
  min-width: 230px;
  font-size: 12px;
  line-height: 1.4;
  text-align: left;
  white-space: normal;
  border-radius: var(--r-box, 10px);
  overflow: hidden auto;
}
:is(#tipbox, #tip, #tc-box).tc-card.tc-full { max-width: min(470px, calc(100vw - 16px)); }
:root[data-theme="dark"] :is(#tipbox, #tip, #tc-box).tc-card { box-shadow: 0 10px 32px rgba(0, 0, 0, 0.6); }

.tc-head {
  display: flex; align-items: baseline; gap: 7px;
  padding: 8px 12px 7px;
  font-weight: 700; font-size: 12.5px;
  color: var(--text); background: var(--tc-wash);   /* ink, not accent: Classic's accent on its wash is 3.9–4.3:1 */
}
.tc-head .tc-ic { flex: none; font-size: 13px; line-height: 1; color: var(--accent); }
.tc-head .tc-title { min-width: 0; }
.tc-head .tc-sub { margin-left: auto; padding-left: 10px; flex: none; font-size: 10.5px; font-weight: 600; color: var(--muted); }
/* the verdict, first thing the eye lands on */
.tc-pill {
  margin-left: auto; flex: none; align-self: center;
  font-size: 10.5px; font-weight: 700; line-height: 1.5; padding: 0 8px; border-radius: 999px;
  background: var(--panel); border: 1px solid currentColor; white-space: nowrap;
}
.tc-sub + .tc-pill { margin-left: 6px; }
.tc-pill.tc-good { color: var(--tc-up); }
.tc-pill.tc-bad  { color: var(--tc-dn); }
.tc-pill.tc-warn { color: var(--tc-warn); }
.tc-pill.tc-info { color: var(--text); border-color: var(--tc-line); }

.tc-body { padding: 9px 12px 10px; }
.tc-lead { font-size: 13px; font-weight: 600; line-height: 1.35; color: var(--text); }

/* what it covers, as chips */
.tc-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.tc-lead + .tc-chips { margin-top: 9px; }
.tc-body > .tc-chips:first-child { margin-top: 0; }
.tc-chip {
  font-size: 11px; line-height: 1.5; padding: 0 8px; border-radius: 999px;
  color: var(--text); background: var(--tc-chip); white-space: nowrap;
}
.tc-chip-more { color: var(--muted); }

/* the two or three things worth knowing */
.tc-notes { margin: 8px 0 0; padding: 0 0 0 14px; font-size: 11.5px; color: var(--text); }
.tc-body > .tc-notes:first-child { margin-top: 0; }
.tc-notes li { margin: 0 0 3px; }
.tc-notes li:last-child { margin-bottom: 0; }
.tc-notes li::marker { color: var(--muted); }

/* figures: key/value rows, or stat tiles for a run of short ones */
.tc-k { font-size: 10px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin: 8px 0 3px; }
.tc-body > .tc-k:first-child { margin-top: 0; }
.tc-kv { font-size: 11.5px; }
.tc-lead + .tc-kv, .tc-kv + .tc-kv, .tc-tiles + .tc-kv { margin-top: 6px; }
.tc-row { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; padding: 2px 0; }
.tc-row + .tc-row { border-top: 1px solid var(--tc-line); }
.tc-rk { color: var(--muted); min-width: 0; }
.tc-rk i { font-style: normal; opacity: 0.8; }
.tc-rk.tc-wide { color: var(--text); }
.tc-rv { flex: none; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
.tc-tiles { display: grid; gap: 0; border: 1px solid var(--tc-line); border-radius: 7px; overflow: hidden; }
.tc-lead + .tc-tiles, .tc-kv + .tc-tiles, .tc-tiles + .tc-tiles, .tc-note + .tc-tiles,
.tc-notes + .tc-tiles, .tc-tiles + .tc-notes, .tc-tiles + .tc-defs { margin-top: 7px; }
.tc-tile { padding: 4px 8px 5px; min-width: 0; }
.tc-tile + .tc-tile { border-left: 1px solid var(--tc-line); }
.tc-tk { font-size: 10px; font-weight: 700; letter-spacing: 0.04em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tc-tv { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--text); }
.tc-tv small { font-size: 10px; font-weight: 600; color: var(--muted); margin-left: 1px; }
.tc-ts { font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tc-scale .tc-tv { font-size: 12.5px; }
.tc-note { font-size: 11.5px; color: var(--text); }
.tc-note + .tc-note, .tc-kv + .tc-note, .tc-tiles + .tc-note { margin-top: 6px; }

/* the action, then the small print */
.tc-foot { border-top: 1px solid var(--tc-line); padding: 7px 12px 8px; }
.tc-act { display: flex; gap: 6px; font-size: 11.5px; color: var(--text); }
.tc-act + .tc-act { margin-top: 3px; }
.tc-arrow { flex: none; color: var(--accent); font-weight: 700; }
.tc-hint { font-size: 10.5px; color: var(--muted); }
.tc-act + .tc-hint { margin-top: 5px; }

/* inline: CAPS emphasis as bold small caps; signed figures in the bull/bear colour */
.tc-card .tc-em { font-weight: 700; font-variant-caps: all-small-caps; letter-spacing: 0.02em; }
.tc-card .tc-up { color: var(--tc-up); font-weight: 700; }
.tc-card .tc-dn { color: var(--tc-dn); font-weight: 700; }

/* hand-tuned pieces: term → meaning, measured results, a short flow */
.tc-defs { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; row-gap: 4px; margin-top: 8px; font-size: 11.5px; }
.tc-body > .tc-defs:first-child { margin-top: 0; }
.tc-dt { font-weight: 700; color: var(--text); white-space: nowrap; }
.tc-dd { color: var(--muted); }
.tc-figs { margin-top: 8px; }
.tc-figs .tc-row { padding: 4px 0; }
.tc-figs .tc-rk { color: var(--text); }
.tc-figs .tc-rk small { display: block; font-size: 10.5px; color: var(--muted); margin-top: 1px; }
.tc-figs .tc-rv { font-size: 14px; }
.tc-steps { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 8px; font-size: 11px; }
.tc-step { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px 1px 2px; border-radius: 999px; background: var(--tc-chip); color: var(--text); white-space: nowrap; }
.tc-step b { display: inline-grid; place-items: center; width: 15px; height: 15px; border-radius: 50%; font-size: 9.5px; background: var(--accent); color: var(--panel); }
.tc-then { color: var(--muted); font-size: 10px; }
.tc-notes + .tc-steps, .tc-steps + .tc-notes { margin-top: 8px; }
.tc-table .tc-rv { font-weight: 600; }
.tc-defs + .tc-k, .tc-notes + .tc-k, .tc-chips + .tc-k { margin-top: 9px; }
.tc-table + .tc-notes, .tc-figs + .tc-notes, .tc-defs + .tc-notes { margin-top: 8px; }

/* ---- in-page briefs (data-briefs; the Nation Tracker's section verdicts and long notes) ---- */
.verdict > p.tcb-lead { color: var(--text); font-size: 14px; font-weight: 600; line-height: 1.5; }
.tcb-pts { margin: 6px 0 0; padding: 0 0 0 18px; color: var(--muted); font-size: 12.5px; line-height: 1.55; max-width: 125ch; }
.tcb-pts li { margin: 2px 0; }
.tcb-pts li::marker { color: var(--accent); }
.tcb-pts b { color: var(--text); }
.tcb-more { margin-top: 4px; }
.tcb-more > summary {
  width: max-content; cursor: pointer; list-style: none;
  color: var(--accent); font-size: 12px; font-weight: 600;
}
.tcb-more > summary::-webkit-details-marker { display: none; }
.tcb-more > summary::before { content: "▸ "; }
.tcb-more[open] > summary::before { content: "▾ "; }
.tcb-tog {
  border: 0; background: none; padding: 0; margin-left: 2px; cursor: pointer;
  font: inherit; font-weight: 600; color: var(--accent);
  text-decoration: underline dotted; text-underline-offset: 2px;
}
.tcb-tog:not(.tcb-open)::before { content: "… "; text-decoration: none; display: inline-block; }

/* definition tiles (a <dl> folded): the term and a one-line gist; an opened tile takes the full row */
.tcb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px; margin: 4px 0 6px; }
.tcb-col { border: 1px solid var(--tc-line); border-radius: 8px; background: var(--panel); min-width: 0; }
.tcb-col[hidden] { display: none; }
.tcb-col > summary { display: block; list-style: none; cursor: pointer; padding: 6px 10px 7px; }
.tcb-col > summary::-webkit-details-marker { display: none; }
.tcb-col > summary > b { display: block; font-size: 12px; color: var(--text); }   /* the label only — not the emphasis inside the gist */
.tcb-gist { display: block; font-size: 11.5px; line-height: 1.35; color: var(--muted); }   /* ≤ 70 chars, so ≤ 2 lines */
.tcb-col:hover { border-color: var(--accent); }
.tcb-col[open] { grid-column: 1 / -1; border-color: var(--accent); }
.tcb-col[open] > summary { padding-bottom: 2px; }
.tcb-col[open] .tcb-gist { display: none; }
.tcb-full { padding: 0 10px 8px; font-size: 12px; line-height: 1.5; color: var(--text); max-width: 1100px; }
.tcb-full p { margin: 0 0 4px; }
.tcb-full p:last-child { margin-bottom: 0; }


/* a sub-section folded to its heading and first sentence (data-sections) */
.tcb-sub { border: 1px solid var(--tc-line); border-radius: 8px; margin: 6px 0; background: var(--panel); }
.tcb-sub > summary { display: block; list-style: none; cursor: pointer; padding: 7px 12px 8px; }
.tcb-sub > summary::-webkit-details-marker { display: none; }
.tcb-sub > summary > b { display: block; font-size: 13px; color: var(--text); }
.tcb-sub > summary > b::before { content: "▸ "; color: var(--accent); }
.tcb-sub[open] > summary > b::before { content: "▾ "; }
.tcb-sub-gist { display: block; font-size: 12px; line-height: 1.45; color: var(--muted); margin-top: 1px; }
.tcb-sub[open] .tcb-sub-gist { display: none; }
.tcb-sub:hover { border-color: var(--accent); }
.tcb-sub-body { padding: 0 12px 10px; }
.tcb-sub-body > :first-child { margin-top: 0; }
