@layer components {
  /* ======================
   * PAGE WITH SIDEBAR
   * ======================
   * Layout with sticky navigation sidebar on desktop.
   * Sidebar hidden on mobile.
   */
  .page-with-sidebar {
    display: grid;
    grid-template-columns: 12rem 1fr;
    gap: var(--inline-space-xl);
    align-items: start;
  }

  @media (max-width: 900px) {
    .page-with-sidebar {
      grid-template-columns: 1fr;
    }
  }

  /* ======================
   * PAGE SIDEBAR
   * ======================
   * Sticky navigation for jumping between sections.
   */
  .page-sidebar {
    position: sticky;
    top: calc(var(--header-height) + var(--block-space));
  }

  /* When preceded by a sticky page-header, increase sidebar top offset */
  .page-header--sticky + .page-with-sidebar .page-sidebar {
    top: calc(var(--header-height) + var(--page-header-sticky-height, 8rem) + var(--block-space));
  }

  @media (max-width: 900px) {
    .page-sidebar {
      display: none;
    }
  }

  .page-sidebar__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--block-space-xs);
  }

  .page-sidebar__link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--inline-space-sm);
    padding: var(--block-space-sm) var(--inline-space);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--color-ink-muted);
    text-decoration: none;
    border-left: 2px solid transparent;
    transition: all 0.15s ease;
  }

  .page-sidebar__link:hover {
    color: var(--color-ink);
    background-color: var(--color-grey-100);
  }

  .page-sidebar__link.is-active {
    color: var(--color-primary);
    border-left-color: var(--color-primary);
    background-color: oklch(from var(--color-primary) l c h / 0.08);
  }

  /* ======================
   * PAGE CONTENT
   * ======================
   * Main content area with stacked sections.
   */
  .page-content {
    display: flex;
    flex-direction: column;
    gap: var(--block-space-lg);
    min-width: 0; /* Prevent grid blowout */
  }

  /* ======================
   * CONTENT SECTION
   * ======================
   * Individual section with title.
   */
  .content-section {
    scroll-margin-top: calc(var(--header-height) + var(--block-space));
  }

  /* When preceded by a sticky page-header, increase scroll offset */
  .page-header--sticky + .page-with-sidebar .content-section {
    scroll-margin-top: calc(var(--header-height) + var(--page-header-sticky-height, 8rem) + var(--block-space));
  }

  .content-section__title {
    font-size: var(--text-lg);
    font-weight: 600;
    margin: 0 0 var(--block-space) 0;
    color: var(--color-ink);
  }

  /* ======================
   * TAG LIST
   * ======================
   * Horizontal list of tags/chips.
   */
  .tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--inline-space-sm);
    list-style: none;
    padding: 0;
    margin: 0;
  }

  .tag {
    display: inline-block;
    font-size: var(--text-sm);
    font-weight: 500;
    padding: var(--block-space-xs) var(--inline-space);
    background-color: var(--color-grey-100);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
  }
}
