/* ==========================================================================
   William Okano — Blog
   Loaded after style.css on generated blog pages. Reuses the site's tokens,
   navigation, and card language; adds the reading surfaces.
   ========================================================================== */

@layer sections {
  .blog-page {
    padding-block-start: calc(var(--nav-height) + var(--space-xl));
    padding-block-end: var(--space-2xl);
    min-height: 100dvh;
  }

  /* --- Listing header --- */
  .blog-eyebrow {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    letter-spacing: 0.05em;
    margin-block-end: var(--space-md);

    & a {
      color: var(--text-muted);
      transition: color 0.2s ease;

      &:hover {
        color: var(--accent);
      }
    }
  }

  .blog-hero {
    margin-block-end: var(--space-xl);
    padding-block-end: var(--space-md);
    border-block-end: 1px solid var(--border);

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

  .blog-lede {
    margin-block-start: var(--space-sm);
    color: var(--text-secondary);
    font-size: var(--text-lg);
  }

  .feed-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
    margin-block-start: var(--space-md);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--accent);
    transition: color 0.2s ease;

    &:hover {
      color: var(--accent-hover);
    }
  }

  /* --- Listing --- */
  .post-list {
    display: grid;
    gap: var(--space-md);
  }

  .post-list-item {
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
  }

  .post-list-title {
    font-family: var(--font-heading);
    font-size: var(--text-xl);
    font-weight: 600;

    & a {
      transition: color 0.2s ease;

      &:hover {
        color: var(--accent);
      }
    }
  }

  .post-list-summary {
    color: var(--text-secondary);
    font-size: var(--text-sm);
  }

  /* style.css scopes this link to .article-card; listing cards need it too. */
  .post-list-item .article-card-link {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    gap: 0.3em;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--accent);
    transition: color 0.2s ease, gap 0.2s ease;

    &:hover {
      color: var(--accent-hover);
      gap: 0.6em;
    }
  }

  /* --- Empty state (no posts published yet) --- */
  .blog-empty {
    display: grid;
    justify-items: center;
    gap: var(--space-md);
    padding-block: var(--space-2xl);
    text-align: center;
    border: 1px dashed var(--border);
    border-radius: var(--radius-md);
    color: var(--text-muted);

    & svg {
      width: 2.5rem;
      height: 2.5rem;
      color: var(--text-muted);
      opacity: 0.6;
    }

    & p {
      max-width: 32ch;
    }
  }

  /* --- Post --- */
  .post-container {
    width: min(92%, 46rem);
  }

  .post-header {
    margin-block-end: var(--space-xl);
    padding-block-end: var(--space-md);
    border-block-end: 1px solid var(--border);

    & h1 {
      font-size: var(--text-2xl);
      margin-block-end: var(--space-sm);
    }
  }

  .post-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4em;
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-block-end: var(--space-sm);
  }

  .post-summary {
    margin-block-start: var(--space-sm);
    color: var(--text-secondary);
    font-size: var(--text-lg);
  }

  .post-translations {
    margin-block-start: var(--space-sm);
    font-size: var(--text-sm);
    color: var(--text-muted);

    & a {
      color: var(--accent);
      text-decoration: underline;
      text-underline-offset: 0.2em;
    }
  }

  .post-translations--single {
    font-style: italic;
  }

  /* --- Prose --- */
  .prose {
    color: var(--text-secondary);

    & > * + * {
      margin-block-start: var(--space-md);
    }

    & h2, & h3, & h4 {
      color: var(--text-primary);
      margin-block-start: var(--space-xl);
      margin-block-end: var(--space-sm);
      scroll-margin-block-start: calc(var(--nav-height) + var(--space-md));
    }

    & h2 { font-size: var(--text-xl); }
    & h3 { font-size: var(--text-lg); }
    & h4 { font-size: var(--text-base); }

    & p {
      max-width: none;
    }

    & a {
      color: var(--accent);
      text-decoration: underline;
      text-underline-offset: 0.2em;
      transition: color 0.2s ease;

      &:hover {
        color: var(--accent-hover);
      }
    }

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

    & ul, & ol {
      padding-inline-start: 1.5em;
      display: flex;
      flex-direction: column;
      gap: var(--space-xs);
    }

    & ul { list-style: disc; }
    & ol { list-style: decimal; }

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

    & blockquote {
      padding-inline-start: var(--space-md);
      border-inline-start: 3px solid var(--accent);
      color: var(--text-secondary);
      font-style: italic;

      & > * + * {
        margin-block-start: var(--space-sm);
      }
    }

    & code {
      background: var(--accent-muted);
      color: var(--accent);
      padding: 0.1em 0.35em;
      border-radius: 0.3em;
    }

    & pre {
      background: var(--bg-secondary);
      border: 1px solid var(--border);
      border-radius: var(--radius-md);
      padding: var(--space-md);
      overflow-x: auto;
      line-height: 1.6;

      & code {
        background: none;
        color: var(--text-primary);
        padding: 0;
        font-size: 0.85em;
      }
    }

    & img {
      border-radius: var(--radius-md);
      margin-inline: auto;
    }

    & hr {
      border: 0;
      border-block-start: 1px solid var(--border);
      margin-block: var(--space-lg);
    }

    & .table-scroll {
      overflow-x: auto;
    }

    & table {
      width: 100%;
      border-collapse: collapse;
      font-size: var(--text-sm);
    }

    & th, & td {
      padding: var(--space-sm);
      border-block-end: 1px solid var(--border);
      text-align: start;
    }

    & th {
      color: var(--text-primary);
      font-family: var(--font-heading);
      font-weight: 600;
    }
  }

  .heading-anchor {
    margin-inline-start: 0.4em;
    color: var(--accent);
    opacity: 0;
    font-weight: 400;
    transition: opacity 0.2s ease;
    text-decoration: none;

    h2:hover > &,
    h3:hover > &,
    h4:hover > &,
    &:focus-visible {
      opacity: 1;
    }
  }

  /* --- Post navigation --- */
  .post-pager {
    display: grid;
    gap: var(--space-md);
    margin-block-start: var(--space-xl);

    @media (min-width: 40em) {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
  }

  .post-pager-link {
    display: flex;
    flex-direction: column;
    gap: 0.2em;
    padding: var(--space-md);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    transition: border-color 0.2s ease, transform 0.2s ease;

    &:hover {
      border-color: var(--accent);
      transform: translateY(-2px);
    }
  }

  .post-pager-link--older {
    text-align: end;
    grid-column: 2;
  }

  .post-pager-label {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.06em;
  }

  .post-pager-title {
    font-family: var(--font-heading);
    font-weight: 500;
    font-size: var(--text-sm);
    color: var(--text-primary);
  }

  .post-footer-cta {
    margin-block-start: var(--space-xl);
    text-align: center;
    max-width: none;
  }

  /* Generated pages use anchors, not buttons, for the language picker. */
  .lang-picker a.lang-option {
    display: inline-block;
    text-decoration: none;
  }
}
