/* The handbook (docs/, made by tools/build-docs.py). A printed game manual on the site's paper: numbered chapters in
   the pixel letters, a contents column at the side, long text set for reading, thin rules instead of boxes.
   Loaded after site.css and retro.css, uses their colours (Cocoa/Pea, dark/light) and sizes. */

.doc-page { max-width: 78rem; }
.toc-n {
  font-family: var(--pixel); font-size: var(--d1); line-height: 1; letter-spacing: 0;
  display: inline-block; min-width: 2.6em; padding: 0.3em 0.45em 0.25em; margin-right: 0.6em; text-align: center;
  color: var(--on-select); background: var(--select); vertical-align: 0.12em;
}

/* ---- Search ---------------------------------------------------------------------------------------------- */
.js .doc-search[hidden] { display: block; }
.doc-search { margin: 0 0 1.4rem; }
.doc-search label { display: block; font-family: var(--pixel); font-size: var(--d1); color: var(--dust); margin: 0 0 0.45rem;
  text-transform: uppercase; letter-spacing: 0.04em; }
.doc-search-row { display: flex; gap: 0; }
.doc-search input {
  flex: 1; min-width: 0; font: inherit; font-size: 1rem; color: var(--text); background: var(--void);
  border: 2px solid var(--line); border-right: 0; border-radius: 0; padding: 0.55rem 0.7rem;
}
.doc-search input::placeholder { color: var(--dust); opacity: 1; }
.doc-search input:focus { outline: none; border-color: var(--select); }
.doc-search button {
  font-family: var(--pixel); font-size: var(--d1); border: 2px solid var(--select); border-radius: 0; cursor: pointer;
  background: var(--select); color: var(--on-select); padding: 0 0.9rem;
}
.doc-search button:hover, .doc-search button:focus-visible { background: var(--text); border-color: var(--text); color: var(--void); }
.doc-search.big { max-width: 40rem; margin: 1.6rem 0 0.6rem; }
.doc-search.big input { font-size: 1.15rem; padding: 0.8rem 0.9rem; }
.doc-search.big button { font-size: var(--d2); padding: 0 1.2rem; }

.doc-results { max-width: 46rem; margin: 1rem 0 2rem; }
.doc-results .doc-count { font-family: var(--pixel); font-size: var(--d1); color: var(--dust); margin: 0 0 0.4rem; }
.doc-results ol { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--text); }
.doc-results li { border-bottom: 1px solid var(--rule); }
.doc-results li a { display: block; padding: 0.8rem 0 0.85rem; text-decoration: none; }
.doc-results .where { display: block; font-size: 0.85rem; color: var(--dust); margin-bottom: 0.15rem; }
.doc-results .head { display: block; font-weight: 600; font-size: 1.08rem; color: var(--text); }
.doc-results .snip { display: block; color: var(--chalk); font-size: 0.95rem; line-height: 1.45; margin-top: 0.2rem; }
.doc-results a:hover .where, .doc-results a:hover .head, .doc-results a:hover .snip,
.doc-results a:focus-visible .where, .doc-results a:focus-visible .head, .doc-results a:focus-visible .snip { color: var(--on-select); }
.doc-results mark { background: none; color: inherit; text-decoration: underline 2px var(--select); text-underline-offset: 0.18em; }
.doc-none { color: var(--chalk); padding: 1rem 0 1rem 1rem; border-left: calc(var(--px) * 2) solid var(--select); max-width: 40rem; }

