/**
 * I4 circular-financing hook exhibit — Bubble Watch / academic theme.
 * Paired with i4-financing-loop.js
 */

body.page-bubble-watch .i4-exhibit,
body.page-i4-hook .i4-exhibit {
  --i4-blue: #1d4ed8;
  --i4-pink: #c2185b;
  --i4-gold: #b45309;
  --i4-cloud: #dbeafe;
  --i4-lab: #fce7f3;
  --i4-chip: #fef3c7;
  --i4-ink: var(--hp-ink, #0b1220);
  --i4-body: var(--hp-body, #64748b);
  --i4-line: var(--hp-line, #e2e8f0);
  background: #fff;
  border: 1px solid var(--i4-line);
  padding: 18px 16px 16px;
  margin: 0 0 20px;
  box-shadow: none;
  border-radius: 0;
}

body.page-bubble-watch .i4-exhibit {
  margin-top: 4px;
}

.i4-exhibit-hd {
  margin-bottom: 14px;
}

.i4-exhibit-title {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  color: var(--i4-ink);
  margin: 0 0 6px;
  line-height: 1.35;
}

.i4-exhibit-dek {
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.55;
  color: var(--i4-body);
  margin: 0;
}

.i4-exhibit-dek strong {
  color: var(--i4-ink);
  font-weight: 600;
}

/* Headline ratio strip */
.i4-headlines {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--i4-line);
}

@media (max-width: 720px) {
  .i4-headlines {
    grid-template-columns: 1fr;
  }
}

.i4-stat {
  padding: 12px 14px;
  border: 1px solid var(--i4-line);
  background: #fff;
  border-radius: 0;
}

.i4-stat-val {
  display: block;
  font-family: var(--font-sans);
  font-size: 20px;
  font-weight: 700;
  color: var(--i4-ink);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  margin-bottom: 4px;
}

.i4-stat-val--down {
  color: var(--hp-sym-down, #dc2626);
}

.i4-stat-val--gold {
  color: var(--i4-gold);
}

.i4-stat-lbl {
  font-family: var(--font-sans);
  font-size: 11px;
  line-height: 1.45;
  color: var(--i4-body);
}

/* SVG canvas — fits content column like other Bubble Watch exhibits */
.i4-canvas-wrap {
  position: relative;
  width: 100%;
  max-width: 100%;
  overflow: visible;
  border: 1px solid var(--i4-line);
  background: #fafbfc;
  margin-bottom: 12px;
}

.i4-canvas-wrap svg {
  display: block;
  width: 100%;
  height: auto;
  min-height: 520px;
  aspect-ratio: 1280 / 720;
}

.i4-zone {
  fill: #fff;
  stroke: none;
}

.i4-zone--right {
  fill: #f8fafc;
}

.i4-rail-line {
  stroke: var(--i4-line);
  stroke-width: 1;
}

.i4-canvas-wrap svg text {
  font-family: var(--font-sans);
  user-select: none;
}

.i4-edge-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 18px;
  cursor: pointer;
}

.i4-edge-hit:focus {
  outline: none;
}

.i4-edge-hit:focus-visible + .i4-edge-visible,
.i4-edge-hit:hover + .i4-edge-visible,
.i4-edge-hit.i4-edge-active + .i4-edge-visible {
  stroke-width: 3.2;
  filter: drop-shadow(0 0 2px rgba(29, 78, 216, 0.35));
}

.i4-edge-visible {
  fill: none;
  pointer-events: none;
  transition: stroke-width 0.12s ease;
}

.i4-edge-dot {
  pointer-events: none;
}

.i4-node {
  cursor: default;
}

.i4-node-label {
  font-family: var(--font-mono, 'JetBrains Mono', ui-monospace, monospace);
  font-size: 10px;
  font-weight: 600;
  fill: var(--i4-ink);
  text-anchor: middle;
}

.i4-node--keystone rect {
  stroke-width: 1.8;
}

.i4-node-role {
  font-size: 9px;
  font-weight: 500;
  fill: var(--i4-body);
  text-anchor: middle;
}

.i4-rail-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  fill: var(--i4-body);
}

.i4-rail-label--zone {
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.06em;
  fill: #94a3b8;
  text-transform: uppercase;
}

.i4-edge-label {
  font-family: var(--font-sans, Inter, system-ui, sans-serif);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  fill: #0b1220;
  pointer-events: none;
}

.i4-edge-label-bg {
  fill: #fff;
  stroke: #0b1220;
  stroke-width: 1;
  pointer-events: none;
}

.i4-edge-label-wrap {
  pointer-events: none;
}

.i4-node-role--keystone {
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  fill: var(--i4-gold);
}

.i4-edge-label--invest {
  fill: var(--i4-blue);
}

.i4-edge-label--back {
  fill: var(--i4-pink);
}

.i4-edge-label--markup {
  fill: var(--i4-gold);
}

/* Provenance panel */
.i4-prov-panel {
  min-height: 88px;
  padding: 12px 14px;
  border: 1px solid var(--i4-line);
  background: var(--hp-paper, #fff);
  margin-bottom: 14px;
}

.i4-prov-panel.is-empty {
  background: var(--hp-grey, #eef1f6);
}

.i4-prov-hint {
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--i4-body);
  margin: 0;
  line-height: 1.5;
}

.i4-prov-edge {
  display: none;
}

.i4-prov-panel.has-edge .i4-prov-hint {
  display: none;
}

.i4-prov-panel.has-edge .i4-prov-edge {
  display: block;
}

.i4-prov-route {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--i4-ink);
  margin: 0 0 6px;
}

.i4-prov-amt {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--i4-body);
  margin: 0 0 8px;
}

