@layer pages {
  .blog-eyebrow {
    color: var(--color-accent-text);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;

    a {
      text-decoration: none;
    }
  }

  .post-meta {
    color: var(--color-text-subtle);
    font-size: var(--text-sm);
  }

  .blog-message {
    display: grid;
    justify-items: center;
    gap: var(--space-4);
    min-block-size: 60vh;
    align-content: center;
    padding: var(--space-10) var(--gutter) var(--space-8);
    text-align: center;

    p {
      color: var(--color-text-muted);
    }
  }

  /* Index: the latest post as a full-bleed hero, Netflix-style. */
  .blog-hero {
    position: relative;
    isolation: isolate;
    display: grid;
    align-items: end;
    min-block-size: min(88svh, 52rem);
    overflow: hidden;

    > .post-cover {
      position: absolute;
      inset: 0;
      z-index: -2;
      inline-size: 100%;
      block-size: 100%;
      object-fit: cover;
    }

    &::before {
      content: "";
      position: absolute;
      inset: 0;
      z-index: -1;
      background:
        linear-gradient(to top, var(--color-bg), transparent 60%),
        linear-gradient(to right, oklch(from var(--color-bg) l c h / 0.85), transparent 70%);
    }
  }

  .blog-hero-body {
    display: grid;
    justify-items: start;
    gap: var(--space-4);
    inline-size: 100%;
    max-inline-size: var(--content-max);
    margin-inline: auto;
    padding: var(--space-10) var(--gutter) var(--space-8);
  }

  .blog-hero-title {
    max-inline-size: 20ch;
    font-size: var(--text-4xl);

    a {
      text-decoration: none;
    }
  }

  .blog-hero-text {
    max-inline-size: 36rem;
    color: var(--color-text);
    font-size: var(--text-lg);
  }

  .blog-list {
    display: grid;
    gap: var(--space-6);
    max-inline-size: var(--content-max);
    margin-inline: auto;
    padding: var(--space-8) var(--gutter) var(--space-10);

    h2 {
      font-size: var(--text-2xl);
    }
  }

  .post-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr));
    gap: var(--space-7) var(--space-5);
  }

  .post-card-link {
    display: grid;
    align-content: start;
    gap: var(--space-3);
    color: inherit;
    text-decoration: none;

    .post-cover {
      aspect-ratio: 16 / 9;
      inline-size: 100%;
      margin-block-end: var(--space-2);
      border-radius: var(--radius-lg);
      object-fit: cover;
      box-shadow: var(--shadow-2);
      transition: translate var(--duration-base) var(--ease-out);
    }

    &:hover {
      color: inherit;

      .post-cover {
        translate: 0 -4px;
      }

      .post-card-title {
        color: var(--color-accent-text);
      }
    }
  }

  .post-card-title {
    font-size: var(--text-xl);
    transition: color var(--duration-fast) var(--ease-out);
  }

  .post-card-text {
    color: var(--color-text-muted);
  }

  /* Post: full-width page, text down the middle. Named lines let blocks break out to "wide" or "full". */
  .post-header,
  .post-body {
    --wide: 12rem;

    display: grid;
    grid-template-columns:
      [full-start] minmax(var(--gutter), 1fr)
      [wide-start] minmax(0, var(--wide))
      [content-start] min(var(--reading-max), 100% - 2 * var(--gutter))
      [content-end] minmax(0, var(--wide))
      [wide-end] minmax(var(--gutter), 1fr) [full-end];

    > * {
      grid-column: content;
    }
  }

  .post-header {
    row-gap: var(--space-4);
    padding-block: var(--space-10) var(--space-7);
  }

  .post-title {
    font-size: var(--text-4xl);
  }

  .post-lede {
    color: var(--color-text-muted);
    font-size: var(--text-xl);
    line-height: var(--leading-snug);
  }

  .post-hero-cover .post-cover {
    inline-size: 100%;
    block-size: clamp(14rem, 45vw, 34rem);
    object-fit: cover;
  }

  .post-body {
    padding-block: var(--space-8);
    color: var(--color-text);
    font-size: var(--text-lg);
    line-height: 1.75;

    > * + * {
      margin-block-start: 1.25em;
    }

    > :is(h2, h3) {
      margin-block-start: 2em;
      scroll-margin-block-start: 5rem;
    }

    > h2 {
      font-size: var(--text-2xl);
    }

    > h3 {
      font-size: var(--text-xl);
    }

    > :is(h2, h3) + * {
      margin-block-start: 0.75em;
    }

    a {
      color: var(--color-text-strong);
      text-decoration-color: var(--color-accent);
      text-decoration-thickness: 2px;
    }

    strong {
      color: var(--color-text-strong);
    }

    :is(ul, ol) {
      display: grid;
      gap: 0.5em;
      padding-inline-start: 1.25em;
    }

    li::marker {
      color: var(--color-accent-text);
    }

    /* Pull quote. */
    > blockquote {
      grid-column: wide;
      margin-block: 2em;
      padding-inline-start: var(--space-6);
      border-inline-start: 3px solid var(--color-accent);
      color: var(--color-text-strong);
      font-size: var(--text-2xl);
      line-height: var(--leading-snug);
      text-wrap: balance;
    }

    /* Pictures and code get the wider column. */
    > :is(p:has(> img:only-child), pre, table, .post-word) {
      grid-column: wide;
    }

    img {
      inline-size: 100%;
      border-radius: var(--radius-lg);
    }

    pre {
      padding: var(--space-5);
      overflow-x: auto;
      border-radius: var(--radius-lg);
      background: var(--color-surface-1);
      font-size: var(--text-sm);
      line-height: var(--leading-normal);
    }

    :not(pre) > code {
      padding: 0.1em 0.35em;
      border-radius: var(--radius-sm);
      background: var(--color-surface-2);
    }

    table {
      border-collapse: collapse;
      font-size: var(--text-md);

      :is(th, td) {
        padding: var(--space-2) var(--space-3);
        border-block-end: 1px solid var(--color-border);
        text-align: start;
      }
    }

    hr {
      margin-block: 2.5em;
    }
  }

  /* A word example: word, meaning, the sentence it came from. */
  .post-word {
    display: grid;
    justify-items: center;
    gap: var(--space-2);
    margin-block: 2em;
    padding: var(--space-7) var(--space-6);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    background:
      radial-gradient(60% 80% at 50% 0%, var(--color-accent-soft), transparent 70%),
      var(--color-surface-1);
    text-align: center;

    p {
      margin: 0;
    }
  }

  .post-word-ar {
    color: var(--color-text-strong);
    font-size: calc(var(--text-4xl) * var(--script-scale));
    font-weight: var(--weight-semibold);
    line-height: 1.4;
  }

  .post-word-gloss {
    color: var(--color-accent-text);
    font-size: var(--text-lg);
  }

  .post-word .post-word-sentence {
    margin-block-start: var(--space-3);
    font-size: calc(var(--text-xl) * var(--reading-scale));
  }

  .post-word-translation {
    color: var(--color-text-muted);
    font-size: var(--text-md);
  }

  .post-cta {
    display: grid;
    justify-items: center;
    gap: var(--space-4);
    max-inline-size: calc(var(--reading-max) + 8rem);
    margin: var(--space-6) auto 0;
    padding: var(--space-8) var(--gutter);
    border: 1px solid var(--color-accent-border);
    border-radius: var(--radius-xl);
    background: radial-gradient(70% 90% at 50% 100%, var(--color-accent-soft), transparent 70%), var(--color-surface-1);
    box-shadow: var(--glow-accent);
    text-align: center;

    h2 {
      max-inline-size: 22ch;
      font-size: var(--text-2xl);
    }

    p {
      color: var(--color-text-muted);
    }

    @media (width < 52rem) {
      margin-inline: var(--gutter);
    }
  }
}
