/* equity - "The poorest children face the highest risk": wealth-quintile
   dot-range chart + interactive avoidable-deaths estimate, each card ending
   with an insight note and its source.
   Section header and the blue (#21568C) section backdrop come from the
   master twig - not part of this component.

   Colors: #4D4D4D -> --clr-gray-dark, #DBDBDB -> --clr-gray-light,
   #1FA29C -> --clr-teal-500, #21568C -> --clr-blue, #F8B323 ->
   --clr-yellow-orange (exact). No token for poorest-red #ED6E68, mid-grey
   #B3B3B3 (closest --clr-neutral-440 #b7b7b7), teal-ink #1D5C55 or table
   header #EFEFEF - minted locally. */
.equity {
  --equity-ink: var(--clr-gray-dark, #4d4d4d);
  --equity-border: var(--clr-gray-light, #dbdbdb);
  --equity-teal: var(--clr-teal-500, #1fa29c);
  --equity-teal-ink: #1d5c55;
  --equity-blue: var(--clr-blue, #21568c);
  --equity-yellow: var(--clr-yellow-orange, #f8b323);
  --equity-poor: #ed6e68;
  --equity-mid: #b3b3b3;
  --equity-th-bg: #efefef;
  --equity-label-w: 110px;

  display: flex;
  flex-direction: column;
  gap: 24px;
  font-family: var(--primary-ff, 'Poppins', sans-serif);
  color: var(--equity-ink);
}

.equity *,
.equity *::before,
.equity *::after {
  box-sizing: border-box;
}

/* ---------- cards ---------- */
.equity__cards {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: stretch;
}

.equity__card {
  flex: 1 1 420px;
  min-width: 0;
  background: var(--clr-white, #fff);
  border: 1px solid var(--equity-border);
  border-radius: 0 24px 0 24px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.equity__card--gap {
  border-radius: 24px 0 24px 0;
}

.equity__card-head {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
}

.equity__card-titles {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.equity__card-title {
  margin: 0;
  font-size: var(--fs-18, 18px);
  line-height: 1.35;
  font-weight: var(--fw-bold, 700);
  color: var(--equity-teal-ink);
}

.equity__card-title--teal {
  color: var(--equity-teal);
}

.equity__card-sub {
  margin: 0;
  font-size: var(--fs-14, 14px);
  line-height: 1.5;
  color: var(--equity-ink);
}

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

/* Site visualisation.css (loaded on Drupal pages) positions every
   .visualization-actions-block absolutely (top/right of its card). Here the
   Enlarge button sits in the card-head flex row, so keep it in flow. */
.equity__card-actions .visualization-actions-block {
  position: static;
  inset: auto;
}

.equity__divider {
  width: 1px;
  height: 30px;
  background: var(--equity-teal);
}

.equity .maximize-popup {
  cursor: pointer;
}

.equity__quint-section {
  display: flex;
  flex-direction: column;
  gap: 18px;
  flex: 1 1 auto;
}

/* ---------- quintile chart ---------- */
.equity__quint-chart {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

.equity__quint-chart.is-narrow {
  --equity-label-w: 84px;
}

.equity__legend {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  font-size: var(--fs-13, 13px);
  color: var(--equity-ink);
}

.equity__legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.equity__legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  flex: none;
}

.equity__legend-dot--poor { background: var(--equity-poor); }
.equity__legend-dot--mid { background: var(--equity-mid); }
.equity__legend-dot--rich { background: var(--equity-teal); }

.equity__rows {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 12px 0 4px;
}

.equity__row {
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: 6px;
  outline-offset: 2px;
}

.equity__row:focus-visible {
  outline: 2px solid var(--equity-teal);
}

.equity__row-label {
  flex: 0 0 var(--equity-label-w);
  font-size: var(--fs-14, 14px);
  font-weight: var(--fw-semibold, 600);
  text-align: right;
  color: var(--equity-ink);
}

.equity__row-track {
  position: relative;
  flex: 1 1 auto;
  height: 44px;
  /* keeps the end dots / value labels inside the card */
  margin-right: 14px;
}

.equity__row-line {
  position: absolute;
  top: 21px;
  height: 3px;
  background: var(--equity-border);
}

.equity__dot {
  position: absolute;
  top: 15px;
  margin-left: -7.5px;
  width: 15px;
  height: 15px;
  border-radius: 999px;
  border: 2px solid var(--clr-white, #fff);
  cursor: default;
  transition: transform 0.12s ease;
}

.equity__dot:hover {
  transform: scale(1.25);
}

.equity__row-hi,
.equity__row-lo {
  position: absolute;
  transform: translateX(-50%);
  font-size: var(--fs-12, 12px);
  font-weight: var(--fw-bold, 700);
  line-height: 1.2;
  white-space: nowrap;
  pointer-events: none;
}

.equity__row-hi {
  top: 0;
  color: var(--equity-poor);
}

.equity__row-lo {
  bottom: -2px;
  color: var(--equity-teal-ink);
}

.equity__ticks {
  display: flex;
  height: 20px;
}

.equity__ticks-spacer {
  flex: 0 0 calc(var(--equity-label-w) + 12px);
}

.equity__ticks-track {
  position: relative;
  flex: 1 1 auto;
  margin-right: 14px;
  border-top: 1px solid var(--equity-border);
}

.equity__tick {
  position: absolute;
  top: 4px;
  transform: translateX(-50%);
  font-size: var(--fs-11, 11px);
  color: var(--equity-ink);
}

/* ---------- tooltip ---------- */
.equity__tip {
  position: fixed;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 180px;
  max-width: 260px;
  padding: 8px 12px;
  background: var(--clr-white, #fff);
  border: 1px solid var(--equity-border);
  border-radius: 6px;
  box-shadow: 0 6px 18px rgba(30, 50, 80, 0.18);
  font-size: var(--fs-12, 12px);
  line-height: 1.45;
  color: var(--equity-ink);
  pointer-events: none;
}

.equity__tip[hidden] {
  display: none;
}

.equity__tip-name {
  font-size: var(--fs-13, 13px);
  margin-bottom: 2px;
}

.equity__tip-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.equity__tip-row.is-current {
  font-weight: var(--fw-semibold, 600);
  color: var(--equity-teal-ink);
}

.equity__tip-swatch {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  flex: none;
}

.equity__tip-label {
  flex: 1 1 auto;
}

.equity__tip-val {
  font-weight: var(--fw-bold, 700);
}

.equity__tip-note {
  margin-top: 4px;
  color: var(--clr-gray-600, #666);
}

/* ---------- table ---------- */
.equity__table-wrap {
  overflow: auto;
  /* border: 1px solid var(--equity-border); */
  /* border-radius: 8px; */
}

.equity__table-wrap[hidden] {
  display: none;
}

.equity__table {
  width: 100%;
  border-collapse: collapse;
}

.equity__table th,
.equity__table td {
  text-align: left;
}

.equity__table thead th {
  position: sticky;
  top: 0;
}

.equity__table .is-num {
  text-align: right;
}

/* ---------- source footnotes ---------- */
.equity__source {
  margin: 0;
  padding-top: 14px;
  border-top: 1px solid var(--equity-border);
  font-size: var(--fs-13, 13px);
  line-height: 1.55;
  color: var(--equity-ink);
}

/* ---------- avoidable-deaths estimate ---------- */
.equity__control {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--equity-border);
}

.equity__control-label {
  font-size: var(--fs-15, 15px);
  line-height: 1.55;
  color: var(--equity-ink);
}

.equity__control-label strong {
  color: var(--equity-teal-ink);
}

.equity__slider {
  width: 100%;
  min-height: 32px;
  margin: 0;
  accent-color: var(--equity-teal);
  cursor: pointer;
}

.equity__control-help {
  margin: 0;
  font-size: var(--fs-13, 13px);
  line-height: 1.5;
  color: var(--equity-ink);
}

.equity__result {
  flex: 1 1 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 20px 24px;
}

.equity__result-text {
  flex: 1 1 200px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.equity__result-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.equity__avoided {
  margin: 0;
  font-size: var(--fs-40, 40px);
  line-height: 1.05;
  font-weight: var(--fw-bold, 700);
  color: var(--equity-blue);
}

.equity__avoided-label {
  margin: 0;
  font-size: var(--fs-15, 15px);
  color: var(--equity-ink);
}

.equity__split {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: var(--fs-14, 14px);
  color: var(--equity-ink);
}

.equity__split-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.equity__split-item strong {
  font-weight: var(--fw-bold, 700);
}

.equity__split-swatch {
  flex: none;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  transform: translateY(1px);
}

.equity__split-swatch--nb { background: var(--equity-yellow); }
.equity__split-swatch--ch { background: var(--equity-blue); }

.equity__donut {
  flex: 0 0 184px;
  position: relative;
  width: 184px;
  height: 184px;
  margin: 0 auto;
}

.equity__donut-svg {
  display: block;
}

.equity__donut-svg circle {
  transition: stroke-dasharray 0.25s ease, stroke-dashoffset 0.25s ease;
}

.equity__donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.equity__donut-pct {
  font-size: 30px;
  line-height: 1;
  font-weight: var(--fw-bold, 700);
  color: var(--equity-blue);
}

.equity__donut-caption {
  margin-top: 4px;
  font-size: 11.5px;
  line-height: 1.3;
  text-align: center;
  color: var(--equity-ink);
}

/* ---------- card footer: insight note + source (pinned to the card
   bottom; equal min-height so both cards' footers line up) ---------- */
.equity__card-foot {
  margin-top: auto;
  min-height: 210px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.equity__note {
  margin: 0;
  padding-top: 16px;
  border-top: 2px solid var(--equity-yellow);
  font-size: var(--fs-14, 14px);
  line-height: 1.65;
  color: var(--equity-ink);
}

.equity__note p {
  margin: 0;
}

.equity__note p + p {
  margin-top: 0.6em;
}

.equity__note strong {
  font-weight: var(--fw-bold, 700);
}

/* ---------- download dropdown (popup) ---------- */
.equity .options-field {
  position: relative;
}

.equity .icon--download {
  cursor: pointer;
}

.equity .options-field-list {
  display: none;
  /* Site chrome positions this flush against the download icon (top:100%,
     no gap) - adds visible space between them. */
  margin-top: var(--sp2, 8px);
}

.equity .options-field:hover .options-field-list,
.equity .options-field:focus-within .options-field-list {
  display: block;
}

/* ---------- enlarge popup (site chrome; only functional rules here) ---------- */
.equity__popup {
  display: none;
}

.equity__popup.is-active {
  display: flex;
}

.equity__popup .popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 35, 0.55);
  z-index: 55;
}

.equity__popup .popup-tab-content {
  display: none;
}

.equity__popup .popup-tab-content.is-active {
  display: block;
}

.equity__popup .custom-modal-close-field {
  cursor: pointer;
}

body.equity-lock-scroll {
  overflow: hidden;
}

@media (max-width: 559px) {
  .equity__card {
    padding: 20px 16px;
  }

  .equity__card-foot {
    min-height: 0;
  }

  .equity__avoided {
    font-size: 34px;
  }
}
