/* document.css — Global styles for individual document reader pages
   Extracted from the common scaffold used by PDF-style readers (add_document.py template + existing pages).
   Goal: eliminate duplication across ~dozens of slug/index.html files.
   Usage in a reader page:
     <link rel="stylesheet" href="/document.css">
   (topics.css can still be linked by topic hubs or pages that need .subdocs etc.)
   Workbook/special viewers (e.g. the multi-sheet POS reconcile) link this + add a small
   page-specific <style> block only for their unique grid / thumb / header components.
*/

:root {
  color-scheme: light;
  --ink: #1c1c1c;
  --muted: #555;
  --line: #d7d7d7;
  --link: #153e75;
  --link-hover: #0f2d55;
  --bg-soft: #f8f8f8;
  --max: 1280px; /* readers use wider max than some topic hubs */
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: #fff;
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.55;
  overflow-x: hidden;
  position: relative;
}

main {
  width: min(calc(100% - 32px), var(--max));
  margin: 0 auto;
  padding: 20px 0 32px;
  position: relative;
  z-index: 1;
}

h1, h2 { line-height: 1.15; margin: 0; }
h1 { font-size: 1.85rem; margin-bottom: 6px; }
h2 {
  font-size: 1.05rem;
  margin: 0 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

p { margin: 0 0 14px; }

a { color: var(--link); text-underline-offset: 2px; }
a:hover, a:focus { color: var(--link-hover); }

.lede { max-width: 920px; color: var(--muted); font-size: 1rem; }

.top-links {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin: 12px 0 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
}

.reader {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 18px;
  align-items: start;
}

.pdf-pane,
.side {
  border: 1px solid var(--line);
  background: #fff;
}

.side {
  padding: 14px;
  position: sticky;
  top: 14px;
}

.doc-preview {
  display: block;
  width: 100%;
  max-height: 280px;
  object-fit: contain;
  margin: 0 0 12px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
}

.facts {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
}

.fact {
  border: 1px solid var(--line);
  padding: 9px;
  background: #fff;
}

.fact span {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 3px;
}

.viewer {
  width: 100%;
  height: calc(100vh - 150px);
  min-height: 700px;
  border: 0;
  background: var(--bg-soft);
  display: block;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 14px 0;
  font-weight: 700;
}

.actions a {
  border: 1px solid var(--line);
  padding: 9px 10px;
  background: var(--bg-soft);
  text-decoration: none;
  color: var(--link);
  display: block;
  text-align: center;
}

details {
  border: 1px solid var(--line);
  padding: 10px;
  background: #fff;
  margin-top: 12px;
}

summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--link);
}

.text-block {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin-top: 14px;
  color: var(--ink);
  font-size: 0.9rem;
  max-height: 380px;
  overflow: auto;
}

.notice {
  margin-top: 30px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.96rem;
}

footer {
  margin-top: 22px;
  color: var(--muted);
  font-size: 0.94rem;
}

footer a { color: var(--link); }

@media (max-width: 860px) {
  main { width: min(calc(100% - 24px), var(--max)); padding-top: 24px; }
  h1 { font-size: 1.85rem; }
  .reader { grid-template-columns: 1fr; }
  .side { position: static; }
  .viewer { height: 72vh; min-height: 520px; }
}

/* Small extra for consistency with some pages that have slightly different action links */
.actions a:hover { background: #fff; }
