/* Plate supplement, code and tables: numbered steps with their code, a code block, and a reference
   table with a title. Generic: any plate's supplement may use them (TEMPLATE.md). */
@layer supplement {
  .steps { grid-column: 1 / -1; counter-reset: step; }
  .step {
    counter-increment: step;
    display: grid; grid-template-columns: minmax(0, 4fr) minmax(0, 8fr); column-gap: calc(var(--col-gap) * 2); row-gap: 0.6rem;
    position: relative;
    padding: 1.4rem 0 1.8rem 4.5rem;
    border-top: 1px solid var(--hair);

    &::before {
      content: counter(step, upper-roman);
      position: absolute; left: 0; top: 1.1rem;
      font: italic 400 2.5rem / 1 var(--serif); color: var(--accent);
    }
    & h3 { grid-column: 1; font-size: 1.6rem; line-height: 1.05; letter-spacing: -0.015em; text-wrap: balance; }
    & p { grid-column: 1; font: 400 var(--fs-mono) / 1.6 var(--mono); color: var(--ink-2); text-wrap: pretty; }
    & .code { grid-column: 2; grid-row: 1 / span 2; }
  }

  /* A code block: scrolls sideways inside itself (it is focusable for keyboard scrolling), never the page */
  .code {
    align-self: start; min-inline-size: 0;
    padding: 1rem 1.1rem;
    background: color-mix(in oklch, var(--white) 4%, var(--black));
    border: 1px solid var(--hair); border-inline-start: 2px solid var(--accent);
    overflow-x: auto; scrollbar-width: thin;
    font: 400 var(--fs-mono) / 1.7 var(--mono); color: var(--ink-3); tab-size: 4;
    & b { color: var(--ink); font-weight: 500; }
  }

  /* Reference table: a title in the margin, a mono table beside it */
  .reference {
    grid-column: 1 / -1;
    display: grid; grid-template-columns: minmax(0, 4fr) minmax(0, 8fr); column-gap: calc(var(--col-gap) * 2);
    padding-block-start: 1.4rem;
    border-top: 1px solid var(--hair-strong);
  }
  .reference__title { font-size: var(--fs-h3); line-height: 1; letter-spacing: -0.02em; text-wrap: balance; padding-inline-start: 4.5rem; }
  .reference__table {
    inline-size: 100%;
    font: 400 var(--fs-mono) / 1.55 var(--mono); color: var(--ink-2);
    & th, & td { padding: 0.7rem 0.9rem 0.8rem 0; text-align: start; vertical-align: top; border-bottom: 1px solid var(--hair); }
    & thead th { font: 500 var(--fs-label) / 1 var(--mono); letter-spacing: var(--track-label); text-transform: uppercase; color: var(--ink-3); border-bottom-color: var(--hair-strong); }
    & tbody th { font: 400 1.35rem / 1.05 var(--serif); color: var(--ink); white-space: nowrap; }
    & tbody th i { color: var(--accent-text); margin-inline-end: 0.2em; }
  }

  @media (width < 64rem) {
    .step { grid-template-columns: minmax(0, 1fr); }
    .step .code { grid-column: 1; grid-row: auto; margin-block-start: 0.6rem; }
    .reference { grid-template-columns: minmax(0, 1fr); row-gap: 1.25rem; }
    .reference__title { padding-inline-start: 0; }
  }
  @media (width < 40rem) {
    .step { padding-inline-start: 3rem; }
    .reference__table thead { display: none; }
    .reference__table tr { display: grid; padding-block: 0.6rem; border-bottom: 1px solid var(--hair); }
    .reference__table :is(th, td) { border: 0; padding-block: 0.2rem; }
  }
}
