/* The help pages: the handbook and the user manual. (DOC-1)
   Built from docs/manual/*.md by scripts/build-manual.sh — edit the Markdown,
   not the generated HTML. Same faces and colours as the app itself, served
   from this server for the same reason (font-src 'self'). */

@font-face { font-family: 'Source Sans 3'; font-weight: 400; font-display: swap;
  src: url('../vendor/fonts/source-sans-3-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Source Sans 3'; font-weight: 600; font-display: swap;
  src: url('../vendor/fonts/source-sans-3-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Source Sans 3'; font-weight: 700; font-display: swap;
  src: url('../vendor/fonts/source-sans-3-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Source Serif 4'; font-weight: 400; font-display: swap;
  src: url('../vendor/fonts/source-serif-4-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Source Serif 4'; font-weight: 600; font-display: swap;
  src: url('../vendor/fonts/source-serif-4-latin-600-normal.woff2') format('woff2'); }

:root {
  color-scheme: light;
  --ground: #f6f4f0; --paper: #ffffff; --ink: #1f1d1a; --muted: #6b645a;
  --line: #e4dfd6; --accent: #2f5d5b; --accent-text: #2f5d5b;
  --accent-soft: #e7efee; --rail: #24211d;
  --head: #f1ede6; --hover: #faf8f5; --mark: #fbe9b7; --code: #4a453e;
  --ui: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --display: 'Source Serif 4', Georgia, 'Times New Roman', serif;
}

/* The same pages at night, following whatever was chosen in the app itself —
   `data-theme` is set by /theme.js, which these pages load for exactly that
   reason. Opening the handbook from a dark session should not be a flash of
   white. (THEME-1) */
:root[data-theme="dark"] {
  color-scheme: dark;
  --ground: #16150f; --paper: #211f19; --ink: #f2efe8; --muted: #a49d90;
  --line: #3a362c; --accent: #3d7a77; --accent-text: #8fc9c3;
  --accent-soft: #1d2f2e; --rail: #100f0c;
  --head: #2a2720; --hover: #262319; --mark: #6b5424; --code: #c8c2b5;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--ground); color: var(--ink); font-family: var(--ui);
  font-size: 15.5px; line-height: 1.6; }

.hb-top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center;
  justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 24px;
  background: var(--rail); color: #c9c3b8; }
.hb-brand { color: #fff; font-weight: 700; text-decoration: none; font-size: 15px; }
.hb-links { display: flex; gap: 4px; flex-wrap: wrap; }
.hb-links a { color: #c9c3b8; text-decoration: none; padding: 5px 10px; border-radius: 6px; font-size: 14px; }
.hb-links a:hover { color: #fff; background: rgba(255,255,255,0.08); }
.hb-links a[aria-current="page"] { color: #fff; background: rgba(255,255,255,0.14); }
.hb-links a.hb-app { color: #9fd0cb; }

.hb-shell { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 32px;
  max-width: 1180px; margin: 0 auto; padding: 28px 24px 80px; }
.hb-toc { position: sticky; top: 64px; align-self: start; max-height: calc(100vh - 84px);
  overflow-y: auto; font-size: 13.5px; padding-right: 8px; }
.hb-toc-title { text-transform: uppercase; letter-spacing: 0.08em; font-size: 11.5px;
  font-weight: 700; color: var(--muted); margin-bottom: 8px; }
.hb-toc ul { list-style: none; margin: 0; padding: 0; }
.hb-toc ul ul { padding-left: 12px; margin: 2px 0 6px; }
.hb-toc a { display: block; color: var(--ink); text-decoration: none; padding: 3px 8px;
  border-radius: 5px; }
.hb-toc a:hover { background: var(--accent-soft); color: var(--accent-text); }
.hb-toc > ul > li > a { font-weight: 600; }

.hb-main { background: var(--paper); border: 1px solid var(--line); border-radius: 12px;
  padding: 36px 44px; min-width: 0; }
.hb-main > * { max-width: 72ch; }
.hb-main > table, .hb-main > .hb-titleblock { max-width: none; }
.hb-titleblock { border-bottom: 1px solid var(--line); margin-bottom: 18px; padding-bottom: 14px; }
.hb-title { font-family: var(--display); font-size: 32px; line-height: 1.2; margin: 0;
  color: var(--accent-text); font-weight: 600; text-wrap: balance; }
.hb-subtitle { margin: 6px 0 0; color: var(--muted); font-size: 16px; }
.hb-edition { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

h1, h2, h3 { font-family: var(--display); color: var(--accent-text); line-height: 1.25;
  text-wrap: balance; scroll-margin-top: 70px; }
.hb-main h1 { font-size: 25px; margin: 40px 0 10px; padding-top: 18px; border-top: 1px solid var(--line); }
.hb-main h2 { font-size: 19px; margin: 28px 0 8px; }
.hb-main h3 { font-size: 16px; margin: 20px 0 6px; }
p { margin: 0 0 12px; }
ul, ol { margin: 0 0 12px; padding-left: 22px; }
li { margin: 3px 0; }
strong { font-weight: 600; }
code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.9em;
  background: var(--accent-soft); padding: 1px 5px; border-radius: 4px; }
a { color: var(--accent-text); }

table { width: 100%; border-collapse: collapse; margin: 6px 0 18px; font-size: 14.5px;
  display: block; overflow-x: auto; }
thead th { text-align: left; background: var(--head); color: var(--ink); font-weight: 600;
  border-bottom: 1px solid var(--line); padding: 8px 10px; }
td { border-bottom: 1px solid var(--line); padding: 8px 10px; vertical-align: top; }
tbody tr:hover td { background: var(--hover); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* The landing page */
.hb-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; margin-top: 18px; }
.hb-card { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 22px 24px; }
.hb-card h2 { margin: 0 0 6px; font-size: 21px; color: var(--accent-text); }
.hb-card p { color: var(--muted); }
.hb-card .hb-go { display: inline-block; margin-top: 4px; background: var(--accent); color: #fff;
  text-decoration: none; padding: 8px 14px; border-radius: 7px; font-weight: 600; }
.hb-card .hb-dl { margin-left: 10px; font-size: 14px; }
.hb-landing { max-width: 900px; margin: 0 auto; padding: 36px 24px 80px; }
.hb-landing h1 { font-size: 30px; margin: 0; }

@media (max-width: 820px) {
  .hb-shell { grid-template-columns: 1fr; padding: 16px 16px 60px; gap: 16px; }
  .hb-toc { position: static; max-height: none; background: var(--paper);
    border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
  .hb-main { padding: 22px 18px; }
  .hb-top { padding: 10px 16px; }
  /* On a phone the contents come first, so only the parts are listed. */
  .hb-toc ul ul { display: none; }
}
@media print {
  @page { size: A4; margin: 16mm 16mm 18mm; }
  /* Paper is white and ink is black, whichever theme the screen was in. */
  :root, :root[data-theme="dark"] {
    color-scheme: light;
    --ground: #fff; --paper: #fff; --ink: #1f1d1a; --muted: #6b645a;
    --line: #e4dfd6; --accent: #2f5d5b; --accent-text: #2f5d5b;
    --accent-soft: #e7efee; --head: #f1ede6; --hover: #fff; --code: #4a453e;
  }
  .hb-top { display: none; }
  body { background: #fff; font-size: 11pt; }
  .hb-shell { display: block; padding: 0; max-width: none; }
  /* The contents print first, on a page of their own. */
  .hb-toc { position: static; max-height: none; overflow: visible; page-break-after: always;
    font-size: 11pt; padding: 0; }
  .hb-main { border: 0; padding: 0; }
  .hb-main > * { max-width: none; }
  .hb-main h1 { page-break-before: auto; }
  h1, h2, h3 { page-break-after: avoid; }
  tr, li { page-break-inside: avoid; }
  table { display: table; }
  a { color: inherit; text-decoration: none; }
}

/* The page title is an h1 too, and the first section heading follows the
   title block's own rule — neither wants the section divider. */
.hb-main .hb-title { border-top: 0; padding-top: 0; margin: 0; font-size: 32px; }
.hb-main .hb-titleblock + h1 { border-top: 0; padding-top: 0; margin-top: 18px; }

/* Searching the Help. (DOC-2) */
.hs { position: relative; flex: 1 1 320px; max-width: 420px; }
.hs-input { width: 100%; font: inherit; font-size: 14px; color: #fff; background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.18); border-radius: 7px; padding: 6px 10px; }
.hs-input::placeholder { color: #a39c90; }
.hs-input:focus { outline: none; background: rgba(255,255,255,0.14); border-color: #7fb0ab; }
.hs-panel { position: absolute; top: calc(100% + 6px); left: 0; width: min(560px, 94vw); max-height: 70vh; overflow-y: auto;
  background: var(--paper); color: var(--ink); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 14px 40px rgba(0,0,0,0.18); padding: 6px 0; z-index: 30; }
.hs-item { display: block; padding: 8px 14px; text-decoration: none; color: inherit; }
.hs-item.on, .hs-item:hover { background: var(--accent-soft); }
.hs-where { display: block; font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.hs-title { display: block; font-weight: 600; color: var(--accent-text); }
.hs-snip { display: block; font-size: 13px; color: var(--code); line-height: 1.45; }
.hs-snip mark { background: var(--mark); color: inherit; padding: 0 1px; border-radius: 2px; }
.hs-empty { padding: 12px 14px; font-size: 14px; color: var(--muted); }
@keyframes hs-flash { from { background: var(--mark); } to { background: transparent; } }
.hs-flash { animation: hs-flash 2.2s ease-out; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { .hs-flash { animation: none; } }
@media (max-width: 820px) { .hs { order: 3; flex-basis: 100%; max-width: none; } }
@media print { .hs { display: none; } }
