#links {
  display: grid;
  grid-template-columns: 1;
  gap: 1em;
  margin: 1em 0;
  padding: 0;
  list-style: none;
}

#links > li {
  /* visit-tracker's removeRow waits for this transition's transitionend
     before removing the row — keep them in sync. */
  transition: opacity 0.3s ease;

  /* Applied when a link is opened while the "new links" filter is active,
     just before the row is removed from the list. */
  &.removing {
    opacity: 0;
  }

  /* Keyboard-navigation selection: an outline.
     Negative margins offset the padding so neighbouring rows don't shift. */
  &.selected {
    outline: 0.1875rem solid var(--link-color);
    border-radius: 0.5rem;
    padding: 0.5em 0.75em;
    margin: -0.5em -0.75em;
    transition: outline-width 0.2s linear;

    /* Brief confirmation that "y" copied the URL. */
    &.copied {
      outline-width: 0.5em;
    }
  }

  h2 {
    font-size: 1em;
    margin: 0;

    a {
      color: var(--fg-color);
      font-weight: bold;
      text-decoration: underline;
      text-decoration-thickness: 0.125rem;
      text-decoration-color: var(--highlight-color);
      transition: none;
      overflow-wrap: break-word;

      display: block;

      &:hover {
        color: var(--link-color);
      }
    }
  }

  &[data-visited] h2 a {
    text-decoration-color: var(--border-color);
    &:hover {
      text-decoration-color: var(--highlight-color);
    }
  }

  /* Title and description take whole lines; the tags and the footer share
     the next one, wrapping when it runs out. */
  & > article {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    column-gap: 0.75em;

    & > h2,
    & > .link-description {
      flex-basis: 100%;
    }
  }

  /* Underlined so a link reads as part of the text rather than as a tag. Real
     padding rather than the footer's negative margin: two links on consecutive
     lines would otherwise overlap, so a link's line grows to 24px instead. */
  .link-description {
    font-size: 0.875em;
    color: var(--mid-color);
    overflow-wrap: break-word;
    white-space: pre-line;
    margin: 0;

    a {
      display: inline-block;
      min-width: 1.5rem;
      padding-block: 0.25em;
      text-decoration: underline;
      text-decoration-thickness: 0.0625rem;
      text-underline-offset: 0.15em;
    }
  }

  /* The same grey pill as the tag page's related tags. Each pill is a real
     24px box, so the strip needs no negative-margin trick. */
  .link-tags {
    font-size: 0.75em;
    padding: 0;
    margin: 0.5em 0 0;
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.3em;

    a {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      box-sizing: border-box;
      min-width: 1.5rem;
      min-height: 1.5rem;
      padding: 0 0.65em;
      border-radius: 1rem;
      overflow-wrap: anywhere;
      background: var(--bg-highlight-color);
      color: var(--fg-color);

      &:hover {
        background: var(--header-bg-color);
        color: var(--highlight-contrast-color);
        text-decoration: none;
      }
    }
  }

  /* Keeps its painted size, 0.75em text on an 18px line, and grows each link's
     hit box to 24px with padding that a negative margin hands straight back. */
  footer {
    font-size: 0.75em;
    color: var(--mid-color);
    display: flex;
    align-items: center;
    gap: 0.5em;
    margin-top: 0.5em;

    a {
      padding: 0.25em 0.5em;
      margin: -0.25em -0.5em;
    }
  }
}