.i4-prov-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.i4-prov-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 0;
}

.i4-prov-badge--primary {
  background: rgba(22, 163, 74, 0.12);
  color: #15803d;
  border: 1px solid rgba(22, 163, 74, 0.35);
}

.i4-prov-badge--reported {
  background: rgba(217, 119, 6, 0.12);
  color: #b45309;
  border: 1px solid rgba(217, 119, 6, 0.35);
}

.i4-prov-badge--soft {
  background: rgba(100, 116, 139, 0.12);
  color: #475569;
  border: 1px solid rgba(100, 116, 139, 0.35);
}

.i4-prov-note {
  font-family: var(--font-sans);
  font-size: 12px;
  line-height: 1.55;
  color: var(--i4-body);
  margin: 0;
}

.i4-prov-note a {
  color: var(--hp-blue, #1d4ed8);
  text-decoration: none;
  font-weight: 500;
}

.i4-prov-note a:hover {
  opacity: 0.85;
}

/* Legend */
.i4-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 18px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--i4-line);
}

.i4-legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--i4-body);
}

.i4-legend-swatch {
  width: 22px;
  height: 0;
  border-top-width: 2.5px;
  border-top-style: solid;
}

.i4-legend-swatch--invest {
  border-color: var(--i4-blue);
}

.i4-legend-swatch--back {
  border-color: var(--i4-pink);
}

.i4-legend-swatch--markup {
  border-top-style: dotted;
  border-color: var(--i4-gold);
}

.i4-legend-swatch--secured {
  border-top-style: dashed;
  border-color: var(--i4-gold);
}

.i4-legend-swatch--reported {
  border-top-style: dashed;
  border-color: var(--i4-body);
  opacity: 0.65;
}

.i4-fig-cap {
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.55;
  color: var(--i4-body);
  margin: 12px 0 0;
}

.i4-fig-cap b {
  color: var(--i4-ink);
  font-weight: 600;
}

/* Concentration mini-bar */
.i4-conc {
  margin: 0 0 14px;
}

.i4-conc-bar {
  display: flex;
  height: 22px;
  border: 1px solid var(--i4-line);
  overflow: hidden;
}

.i4-conc-seg {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--i4-ink);
  white-space: nowrap;
  min-width: 0;
}

.i4-conc-seg--msft {
  background: #93c5fd;
  flex: 52;
}

.i4-conc-seg--amzn {
  background: #fcd34d;
  flex: 44;
}

.i4-conc-seg--other {
  background: var(--hp-grey, #eef1f6);
  flex: 4;
}

.i4-conc-cap {
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--i4-body);
  margin: 6px 0 0;
}

/* Edge ledger — clean amount table (layoffs card parity) */
.i4-edge-ledger {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

@media (max-width: 980px) {
  .i4-edge-ledger {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .i4-edge-ledger {
    grid-template-columns: 1fr;
  }
}

.i4-ledger-col {
  border: 1px solid var(--i4-line);
  background: #fff;
  padding: 10px 10px 8px;
}

.i4-ledger-legend {
  border: 1px solid var(--i4-line);
  background: #fff;
  padding: 10px 12px;
  align-self: stretch;
}

.i4-ledger-legend .i4-legend {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

.i4-ledger-meta {
  border: 1px solid var(--i4-line);
  background: #fff;
  padding: 10px 12px;
  align-self: stretch;
}

.i4-ledger-meta-cap {
  margin: 0 0 10px;
  font-size: 12px;
  line-height: 1.55;
}

.i4-ledger-meta-source {
  font-family: var(--font-sans);
  font-size: 11px;
  line-height: 1.5;
  color: var(--i4-body);
  margin: 0;
}

@media (max-width: 980px) {
  .i4-ledger-legend,
  .i4-ledger-meta {
    grid-column: 1 / -1;
  }
}

.i4-ledger-col-title {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--i4-body);
  margin: 0 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--i4-line);
}

.i4-ledger-row {
  display: grid;
  grid-template-columns: 72px 1fr auto auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  text-align: left;
  padding: 7px 6px;
  border: 0;
  border-bottom: 1px solid #eef1f6;
  background: transparent;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.i4-ledger-row:last-child {
  border-bottom: 0;
}

.i4-ledger-row:hover,
.i4-ledger-row:focus,
.i4-ledger-row.i4-ledger-row--active {
  background: #f6f8fb;
  outline: none;
}

.i4-ledger-type {
  font-family: var(--font-mono, 'JetBrains Mono', ui-monospace, monospace);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--i4-body);
}

.i4-ledger-route {
  font-size: 11px;
  color: var(--i4-body);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.i4-ledger-amt {
  font-family: var(--font-mono, 'JetBrains Mono', ui-monospace, monospace);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.i4-ledger-amt--invest { color: var(--i4-blue); }
.i4-ledger-amt--back { color: var(--i4-pink); }
.i4-ledger-amt--markup { color: var(--i4-gold); }

.i4-ledger-badge {
  font-family: var(--font-mono, 'JetBrains Mono', ui-monospace, monospace);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  border: 1px solid var(--i4-line);
  white-space: nowrap;
}

.i4-ledger-badge--primary {
  background: rgba(22, 163, 74, 0.08);
  color: #15803d;
  border-color: rgba(22, 163, 74, 0.25);
}

.i4-ledger-badge--reported {
  background: rgba(217, 119, 6, 0.08);
  color: #b45309;
  border-color: rgba(217, 119, 6, 0.25);
}

.i4-ledger-badge--soft {
  background: #f1f5f9;
  color: #64748b;
}
