/*
 * The guides: one guide (guide.php) and the list of them (guides.php).
 * Everything here is on top of site.css and uses its colour names, so both
 * themes work. The pictures are drawings of label sheets, which are always
 * white paper with black print (--sheet), as on every label preview.
 *
 *   .guide-crumbs    "Guides › this guide" above the heading
 *   .guide-layout    the "On this page" list, and the guide beside it
 *   .guide-toc       that list
 *   .guide-section   one part of a guide, with a hairline above it
 *   .guide-figure    a picture with its caption
 *   .guide-cards     the list of guides on /guides
 */

/* ---- Where the guide sits ---------------------------------------------------- */
.guide-crumbs { margin: 0 0 12px; font-size: .9rem; }
.guide-crumbs ol { display: flex; flex-wrap: wrap; gap: 4px 8px; margin: 0; padding: 0; list-style: none; }
.guide-crumbs li { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--muted); }
.guide-crumbs li + li::before { content: "\203A"; color: var(--muted); }
.guide-crumbs a { display: inline-flex; align-items: center; min-height: 44px; }
.guide-crumbs span { overflow-wrap: anywhere; }

.guide-head .lead { max-width: 40em; }
.guide-date { margin: 10px 0 0; color: var(--muted); font-size: .9rem; }
.guide-head .button-row { margin-top: 18px; }

/* ---- The page: what's on it, then the guide itself ------------------------------ */
.guide-layout { display: grid; gap: 28px; }
.guide-layout > * { min-width: 0; }
.guide-body { max-width: 46rem; }

/* "On this page": a box of links on phones and tablets, a column that stays in view on wide screens. */
.guide-toc { padding: 14px 16px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.guide-toc-title { margin: 0 0 10px; color: var(--muted); font: 600 .75rem/1.3 var(--mono); letter-spacing: .12em; text-transform: uppercase; }
.guide-toc ol { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.guide-toc a {
  display: inline-flex; align-items: center; min-height: 40px; padding: 5px 11px;
  border: 1px solid var(--line); border-radius: var(--radius-small);
  color: var(--ink); font-size: .9rem; font-weight: 500; line-height: 1.2; text-decoration: none;
}
.guide-toc a:hover { border-color: var(--ink); }
@media (pointer: coarse) {
  .guide-toc a { min-height: 44px; }
}
@media (min-width: 1040px) {
  .guide-layout { grid-template-columns: 220px minmax(0, 1fr); gap: 56px; align-items: start; }
  .guide-toc {
    position: sticky; top: calc(var(--header-h) + 24px);
    max-height: calc(100vh - var(--header-h) - 48px - var(--banner-space, 0px)); overflow-y: auto;
    margin: -6px; padding: 6px; border: 0; border-radius: 0; background: none;
  }
  .guide-toc ol { display: block; }
  .guide-toc a {
    display: flex; min-height: 34px; padding: 6px 12px;
    border: 0; border-left: 2px solid var(--line); border-radius: 0; color: var(--muted);
  }
  .guide-toc a:hover { border-left-color: var(--field-line); color: var(--ink); }
}

/* ---- One part of a guide ------------------------------------------------------- */
.guide-section { margin: 0; padding: 36px 0 8px; border-top: 1px solid var(--line); scroll-margin-top: calc(var(--header-h) + 16px); }
.guide-section:first-child { padding-top: 0; border-top: 0; }
.guide-section > h2 { margin-bottom: .6em; font-size: 1.5rem; }
.guide-section h3 { margin-top: 1.4em; }
.guide-section .step-list h3 { margin-top: 4px; }
.guide-section li { margin-bottom: .45em; }
.guide-section .step-list > li { margin-bottom: 0; }
.guide-list { padding-left: 1.2em; }
.guide-list > li::marker { color: var(--muted); }
.guide-section .alert { margin: 16px 0; }
.guide-section .table-wrap { margin: 16px 0 20px; }
/* The first cell of each row names the row: plain text, not the small capitals of a column heading. */
.guide-section tbody th { color: var(--ink); font-size: inherit; font-weight: 600; letter-spacing: 0; text-transform: none; white-space: normal; }
.guide-section code { overflow-wrap: anywhere; }
/* In a table, a field is never broken in the middle ("{{today" / "}}"): it keeps one line. */
.guide-section td code, .guide-section th code { white-space: nowrap; overflow-wrap: normal; }
/* On a phone, a table with code in it puts each cell under the one before (the code, then what it
   prints), so the whole field fits and the next column is not pushed out of sight. Browsers without
   :has() keep the table, which scrolls sideways inside its own box. */
@media (max-width: 599px) {
  .guide-section .table-wrap:has(tbody code) table,
  .guide-section .table-wrap:has(tbody code) thead,
  .guide-section .table-wrap:has(tbody code) tbody,
  .guide-section .table-wrap:has(tbody code) tr,
  .guide-section .table-wrap:has(tbody code) th,
  .guide-section .table-wrap:has(tbody code) td { display: block; }
  .guide-section .table-wrap:has(tbody code) tr { padding: 8px 0; border-bottom: 1px solid var(--line); }
  .guide-section .table-wrap:has(tbody code) tbody tr:last-child { border-bottom: 0; }
  .guide-section .table-wrap:has(tbody code) th,
  .guide-section .table-wrap:has(tbody code) td { padding: 2px 12px; border-bottom: 0; background: none; }
  .guide-section .table-wrap:has(tbody code) thead tr { background: color-mix(in srgb, var(--ink) 3%, var(--card)); }
}
.guide-buttons { margin: 18px 0 8px; }

/* A picture of labels, drawn by the site's own engine: white paper on the grey "desk". */
.guide-figure { margin: 20px 0 24px; }
.guide-figure img {
  display: block; width: auto; max-width: 100%; height: auto;
  padding: 12px; border-radius: var(--radius-small); background: var(--desk);
  box-sizing: border-box;
}
.guide-figure figcaption { margin-top: 8px; color: var(--muted); font-size: .9rem; }

.guide-end p { max-width: 40em; }
.guide-related ul { margin: 0 0 12px; padding: 0; list-style: none; }
.guide-related li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.guide-related li a { font-weight: 600; }
.guide-related .muted { display: block; font-size: .95rem; }

/* ---- The list of guides (/guides) ------------------------------------------------ */
.guide-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin: 0; padding: 0; list-style: none; }
.guide-card { position: relative; display: flex; flex-direction: column; margin: 0; }
.guide-card h2 { margin: 0 0 8px; font-size: 1.2rem; line-height: 1.3; }
.guide-card h2 a { color: var(--ink); text-decoration: none; }
/* The whole card is the link (a bigger target than the title alone). */
.guide-card h2 a::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }
.guide-card h2 a:hover { text-decoration: underline; }
.guide-card p { margin: 0; }
.guide-card .guide-date { margin-top: auto; padding-top: 12px; font-size: .85rem; }
.guide-tools ul { padding-left: 1.2em; }
.guide-tools li { margin-bottom: .5em; }

@media print {
  .guide-toc, .guide-buttons, .guide-head .button-row { display: none; }
}