/* ---- First page: topics and handhelds as a table of contents ------------------------------------------- */
.doc-intro { font-size: 1.12rem; }
.doc-quick {
  max-width: 40rem; margin: 1.2rem 0 0.4rem; padding: 0.85rem 1.1rem;
  border-left: calc(var(--px) * 2) solid var(--select); background: var(--spine);
  line-height: 1.5;
}
.doc-quick-kicker {
  font-family: var(--pixel); font-size: var(--d1); text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--dust); margin-right: 0.45rem;
}
.doc-quick a {
  font-weight: 700; color: var(--text); text-decoration: underline 2px var(--select); text-underline-offset: 0.2em;
}
.doc-quick a::after { content: " ›"; font-family: var(--pixel); color: var(--select); }
.doc-quick a:hover, .doc-quick a:focus-visible { color: var(--on-select); background: var(--select); }
.doc-quick a:hover::after, .doc-quick a:focus-visible::after { color: var(--on-select); }
.doc-quick-line { display: block; color: var(--chalk); font-size: 0.95rem; margin-top: 0.25rem; }
.doc-topics { margin-top: 2.6rem; }
.doc-topics > h2 { margin: 0; padding-bottom: 0.5rem; border-bottom: 2px solid var(--text); }
/* a chapter: its number and name in a column of their own, its topics beside them */
.doc-chapter { display: grid; grid-template-columns: 1fr; padding: 1.6rem 0 0.4rem; border-bottom: 1px solid var(--rule); }
.doc-chapter-h { margin: 0 0 0.4rem; font-size: var(--d2); display: flex; align-items: center; }
.doc-chapter-body { display: grid; grid-template-columns: 1fr; column-gap: 2.6rem; }
@media (min-width: 52rem) { .doc-chapter-body { grid-template-columns: 1fr 1fr; } }
@media (min-width: 64rem) {
  .doc-chapter { grid-template-columns: 12rem minmax(0, 1fr); column-gap: 2.6rem; }
  .doc-chapter-h { position: sticky; top: 6rem; align-self: start; padding-top: 1rem; }
}
@media (min-width: 84rem) { .doc-chapter-body { grid-template-columns: 1fr 1fr 1fr; } }
.doc-chapter-body > .doc-devices { grid-column: 1 / -1; padding: 1rem 0 1.4rem; }
.doc-topic { padding: 1rem 0 1.4rem; }
.doc-topic h4 { margin: 0; font-size: 1.05rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text); }
.doc-topic > p { color: var(--dust); margin: 0.45rem 0 0.6rem; font-size: 0.95rem; }
.doc-topic ul, .doc-device-list, .doc-more-devices ul { list-style: none; margin: 0; padding: 0; }
.doc-topic li a, .doc-device-list a, .doc-more-devices li a {
  display: flex; align-items: baseline; gap: 0.5rem; padding: 0.28rem 0; text-decoration: none; color: var(--chalk);
}
.doc-topic li a::after, .doc-device-list a::after {
  content: ""; flex: 1; border-bottom: 2px dotted var(--rule); transform: translateY(-0.25em); order: 1;
}
.doc-topic li a::before, .doc-device-list a::before {
  content: "›"; order: 2; font-family: var(--pixel); color: var(--dust);
}
.doc-topic li a:hover, .doc-device-list a:hover, .doc-topic li a:focus-visible, .doc-device-list a:focus-visible { color: var(--on-select); }
.doc-topic li a:hover::before, .doc-device-list a:hover::before { color: var(--on-select); }
.doc-devices > p { color: var(--dust); margin: 0 0 0.8rem; max-width: 40rem; }
.doc-device-list { max-width: 40rem; }
.doc-device-list a { font-size: 1.05rem; padding: 0.45rem 0; border-bottom: 1px solid var(--rule); color: var(--text); }
.doc-device-list a::after { border: 0; }
.doc-more-devices { margin-top: 1rem; max-width: 40rem; }
.doc-more-devices summary { cursor: pointer; color: var(--dust); }

