/* User manual (manual.html), in the CRM page's Help tab and on /help. Uses app.css's tokens (Graphite). */

/* Contents on the left (4 of 12, sticky), the guide on the right (8): a comfortable line length. */
.help-layout { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gutter); align-items: start; }
.help-toc { grid-column: span 4; position: sticky; top: 128px; max-height: calc(100vh - 152px); overflow: auto; padding: 16px; }
.help-main { grid-column: span 8; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.help-toc-box > summary { margin: 0 0 8px; padding: 0 8px; font-size: 12px; line-height: 16px; font-weight: 500; color: var(--muted); list-style: none; pointer-events: none; }
.help-toc-box > summary::-webkit-details-marker { display: none; }
.help-toc ol { display: flex; flex-direction: column; gap: 2px; margin: 0; padding: 0; list-style: none; }
.help-toc a { display: block; padding: 6px 8px; border-radius: 6px; color: var(--ink-2); font-size: 14px; line-height: 20px; text-decoration: none; }
.help-toc a:hover { background: var(--subtle); color: var(--ink); }
.help-toc a.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.help-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.help-tools input[type=search] { flex: 1 1 240px; width: auto; }
.help-empty { padding: 16px 20px; }

.manual { display: flex; flex-direction: column; gap: 16px; }
.manual-section { display: flex; flex-direction: column; gap: 12px; min-width: 0; padding: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow-wrap: break-word; scroll-margin-top: 128px; }
.manual-section h2 { font-size: 20px; line-height: 28px; }
.manual-section h3 { margin-top: 8px; font-size: 16px; line-height: 24px; font-weight: 600; }
.manual-section p, .manual-section li, .manual-section td, .manual-section dd { color: var(--ink); }
.manual-section ul, .manual-section ol { display: flex; flex-direction: column; gap: 6px; margin: 0; padding-left: 22px; }
.manual-section .steps { gap: 8px; }
.manual-section .steps > li { padding-left: 4px; }
.manual-section .checklist { list-style: none; padding-left: 0; }
.manual-section .checklist > li { position: relative; padding-left: 28px; }
.manual-section .checklist > li::before { content: ""; position: absolute; left: 6px; top: 5px; width: 5px; height: 10px; border: solid var(--ok); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.manual-section code { padding: 1px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--canvas); font-size: 13px; }
.manual-section .muted { color: var(--muted); }

.manual-table { width: 100%; border-collapse: collapse; }
.manual-table th, .manual-table td { padding: 12px 16px 12px 0; text-align: left; vertical-align: top; border-top: 1px solid var(--subtle); }
.manual-table th { padding-top: 0; border-top: 0; font-size: 12px; line-height: 16px; font-weight: 500; color: var(--muted); }
.manual-table th:last-child, .manual-table td:last-child { padding-right: 0; }

/* Callouts: a tint and a word in bold, never a coloured left edge. */
.callout { padding: 12px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--canvas); }
.callout.tip { border-color: color-mix(in srgb, var(--accent) 25%, var(--line)); background: var(--accent-soft); }
.callout.ok { border-color: color-mix(in srgb, var(--ok) 25%, var(--line)); background: var(--ok-bg); }
.callout.warn { border-color: var(--warn-line); background: var(--warn-bg); }

/* How it works: three steps of the same height, arrows between them. */
.how-it-works { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr); gap: 8px; align-items: stretch; }
.hiw-step { display: flex; flex-direction: column; gap: 4px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--canvas); }
.hiw-step span { color: var(--ink-2); font-size: 13px; line-height: 20px; }
.hiw-arrow { align-self: center; color: var(--accent); font-size: 18px; }

details.faq { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
details.faq + details.faq { margin-top: -4px; }
details.faq > summary { position: relative; padding: 12px 44px 12px 16px; font-weight: 500; list-style: none; cursor: pointer; }
details.faq > summary::-webkit-details-marker { display: none; }
details.faq > summary::after { content: "+"; position: absolute; right: 16px; top: 10px; font-size: 18px; color: var(--muted); }
details.faq[open] > summary::after { content: "–"; }
details.faq > :not(summary) { margin: 0 16px 12px; }
details.faq > ol, details.faq > ul { padding-left: 38px; }

.support-card { display: flex; flex-direction: column; gap: 8px; padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--canvas); }
.manual-section .support-lines { display: flex; flex-direction: column; gap: 4px; padding: 0; list-style: none; }
.support-lines li { display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 8px; }
/* Contact lines with nothing to show stay out of the layout (display:grid would otherwise keep their space). */
.support-lines li[hidden] { display: none; }
.support-lines b { color: var(--muted); font-weight: 500; }

.glossary { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 16px; }
.glossary dt { font-weight: 600; }
.glossary dd { margin: 0; }

mark.help-hit { background: #fde68a; color: #111318; border-radius: 2px; }

@media (max-width: 960px) {
  .help-toc, .help-main { grid-column: 1 / -1; }
  .help-toc { position: static; max-height: none; padding: 12px 16px; }
  .help-toc-box > summary { margin: 0; padding: 0; pointer-events: auto; cursor: pointer; font-size: 14px; line-height: 22px; color: var(--ink); }
  .help-toc-box > summary::after { content: " ▾"; color: var(--muted); }
  .help-toc-box[open] > summary { margin-bottom: 8px; }
  .help-toc ol { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .help-tools .btn { flex: 1 1 100%; }
  .manual-section { padding: 16px; }
  .help-toc ol { grid-template-columns: minmax(0, 1fr); }
  .how-it-works { grid-template-columns: minmax(0, 1fr); }
  .hiw-arrow { justify-self: center; transform: rotate(90deg); line-height: 1; }
  .glossary { grid-template-columns: minmax(0, 1fr); }
  .glossary dd { margin-bottom: 8px; }
  /* A wide table scrolls in its own box (help.js lets the keyboard reach it). */
  .manual-table { display: block; overflow-x: auto; }
}

/* Inside the Android app, which has its own title bar. */
.in-app .topbar { display: none; }
.in-app main.shell { padding-top: 16px; }
.in-app .help-page-head { display: none; }
.in-app .manual-section, .in-app .manual details { scroll-margin-top: 16px; }

@media print {
  .help-toc, .help-tools, .topbar, .help-page-head, .no-print { display: none !important; }
  .help-layout { display: block; }
  .manual-section { break-inside: avoid-page; border: 0; padding: 0 0 12px; }
  details.faq > summary::after { content: ""; }
}
