/*
 * Grosik public site: content styles for the Read pages (/help/, /privacy/, /for-agents/).
 * Loaded after /site/tokens.css and /site/site.css (which owns the shell, base type, links,
 * code, kbd and focus). Everything here is scoped to .pg so it cannot leak into other pages.
 *
 * Layout: one article column at the reading measure. From 60rem the "On this page" index
 * becomes a sticky left column, like the app's rail; below that it is a compact ruled list.
 * World (DESIGN.md): the transfer slip. Printed labels name boxes, rules separate rows,
 * the dashed blank box means "not filled in yet", code sits in a sunk field like the app's
 * copy blocks. No cards, no eyebrows, no side stripes.
 */

.pg {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-6);
}
@media (min-width: 60rem) {
  .pg {
    grid-template-columns: 14rem minmax(0, 1fr);
    grid-template-areas: 'head head' 'toc body';
    column-gap: var(--s-7);
    row-gap: var(--s-6);
  }
  .pg-head { grid-area: head; }
  .pg-toc { grid-area: toc; }
  .pg-body { grid-area: body; }
}

/* ---- Page head ------------------------------------------------------------ */
.pg-head { max-width: 46rem; }
.pg-head h1 { margin-bottom: var(--s-4); }
.pg-lead { font-size: var(--t-lg); line-height: 1.4; color: var(--ink-2); }
.pg-updated { margin-top: var(--s-3) !important; font-size: var(--t-sm); color: var(--ink-2); }

/* ---- On this page --------------------------------------------------------- */
.pg-toc {
  align-self: start;
  padding: var(--s-3) var(--s-4) var(--s-4);
  background: var(--paper-sunk);
  border-radius: var(--r-1);
}
.pg-toc h2 {
  margin: 0 0 var(--s-2);
  font-size: var(--t-xs); font-weight: var(--w-medium);
  letter-spacing: var(--label-tracking); text-transform: uppercase;
  color: var(--print);
}
.pg-toc ol {
  list-style: none; margin: 0; padding: 0;
  columns: 2 9rem; column-gap: var(--s-4);
}
.pg-toc li { break-inside: avoid; max-width: none; }
.pg-toc a {
  display: flex; align-items: center;
  min-height: var(--tap); padding: var(--s-1) 0;
  font-size: var(--t-sm); font-weight: var(--w-medium);
  line-height: var(--lh-tight);
  text-decoration: none;
}
.pg-toc a:hover { text-decoration: underline; }
@media (min-width: 60rem) {
  .pg-toc {
    position: sticky; top: calc(4rem + var(--s-4));
    max-height: calc(100dvh - 4rem - var(--s-6));
    overflow-y: auto;
    padding: 0; background: none;
  }
  .pg-toc ol { columns: auto; border-top: var(--rule) solid var(--print-rule); }
  .pg-toc li { border-bottom: var(--rule) solid var(--print-rule); }
  .pg-toc a { min-height: 2.5rem; }
}

/* ---- Article -------------------------------------------------------------- */
.pg-body { max-width: 46rem; min-width: 0; }
.pg-body > section + section { margin-top: var(--s-7); }
.pg-body section { scroll-margin-top: calc(4rem + var(--s-4)); }
.pg-body h2 {
  padding-top: var(--s-4);
  border-top: var(--rule-strong, 2px) solid var(--print);
  margin-bottom: var(--s-4);
}
.pg-body h3 { margin: var(--s-6) 0 var(--s-2); scroll-margin-top: calc(4rem + var(--s-4)); }
.pg-body h2 + h3 { margin-top: var(--s-4); }
.pg-body p + p, .pg-body p + ul, .pg-body p + ol, .pg-body ul + p, .pg-body ol + p,
.pg-body p + .pg-table, .pg-body .pg-table + p, .pg-body p + .pg-code, .pg-body .pg-code + p,
.pg-body .pg-code + .pg-code, .pg-body p + dl, .pg-body dl + p { margin-top: var(--s-3); }
.pg-body ul, .pg-body ol { margin: 0; padding-left: 1.25rem; }
.pg-body li + li { margin-top: var(--s-2); }
.pg-body li::marker { color: var(--print); }
.pg-body ol > li::marker { font-weight: var(--w-medium); font-variant-numeric: tabular-nums; }
.pg-body strong { color: var(--ink); }
.pg-muted { color: var(--ink-2); }

/* A short summary at the top of a page: a sheet lifted off the pad. */
.pg-sheet {
  padding: var(--s-4) var(--s-5);
  background: var(--paper-raised);
  border-radius: var(--r-2);
  box-shadow: var(--shadow-1), 0 0 0 1px var(--print-rule);
}
.pg-sheet ul { padding-left: 1.25rem; }

