/* Key figures (front end and editor). Values of the group pages.
   Variants (is-v-…): lines (default, dividers), statrow (smaller numbers), icons (icon above, centred),
   dots (teal circle left), vdots (dots with a label line above), plain (no dividers), compact (only as wide as
   the content, no dividers), grid (line above each figure, several rows). */
.sg-figures {
  --cols: 4;
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  container-type: inline-size; /* long values scale with the width of the row (cqi) */

  &.has-cols-3 { --cols: 3; }
  &.has-cols-5 { --cols: 5; }
}

.sg-figure {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 26px;
  border-left: 1px solid var(--wp--custom--teal-wash);

  &:first-child { border-left: 0; padding-left: 0; }
}

/* the first figure of every row has no divider – per number of columns (below 901 px the rules further down
   decide, the rows change there) */
@media (min-width: 901px) {
  .sg-figures:not(.has-cols-3, .has-cols-5) .sg-figure:nth-child(4n + 1),
  .sg-figures.has-cols-3 .sg-figure:nth-child(3n + 1),
  .sg-figures.has-cols-5 .sg-figure:nth-child(5n + 1) { border-left: 0; padding-left: 0; }
}

.sg-figure__n {
  font-size: clamp(30px, 3.2vw, 40px);
  font-weight: 700;
  line-height: 1;
  color: var(--wp--preset--color--teal);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* words or long values: sized by the width of the row, so "Nationwide" fits a third of a text column;
   between words they may wrap, inside a word only as hyphenation */
.sg-figure.is-long .sg-figure__n {
  font-size: clamp(18px, 3.6cqi, 28px);
  line-height: 1.15;
  white-space: normal;
  hyphens: auto;
}

.sg-figure__u {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--wp--preset--color--teal);
}

.sg-figure__l {
  font-size: 13px;
  font-weight: 700;
  font-style: italic;
  color: var(--wp--preset--color--ink);
}

.sg-figure__d {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--wp--custom--muted);
}

.sg-figure__k { display: none; }

.sg-figure__icon {
  display: block;
  width: 34px;
  height: 34px;
  margin-bottom: 8px;
  color: var(--wp--preset--color--teal);

  & svg { width: 100%; height: 100%; stroke: currentColor; fill: none; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
}

/* statrow: five figures with dividers, a bit smaller */
.sg-figures.is-v-statrow .sg-figure__n,
.sg-figures.is-v-plain .sg-figure__n,
.sg-figures.is-v-grid .sg-figure__n { font-size: clamp(28px, 3vw, 38px); }

/* icons: icon above, everything centred */
.sg-figures.is-v-icons .sg-figure { align-items: center; text-align: center; }

/* plain + compact: no dividers */
.sg-figures:is(.is-v-plain, .is-v-compact) .sg-figure { border-left: 0; padding: 0 26px 0 0; }
.sg-figures.is-v-compact {
  grid-template-columns: repeat(var(--cols), auto);
  justify-content: start;
  gap: 0 40px;
  margin-block: 4px;
  flex: none; /* in a row group (map footer) it keeps its own width instead of being squeezed */

  & .sg-figure { padding: 0; }
}

/* grid: line above each figure */
.sg-figures.is-v-grid .sg-figure {
  padding-block: 18px;
  border-top: 1px solid var(--wp--custom--teal-wash);
}

/* dots: teal circle left of number, unit, label and text */
.sg-figures:is(.is-v-dots, .is-v-vdots) {
  gap: 32px;

  & .sg-figure {
    display: grid;
    grid-template-columns: 44px 1fr;
    gap: 4px 14px;
    align-items: start;
    padding: 0;
    border: 0;

    &::before {
      content: "";
      grid-row: 1 / 5;
      width: 44px;
      height: 44px;
      border-radius: 50%;
      background: var(--wp--preset--color--teal);
    }

    & > * { grid-column: 2; }
  }

  & .sg-figure__n { font-size: 32px; line-height: 1.05; }
  & .sg-figure__n:has(+ .sg-figure__u) { margin-bottom: -2px; }
}

/* vdots: the value label sits above, over the full width with a line below */
.sg-figures.is-v-vdots .sg-figure {
  &::before { grid-row: 2 / 6; }

  & .sg-figure__k {
    display: block;
    grid-column: 1 / -1;
    min-height: 2.6em;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(14, 110, 100, .25);
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--wp--preset--color--teal);
  }
}

.sg-section.is-dark {
  & .sg-figure { border-left-color: rgba(255, 255, 255, .25); }
  & .sg-figure__n { color: #fff; }
  & .sg-figure__d { color: rgba(255, 255, 255, .85); } /* 4.5:1 on teal */
}

@media (max-width: 900px) {
  .sg-figures:not(.is-v-compact) { --cols: 2 !important; row-gap: 28px; }
  .sg-figures:not(.is-v-compact, .is-v-dots, .is-v-vdots) .sg-figure:nth-child(odd) { border-left: 0; padding-left: 0; }
  .sg-figures.has-cols-3:not(.is-v-compact, .is-v-dots, .is-v-vdots) { --cols: 1 !important; }
  .sg-figures.has-cols-3 .sg-figure { border-left: 0; padding-left: 0; }

  /* statrow: three per row */
  .sg-figures.is-v-statrow { --cols: 3 !important; gap: 24px 0; }
  .sg-figures.is-v-statrow .sg-figure:nth-child(odd) { border-left: 1px solid var(--wp--custom--teal-wash); padding-left: 26px; }
  .sg-figures.is-v-statrow .sg-figure:nth-child(3n + 1) { border-left: 0; padding-left: 0; }

  .sg-figures:is(.is-v-dots, .is-v-vdots) { gap: 28px; }
  .sg-figures.has-cols-3:is(.is-v-dots, .is-v-vdots) { --cols: 1 !important; gap: 32px; }
}

@media (max-width: 560px) {
  .sg-figures.is-v-compact {
    grid-template-columns: repeat(3, 1fr);
    gap: 0 16px;

    & .sg-figure__n { font-size: 30px; }
  }
}

/* phones: one column; grid (investor key figures) stays two, small (Business Unit) stays three */
@media (max-width: 480px) {
  .sg-figures:not(.is-v-compact, .is-v-grid, .is-v-small) { --cols: 1 !important; }
  .sg-figures:not(.is-v-small) .sg-figure { border-left: 0 !important; padding-left: 0 !important; }
}

/* small: three figures in a row with grey lines, number 24 px (Business Unit facts) */
.sg-figures.is-v-small {
  margin-block: 8px;

  & .sg-figure { padding: 0 16px; border-left-color: var(--wp--custom--line); gap: 2px; }
  & .sg-figure:first-child { padding-left: 0; }
  & .sg-figure__n { font-size: 24px; line-height: 1.1; }
  & .sg-figure__d { font-size: 12.5px; color: var(--wp--custom--body); }
}
@media (max-width: 900px) {
  .sg-figures.is-v-small { --cols: 3 !important; }
  .sg-figures.is-v-small .sg-figure:nth-child(odd):not(:first-child) { border-left: 1px solid var(--wp--custom--line); padding-left: 16px; }
}
