@layer components {
  /* When something is due, as three choices on 32px lines: no date, a date, or several days. A choice not taken reads
     as its name; the one taken shows its date in place of the name, and several days their first and last, one over
     the other. A choice is a round button, its ring thick in the ink once taken. */
  .due-date {
    align-items: center;
    column-gap: 0.4em;
    display: grid;
    grid-auto-rows: minmax(var(--control-size), auto);
    grid-template-columns: auto auto minmax(0, 1fr);
    justify-items: start;
  }

  /* A round button: a thin ring, thick in the ink once chosen. How a to-do stops repeating chooses the same way. */
  :is(.due-date, .todo__repeat-until) .checkbox[type="radio"] {
    block-size: 1.2em;
    border: 1px solid var(--tint-ink-50);
    border-radius: 50%;
    flex: none;
    inline-size: 1.2em;
    transform: none;

    &::before {
      display: none;
    }

    &:checked {
      border: 0.33em solid var(--color-ink);
    }
  }

  .due-date__choice {
    cursor: pointer;
    display: contents;

    > .checkbox {
      grid-column: 1;
    }

    > span {
      grid-column: 2 / -1;
    }
  }

  .due-date__choice--none > * {
    grid-row: 1;
  }

  .due-date__choice--day > *,
  .due-date__start {
    grid-row: 2;
  }

  .due-date__choice--days > *,
  .due-date__from {
    grid-row: 3;
  }

  .due-date__from,
  .due-date__until {
    grid-column: 2;
  }

  .due-date__start {
    grid-column: 2 / -1;
  }

  .due-date:has([value=days]:checked) .due-date__start {
    grid-column: 3;
    grid-row: 3;
  }

  .due-date__until,
  .due-date__end {
    grid-row: 4;
    margin-block-start: 0.4em;
  }

  .due-date__end {
    grid-column: 3;
  }

  /* What shows of each choice, by which is taken. */
  .due-date:has([value=day]:checked) .due-date__choice--day .due-date__type,
  .due-date:has([value=days]:checked) .due-date__choice--days .due-date__type,
  .due-date:has([value=none]:checked) .due-date__start,
  .due-date:not(:has([value=days]:checked)) :is(.due-date__from, .due-date__until, .due-date__end) {
    display: none;
  }

  /* What only a dated thing asks, such as how it repeats, stands only once it has a date. */
  form:has(.due-date [value=none]:checked) .due-date__dated {
    display: none;
  }
}
