/*
 * A company's own ten years of one figure (HistoryLineHelper#history_line_tag,
 * tasks/growth/milestones/17 D8): an ink line over a flat paper area the
 * width of its card, a dashed rule at the median, today's reading as a dot
 * with its figure and the median's in a margin on the right, the high and the
 * low marked where they fell, and the years along a ruled foot.
 *
 * The SVG stretches to the plot (`preserveAspectRatio="none"`), so the
 * strokes keep their width with `vector-effect`, and the dots and labels are
 * HTML set over it at `--x` and `--y` (percentages of the plot, from
 * Companies::HistoryLinePlot), not SVG the stretch would distort.
 */
@layer components {
  .history-line {
    margin: 0;
  }

  .history-line__plot {
    position: relative;
    margin-block-start: var(--space-lg);
    margin-inline-end: var(--space-4xl);
    border-block-end: var(--rule-width) solid var(--color-rule-strong);
  }

  .history-line__chart {
    display: block;
    inline-size: 100%;
    block-size: 7rem;
    overflow: visible;
  }

  .history-line__area {
    fill: var(--color-surface-sunken);
  }

  .history-line__line {
    fill: none;
    stroke: var(--color-ink);
    stroke-width: 1.5;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
  }

  .history-line__median {
    stroke: var(--color-ink-muted);
    stroke-width: 1;
    stroke-dasharray: 4 3;
    vector-effect: non-scaling-stroke;
  }

  .history-line__dot {
    position: absolute;
    inset-inline-start: var(--x);
    inset-block-start: var(--y);
    inline-size: var(--space-xs);
    block-size: var(--space-xs);
    border-radius: var(--radius-pill);
    background-color: var(--color-ink);
    translate: -50% -50%;
  }

  .history-line__dot--now {
    inline-size: var(--space-sm);
    block-size: var(--space-sm);
    background-color: var(--color-accent);
  }

  /* The high's and the low's figures, above and below their dots. */
  .history-line__note {
    position: absolute;
    inset-inline-start: var(--x);
    inset-block-start: var(--y);
    color: var(--color-ink-muted);
    font-family: var(--font-data);
    font-size: var(--text-meta-xs);
    font-variant-numeric: tabular-nums lining-nums;
    white-space: nowrap;
  }

  .history-line__note--above {
    --lift: calc(-100% - var(--space-xs));
  }

  .history-line__note--below {
    --lift: var(--space-xs);
  }

  .history-line__anchor--start {
    translate: calc(var(--space-xs) * -1) var(--lift);
  }

  .history-line__anchor--middle {
    translate: -50% var(--lift);
  }

  .history-line__anchor--end {
    translate: calc(-100% + var(--space-xs)) var(--lift);
  }

  /* Today's figure and the median's, in the margin beside the plot. */
  .history-line__margin {
    position: absolute;
    inset-inline-start: calc(100% + var(--space-xs));
    inset-block-start: var(--y);
    display: grid;
    color: var(--color-ink-muted);
    font-family: var(--font-data);
    font-size: var(--text-meta-xs);
    line-height: var(--leading-meta-xs);
    font-variant-numeric: tabular-nums lining-nums;
    white-space: nowrap;
    translate: 0 -50%;
  }

  .history-line__margin-figure {
    color: var(--color-ink);
    font-size: var(--text-ui-sm);
    font-weight: var(--weight-medium);
  }

  .history-line__margin--now .history-line__margin-figure {
    font-weight: var(--weight-semibold);
  }

  /* The years along the foot, under the plot only. */
  .history-line__axis {
    position: relative;
    block-size: calc(var(--text-meta-xs) * var(--leading-meta-xs));
    margin-block-start: var(--space-2xs);
    margin-inline-end: var(--space-4xl);
    color: var(--color-ink-muted);
    font-family: var(--font-data);
    font-size: var(--text-meta-xs);
    font-variant-numeric: tabular-nums lining-nums;
  }

  /* A year is centred on its January. */
  .history-line__year {
    position: absolute;
    inset-inline-start: var(--x);
    translate: -50%;
  }
}
