/* -- Comment Header (website) ---------------------------------------
   Introduces a discussion: the title with the comment count (a Badge) and
   the sorting - a native Select, or sort links (aria-current) in the tabs
   variant - plus optional actions (follow the thread). */

@layer components {
  .mk-comment-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1rem;
    box-sizing: border-box;
    width: 100%;
    padding-block-end: 0.875rem;
    border-block-end: 1px solid var(--border);
  }

  .mk-comment-header-title {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.01em;
  }

  .mk-comment-header-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
  }

  /* "Sort by" + the select, one label */
  .mk-comment-header-sort {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--muted-foreground);
    font-size: 0.8125rem;
    white-space: nowrap;

    & .select { width: auto; }
  }

  /* sort links: a small segmented row */
  .mk-comment-header-tabs {
    display: inline-flex;
    gap: 0.125rem;
    padding: 0.1875rem;
    border-radius: var(--radius-md);
    background: var(--muted);

    & a {
      padding: 0.25rem 0.75rem;
      border-radius: calc(var(--radius-md) - 2px);
      color: var(--muted-foreground);
      font-size: 0.8125rem;
      font-weight: 500;
      text-decoration: none;
      transition: color 120ms, background-color 120ms;

      &:hover { color: var(--foreground); }
      &[aria-current] { background: var(--background); color: var(--foreground); box-shadow: var(--shadow-xs); }
      &:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
    }
  }

  /* who is talking: an Avatar group + a sentence, on its own row */
  .mk-comment-header-people {
    display: flex;
    flex-basis: 100%;
    align-items: center;
    gap: 0.625rem;
    color: var(--muted-foreground);
    font-size: 0.8125rem;

    & strong { color: var(--foreground); font-weight: 600; }
  }

  /* plain: no rule under the header */
  .mk-comment-header[data-variant="plain"] { padding-block-end: 0; border-block-end: 0; }

  /* -- Accessibility ------------------------------------------- */
  @media (prefers-reduced-motion: reduce) {
    .mk-comment-header-tabs a { transition: none; }
  }

  @media (prefers-contrast: more) {
    .mk-comment-header-sort,
    .mk-comment-header-tabs a { color: var(--foreground); }
  }

  @media (forced-colors: active) {
    .mk-comment-header-tabs { border: 1px solid CanvasText; }
    .mk-comment-header-tabs a[aria-current] { forced-color-adjust: none; background: Highlight; color: HighlightText; }
  }
}