/* ---- A page: contents at the side, the text in the middle ---------------------------------------------- */
.doc-grid { display: grid; grid-template-columns: 1fr; gap: 0 3.5rem; }
@media (min-width: 64rem) {
  .doc-grid { grid-template-columns: 17rem minmax(0, 1fr); }
  .doc-side { position: sticky; top: 6rem; align-self: start; max-height: calc(100vh - 7rem); overflow: auto;
    padding-right: 0.6rem; scrollbar-width: thin; }
  .doc-side .doc-toc > summary { display: none; }
}
.doc-toc summary { cursor: pointer; font-family: var(--pixel); font-size: var(--d1); text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--text); padding: 0.7rem 0; border-top: 2px solid var(--text); border-bottom: 1px solid var(--rule); }
.doc-toc nav { padding-bottom: 1rem; }
/* five chapters that fold: the one you are reading is open, its number lit; the others show how many pages wait inside */
.toc-group { border-bottom: 1px solid var(--rule); }
.doc-toc .toc-group > summary { list-style: none; display: flex; align-items: center; gap: 0; padding: 0.65rem 0;
  border: 0; color: var(--chalk); }
.toc-group > summary::-webkit-details-marker { display: none; }
.toc-group > summary .toc-n { min-width: 2.3em; padding: 0.25em 0.3em 0.2em; margin-right: 0.7em; background: var(--spine-hi); color: var(--text); }
.toc-group:has([aria-current="page"]) > summary .toc-n { background: var(--select); color: var(--on-select); }
.toc-group:has([aria-current="page"]) > summary { color: var(--text); }
.toc-count { margin-left: auto; color: var(--dust); font-size: var(--d1); }
.toc-group > summary::after { content: "+"; width: 1.6em; text-align: right; color: var(--dust); }
.toc-group[open] > summary::after { content: "\2212"; }
.toc-group > summary:hover, .toc-group > summary:hover::after { color: var(--select); }
.toc-group > summary:focus-visible { outline: 2px solid var(--select); outline-offset: 2px; }
.toc-group > ul:last-child { margin-bottom: 0.9rem; }
.toc-topic { font-size: 0.78rem; color: var(--dust); margin: 0.8rem 0 0.25rem 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }
.toc-group > .toc-topic:first-of-type { margin-top: 0.15rem; }
.doc-toc ul { list-style: none; margin: 0; padding: 0; }
.doc-toc li a { display: block; padding: 0.22rem 0 0.22rem 0.8rem; font-size: 0.92rem; color: var(--chalk); text-decoration: none;
  border-left: 2px solid var(--rule); line-height: 1.3; }
.doc-toc li a[aria-current="page"] { border-left-color: var(--select); color: var(--text); font-weight: 600; }
.doc-toc li a:hover { color: var(--on-select); }

.doc-body { min-width: 0; max-width: 46rem; }
.doc-head { margin: 0 0 1.6rem; padding-bottom: 1rem; border-bottom: 2px solid var(--text); }
.doc-kicker { margin: 0 0 0.7rem; color: var(--dust); font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.05em; display: flex; align-items: center; }
.doc-kicker-topic { color: var(--dust); }
.doc-kicker-topic::before { content: "/"; margin: 0 0.6em; color: var(--rule); }
.doc-head h1 { margin: 0; font-size: var(--h1); line-height: 1.15; }
.doc-body > p, .doc-body li { line-height: 1.6; }
.doc-body h2 { margin-top: 2.6rem; padding-top: 0.9rem; border-top: 1px solid var(--rule); scroll-margin-top: 6rem; }
.doc-body h3, .doc-body h4 { scroll-margin-top: 6rem; }
.doc-body h2:target, .doc-body h3:target, .doc-body h4:target { text-decoration: underline 3px var(--select); text-underline-offset: 0.25em; }
.doc-body ul, .doc-body ol { padding-left: 1.3rem; }
.doc-body li { margin: 0.3rem 0; }
.doc-body li > ul, .doc-body li > ol { margin: 0.3rem 0; }
.doc-body li::marker { color: var(--dust); }
.doc-body img { margin: 1.2rem 0; width: 100%; max-width: 38rem; height: auto; image-rendering: auto;
  border: 2px solid var(--rule); }
