@layer components {
  /* Base
  /* -------------------------------------------------------------------------- */

  /* A card of one income stream's adjustments */
  .adjustment-group {
    --adjustment-padding-block: var(--block-space);
    --adjustment-padding-inline: calc(var(--inline-space-double) + var(--inline-space));
  }

  /* One adjustment: what it is, then its kind, the change and its actions.
     On phones the kind and actions drop below. From tablet up each row is a
     subgrid of its card's list, so kinds and changes line up in columns
     whatever the width of each figure. */
  .adjustment {
    align-items: center;
    border-block-end: var(--border);
    column-gap: var(--inline-space-double);
    display: grid;
    grid-template-areas:
      "main change"
      "kind actions";
    grid-template-columns: minmax(0, 1fr) auto;
    padding: var(--adjustment-padding-block) var(--adjustment-padding-inline);
    row-gap: var(--block-space-half);

    &:last-child {
      border-block-end: 0;
    }

    @media (min-width: 640px) {
      grid-column: 1 / -1;
      grid-template-areas: "main kind change actions";
      grid-template-columns: subgrid;
    }
  }

  /* Elements
  /* -------------------------------------------------------------------------- */

  .adjustment-group__header {
    align-items: baseline;
    background-color: var(--color-surface-subtle);
    border-block-end: var(--border);
    border-start-end-radius: inherit;
    border-start-start-radius: inherit;
    display: flex;
    flex-wrap: wrap;
    gap: var(--inline-space) var(--inline-space-double);
    justify-content: space-between;
    padding: var(--block-space-half) var(--adjustment-padding-inline);
  }

  /* The columns every row in the card shares */
  .adjustment-group__list {
    @media (min-width: 640px) {
      column-gap: var(--inline-space-double);
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto auto auto;
    }
  }

  .adjustment-group__title {
    font-size: var(--text-small);
    font-weight: 600;
  }

  .adjustment-group__details {
    color: var(--color-ink-muted);
    font-size: var(--text-x-small);
  }

  .adjustment__main {
    grid-area: main;
  }

  .adjustment__title {
    font-size: var(--text-small);
    font-weight: 500;
  }

  .adjustment__details {
    color: var(--color-ink-muted);
    font-size: var(--text-x-small);
    margin-block-start: 0.15em;
  }

  .adjustment__kind {
    grid-area: kind;
    justify-self: start;

    @media (min-width: 640px) {
      justify-self: end;
    }
  }

  /* Figures line up down the card, and read as the row's headline number. The
     minimum width keeps the column close to the same place across cards. */
  .adjustment__change {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    grid-area: change;
    min-inline-size: 11ch;
    text-align: end;
    white-space: nowrap;
  }

  /* Revealed on hover or keyboard focus with a pointer; always shown on touch */
  .adjustment__actions {
    display: flex;
    grid-area: actions;
    justify-content: end;

    @media (any-hover: hover) {
      .btn {
        opacity: 0;
        transition: opacity var(--duration-fast) var(--ease-out-expo);
      }

      .adjustment:is(:hover, :focus-within) & .btn {
        opacity: 1;
      }
    }
  }
}
