/* Long-form article prose: headings, lists, quotes, tables, code (Shiki). */
@layer components {
  .prose {
    max-inline-size: var(--measure);
    line-height: var(--leading-prose);
    hyphens: auto;
    hyphenate-limit-chars: 7 3 3;
  }

  .prose > * + * {
    margin-top: 1.05em;
  }

  .prose > h2:first-child,
  .prose > h3:first-child {
    margin-top: 0;
  }

  .prose p {
    text-wrap: pretty;
  }

  .prose h2,
  .prose h3 {
    position: relative;
    color: var(--color-fg);
    line-height: var(--leading-tight);
    scroll-margin-top: var(--space-8);
  }

  .prose h2 {
    margin-top: var(--space-12);
    font-size: var(--fs-xl);
    font-weight: var(--weight-semibold);
  }

  .prose h3 {
    margin-top: var(--space-8);
    font-size: var(--fs-lg);
    font-weight: var(--weight-semibold);
  }

  .prose h2:target,
  .prose h3:target {
    background: var(--color-callout-bg);
    border-inline-start: 2px solid var(--color-accent);
    padding-inline-start: var(--space-3);
    margin-inline-start: calc(-1 * var(--space-3) - 2px);
  }

  .prose .heading-anchor {
    margin-inline-start: 0.4em;
    color: var(--color-muted);
    font-weight: var(--weight-regular);
    font-size: 0.85em;
    text-decoration: none;
    opacity: 0;
    transition: opacity 150ms ease;
  }

  .prose .heading-anchor:focus-visible {
    opacity: 1;
    text-decoration: underline;
  }

  .prose .heading-anchor::before {
    content: '#';
  }

  .prose h2:hover .heading-anchor,
  .prose h3:hover .heading-anchor,
  .prose .heading-anchor:hover {
    opacity: 1;
  }

  @media (hover: none) {
    .prose .heading-anchor {
      opacity: 1;
    }
  }

  .prose ul,
  .prose ol {
    padding-inline-start: 1.25rem;
  }

  .prose li + li {
    margin-top: var(--space-1);
  }

  .prose strong {
    font-weight: var(--weight-bold);
    color: var(--color-fg);
  }

  .prose em {
    font-style: italic;
  }

  .prose blockquote {
    margin-inline: 0;
    padding: var(--space-2) var(--space-4);
    border-inline-start: 3px solid var(--color-rule-medium);
    background: var(--color-callout-bg);
    color: var(--color-muted);
    font-style: italic;
  }

  .prose blockquote > * + * {
    margin-top: 0.6em;
  }

  .prose hr {
    margin-block: var(--space-8);
    border: 0;
    height: 1px;
    background: var(--color-rule);
  }

  .prose table {
    width: 100%;
    max-width: 100%;
    border-collapse: collapse;
    font-size: 0.95em;
    display: block;
    overflow-x: auto;
  }

  .prose thead {
    background: var(--color-code-bg);
    text-align: start;
  }

  .prose th,
  .prose td {
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--color-rule);
    vertical-align: top;
  }

  .prose th {
    font-weight: var(--weight-semibold);
  }

  .prose code {
    font-family: var(--font-mono);
    font-size: 0.88em;
    background: var(--color-code-bg);
    border-radius: var(--radius-sm);
    padding: 0.08em 0.25em;
  }

  .prose pre {
    max-width: 100%;
    overflow-x: auto;
    scrollbar-gutter: stable;
    padding: var(--space-4);
    background: var(--color-code-bg);
    border: 1px solid var(--color-rule);
    border-radius: var(--radius-md);
    line-height: 1.55;
    scrollbar-width: thin;
    scrollbar-color: var(--color-rule-medium) var(--color-code-bg);
  }

  .prose pre::-webkit-scrollbar {
    height: 8px;
  }

  .prose pre::-webkit-scrollbar-track {
    background: var(--color-code-bg);
  }

  .prose pre::-webkit-scrollbar-thumb {
    background: var(--color-rule-medium);
    border-radius: var(--radius-sm);
  }

  .prose pre code {
    background: transparent;
    padding: 0;
  }

  /* Shiki dual-theme: defaultColor: false emits --shiki-light / --shiki-dark
     vars on every token; light-dark() picks the active variant from
     color-scheme on :root. */
  .prose pre.astro-code,
  .prose pre.astro-code code,
  .prose pre.astro-code span {
    color: light-dark(var(--shiki-light), var(--shiki-dark));
    background-color: light-dark(
      var(--shiki-light-bg, var(--color-code-bg)),
      var(--shiki-dark-bg, var(--color-code-bg))
    );
  }
}