.doc-body blockquote { margin: 1.2rem 0; padding: 0.2rem 0 0.2rem 1.1rem; border-left: calc(var(--px) * 2) solid var(--select); color: var(--chalk); }
.doc-body pre { overflow-x: auto; padding: 0.9rem 1rem; background: var(--spine); font-size: 0.9rem; line-height: 1.45; }
.doc-body pre code { background: none; box-shadow: none; padding: 0; font-size: inherit; }
.doc-body hr { border: 0; border-top: 1px solid var(--rule); margin: 2rem 0; }
.doc-body code { overflow-wrap: anywhere; }

.doc-table { overflow-x: auto; margin: 1rem 0 1.4rem; }
.doc-table table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.doc-table th { text-align: left; border-bottom: var(--px) solid var(--text); padding: 0.45rem 0.9rem 0.45rem 0; font-weight: 600; vertical-align: bottom; }
.doc-table td { border-top: 1px solid var(--rule); padding: 0.5rem 0.9rem 0.5rem 0; vertical-align: top; line-height: 1.45; }
@media (max-width: 40rem) {
  /* small screens: each row as a short list, its column names in front */
  .doc-table thead { display: none; }
  .doc-table table, .doc-table tbody, .doc-table tr, .doc-table td { display: block; width: 100%; }
  .doc-table tr { border-top: 1px solid var(--rule); padding: 0.5rem 0; }
  .doc-table td { border: 0; padding: 0.12rem 0; }
  .doc-table td:first-child { font-weight: 600; color: var(--text); }
  .doc-table td[data-label]:not(:first-child)::before { content: attr(data-label) ": "; color: var(--dust); }
  .doc-table td[data-label=""]::before { content: none; }
}

.doc-onpage { margin: 0 0 2rem; padding: 0 0 1rem; border-bottom: 1px solid var(--rule); }
.doc-onpage p { font-family: var(--pixel); font-size: var(--d1); color: var(--dust); text-transform: uppercase; letter-spacing: 0.04em; margin: 0 0 0.5rem; }
.doc-onpage ol { margin: 0; padding-left: 1.6rem; columns: 2 16rem; column-gap: 2rem; }
.doc-onpage li { margin: 0.1rem 0; break-inside: avoid; }
.doc-onpage li::marker { font-family: var(--pixel); font-size: var(--d1); color: var(--dust); }

.doc-pager { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 3.5rem; padding-top: 1rem; border-top: 2px solid var(--text); }
.doc-pager a { text-decoration: none; padding: 0.5rem 0; color: var(--text); font-weight: 600; }
.doc-pager a span { display: block; font-family: var(--pixel); font-size: var(--d1); font-weight: 400; color: var(--dust); margin-bottom: 0.3rem; text-transform: uppercase; }
.doc-pager .prev span::before { content: "‹ "; }
.doc-pager .next { grid-column: 2; text-align: right; }
.doc-pager .next span::after { content: " ›"; }
.doc-pager a:hover span { color: var(--on-select); }

/* Pixel letters for everything (the header's Letters switch): the long text stays readable */
:root[data-text="pixel"] .doc-toc li a { font-size: var(--d1); line-height: 1.6; }
:root[data-text="pixel"] .doc-results .where, :root[data-text="pixel"] .toc-topic { font-size: var(--d1); }
:root[data-text="pixel"] .doc-toc .toc-group > summary { font-size: var(--d1); }

@media print {
  .topline, .foot, .doc-side, .doc-pager, .crumbs, .doc-search { display: none !important; }
  .doc-grid { display: block; }
}
/* Phones: the page list starts folded (docs.js folds it; without JS it stays open) */
@media (max-width: 63.99rem) { .js .doc-toc:not(.is-set) > nav { display: none; } }
.doc-onpage + h2 { border-top: 0; margin-top: 0; padding-top: 0; }
