/*
 * The Dividends card (companies/keystats/_dividends): the figures, the bar
 * a year, and the key under them.
 */
@layer components {
  /* The Dividends card (companies/keystats/_dividends): four figures in two
     columns, then a bar a year — what was paid in the series colour, a
     forecast outlined on the forecast tint, a forecast year's paid part
     filled from the foot — its total over it, its year and change under. */
  .dividend-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-sm) var(--space-md);
    margin: 0;
    padding-block: var(--space-sm);
    border-block-end: var(--rule-hairline);

    & dd {
      margin: 0;
      font-weight: var(--weight-semibold);
    }
  }

  .dividend-stats__cell {
    display: grid;
    gap: var(--space-3xs);
  }

  .dividend-chart {
    --dividend-chart-height: 7rem;

    display: grid;
    grid-auto-columns: minmax(0, 1fr);
    grid-auto-flow: column;
    align-items: end;
    gap: var(--space-2xs);
    margin: var(--space-sm) 0 0;
    padding: 0;
    list-style: none;
    font-family: var(--font-data);
    font-variant-numeric: tabular-nums lining-nums;
  }

  /* One column, held to the year's width: an auto column grew to a label's,
     and took the bar with it. */
  .dividend-chart__year {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    gap: var(--space-3xs);
    min-inline-size: 0;
  }

  .dividend-chart__total,
  .dividend-chart__change {
    color: var(--color-ink-subtle);
    font-size: var(--text-meta-xs);
    white-space: nowrap;
  }

  /* A line even with no change to show, or that year's foot drops below the
     others': the first year, and the year after one of no dividend. */
  .dividend-chart__change {
    min-block-size: 1lh;
  }

  .dividend-chart__bar {
    inline-size: 100%;
    block-size: calc(var(--share) * var(--dividend-chart-height));
    background: linear-gradient(to top, var(--color-series-1) calc(var(--paid) * 100%), transparent 0);
  }

  .is-forecast .dividend-chart__bar {
    border: var(--rule-width) dashed var(--color-rule-control);
    background-color: var(--color-forecast);
  }

  .dividend-chart__label {
    padding-block-start: var(--space-3xs);
    border-block-start: var(--rule-hairline);
    inline-size: 100%;
    color: var(--color-ink-muted);
    font-size: var(--text-meta-xs);
    text-align: center;
  }

  .dividend-key {
    display: inline-block;
    inline-size: 0.75rem;
    block-size: 0.75rem;
    vertical-align: middle;
  }

  .dividend-key--paid {
    background-color: var(--color-series-1);
  }

  .dividend-key--forecast {
    border: var(--rule-width) dashed var(--color-rule-control);
    background-color: var(--color-forecast);
  }
}
