/* At-a-glance, facts, media figures, post nav, TOC, gallery, related posts. */
@layer components {
  .at-a-glance {
    margin-top: var(--space-8);
    padding-block: var(--space-5);
    border-block: 1px solid var(--color-rule);
  }

  .at-a-glance dl,
  .facts dl {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin: var(--space-4) 0 0;
  }

  .at-a-glance__row,
  .facts dl > div {
    display: grid;
    grid-template-columns: minmax(6rem, max-content) minmax(0, 1fr);
    gap: var(--space-4);
  }

  .at-a-glance dt,
  .facts dt {
    color: var(--color-muted);
    font-size: var(--fs-caption);
  }

  .facts {
    margin-top: var(--space-8);
    padding-top: var(--space-6);
    border-top: 1px solid var(--color-rule);
  }

  /* Let prose wrap beside .at-a-glance and continue below it. */
  @media (min-width: 1100px) {
    .post > .at-a-glance {
      float: right;
      width: min(18rem, 42%);
      margin-top: var(--space-8);
      margin-right: 0;
      margin-bottom: var(--space-4);
      margin-left: var(--space-8);
    }

    .post > .post-media,
    .post > .post-gallery,
    .related-posts,
    .post-nav {
      clear: both;
    }
  }

  .post-media {
    max-inline-size: min(100%, var(--measure-wide));
    margin: var(--space-8) 0 0;
  }

  .post-media img,
  .post-media video {
    border: 1px solid var(--color-rule);
    border-radius: var(--radius-md);
    background: var(--color-code-bg);
    width: 100%;
  }

  .post-media figcaption,
  .media-transcript {
    max-width: var(--measure);
    margin-top: var(--space-2);
    color: var(--color-muted);
    font-size: var(--fs-caption);
    line-height: 1.45;
  }

  .media-transcript strong {
    color: var(--color-fg);
    font-weight: var(--weight-semibold);
  }

  .post-nav {
    margin-top: var(--space-12);
    padding-top: var(--space-6);
    border-top: 1px solid var(--color-rule);
  }

  .post-nav__list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
    gap: var(--space-4);
    list-style: none;
    padding: 0;
    margin: 0;
  }

  .post-nav__next {
    justify-self: end;
  }

  .post-nav a {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--color-rule);
    border-radius: var(--radius-md);
    color: var(--color-fg);
    text-decoration: none;
    min-height: 44px;
    transition: border-color 150ms ease;
  }

  .post-nav a:hover,
  .post-nav a:focus-visible {
    border-color: var(--color-rule-strong);
  }

  .post-nav a.next {
    text-align: end;
  }

  .post-nav .post-nav__label {
    color: var(--color-muted);
    font-size: var(--fs-caption);
  }

  .post-nav .post-nav__title {
    color: var(--color-fg);
    font-weight: var(--weight-semibold);
  }

  .post-toc {
    margin-top: var(--space-6);
    padding: var(--space-3) var(--space-4);
    border-inline-start: 2px solid var(--color-rule);
    font-size: var(--fs-caption);
    color: var(--color-muted);
    max-height: 60vh;
    overflow-y: auto;
  }

  .post-header h1,
  .post-nav .post-nav__title,
  .project-card h3 {
    overflow-wrap: anywhere;
  }

  .post-toc ol {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
  }

  .post-toc a {
    display: inline-flex;
    align-items: center;
    min-block-size: 24px;
    padding-block: 2px;
    color: var(--color-muted);
    text-decoration: none;
  }

  .post-toc a:hover,
  .post-toc a:focus-visible {
    color: var(--color-fg);
  }

  .post-gallery {
    list-style: none;
    padding: 0;
    margin: var(--space-8) 0 0;
    display: grid;
    gap: var(--space-6);
  }

  .post > .post-gallery {
    width: 100%;
  }

  .post-gallery .post-media {
    max-inline-size: 100%;
    margin: 0;
  }

  .external-link-icon {
    display: inline-block;
    margin-inline-start: 0.25em;
    vertical-align: -0.125em;
    opacity: 0.85;
  }

  .related-posts {
    margin-top: var(--space-12);
    padding-top: var(--space-6);
    border-top: 1px solid var(--color-rule);
  }

  .related-posts h2 {
    font-size: var(--fs-lg);
    font-weight: var(--weight-semibold);
    margin-bottom: var(--space-4);
  }

  .empty-state {
    max-width: var(--measure);
    padding-block: var(--space-6);
  }
}
