/* Plate supplement: an optional slot between §2 Source and the cross-reference, open to any project
   with more to say than the template holds (TEMPLATE.md, "Plate supplement"). Frame components only:
   the project fills them with its own words. This file: the slot, its parts, numbered clauses and
   a listing (a figure that shows a raw response as text). Code and tables: p-supplement-code.css.
   Known gaps (condition report) and footnote: p-supplement-report.css. */
@layer supplement {
  .supplement { display: block; max-inline-size: var(--page-max); margin-inline: auto; }

  /* One part of the supplement: a 12-column section under a strong rule */
  .supplement__part {
    display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--col-gap);
    row-gap: clamp(2rem, 4vw, 3.5rem);
    margin-block-start: var(--section); padding-block-start: clamp(2rem, 4vw, 3rem);
    border-top: 1px solid var(--hair-strong);
  }
  .supplement__head { grid-column: 1 / -1; display: grid; gap: 1rem; }
  .supplement__title {
    font-size: var(--fs-h2); line-height: 0.85; letter-spacing: -0.035em; text-wrap: balance; max-inline-size: 16ch;
    & em { color: var(--accent); }
  }
  .supplement__lede { font-style: italic; color: var(--ink-2); max-inline-size: 40ch; }

  /* Clauses: numbered claims, 01 … nn. Plain numbers, not §: the plate's own sections hold §1 and §2 */
  .clauses {
    grid-column: 1 / span 7; counter-reset: clause;

    & li {
      counter-increment: clause;
      display: grid; grid-template-columns: 4.5rem minmax(0, 1fr); column-gap: 1rem; row-gap: 0.5rem;
      padding-block: 1.25rem 1.5rem; border-top: 1px solid var(--hair);
      &::before { content: counter(clause, decimal-leading-zero); grid-row: 1 / span 2; font: 500 var(--fs-mono) / 2 var(--mono); color: var(--accent-text); }
    }
    & li:first-child { border-top: 0; padding-block-start: 0; }
    & h3 { font-size: var(--fs-h3); line-height: 1; letter-spacing: -0.02em; text-wrap: balance; }
    & p { font: 400 var(--fs-mono) / 1.65 var(--mono); color: var(--ink-2); max-inline-size: 62ch; text-wrap: pretty; }
  }
  /* The honest counter-clause: when to use something else */
  .clauses__caveat {
    grid-column: 1 / span 7; padding: 1rem 0 0 5.5rem; border-top: 1px solid var(--hair);
    font-size: 1.15rem; line-height: 1.35; color: var(--ink-2); text-wrap: pretty;
    & b { color: var(--ink); font-weight: 400; font-style: italic; }
  }

  /* Listing: a numbered figure that shows a live response as text, beside the clauses */
  .listing {
    grid-column: 8 / -1; grid-row: 2 / span 2; align-self: start; min-inline-size: 0;
    position: sticky; top: calc(var(--rail-h) + 1.5rem);
  }
  .listing__head {
    display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.3rem 1rem;
    padding-block-end: 0.6rem; border-bottom: 2px solid var(--accent);
  }
  .listing__text {
    block-size: clamp(18rem, 52vh, 34rem); overflow: clip;
    padding-block: 0.8rem;
    font: 400 var(--fs-label) / 1.55 var(--mono); color: var(--ink-3);
    white-space: pre-wrap; word-break: break-all;
    mask-image: linear-gradient(#000 65%, transparent);
  }
  .listing figcaption {
    padding-block-start: 0.8rem; border-top: 1px solid var(--hair);
    font: 400 var(--fs-mono) / 1.55 var(--mono); color: var(--ink-2); text-wrap: pretty;
    & output { color: var(--accent-text); font-variant-numeric: tabular-nums; }
  }

  @media (width < 64rem) {
    .clauses, .clauses__caveat, .listing { grid-column: 1 / -1; grid-row: auto; }
    .listing { position: static; }
    .listing__text { block-size: 16rem; }
  }
  @media (width < 30rem) {
    .clauses li { grid-template-columns: minmax(0, 1fr); }
    .clauses li::before { grid-row: auto; }
    .clauses__caveat { padding-inline-start: 0; }
  }
}