/* ---- Tables (shortcuts, limits, what is stored) ---------------------------- */
.pg-table { width: 100%; overflow-x: auto; }
.pg-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--t-md);
}
.pg-table caption {
  text-align: left; padding-bottom: var(--s-2);
  font-size: var(--t-xs); font-weight: var(--w-medium);
  letter-spacing: var(--label-tracking); text-transform: uppercase; color: var(--print);
}
.pg-table th, .pg-table td {
  padding: var(--s-3) var(--s-3) var(--s-3) 0;
  text-align: left; vertical-align: top;
  border-bottom: var(--rule) solid var(--print-rule);
}
.pg-table th:last-child, .pg-table td:last-child { padding-right: 0; }
.pg-table thead th {
  padding-top: 0;
  font-size: var(--t-xs); font-weight: var(--w-medium);
  letter-spacing: var(--label-tracking); text-transform: uppercase; color: var(--print);
  border-bottom: var(--rule) solid var(--print-box);
}
.pg-table tbody th { font-weight: var(--w-regular); color: var(--ink); }
.pg-table td.num { text-align: right; font-variant-numeric: tabular-nums lining-nums; white-space: nowrap; font-weight: var(--w-medium); }
.pg-table th.num { text-align: right; }
.pg-table .keys { white-space: nowrap; width: 1%; }
.pg-table kbd + kbd { margin-left: 2px; }

/* ---- Not available yet: the dashed blank box, as in the split editor ------- */
.pg-blank {
  margin-top: var(--s-3);
  padding: var(--s-4) var(--s-5);
  border: var(--rule) dashed var(--print-box);
  border-radius: var(--r-1);
}
.pg-blank ul { columns: 2 14rem; column-gap: var(--s-6); }
.pg-blank li { break-inside: avoid; }

/* ---- Tools list (for agents) ----------------------------------------------- */
.pg-tools { margin: var(--s-4) 0 0; padding: 0; border-top: var(--rule) solid var(--print-rule); }
.pg-tool {
  padding: var(--s-4) 0;
  border-bottom: var(--rule) solid var(--print-rule);
}
.pg-tool dt { margin: 0 0 var(--s-1); }
.pg-tool dt code { font-size: var(--t-md); font-weight: var(--w-bold); color: var(--ink); background: none; padding: 0; }
.pg-tool dd { margin: 0; max-width: var(--measure); }
.pg-tool .pg-params { margin-top: var(--s-2); font-size: var(--t-sm); color: var(--ink-2); }
.pg-tool .pg-params code { font-size: var(--t-sm); }

/* ---- Code blocks: a printed label, the text in a sunk field, a Copy button -- */
.pg-code { min-width: 0; }
.pg-code__bar {
  display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-3);
  margin-bottom: var(--s-2);
}
.pg-code__bar .label-print { padding-bottom: 2px; }
.pg-code pre {
  max-width: 100%;
  /* Snippets must stay exactly as copied: no wrapping, scroll inside the box instead. */
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
  font-size: var(--t-sm);
  line-height: 1.5;
  tab-size: 2;
}
.pg-code pre code { font-size: inherit; }
.pg-copy {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 36px; padding: 0 var(--s-3);
  font: inherit; font-size: var(--t-sm); font-weight: var(--w-medium);
  color: var(--print); background: var(--paper-raised);
  border: var(--rule) solid var(--print-box); border-radius: var(--r-1);
  cursor: pointer;
  transition: background-color var(--dur-1) var(--ease-out), transform var(--dur-1) var(--ease-out);
}
.pg-copy:hover { background: var(--print-wash); color: var(--print-strong); }
.pg-copy:active { transform: translateY(1px); }
.pg-copy svg { width: 16px; height: 16px; flex: none; }
.pg-copy[hidden] { display: none; }

/* Example requests to an agent: quoted plain words, set like handwriting on the slip (ink). */
.pg-asks { list-style: none; padding: 0 !important; display: grid; gap: var(--s-2); }
.pg-asks li {
  margin: 0 !important;
  padding: var(--s-3) var(--s-4);
  background: var(--paper-sunk);
  border-radius: var(--r-1);
  color: var(--ink);
}

/* Step lists: the number printed in the margin, like a form's numbered boxes. */
.pg-steps { counter-reset: step; list-style: none; padding-left: 0 !important; }
.pg-steps > li {
  counter-increment: step;
  position: relative;
  padding-left: 2.25rem;
  min-height: 1.75rem;
}
.pg-steps > li::before {
  content: counter(step);
  position: absolute; left: 0; top: -1px;
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.5rem; height: 1.5rem;
  border: var(--rule) solid var(--print-box); border-radius: var(--r-1);
  color: var(--print); font-size: var(--t-xs); font-weight: var(--w-medium);
  font-variant-numeric: tabular-nums;
}

@media (forced-colors: active) {
  .pg-copy { border-color: ButtonText; }
  .pg-body h2 { border-top-color: CanvasText; }
}
