/* Im Ruhezustand ohne Unterstrich; Zustandsregeln und Skip-Link-Fokus bleiben. */
a[href],
#content a[href]:not(.heading-permalink),
#sidebar a[href],
#footer a[href] {
  text-decoration-line: none;
}

/* Inline-Links erhalten neben Farbe ein dauerhaftes typografisches Signal. */
#content a[href]:not(.heading-permalink),
#sidebar a[href] {
  font-weight: 600;
}

/* Rückmeldung nur an vorhandenen Links; Inhalt bleibt im normalen Textfluss. */
#content a[href]:not(.heading-permalink):focus-visible,
#sidebar a[href]:focus-visible,
#footer a[href]:focus-visible,
#content a[href]:not(.heading-permalink):active,
#sidebar a[href]:active,
#footer a[href]:active {
  text-decoration-line: underline;
  text-decoration-thickness: 0.14em;
}

/* Die Kacheln bewegen sich nicht; ihre Innenkante ergänzt die Bestandsfarben. */
#nav a[href]:active {
  box-shadow: inset 0 0 0 2px var(--color-link);
}

@media (hover: hover) and (pointer: fine) {
  #content a[href]:not(.heading-permalink):hover,
  #sidebar a[href]:hover,
  #footer a[href]:hover {
    text-decoration-line: underline;
    text-decoration-thickness: 0.14em;
  }

  #nav a[href]:hover:not(:active) {
    box-shadow: inset 0 0 0 1px var(--color-border);
  }
}

/* Bewegung ist Opt-in über die Systemeinstellung, nicht nur nachträglich verkürzt. */
@media (prefers-reduced-motion: no-preference) {
  #content a[href]:not(.heading-permalink),
  #sidebar a[href],
  #footer a[href] {
    transition: color 160ms ease, text-underline-offset 160ms ease;
  }

  #sidebar .social a[href],
  #footer a[href] {
    transition: color 160ms ease, text-underline-offset 160ms ease, transform 160ms ease;
  }

  #nav a[href] {
    transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
  }

  #content a[href]:not(.heading-permalink):focus-visible,
  #sidebar a[href]:focus-visible,
  #footer a[href]:focus-visible {
    text-underline-offset: 0.24em;
  }

  #content a[href]:not(.heading-permalink):active,
  #sidebar a[href]:active,
  #footer a[href]:active {
    text-underline-offset: 0.1em;
  }

  /* Nur bereits inline-flex dargestellte Einzelaktionen, niemals Absatzlinks. */
  #sidebar .social a[href]:active,
  #footer a[href]:active {
    transform: translateY(1px);
  }

  @media (hover: hover) and (pointer: fine) {
    #content a[href]:not(.heading-permalink):hover:not(:active),
    #sidebar a[href]:hover:not(:active),
    #footer a[href]:hover:not(:active) {
      text-underline-offset: 0.24em;
    }

    #sidebar .social a[href]:hover:not(:active),
    #footer a[href]:hover:not(:active) {
      transform: translateY(-1px);
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  /* Überschreibt auch die 0.01ms-Bestandsregel: kein Restübergang bei Links. */
  a[href] {
    transition: none !important;
  }
}
