/*
  Shared prose styles for rendered markdown content.
  Imported by public/plugins/<name>/index.md for VSCode preview fidelity.
  Also imported by Markdown.astro for the live site.
*/

.markdown-content {
  max-width: var(--content-max-width, 760px);
  margin-inline: auto;

  /* ── Headings ──────────────────────────────────────────────── */

  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    font-family: var(--family-sans, system-ui, sans-serif);
    font-weight: var(--fw-semibold, 600);
    line-height: var(--lh-heading, 1.25);
    color: var(--color-fg, #111);
    scroll-margin-top: calc(var(--nav-height, 56px) + 1rem);
  }

  h1 {
    font-size: var(--hu, 2.25rem);
    margin-block-start: 0;
    margin-block-end: 1.5rem;
  }

  h2 {
    font-size: var(--hh, 1.75rem);
    margin-block-start: 2.5rem;
    margin-block-end: 0.75rem;
    padding-block-end: 0.375rem;
    border-bottom: 1px solid var(--color-border, #e5e7eb);
  }

  h3 {
    font-size: var(--hl, 1.5rem);
    margin-block-start: 2rem;
    margin-block-end: 0.5rem;
  }

  h4 {
    font-size: var(--hm, 1.25rem);
    margin-block-start: 1.5rem;
    margin-block-end: 0.5rem;
  }

  h5,
  h6 {
    font-size: var(--hs, 1rem);
    margin-block-start: 1.5rem;
    margin-block-end: 0.5rem;
  }

  /* ── Body text ─────────────────────────────────────────────── */

  p {
    font-weight: var(--fw-regular, 400);
    line-height: var(--lh-body, 1.75);
    margin-block-end: 1rem;
  }

  /* ── Links ─────────────────────────────────────────────────── */

  a {
    color: var(--color-accent, #3b82f6);
    text-decoration: underline;
    text-underline-offset: 2px;

    &:hover {
      color: var(--color-accent-hover, #2563eb);
    }
  }

  /* ── Lists ─────────────────────────────────────────────────── */

  ul,
  ol {
    padding-inline-start: 1.5rem;
    margin-block-end: 1rem;

    li {
      font-weight: var(--fw-regular, 400);
      line-height: var(--lh-body, 1.75);
      margin-block-end: 0.25rem;
    }
  }

  ul {
    list-style: disc;
  }

  ol {
    list-style: decimal;
  }

  /* ── Definition lists ──────────────────────────────────────── */

  dl {
    margin-block-end: 1rem;
  }

  dt {
    font-weight: var(--fw-semibold, 600);
    line-height: var(--lh-body, 1.75);
    color: var(--color-fg, #111);
    margin-block-start: 0.75rem;

    &:first-child {
      margin-block-start: 0;
    }
  }

  dd {
    line-height: var(--lh-body, 1.75);
    margin-inline-start: 0.25rem;
    padding-inline-start: 1rem;
    border-inline-start: 2px solid var(--color-border, #e5e7eb);

    & + dd {
      margin-block-start: 0.25rem;
    }

    > :last-child {
      margin-block-end: 0;
    }
  }

  /* ── Code ──────────────────────────────────────────────────── */

  code {
    font-family: var(--family-mono, monospace);
    font-size: var(--bm, 1rem);
    font-weight: var(--fw-regular, 400);
    line-height: var(--lh-code, 1.6);
    background-color: var(--color-code-bg, #f3f4f6);
    border-radius: var(--radius-sm, 0.25rem);
    padding-inline: 0.3em;
    padding-block: 0.1em;
  }

  pre {
    font-family: var(--family-mono, monospace);
    font-size: var(--bm, 1rem);
    font-weight: var(--fw-regular, 400);
    line-height: var(--lh-code, 1.6);
    background-color: var(--color-code-bg, #f3f4f6);
    border: 1px solid var(--color-border, #e5e7eb);
    border-radius: var(--radius-md, 0.375rem);
    padding: 1rem;
    /* Long lines wrap rather than scroll the page sideways. */
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    overflow-x: auto;
    margin-block-end: 1rem;

    code {
      background: none;
      padding: 0;
      font-size: inherit;
    }
  }

  /* ── Blockquote ────────────────────────────────────────────── */

  blockquote {
    border-inline-start: 3px solid var(--color-accent, #3b82f6);
    padding-inline-start: 1rem;
    margin-inline-start: 0;
    margin-block-end: 1rem;
    color: var(--color-fg-muted, #6b7280);

    p {
      margin-block-end: 0;
    }
  }

  /* ── Table ─────────────────────────────────────────────────── */

  table {
    width: stretch;
    border-collapse: collapse;
    margin-block-end: 1rem;
    font-size: var(--bs, 0.875rem);
    font-weight: var(--fw-regular, 400);
    line-height: var(--lh-body-sm, 1.6);
  }

  th,
  td {
    text-align: left;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border, #e5e7eb);
  }

  th {
    font-weight: var(--fw-semibold, 600);
    background-color: var(--color-code-bg, #f3f4f6);
  }

  /* ── HR ────────────────────────────────────────────────────── */

  hr {
    border: none;
    border-top: 1px solid var(--color-border, #e5e7eb);
    margin-block: 2rem;
  }

  /* ── Images ────────────────────────────────────────────────── */

  img {
    border-radius: var(--radius-md, 0.375rem);
    max-width: 100%;
    height: auto;
  }

  p img {
    display: inline;
    vertical-align: middle;
  }

  /* ── Block-level breakout (mobile only) ───────────────────────
     At mobile, --content-padding-inline is 0 and
     --prose-padding-inline provides edge-to-edge breakout.
     On desktop these elements stay within the prose width.
  ─────────────────────────────────────────────────────────────── */

  @media (width < 768px) {
    pre,
    .markdown-alert,
    .markdown-tabs,
    .markdown-steps {
      --_outer: var(--content-padding-inline, 0px);
      --_inner: var(--prose-padding-inline, 1rem);
      width: calc(100% + var(--_inner) * 2);
      margin-inline: calc(var(--_inner) * -1);
    }

    pre {
      border-radius: 0;
      border-left: none;
      border-right: none;
      font-size: var(--bs, 0.875rem);
      padding: 0.75rem 1rem;
      overflow-x: auto;
      -webkit-overflow-scrolling: touch;

      code {
        font-size: inherit;
        white-space: pre;
      }
    }

    .markdown-alert {
      border-radius: 0;
    }

    /* Re-indent steps content so number circles align with prose text */
    .markdown-steps {
      padding-inline: var(--prose-padding-inline, 1rem);
    }
  }
}
