/* snapshot - "Country snapshot" widget (MNCH key-theme page).
   Section header + light (#F3F5F7) backdrop come from the master twig.

   Colors from the design matched to existing tokens where exact:
   #4D4D4D --clr-gray-dark, #21568C --clr-blue, #1FA29C --clr-teal-500,
   #F8B323 --clr-yellow-orange. The rest (#15766F label teal, FCV tag
   fills, direction tones) have no token and are scoped locally below. */
.snapshot {
  --snapshot-label: #15766f;
  --snapshot-tag-fcv: #d5e9e8;
  --snapshot-tag-non: #e9ecef;
  --snapshot-good: var(--clr-teal-500, #1fa29c);
  --snapshot-bad: #ed6e68;
  --snapshot-flat: var(--clr-gray-dark, #4d4d4d);
  --snapshot-note-up: #15766f;
  --snapshot-note-down: #c2410c;
  --snapshot-note-flat: #6b6b6b;
  --snapshot-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);

  display: flex;
  flex-direction: column;
  gap: 24px;
  font-family: var(--primary-ff, 'Poppins', sans-serif);
  color: var(--clr-gray-dark, #4d4d4d);
}

/* ---------- control bar ---------- */
.snapshot__bar {
  background: var(--clr-white, #fff);
  border-radius: 0 24px 0 24px;
  padding: 20px clamp(18px, 2.5vw, 28px);
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px 24px;
  box-shadow: var(--snapshot-shadow);
}

.snapshot__picker {
  flex: 0 1 380px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.snapshot__picker-label {
  font-size: var(--fs-14, 14px);
  font-weight: var(--fw-bold, 700);
  color: var(--snapshot-label);
}

.snapshot__select-wrap {
  position: relative;
  display: flex;
}

.snapshot__select {
  font: inherit;
  font-size: var(--fs-16, 16px);
  font-weight: var(--fw-bold, 700);
  width: 100%;
  min-height: 46px;
  padding: 0 52px 0 24px;
  border: 0;
  border-radius: 999px;
  background: var(--clr-teal-500, #1fa29c);
  color: var(--clr-white, #fff);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.snapshot__select:focus-visible {
  outline: 3px solid var(--clr-blue, #21568c);
  outline-offset: 2px;
}

.snapshot__select option {
  color: var(--clr-gray-dark, #4d4d4d);
  background: var(--clr-white, #fff);
}

.snapshot__select-chevron {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--clr-white, #fff);
  pointer-events: none;
}

/* ---------- Select2 country picker (QC 452641) ----------
   snapshot.js upgrades .snapshot__select to Select2 when the library is
   loaded, so the open list can be height-limited (a native <select> list
   can't). The closed pill mirrors .snapshot__select above; the list itself
   is appended to <body>, styled via dropdownCssClass. */
.snapshot .select2-container {
  width: 100% !important; /* beats custom-select2.css's 240px if both load */
}

.snapshot .select2-container .select2-selection--single.snapshot__select2-selection {
  height: 46px;
  border: 0;
  border-radius: 999px;
  background: var(--clr-teal-500, #1fa29c);
  outline: 0;
}

.snapshot .select2-container .snapshot__select2-selection .select2-selection__rendered {
  padding: 0 52px 0 24px;
  line-height: 46px;
  font-size: var(--fs-16, 16px);
  font-weight: var(--fw-bold, 700);
  color: var(--clr-white, #fff);
}

/* Select2's own arrow is replaced by the existing .snapshot__select-chevron. */
.snapshot .select2-container .snapshot__select2-selection .select2-selection__arrow {
  display: none;
}

.snapshot .select2-container--focus .snapshot__select2-selection {
  outline: 3px solid var(--clr-blue, #21568c);
  outline-offset: 2px;
}

.snapshot .select2-container--open + .snapshot__select-chevron {
  transform: translateY(-50%) rotate(180deg);
}

.select2-dropdown.snapshot__select2-dropdown {
  margin-top: 6px;
  border: 1px solid #dfe5ea;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 10px 24px rgba(30, 50, 80, 0.16);
}

/* The height QC asked to reduce: ~7 rows visible, rest scrolls. */
.select2-dropdown.snapshot__select2-dropdown .select2-results > .select2-results__options {
  max-height: 260px;
  padding: 6px 0;
  overflow-y: auto;
}

.select2-dropdown.snapshot__select2-dropdown .select2-results__option {
  padding: 8px 20px;
  font-size: var(--fs-15, 15px);
  line-height: 1.4;
  color: var(--clr-gray-dark, #4d4d4d);
  background: transparent;
  border: 0;
}

.select2-dropdown.snapshot__select2-dropdown .select2-results__option--selected {
  font-weight: var(--fw-bold, 700);
  color: var(--clr-teal-500, #1fa29c);
}

.select2-dropdown.snapshot__select2-dropdown .select2-results__option--highlighted.select2-results__option--selectable {
  background: #e8f5f4;
  color: var(--clr-teal-500, #1fa29c);
}

.snapshot__fcs-tag {
  align-self: flex-end;
  display: inline-flex;
  align-items: center;
  min-height: 46px;
  box-sizing: border-box;
  padding: 0 16px;
  border-radius: 0 14px 0 14px;
  background: var(--snapshot-tag-non);
  color: var(--clr-gray-dark, #4d4d4d);
  font-size: var(--fs-13, 13px);
  font-weight: var(--fw-bold, 700);
}

.snapshot__fcs-tag--fcv {
  background: var(--snapshot-tag-fcv);
}

.snapshot__fcs-tag[hidden],
.snapshot__profile-link[hidden],
.snapshot__metrics[hidden],
.snapshot__empty[hidden] {
  display: none;
}

.snapshot__spacer {
  flex: 1 1 0;
}

.snapshot__profile-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-size: var(--fs-14, 14px);
  font-weight: var(--fw-bold, 700);
  color: var(--clr-blue, #21568c);
  text-decoration: none;
}

.snapshot__profile-link:hover,
.snapshot__profile-link:focus-visible {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.snapshot__profile-link-arrow {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--clr-yellow-orange, #f8b323);
  color: var(--clr-white, #fff);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}

.snapshot__profile-link:hover .snapshot__profile-link-arrow {
  transform: translateX(3px);
}

.snapshot__empty {
  margin: 0;
  font-size: var(--fs-16, 16px);
  line-height: 1.6;
}

/* ---------- tiles ---------- */
.snapshot__metrics {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr));
  gap: 24px;
}

.snapshot__tile {
  margin: 0;
  background: var(--clr-white, #fff);
  border-radius: 0 16px 0 16px;
  padding: 20px;
  display: flex;
  box-shadow: var(--snapshot-shadow);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.snapshot__tile--flip {
  border-radius: 16px 0 16px 0;
}

.snapshot__tile:hover {
  box-shadow: 0 8px 20px rgba(30, 50, 80, 0.12);
  transform: translateY(-2px);
}

.snapshot__tile-inner {
  padding-left: 16px;
  border-left: 3px solid var(--clr-yellow-orange, #f8b323);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.snapshot__tile-value-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 10px;
}

.snapshot__tile-value {
  font-size: var(--fs-34, 34px);
  line-height: 1.05;
  font-weight: var(--fw-bold, 700);
  color: var(--clr-blue, #21568c);
}

.snapshot__tile-unit {
  font-size: var(--fs-15, 15px);
  font-weight: var(--fw-semibold, 600);
}

.snapshot__tile-dir {
  display: inline-flex;
  cursor: help;
  color: var(--snapshot-flat);
}

.snapshot__tile-dir--good { color: var(--snapshot-good); }
.snapshot__tile-dir--bad { color: var(--snapshot-bad); }

/* Triangle path points down; rising values flip it. */
.snapshot__tile-dir--up svg {
  transform: rotate(180deg);
}

.snapshot__tile-since {
  font-size: var(--fs-12, 12px);
}

.snapshot__tile-label {
  font-size: var(--fs-14, 14px);
  line-height: 1.5;
}

.snapshot__tile-note {
  font-size: var(--fs-13, 13px);
  line-height: 1.4;
  font-weight: var(--fw-semibold, 600);
  color: var(--snapshot-note-flat);
}

.snapshot__tile-note--up { color: var(--snapshot-note-up); }
.snapshot__tile-note--down { color: var(--snapshot-note-down); }

@media (max-width: 559px) {
  .snapshot__picker {
    flex-basis: 100%;
  }
  .snapshot__spacer {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .snapshot__tile,
  .snapshot__profile-link-arrow {
    transition: none;
  }
  .snapshot__tile:hover,
  .snapshot__profile-link:hover .snapshot__profile-link-arrow {
    transform: none;
  }
}
