/*
 * site-nav: content of the sidebar/drawer (.app__nav from layout.css): grouped links with a sprite
 * icon, the current page marked by aria-current="page". It carries its own dark background so it
 * also renders outside the drawer. Groups: a .site-nav__heading over a list, or a collapsible
 * <details class="site-nav__group"><summary class="site-nav__summary">…</summary><ul>…</ul></details>
 * (open by default; the one holding the current page must be open). The brand block at the top is
 * <a class="brand-logo brand-logo--on-dark site-nav__brand">.
 */
@layer components {
  .site-nav {
    display: grid;
    gap: var(--space-2);
    padding: var(--space-2);
    border-radius: var(--radius-lg);
    background: var(--color-nav);
    color: var(--color-on-nav);
  }

  .site-nav__heading {
    padding-inline: var(--space-3);
    font-size: var(--text-xs);
    font-weight: var(--weight-medium);
    text-transform: uppercase;
  }

  .site-nav__list {
    display: grid;
    gap: var(--space-1);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .site-nav__link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    border-radius: var(--radius-md);
    color: var(--color-on-nav);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    text-decoration: none;

    &:hover {
      background: var(--color-nav-hover);
      color: var(--color-on-nav);
    }

    &:active,
    &[aria-current="page"] {
      background: var(--color-nav-active);
    }

    /* The teal ring vanishes on the dark sidebar; white keeps 9.41:1 (DESIGN.md pairs). */
    &:focus-visible {
      outline-color: var(--color-on-nav);
    }
  }

  /* Brand teal is decorative on dark backgrounds: it marks the current page without text. */
  .site-nav__link[aria-current="page"] {
    box-shadow: inset var(--space-1) 0 0 var(--color-brand);
  }

  /* A link with no href is not focusable; aria-disabled tells assistive tech why. */
  .site-nav__link[aria-disabled="true"] {
    background: none;
    cursor: not-allowed;
    opacity: 0.7;
  }

  .site-nav__icon {
    flex: none;
    width: 1.25em;
    height: 1.25em;
  }

  .site-nav__brand {
    margin: var(--space-2) var(--space-3) var(--space-4);
  }

  /* Collapsible group: the summary looks like a heading with a chevron that turns when open. */
  .site-nav__group {
    display: grid;
    gap: var(--space-1);
  }

  .site-nav__summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    color: var(--color-on-nav);
    font-size: var(--text-xs);
    font-weight: var(--weight-medium);
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
    list-style: none;
    opacity: 0.85;

    &::-webkit-details-marker {
      display: none;
    }

    &:hover {
      background: var(--color-nav-hover);
      opacity: 1;
    }

    & svg {
      flex: none;
      inline-size: 1em;
      block-size: 1em;
      transition: transform var(--duration-fast) var(--ease-out);
    }
  }

  .site-nav__group[open] .site-nav__summary svg {
    transform: rotate(180deg);
  }

  /* A badge in the sidebar (unread count) inverts onto the dark surface. */
  .site-nav__count {
    margin-inline-start: auto;
    padding: 0 var(--space-2);
    border-radius: var(--radius-full);
    background: var(--color-on-nav);
    color: var(--color-nav);
    font-size: var(--text-xs);
    font-variant-numeric: tabular-nums;
  }
}
