/* t2030-indicator-count - Adolescent Health "How many adolescent-specific
   indicators each country tracks" section body: one white card with the
   per-country indicator-count bar list. Section header and the dark navy
   (#21568C) backdrop are rendered by the master twig.

   Design colors matched to tokens where exact: #4D4D4D --clr-gray-dark,
   #21568C --clr-blue. No token for the rest - scoped below. */
.t2030-indicator-count {
  --ic-ink: var(--clr-gray-dark, #4d4d4d);
  --ic-muted: #6b6b6b;
  --ic-border: var(--clr-gray-light, #dbdbdb);
  --ic-navy: var(--clr-blue, #21568c);
  --ic-teal: var(--clr-teal-500, #1fa29c);
  --ic-track: #f3f5f7;
  --ic-seg-bg: #e3e3e3;
  --ic-row-hover: #eef2f6;
  --ic-bar: #d8a822;
  --ic-cols: minmax(96px, 200px) minmax(0, 1fr) 64px;
  --ic-th-bg: #efefef;

  min-width: 0;
  font-family: var(--primary-ff, 'Poppins', sans-serif);
  color: var(--ic-ink);
}

.t2030-indicator-count [hidden] {
  display: none !important;
}

/* ---------- top download ---------- */
.t2030-indicator-count__main {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.t2030-indicator-count__toolbar-top {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  height: 33px;
}

/* Site visualisation.css positions every .share-download-options absolutely
   (align-top: top -40px, right 0), which lifts the bar into the section
   header and the card up under it on Drupal pages. Keep it in flow here. */
.t2030-indicator-count__toolbar-top .share-download-options {
  position: static;
  inset: auto;
  padding: 0;
}

/* Site download chrome (share-download-options) is styled by the site; only
   the hover/focus reveal is needed for it to function standalone. Icon/
   label colour is NOT set here - reusing the exact same .icon--download/
   .text-icon-clr1 markup as MNCH (mnch/death, mnch/mortality) means the
   master twig's own section wrapper (.odd-even-style,
   base/odd-even-styles/odd-even-styles.css + elements/icons/icons.css)
   already supplies the right colour per section, light or dark, with no
   per-component override needed. */
.t2030-indicator-count .options-field {
  position: relative;
}

.t2030-indicator-count .maximize-popup,
.t2030-indicator-count .icon--download {
  cursor: pointer;
}

.t2030-indicator-count .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);
}

.t2030-indicator-count .options-field:hover .options-field-list,
.t2030-indicator-count .options-field:focus-within .options-field-list {
  display: block;
}

.t2030-indicator-count__card {
  min-width: 0;
  box-sizing: border-box;
  background: var(--clr-white, #fff);
  border: 0;
  border-radius: 0 20px 0 20px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.t2030-indicator-count__card-head {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
}

.t2030-indicator-count__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. */
.t2030-indicator-count__card-actions .visualization-actions-block {
  position: static;
  inset: auto;
}

.t2030-indicator-count__divider {
  width: 1px;
  height: 30px;
  background: var(--ic-navy);
}

.t2030-indicator-count__heading {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.t2030-indicator-count__title {
  margin: 0;
  font-size: var(--fs-20, 20px);
  line-height: 1.35;
  font-weight: var(--fw-bold, 700);
  color: var(--ic-ink);
}

.t2030-indicator-count__sub {
  margin: 0;
  font-size: var(--fs-14, 14px);
  line-height: 1.6;
  color: var(--ic-ink);
}

.t2030-indicator-count__chart {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ---------- sort radios ---------- */
.t2030-indicator-count__controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  align-items: center;
}

.t2030-indicator-count__seg-group {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--ic-seg-bg);
  border-radius: 999px;
}

/* The site's button.css sets `body button:hover, body button:focus` to
   teal bg + white text, which beats this one-class rule. Applying the
   base colours to :hover/:focus too keeps them; the state rules below
   (hover / checked / selected) still win. */
.t2030-indicator-count__seg-btn,
.t2030-indicator-count__seg-btn:hover,
.t2030-indicator-count__seg-btn:focus {
  white-space: nowrap;
  font: inherit;
  font-size: var(--fs-13, 13px);
  font-weight: var(--fw-semibold, 600);
  min-height: 34px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ic-ink);
  cursor: pointer;
}

.t2030-indicator-count__seg-btn[aria-checked="false"]:hover {
  background: var(--clr-white, #fff);
}

/* Teal like every other t2030 chart's Sort toggle (trend-panel, mortality,
   death, indicators, gender) - was navy (QC 452623). */
.t2030-indicator-count__seg-btn[aria-checked="true"] {
  background: var(--ic-teal);
  color: var(--clr-white, #fff);
}

.t2030-indicator-count__seg-btn:focus-visible {
  outline: 2px solid var(--ic-navy);
  outline-offset: 2px;
}

/* ---------- bar list ---------- */
.t2030-indicator-count__list {
  position: relative; /* tooltip anchor */
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.t2030-indicator-count__rows {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.t2030-indicator-count__head,
.t2030-indicator-count__row {
  display: grid;
  grid-template-columns: var(--ic-cols);
  gap: 12px;
}

.t2030-indicator-count__head {
  font-size: var(--fs-12, 12px);
  font-weight: var(--fw-bold, 700);
  color: var(--ic-muted);
  padding: 0 6px 4px;
}

.t2030-indicator-count__head-val {
  justify-self: end;
  text-align: right;
  white-space: nowrap;
}

.t2030-indicator-count__row {
  align-items: center;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: default;
}

.t2030-indicator-count__row:hover,
.t2030-indicator-count__row.is-active {
  background: var(--ic-row-hover);
}

/* ---------- tooltip ----------
   Replaces the old detail line above the list (its height changed per note
   and made the bars jump - QC 452630). Same look as the trend-panel /
   mortality tooltips; wider max-width since the example notes are long.
   Positioned by indicator-count.js (showTooltip) inside __list. */
.t2030-indicator-count__tooltip {
  position: absolute;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 160px;
  max-width: min(340px, calc(100% - 8px));
  box-sizing: border-box;
  padding: 8px 12px;
  background: var(--clr-white, #fff);
  border: 1px solid #dfe5ea;
  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(--ic-ink);
  pointer-events: none;
}

.t2030-indicator-count__tooltip-name {
  font-size: var(--fs-13, 13px);
}

.t2030-indicator-count__tooltip-val {
  font-weight: var(--fw-semibold, 600);
  color: #1d5c55;
}

.t2030-indicator-count__tooltip-note {
  margin-top: 2px;
  color: var(--ic-muted);
}

.t2030-indicator-count__row:focus-visible {
  outline: 2px solid var(--ic-navy);
  outline-offset: 1px;
}

.t2030-indicator-count__label {
  min-width: 0;
  font-size: var(--fs-14, 14px);
  line-height: 1.3;
  color: var(--ic-ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.t2030-indicator-count__track {
  position: relative;
  height: 16px;
  background: var(--ic-track);
  border-radius: 2px;
}

.t2030-indicator-count__bar {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  background: var(--ic-bar);
  border-radius: 2px;
  transition: width 0.25s ease;
}

.t2030-indicator-count__val {
  font-size: var(--fs-14, 14px);
  font-weight: var(--fw-bold, 700);
  text-align: right;
  color: var(--ic-ink);
}

.t2030-indicator-count__source {
  margin: 0;
  font-size: var(--fs-12, 12px);
  line-height: 1.6;
  color: var(--ic-muted);
}

/* ---------- table ---------- */
.t2030-indicator-count__table-wrap {
  overflow: auto;
  /* border: 1px solid var(--ic-border); */
  /* border-radius: 8px; */
}

.t2030-indicator-count__table {
  width: 100%;
  border-collapse: collapse;
}

.t2030-indicator-count__table th,
.t2030-indicator-count__table td {
  text-align: left;
}

.t2030-indicator-count__table thead th {
  position: sticky;
  top: 0;
}

.t2030-indicator-count__table .is-num {
  text-align: right;
}

/* ---------- enlarge popup (site chrome; only functional rules here) ---------- */
.t2030-indicator-count__popup {
  display: none;
}

.t2030-indicator-count__popup.is-active {
  display: flex;
}

.t2030-indicator-count__popup .popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 35, 0.55);
  z-index: 55;
}

.t2030-indicator-count__popup .popup-tab-content {
  display: none;
}

.t2030-indicator-count__popup .popup-tab-content.is-active {
  display: block;
}

/* indicator-count.js moves .t2030-indicator-count__controls into the
   popup's own Download row on enlarge (and back on close), so it sits
   outside .popup-content's scroll area instead of scrolling away with
   the chart rows. Lay the two out as one row: controls on the left, the
   existing Download link on the right. */
.t2030-indicator-count__popup .popup-download-options {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* justify-content:space-between (instead of this) only positions the
   Download link right when .t2030-indicator-count__controls is also
   present - on the Table tab, .controls gets hidden (see setView),
   leaving it as the only flex child, which space-between would then
   place at flex-start (left) instead. margin-left:auto keeps it pinned
   right regardless. */
.t2030-indicator-count__popup .popup-download-options > ul {
  margin-left: auto;
}

.t2030-indicator-count__popup .custom-modal-close-field {
  cursor: pointer;
}

body.indicator-count-lock-scroll {
  overflow: hidden;
}

@media (max-width: 600px) {
  .t2030-indicator-count {
    --ic-cols: minmax(84px, 120px) minmax(0, 1fr) 36px;
  }

  .t2030-indicator-count__card { padding: 18px 14px; }
  .t2030-indicator-count__seg-btn { padding: 0 12px; }
  .t2030-indicator-count__head,
  .t2030-indicator-count__row { gap: 8px; }
  .t2030-indicator-count__label,
  .t2030-indicator-count__val { font-size: var(--fs-13, 13px); }
  .t2030-indicator-count__divider { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .t2030-indicator-count__bar {
    transition: none;
  }
}
