@layer components {
  .nav-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-3);

    font-family: inherit;
    font-size: var(--text-normal);
    font-weight: var(--font-weight-semibold);
    color: var(--color-muted);
    text-decoration: none;
    background-color: transparent;
    border-radius: var(--radius-md);
    border: none;

    cursor: pointer;
    user-select: none;
    transition:
      background-color 0.2s ease,
      color 0.2s ease;
  }

  .nav-link:hover:not(.nav-link--active),
  .nav-link:focus-visible:not(.nav-link--active) {
    color: var(--color-ink);
    background-color: var(--color-selected);
  }

  .nav-link--active {
    background-color: var(--color-selected);
    color: var(--color-blue-accent);
  }

  /* Sidebar */
  .sidebar {
    width: 200px; /* a width of its own: no step of the spacing scale is a column */
    min-width: 200px;
    height: 100dvh;
    position: sticky;
    top: 0;
    /* Over the columns beside it: sticky makes it a layer of its own, so its menus' z-index counts only inside it.
       The AI usage, wider than the sidebar, lay under the outline (whose links are positioned) without this. */
    z-index: var(--z-nav);
    flex-shrink: 0;
    box-sizing: border-box;
    padding-inline: var(--space-2);
    /* On the canvas grey like the columns beside it */
    background-color: var(--color-canvas);
  }

  .sidebar.is-sidebar-collapsed {
    width: auto;
    min-width: 0;
  }

  /* Calm like a desktop app's sidebar: the links in the text's color, not bold, their icons as large as their text and
     in its color; close to the edge (8px to the sidebar's edge, 8px inside them, so icons start 16px in) and 40px high
     to tap on a tablet (.sidebar-nav .nav-link). Chosen in blue as everywhere (.nav-link--active, here against the
     text's color above), under the pointer grey. */
  .sidebar .nav-link {
    padding-inline: var(--space-2);
    font-weight: var(--font-weight-normal);
    color: var(--color-ink);
  }

  .sidebar .nav-link--active {
    color: var(--color-blue-accent);
  }

  .sidebar .sidebar-nav .nav-link:is(:hover, :focus-visible):not(.nav-link--active, .nav-link--danger) {
    color: var(--color-ink);
    background-color: var(--color-border);
  }

  /* The logo in line with the icons below it */
  .sidebar-logo {
    padding-inline-start: var(--space-2);
  }

  .is-sidebar-collapsed .sidebar-toggle {
    rotate: 180deg;
  }

  /* Square icon links, same size as the toggle button */
  .sidebar.is-sidebar-collapsed .nav-link {
    padding: var(--space-2);
    font-size: var(--text-large);
  }

  /* Styling for sidebar links */
  .sidebar-nav .nav-link {
    width: 100%;
    padding-block: var(--space-2);
  }

  .sidebar-nav .nav-link:hover:not(.nav-link--active),
  .sidebar-nav .nav-link:focus-visible:not(.nav-link--active) {
    color: var(--color-blue-accent);
  }

  /* The open project's pages, set apart from the project list, a little more than the sidebar's own gap (24.11.,
     Niklas: less than before) */
  .sidebar-project {
    margin-block-start: var(--space-2);
  }

  /* The project's title over its pages like a section's heading: smaller than they are and bold, in line with their
     icons; long titles end after two lines (title shows all) */
  .sidebar-project-title {
    margin-block: 0 var(--space-1);
    padding-inline-start: var(--space-2);
    font-size: var(--text-small);
    font-weight: var(--font-weight-semibold);
    color: var(--color-ink);
  }

  /* The account at the bottom of the sidebar (layouts/_account_menu): its name, then a chevron at the end showing
     that it opens a menu */
  .account-menu__chevron {
    margin-inline-start: auto;
  }

  /* Its menu opens upwards, wide enough to read in the collapsed sidebar too, the legal pages in one row */
  .account-menu .dropdown-menu {
    min-inline-size: 14rem;
    right: auto;
  }

  .dropdown-menu {
    position: absolute;
    width: 100%;
    right: 0;
    left: auto;
    z-index: var(--z-nav);
    overflow: hidden;
    border: var(--border);
  }

  .dropdown-menu--up[open] {
    position: absolute;
    top: auto;
    bottom: calc(100% + var(--space-2));
    left: 0;
    right: 0;
  }

  /* Styling for dropdown links */
  .dropdown-menu .nav-link {
    padding-block: var(--space-2);
    border-radius: 0;
    width: 100%;
  }

  .dropdown-menu .nav-link:hover:not(.nav-link--active),
  .dropdown-menu .nav-link:focus-visible:not(.nav-link--active) {
    color: var(--color-blue-accent);
  }

  /* Danger variant for nav links */
  .nav-link.nav-link--danger {
    color: var(--color-negative);
  }

  .nav-link.nav-link--danger:hover:not(.nav-link--active),
  .nav-link.nav-link--danger:focus-visible:not(.nav-link--active) {
    color: var(--color-negative);
    background-color: var(--color-negative-soft);
  }
}
