/* ida - "GFF partner countries are investing more of their IDA in women,
   children and adolescents": diverging bar + stat tiles + grants-to-
   financing flow bars. Bespoke layout (no shared chart-kit chrome, and no
   other existing component shares this shape) - section header and
   backdrop come from the master twig, not part of this component.

   Values below are the mockup's own cascade-resolved (last `:root`-block-
   wins) computed style for #ida's markup, not an approximation: card
   border:0 + border-radius 16px 16px 0 16px + box-shadow (its "GFF Data
   Portal live palette" layer, `.card{border:0;border-radius:var(--radius)
   var(--radius) 0 var(--radius)}` + the refinement layer's box-shadow),
   title color #0f6f73 (`.card h3{color:#0f6f73}`), body/sub copy on
   var(--muted), diverging-bar arrowhead (::after border-triangle on the
   "up" bar only), 230/1fr/130 flow-row columns, etc. Colors reuse the
   shared --hf-* tokens (../shared/css/hf-charts.css), which are themselves
   literal hex taken verbatim from that same resolved mockup palette. */
.hf-ida {
  font-family: var(--primary-ff, 'Poppins', sans-serif);
  color: var(--hf-ink, #2b3440);
}

.hf-ida__layout {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 20px;
}

.hf-ida__card {
  background: var(--hf-surface, #ffffff);
  border: 0;
  border-radius: var(--hf-radius, 16px) var(--hf-radius, 16px) 0 var(--hf-radius, 16px);
  box-shadow: var(--hf-shadow, 0 6px 22px -14px rgba(20, 48, 79, .35));
  padding: 24px;
  min-width: 0;
}

.hf-ida__card--flow {
  grid-column: 1 / -1;
}

/* Title row: title/sub stay stacked (same as before - title-group is
   just a block wrapper, no flex of its own needed), card-actions
   (divider + Enlarge) sits to its right, same pattern as every other HF
   widget's own __title-row/__card-actions/__divider. */
.hf-ida__title-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.hf-ida__title-group {
  min-width: 0;
}

.hf-ida__card-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: none;
}

.hf-ida__card-actions .visualization-actions-block {
  position: static;
  inset: auto;
}

.hf-ida__divider {
  width: 1px;
  height: 30px;
  background: var(--clr-teal-dark, #0a544f);
}

.hf-ida .maximize-popup {
  cursor: pointer;
}

.hf-ida__title {
  margin: 0;
  font-size: var(--fs-20, 20px);
  line-height: 1.3;
  font-weight: var(--fw-bold, 700);
  color: var(--clr-teal-dark, #0a544f);
}

.hf-ida__sub {
  margin: 5px 0 0;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--hf-muted, #6b7786);
}

.hf-ida__source {
  margin: 14px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--hf-grid, #e6eaf0);
  font-size: var(--fs-13, 13px);
  line-height: 1.55;
  color: var(--hf-ink-2, #46515f);
}

.hf-ida__source b {
  color: var(--hf-ink-2, #46515f);
  font-weight: 600;
}

/* ---------- diverging bar ---------- */
.hf-ida__diverge {
  margin: 26px 0 8px;
  position: relative;
}

.hf-ida__diverge-row {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}

.hf-ida__diverge-label b {
  display: block;
  font-size: 15px;
  color: var(--hf-ink, #2b3440);
}

.hf-ida__diverge-label span {
  font-size: 12.5px;
  color: var(--hf-muted, #6b7786);
}

/* margin-right reserves room for the "up" bar's arrowhead, which pokes
   `right:-18px` past the bar's OWN right edge (see .is-up::after below) -
   when a series' value sits at the domain max, the bar's right edge
   coincides with the track's right edge, so the arrow pokes 18px past
   the track itself. In-page that overflow lands harmlessly in the
   card's own padding; inside the Enlarge popup there isn't always that
   much room before the popup's rounded corner/edge, clipping it. Margin
   (not padding) so the bar's own 0-100% positioning math, which resolves
   against the track's box, actually shrinks instead of still reaching
   the old unreserved edge. */
.hf-ida__diverge-track {
  position: relative;
  height: 64px;
  margin-right: 18px;
  background: repeating-linear-gradient(90deg, transparent 0 calc(10% - 1px), var(--hf-grid, #e6eaf0) calc(10% - 1px) 10%);
}

.hf-ida__diverge-zero {
  position: absolute;
  top: -10px;
  bottom: -10px;
  width: 2px;
  background: var(--hf-ink-2, #46515f);
}

.hf-ida__diverge-bar {
  position: absolute;
  top: 8px;
  bottom: 8px;
  display: flex;
  align-items: center;
}

.hf-ida__diverge-bar.is-up {
  background: linear-gradient(90deg, var(--hf-brand, #1f4e80), var(--hf-brand-2, #2f6fb3));
  border-radius: 0 10px 10px 0;
  justify-content: flex-end;
}

.hf-ida__diverge-bar.is-up::after {
  content: "";
  position: absolute;
  right: -18px;
  border: 24px solid transparent;
  border-left: 18px solid var(--hf-brand-2, #2f6fb3);
  border-right: 0;
}

.hf-ida__diverge-bar.is-down {
  background: linear-gradient(270deg, var(--hf-coral, #ef6f6c), var(--hf-coral-2, #f39a97));
  border-radius: 10px 0 0 10px;
}

.hf-ida__diverge-bar span {
  font-family: var(--primary-ff, 'Poppins', sans-serif);
  font-weight: var(--fw-bold, 700);
  font-size: 26px;
  color: #fff;
  padding: 0 16px;
}

.hf-ida__diverge-axis {
  position: relative;
  height: 18px;
  margin-left: 226px;
}

.hf-ida__diverge-axis span {
  position: absolute;
  transform: translateX(-50%);
  font-size: 11.5px;
  color: var(--hf-muted, #6b7786);
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* ---------- stat tiles ---------- */
.hf-ida__side {
  display: grid;
  gap: 20px;
}

.hf-ida__tile {
  background: var(--hf-surface, #ffffff);
  border-radius: var(--hf-radius, 16px) var(--hf-radius, 16px) 0 var(--hf-radius, 16px);
  padding: 22px 24px;
  border-left: 5px solid var(--hf-lime, #f5b324);
}

.hf-ida__tile--highlight {
  background: linear-gradient(135deg, var(--hf-navy, #14304f), var(--hf-brand-2, #2f6fb3));
  color: #fff;
  border-left-color: var(--hf-lime, #f5b324);
}

/* Leverage tile's dot row: `leverage.grant` lime dots, an arrow, then
   `leverage.linked` plain dots - the "1 : 7" ratio drawn out literally.
   The arrow gets its own margin on top of the row's flex `gap`, so it
   sits with visibly more space around it than dot-to-dot spacing - same
   as the mockup's own `.lev em{margin:0 2px}` on top of `.lev{gap:5px}`. */
.hf-ida__lev {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 10px;
}

.hf-ida__lev-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--hf-brand, #1f4e80);
}

.hf-ida__lev-dot--lime {
  background: var(--hf-lime, #f5b324);
}

.hf-ida__lev-arrow {
  font-style: normal;
  color: var(--hf-muted, #6b7786);
  margin: 0 2px;
}

.hf-ida__tile-value {
  font-family: var(--primary-ff, 'Poppins', sans-serif);
  font-weight: var(--fw-bold, 700);
  font-size: var(--fs-40, 40px);
  line-height: 1.05;
  color: var(--hf-brand, #1f4e80);
}

.hf-ida__tile--highlight .hf-ida__tile-value {
  color: var(--hf-lime, #f5b324);
}

.hf-ida__tile-text {
  font-size: 13.5px;
  margin: 6px 0 0;
  line-height: 1.45;
}

/* The committed tile (.hf-ida__tile--highlight) sits on a navy/brand-2
   gradient - .hf-footnote-ref's shared default color (hf-charts.css) is
   that same brand-2 blue, which would nearly vanish against it, so this
   tile overrides the ref to white; the plain-surface leverage tile keeps
   the shared blue as-is. */
.hf-ida__tile--highlight .hf-footnote-ref {
  color: var(--clr-white, #fff) !important;
}

/* ---------- flow bars ---------- */
.hf-ida__flow {
  margin: 18px 0 6px;
}

.hf-ida__flow-inner {
  display: grid;
  gap: 14px;
}

.hf-ida__flow-row {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr) 130px;
  gap: 14px;
  align-items: center;
}

.hf-ida__flow-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--hf-ink, #2b3440);
}

.hf-ida__flow-bar {
  height: 30px;
  border-radius: 0 8px 8px 0;
  background: linear-gradient(90deg, var(--hf-brand, #1f4e80), var(--hf-brand-2, #2f6fb3));
}

/* Rows 1-2 ("GFF grant funding mobilized", "GFF co-financing grants
   committed") are lime in the mockup (its `.fb.g`); only row 1, the
   broadest/least-precise figure of the three, is also faded to .55
   opacity. Row 3 ("IDA and IBRD financing linked...") stays the plain
   blue-gradient `.fb` above. See js/ida.js's renderFlow. */
.hf-ida__flow-row.is-lime .hf-ida__flow-bar {
  background: var(--hf-lime, #f5b324);
}

.hf-ida__flow-row.is-faded .hf-ida__flow-bar {
  background: var(--hf-lime, #f5b324);
  opacity: .55;
}

.hf-ida__flow-value {
  font-family: var(--primary-ff, 'Poppins', sans-serif);
  font-size: 17px;
  color: var(--hf-brand, #1f4e80);
}

.hf-ida__note {
  margin: 14px 0 0;
  padding-left: 14px;
  border-left: 3px solid var(--toggler-active-bg, #00413c);
  font-size: var(--fs-14, 14px);
  line-height: 1.65;
  color: var(--hf-ink, #2b3440);
}

.hf-ida__footnotes {
  margin: 14px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--hf-grid, #e6eaf0);
  font-size: 12px;
  line-height: 1.6;
  color: var(--hf-ink-2, #46515f);
}

.hf-ida__footnotes[hidden] {
  display: none;
}

@media (max-width: 820px) {
  .hf-ida__layout {
    grid-template-columns: 1fr;
  }
}

/* Below 767, the label column (210/230px) plus the bar track stop having
   room to breathe - same fix/shape as t2030-trend-panel's own
   .chart/.chart-inner pair (shared-components/trend-panel/css/
   trend-panel.css) for its row+track layout: float the inner content at
   its natural width and let the OUTER mount scroll to it horizontally,
   instead of reflowing the row (which would squeeze the track down to
   nothing) or shrinking text to fit. Capped height + vertical scroll too,
   so a long diverge/flow list scrolls inside the card instead of pushing
   the rest of the page down. Scoped to each card (not the bare mount
   class) - js/ida.js's wirePopups() moves this same mount into its
   Enlarge popup on open, where the popup already lays the chart out
   full-size; unscoped, this would follow it in and fight that layout. */
@media (max-width: 767px) {
  .hf-ida__card--diverge .hf-ida__diverge {
    max-height: 350px;
    overflow-x: auto;
    overflow-y: auto;
  }
  .hf-ida__card--diverge .hf-ida__diverge-inner {
    min-width: 600px;
  }
  .hf-ida__card--flow .hf-ida__flow {
    max-height: 350px;
    overflow-x: auto;
    overflow-y: auto;
  }
  .hf-ida__card--flow .hf-ida__flow-inner {
    min-width: 600px;
  }
}
