/* Book layout: chapter list + reading page. Used by /rules and the Staff Hub handbook. */

.book {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

.book-toc {
  position: sticky;
  top: calc(var(--nav-height, 60px) + 20px);
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-left: 10px;
  border-left: 1px solid var(--border);
}

.book-toc-title {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 0 0 8px;
}

.book-toc-item {
  display: block;
  position: relative;
  background: none;
  border: none;
  text-align: left;
  font-family: inherit;
  font-size: 13px;
  color: var(--text-2);
  text-decoration: none;
  padding: 6px 8px;
  border-radius: var(--r);
  cursor: pointer;
  transition: color 0.12s, background 0.12s;
}
.book-toc-item:hover { color: var(--text); background: var(--bg-2); }
.book-toc-item.active { color: var(--accent); background: var(--accent-dim); }
.book-toc-item.active::before {
  content: '';
  position: absolute;
  left: -11px; top: 6px; bottom: 6px;
  width: 2px;
  border-radius: 2px;
  background: var(--accent);
}

.book-page {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 28px 32px 32px;
  min-width: 0;
}

.book-pager {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.book-pager button {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text-2);
  font-family: inherit;
  font-size: 12.5px;
  padding: 8px 12px;
  cursor: pointer;
  text-align: left;
}
.book-pager button:hover { color: var(--accent); border-color: var(--accent); }
.book-pager small { display: block; font-size: 10.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em; }
.book-pager .next { margin-left: auto; text-align: right; }

/* Reading typography */
.book-prose { font-size: 14px; line-height: 1.7; color: var(--text-2); }
.book-prose > :first-child { margin-top: 0; }
.book-prose > :last-child { margin-bottom: 0; }
.book-prose h1 {
  font-family: var(--font-display, inherit);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 0 0 12px;
}
.book-prose h2 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin: 26px 0 10px;
  scroll-margin-top: calc(var(--nav-height, 60px) + 16px);
}
.book-prose h3 { font-size: 14.5px; font-weight: 700; color: var(--text); margin: 18px 0 8px; }
.book-prose p { margin: 0 0 12px; }
.book-prose a { color: var(--accent); text-decoration: none; }
.book-prose a:hover { text-decoration: underline; }
.book-prose strong { color: var(--text); font-weight: 600; }
.book-prose ul, .book-prose ol { margin: 0 0 12px; padding-left: 22px; }
.book-prose li { margin-bottom: 5px; }
.book-prose li::marker { color: var(--text-3); }
.book-prose hr { border: none; border-top: 1px solid var(--border); margin: 24px 0; }
.book-prose code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 12px;
  padding: 1px 5px;
}
.book-prose blockquote {
  border-left: 2px solid var(--accent);
  margin: 0 0 12px;
  padding: 2px 0 2px 12px;
  color: var(--text-3);
}
.book-prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin: 0 0 14px;
  display: block;
  overflow-x: auto;
}
.book-prose th, .book-prose td { border: 1px solid var(--border); padding: 7px 10px; text-align: left; vertical-align: top; }
.book-prose th { background: var(--bg); font-weight: 600; color: var(--text); }

/* Markdown editor with live preview (Admin → Site Rules, Superuser → Staff Guides) */
.doc-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.doc-editor-pane { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.doc-editor-pane > .label { margin: 0; }
.doc-editor textarea.input { min-height: 560px; resize: vertical; line-height: 1.55; font-size: 13px; tab-size: 2; }
.doc-editor .book-page { padding: 20px 22px; max-height: 640px; overflow-y: auto; }
.doc-editor-help { font-size: 12px; color: var(--text-3); margin: 0 0 12px; line-height: 1.6; }
.doc-editor-help code { background: var(--bg-2); border: 1px solid var(--border); border-radius: 3px; font-size: 11.5px; padding: 0 4px; }
.doc-editor-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.doc-editor-meta { font-size: 12px; color: var(--text-3); }

@media (max-width: 1100px) {
  .doc-editor { grid-template-columns: minmax(0, 1fr); }
  .doc-editor textarea.input { min-height: 360px; }
}

@media (max-width: 860px) {
  .book { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  /* Chapters become a row of underline tabs, like .tab-btn */
  .book-toc {
    position: static;
    flex-direction: row;
    overflow-x: auto;
    gap: 0;
    padding: 0;
    border-left: none;
    border-bottom: 1px solid var(--border);
  }
  .book-toc-title { display: none; }
  .book-toc-item {
    flex-shrink: 0;
    border-radius: 0;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    padding: 8px 12px;
    white-space: nowrap;
  }
  .book-toc-item:hover { background: none; }
  .book-toc-item.active { background: none; border-bottom-color: var(--accent); }
  .book-toc-item.active::before { display: none; }
  .book-page { padding: 20px 16px 24px; }
  .book-prose h1 { font-size: 22px; }
}
