/* t2030-trend-panel - shared key-theme trend card (dot/dumbbell chart + insights
   aside). Section header and backdrop are rendered by the master twig.

   Design colors matched to tokens where exact: #4D4D4D --clr-gray-dark,
   #DBDBDB --clr-gray-light, #21568C --clr-blue, #1FA29C --clr-teal-500,
   #F8B323 --clr-yellow-orange. No token for the rest - scoped below. */
.t2030-trend-panel {
  --tp-ink: var(--clr-gray-dark, #4d4d4d);
  --tp-muted: #6b6b6b;
  --tp-border: var(--clr-gray-light, #dbdbdb);
  --tp-navy: var(--clr-blue, #21568c);
  --tp-teal: var(--clr-teal-500, #1fa29c);
  --tp-title: #15766f;
  --tp-gold: var(--clr-yellow-orange, #f8b323);
  --tp-rose: #ed6e68;
  --tp-seg-bg: #e3e3e3;
  --tp-row-hover: #edf5f5;
  --tp-aside-bg: #f3f5f7;
  --tp-th-bg: #efefef;
  --tp-name-w: 148px;
  --tp-fcv-w: 12px;
  --tp-val-w: 56px;
  --tp-name-fs: 12px;

  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  font-family: var(--primary-ff, 'Poppins', sans-serif);
  color: var(--tp-ink);
}

/* Light section backdrop (#EEF2F6) - design uses a matching aside tint. */
.t2030-trend-panel--on-light {
  --tp-aside-bg: #eef2f6;
}

.t2030-trend-panel [hidden] {
  display: none !important;
}

/* ---------- top download ---------- */
.t2030-trend-panel__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-trend-panel__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 - same
   mechanism regardless of this component's own `backdrop` modifier. */
.t2030-trend-panel .options-field {
  position: relative;
}

.t2030-trend-panel .maximize-popup,
.t2030-trend-panel .icon--download {
  cursor: pointer;
}

.t2030-trend-panel .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-trend-panel .options-field:hover .options-field-list,
.t2030-trend-panel .options-field:focus-within .options-field-list {
  display: block;
}

/* ---------- card ---------- */
.t2030-trend-panel__card {
  background: var(--clr-white, #fff);
  border: 0;
  border-radius: 0 24px 0 24px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
  box-sizing: border-box;
}

.t2030-trend-panel__title-row {
  display: flex;
  /* nowrap - see gender.css's own comment on this exact rule: a wrapping
     outer row can strand .card-actions alone on its own line, where
     justify-content:space-between collapses it to the start (left)
     instead of staying pinned right. .title-group wraps title/sub
     internally instead. */
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.t2030-trend-panel__title-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 0;
  min-width: 0;
}

.t2030-trend-panel__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 title-row flex row, so keep it in flow. */
.t2030-trend-panel__card-actions .visualization-actions-block {
  position: static;
  inset: auto;
}

.t2030-trend-panel__divider {
  width: 1px;
  height: 30px;
  background: var(--tp-teal);
}

.t2030-trend-panel__title {
  margin: 0;
  font-size: var(--fs-20, 20px);
  line-height: 1.35;
  font-weight: var(--fw-bold, 700);
  color: var(--tp-title);
}

.t2030-trend-panel__sub {
  margin: 0 0 0 16px;
  padding-left: 16px;
  border-left: 2px solid var(--tp-teal);
  font-size: var(--fs-14, 14px);
  line-height: 1.5;
  color: var(--tp-ink);
}

.t2030-trend-panel__body {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: flex-start;
}

.t2030-trend-panel__chart-col {
  flex: 2 1 460px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  container-type: inline-size;
}

/* ---------- sort / show ---------- */
.t2030-trend-panel__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 32px;
}

.t2030-trend-panel__seg {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.t2030-trend-panel__seg--select {
  display: none;
}

.t2030-trend-panel__seg-label {
  font-size: var(--fs-14, 14px);
  font-weight: var(--fw-bold, 700);
  color: var(--tp-ink);
}

.t2030-trend-panel__seg-group {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--tp-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-trend-panel__seg-btn,
.t2030-trend-panel__seg-btn:hover,
.t2030-trend-panel__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(--tp-ink);
  cursor: pointer;
}

.t2030-trend-panel__seg-btn[aria-checked="false"]:hover {
  background: var(--clr-white, #fff);
}

.t2030-trend-panel__seg-btn[aria-checked="true"] {
  background: var(--tp-teal);
  color: var(--clr-white, #fff);
}

.t2030-trend-panel__select-wrap {
  position: relative;
  display: flex;
}

.t2030-trend-panel__select {
  font: inherit;
  font-size: var(--fs-14, 14px);
  font-weight: var(--fw-bold, 700);
  min-height: 40px;
  padding: 0 42px 0 18px;
  border: 0;
  border-radius: 999px;
  background: var(--tp-teal);
  color: var(--clr-white, #fff);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.t2030-trend-panel__select option {
  color: var(--tp-ink);
  background: var(--clr-white, #fff);
}

.t2030-trend-panel__select-chevron {
  position: absolute;
  right: 14px;
  top: 50%;
  margin-top: -9px;
  color: var(--clr-white, #fff);
  pointer-events: none;
}

.t2030-trend-panel__seg-btn:focus-visible,
.t2030-trend-panel__select:focus-visible,
.t2030-trend-panel__row:focus-visible {
  outline: 2px solid var(--tp-navy);
  outline-offset: 2px;
}

@container (max-width: 720px) {
  .t2030-trend-panel__seg--radio { display: none; }
  .t2030-trend-panel__seg--select { display: flex; }
}

/* ---------- sort note + legend ---------- */
.t2030-trend-panel__sort-note {
  margin: 0;
  font-size: var(--fs-13, 13px);
  line-height: 1.5;
  color: var(--tp-ink);
}

.t2030-trend-panel__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  font-size: var(--fs-13, 13px);
  color: var(--tp-ink);
}

.t2030-trend-panel__legend-extra {
  display: contents;
}

/* Baseline: an empty swatch's baseline is its bottom edge, so each marker
   sits bottom-aligned on the label text's baseline (QC 452653). */
.t2030-trend-panel__legend-item {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
}

.t2030-trend-panel__swatch {
  flex: none;
  display: inline-block;
  box-sizing: border-box;
}

.t2030-trend-panel__swatch--earlier,
.t2030-trend-panel__swatch--improved,
.t2030-trend-panel__swatch--worsened {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.t2030-trend-panel__swatch--earlier {
  border: 2px solid var(--tp-navy);
  background: var(--clr-white, #fff);
}

.t2030-trend-panel__swatch--improved { background: var(--tp-navy); }
.t2030-trend-panel__swatch--worsened { background: var(--tp-rose); }

/* Band swatch - background colour set inline from the JSON. */
.t2030-trend-panel__swatch--band {
  width: 10px;
  height: 10px;
  border: 1px solid var(--tp-border);
}

/* Reference-line swatch - border colour set inline from the JSON. */
.t2030-trend-panel__swatch--ref {
  width: 16px;
  height: 0;
  border-top: 2px dashed var(--tp-gold);
}

.t2030-trend-panel__swatch--fcv {
  width: 7px;
  height: 7px;
  background: var(--tp-teal);
  /* Lift so the rotated diamond's bottom point sits on the baseline. */
  transform: translateY(-1.5px) rotate(45deg);
}

/* ---------- chart ---------- */
.t2030-trend-panel__chart {
  border: 1px solid var(--tp-border);
  border-radius: 8px;
  /* 24px top (was 12px) - .t2030-trend-panel__band-label sits at
     top:-12px relative to .chart-inner, which starts right after this
     padding; at 12px the two exactly cancelled out, landing the "HIGH"/
     "VERY HIGH" labels flush against this card's own top border with no
     clearance from the legend row above it (reported, screenshot). Now
     12px of clear space above the label instead of 0. */
  padding: 24px 8px 0 0;
  background: var(--clr-white, #fff);
}

.t2030-trend-panel__chart-inner {
  position: relative;
}

/* Bands + reference lines, aligned with the row tracks. */
.t2030-trend-panel__overlay {
  position: absolute;
  top: 0;
  bottom: 26px;
  left: calc(var(--tp-name-w) + var(--tp-fcv-w));
  right: var(--tp-val-w);
  pointer-events: none;
}

.t2030-trend-panel__band {
  position: absolute;
  top: 0;
  bottom: 0;
}

.t2030-trend-panel__band-label {
  position: absolute;
  top: -12px;
  left: 4px;
  font-size: var(--fs-10, 10px);
  line-height: 1.2;
  font-weight: var(--fw-bold, 700);
  letter-spacing: 0.06em;
  color: var(--tp-muted);
  white-space: nowrap;
}

.t2030-trend-panel__ref {
  position: absolute;
  top: -6px;
  bottom: 0;
  border-left: 2px dashed var(--tp-gold);
}

.t2030-trend-panel__spacer {
  height: 14px;
}

.t2030-trend-panel__rows {
  position: relative;
  display: flex;
  flex-direction: column;
}

.t2030-trend-panel__row {
  display: flex;
  align-items: center;
  height: 22px;
  padding-left: 10px;
  border-radius: 4px;
  cursor: default;
}

.t2030-trend-panel__row:hover,
.t2030-trend-panel__row:focus-visible {
  background: var(--tp-row-hover);
}

.t2030-trend-panel__row-name {
  flex: 0 0 var(--tp-name-w);
  padding-right: 6px;
  box-sizing: border-box;
  text-align: right;
  font-size: var(--tp-name-fs);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.t2030-trend-panel__row-fcv-cell {
  flex: 0 0 var(--tp-fcv-w);
  display: flex;
  justify-content: center;
}

.t2030-trend-panel__row-fcv {
  width: 6px;
  height: 6px;
  background: var(--tp-teal);
  transform: rotate(45deg);
}

.t2030-trend-panel__row-track {
  position: relative;
  flex: 1 1 auto;
  height: 22px;
}

.t2030-trend-panel__row-line {
  position: absolute;
  top: 9.5px;
  height: 3px;
  border-radius: 2px;
  background: var(--tp-navy);
}

.t2030-trend-panel__dot {
  position: absolute;
  top: 5.5px;
  margin-left: -5.5px;
  width: 11px;
  height: 11px;
  border-radius: 999px;
  box-sizing: border-box;
}

.t2030-trend-panel__dot--earlier {
  border: 2px solid var(--tp-navy);
  background: var(--clr-white, #fff);
}

.t2030-trend-panel__dot--latest {
  background: var(--tp-navy);
}

.t2030-trend-panel__row--worse .t2030-trend-panel__row-line { background: var(--tp-rose); }
.t2030-trend-panel__row--worse .t2030-trend-panel__dot--earlier { border-color: var(--tp-rose); }
.t2030-trend-panel__row--worse .t2030-trend-panel__dot--latest { background: var(--tp-rose); }

.t2030-trend-panel__row-value {
  flex: 0 0 var(--tp-val-w);
  text-align: right;
  font-size: var(--fs-12, 12px);
}

.t2030-trend-panel__ticks {
  display: flex;
  height: 26px;
  margin-top: 4px;
  background: var(--clr-white, #fff);
}

.t2030-trend-panel__ticks-left {
  flex: 0 0 calc(var(--tp-name-w) + var(--tp-fcv-w));
}

.t2030-trend-panel__ticks-right {
  flex: 0 0 var(--tp-val-w);
}

.t2030-trend-panel__ticks-track {
  position: relative;
  flex: 1 1 auto;
  border-top: 1px solid var(--tp-border);
}

.t2030-trend-panel__tick {
  position: absolute;
  top: 4px;
  transform: translateX(-50%);
  font-size: var(--fs-11, 11px);
  white-space: nowrap;
}

.t2030-trend-panel__tooltip {
  position: absolute;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 140px;
  max-width: 240px;
  padding: 8px 12px;
  background: var(--clr-white, #fff);
  border: 1px solid var(--tp-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;
  pointer-events: none;
}

.t2030-trend-panel__tooltip-name {
  font-size: var(--fs-13, 13px);
}

.t2030-trend-panel__tooltip-chg {
  font-weight: var(--fw-semibold, 600);
  color: #1d5c55;
}

.t2030-trend-panel__tooltip-chg--worse {
  color: #c2410c;
}

.t2030-trend-panel__tooltip-note {
  color: var(--tp-muted);
}

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

/* ---------- insights aside ---------- */
.t2030-trend-panel__aside {
  flex: 1 1 280px;
  max-width: 380px;
  align-self: stretch;
  background: var(--tp-aside-bg);
  border-radius: 0 20px 0 20px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-sizing: border-box;
}

.t2030-trend-panel__aside-title {
  margin: 0;
  font-size: var(--fs-18, 18px);
  line-height: 1.35;
  font-weight: var(--fw-bold, 700);
  color: var(--tp-ink);
}

.t2030-trend-panel__insights {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.t2030-trend-panel__insight {
  margin: 0;
  padding-left: 18px;
  border-left: 3px solid var(--tp-gold);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.t2030-trend-panel__insight-value {
  font-size: var(--fs-34, 34px);
  line-height: 1.05;
  font-weight: var(--fw-bold, 700);
  color: var(--tp-navy);
}

.t2030-trend-panel__insight-text {
  font-size: var(--fs-15, 15px);
  line-height: 1.55;
}

.t2030-trend-panel__close {
  margin: 0;
  padding-top: 14px;
  border-top: 1px solid var(--tp-border);
  font-size: var(--fs-14, 14px);
  line-height: 1.6;
}

/* ---------- responsive ---------- */
@media (min-width: 901px) {
  .t2030-trend-panel__aside {
    position: sticky;
    top: 96px;
    align-self: flex-start;
  }
}

@media (max-width: 1000px) {
  .t2030-trend-panel__sub {
    border-left: 0;
    padding-left: 0;
    margin-left: 0;
  }
}

@media (max-width: 900px) {
  .t2030-trend-panel__aside {
    max-width: none;
  }
}

@media (max-width: 767px) {
  .t2030-trend-panel {
    --tp-name-w: 96px;
    --tp-val-w: 40px;
    --tp-name-fs: 11px;
  }

  /* The pipe between the popup's Sort-by/Show pill dropdowns (shown
     unconditionally by .t2030-trend-panel__popup .t2030-trend-panel__
     seg-divider above) has no room to read as a divider once those
     dropdowns stack/wrap at this width - hide it, matching
     .t2030-trend-panel__divider's own mobile treatment below. */
  .t2030-trend-panel__popup .t2030-trend-panel__seg-divider {
    display: none;
  }

  .t2030-trend-panel__popup .popup-download-options {
    flex-direction: column;
    align-items: flex-start;
  }

  .t2030-trend-panel__popup .t2030-trend-panel__controls {
    gap: 12px 15px;
  }
}

@media (max-width: 520px) {
  .t2030-trend-panel__popup .t2030-trend-panel__controls {
    flex-direction: column;
  }

  .t2030-trend-panel__popup .t2030-trend-panel__seg-divider {
    display: none;
  }
}

@media (max-width: 600px) {
  .t2030-trend-panel__seg-btn { padding: 0 12px; }
  .t2030-trend-panel__card { padding: 18px 14px; }
  .t2030-trend-panel__divider { display: none; }
}

/* ---------- table ---------- */
.t2030-trend-panel__table-wrap {
  overflow: auto;
  /* border: 1px solid var(--tp-border); */
  /* border-radius: 8px; */
}

.t2030-trend-panel__table {
  width: 100%;
  border-collapse: collapse;
}

.t2030-trend-panel__table th,
.t2030-trend-panel__table td {
  text-align: left;
}

.t2030-trend-panel__table thead th {
  position: sticky;
  top: 0;
}

.t2030-trend-panel__table .is-num {
  text-align: right;
}

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

.t2030-trend-panel__popup.is-active {
  display: flex;
}

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

.t2030-trend-panel__popup .popup-tab-content {
  display: none;
}

.t2030-trend-panel__popup .popup-tab-content.is-active {
  display: block;
}

/* trend-panel.js moves .t2030-trend-panel__controls (Sort by/Show) 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-trend-panel__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-trend-panel__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-trend-panel__popup .popup-download-options > ul {
  margin-left: auto;
}

.t2030-trend-panel__popup .t2030-trend-panel__controls {
  justify-content: flex-start;
  gap: 12px 20px;
}

.t2030-trend-panel__popup .t2030-trend-panel__select {
  font-size: 13px;
  min-height: 34px;
}

/* Vertical divider between the Sort by/Show pills, popup-only (matches
   the pill dropdowns themselves being popup-only). */
.t2030-trend-panel__seg-divider {
  display: none;
}

.t2030-trend-panel__popup .t2030-trend-panel__seg-divider {
  display: block;
  flex: none;
  width: 1px;
  height: 30px;
  background: var(--tp-teal);
}

.t2030-trend-panel__popup .custom-modal-close-field {
  cursor: pointer;
}

body.trend-panel-lock-scroll {
  overflow: hidden;
}
