/*
 * Book content styles (sections 4 and 14): the look of the pre-built chapter pages.
 * Shared by the React app and the admin interface's page previews (served at /static/book.css),
 * so an import preview looks exactly like the reader's page.
 */
:root {
  --book-ink: #1d2327;
  --book-muted: #5b6770;
  --book-paper: #fbfaf7;
  --book-rule: #e3ded3;
  --book-accent: #1f4e5a;
  --book-code-bg: #f3f1ea;
  --book-note: #eef3f6;
  --book-key: #eef6ef;
  --book-watch: #fbf0e6;
  --book-why: #f3eef8;
  --book-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --book-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
.book-content { font-family: var(--book-serif); font-size: 1.125rem; line-height: 1.65; color: var(--book-ink); overflow-wrap: break-word; }
.book-content p { margin: 0 0 1em; }
.book-content h2 { font-size: 1.45rem; line-height: 1.3; margin: 2em 0 0.6em; scroll-margin-top: 96px; }
.book-content h3, .book-content h4 { font-size: 1.15rem; margin: 1.5em 0 0.5em; }
.book-content a { color: var(--book-accent); }
.book-content a.xref { text-decoration-style: dotted; }
.book-content a.outbound::after { content: " ↗"; font-size: 0.8em; }
.book-content img { max-width: 100%; height: auto; }
.book-content ul, .book-content ol { padding-left: 1.4em; }
.chapter-marker p { font: 600 0.85rem/1.2 system-ui, sans-serif; letter-spacing: 0.18em; color: var(--book-muted); margin: 0; }
.chapter-title p { font-size: 2.4rem; line-height: 1.15; font-weight: 600; margin: 0.2em 0; }
.chapter-subtitle p { font-size: 1.3rem; color: var(--book-muted); margin: 0 0 1em; }
.chapter-lead p { font-size: 1.25rem; }
nav.in-this-chapter, aside.chapter-at-a-glance:not(.glance) { border: 1px solid var(--book-rule); border-radius: 10px; padding: 1em 1.25em; margin: 1.5em 0; background: #fff; }
nav.in-this-chapter h3 { margin-top: 0; font: 600 0.9rem system-ui, sans-serif; letter-spacing: 0.1em; text-transform: uppercase; color: var(--book-muted); }
aside.callout { border-left: 4px solid var(--book-accent); border-radius: 0 10px 10px 0; padding: 0.9em 1.2em; margin: 1.5em 0; background: var(--book-note); }
aside.callout p:last-child { margin-bottom: 0; }
aside.callout-key-idea { background: var(--book-key); border-color: #2f6b3a; }
aside.callout-watch-out { background: var(--book-watch); border-color: #a3541b; }
aside.callout-why-it-matters { background: var(--book-why); border-color: #5b3c88; }
.callout-title { margin: 0 0 0.5em; font-size: 1.05rem; }
.callout-label { font: 700 0.75rem system-ui, sans-serif; letter-spacing: 0.12em; text-transform: uppercase; margin-right: 0.4em; }
figure { margin: 1.75em 0; }
figure figcaption { font-size: 0.95rem; color: var(--book-muted); margin-top: 0.5em; }
figure.table { overflow-x: auto; }
figure.table figcaption { margin: 0 0 0.5em; }
figure.table table { border-collapse: collapse; width: 100%; font-size: 0.95rem; font-family: system-ui, sans-serif; }
figure.table th, figure.table td { border-bottom: 1px solid var(--book-rule); padding: 0.45em 0.6em; text-align: left; vertical-align: top; }
figure.table thead th { border-bottom: 2px solid var(--book-ink); }
.equation { overflow-x: auto; margin: 1.25em 0; text-align: center; }
math[display="block"] { font-size: 1.15em; }
.code-sample { position: relative; margin: 1.5em 0; border-radius: 10px; background: var(--book-code-bg); border: 1px solid var(--book-rule); }
.code-sample .code-label { font: 600 0.72rem system-ui, sans-serif; letter-spacing: 0.08em; color: var(--book-muted); padding: 0.6em 1em 0; }
.code-sample pre { margin: 0; padding: 0.6em 1em 1em; overflow-x: auto; }
.code-sample code { font-family: var(--book-mono); font-size: 0.86rem; line-height: 1.5; white-space: pre; }
.code-sample .code-actions { position: absolute; top: 0.4em; right: 0.5em; display: flex; gap: 0.35em; }
.code-sample .code-actions button, .element-actions button { font: 500 0.75rem system-ui, sans-serif; border: 1px solid var(--book-rule); background: #fff; border-radius: 999px; padding: 0.25em 0.7em; cursor: pointer; }
.element-actions { display: flex; justify-content: flex-end; gap: 0.35em; margin-top: -0.75em; margin-bottom: 1em; }
.question { padding: 0.25em 0; }
.question .answer-button { font: 500 0.75rem system-ui, sans-serif; border: 1px solid var(--book-rule); background: #fff; border-radius: 999px; padding: 0.2em 0.7em; margin-left: 0.5em; cursor: pointer; color: var(--book-accent); }
.reference { font-size: 0.95rem; }
.reference p { margin-bottom: 0.6em; }
:target { animation: book-target 2s ease-out; }
@keyframes book-target { from { background: #fff3c4; } to { background: transparent; } }
@media (prefers-reduced-motion: reduce) { :target { animation: none; } }
.missing-image { display: block; padding: 1.5em; border: 1px dashed var(--book-rule); border-radius: 10px; color: var(--book-muted); font: 0.9rem system-ui, sans-serif; text-align: center; }

/*
 * Chapter at a Glance (section 4). One look for the book page's aside (marked up when served, see
 * style_glance_html) and the app's Glance component: the argument on a deep teal panel, then each
 * numbered point in its own box with a large brass number. Locked boxes and the invitation below
 * them are shown to signed-out visitors, who see half the points.
 */
.glance {
  --glance-deep: #1f4e5a; --glance-deep-text: #f2f7f7; --glance-label: #a8cdd4;
  --glance-ground: #e6eff0; --glance-line: #cfdfe2; --glance-brass: #9a6a12; --glance-body: #44525a;
  margin: 1.75em 0; font-family: var(--book-serif); color: var(--book-ink);
}
.glance .glance-head { background: var(--glance-deep); color: var(--glance-deep-text); border-radius: 14px 14px 0 0; padding: 20px 26px 24px; }
.glance .glance-head:last-child { border-radius: 14px; }
.glance .glance-title { margin: 0 0 8px; font: 600 0.85rem/1.3 system-ui, -apple-system, "Segoe UI", sans-serif; letter-spacing: 0.02em; color: var(--glance-label); }
.glance .glance-argument { margin: 0; font-size: 1.28rem; line-height: 1.5; }
.glance .glance-count { margin: 10px 0 0; font: 500 0.9rem system-ui, -apple-system, "Segoe UI", sans-serif; }
.glance .glance-count a { color: #fff; text-underline-offset: 3px; }
.glance .glance-body { background: var(--glance-ground); border-radius: 0 0 14px 14px; padding: 16px; }
.glance .glance-points { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); gap: 12px; margin: 0; padding: 0; list-style: none; }
.glance .glance-point { position: relative; margin: 0; padding: 14px 16px 15px 62px; background: #fff; border: 1px solid var(--glance-line); border-radius: 10px; font-size: 0.98rem; line-height: 1.5; color: var(--glance-body); }
.glance .glance-point p { margin: 0; }
.glance .glance-point strong { display: block; margin-bottom: 4px; font-size: 1.06rem; line-height: 1.35; color: var(--book-ink); }
.glance .glance-n { position: absolute; left: 0; top: 10px; width: 56px; text-align: center; font: 600 2.1rem/1 var(--book-serif); font-variant-numeric: lining-nums; color: var(--glance-brass); }
.glance .glance-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.glance .glance-guide { margin: 14px 6px 2px; font-size: 0.98rem; line-height: 1.55; color: var(--glance-body); }

/* Points held back from a signed-out visitor: numbers and blank lines only, then the invitation. */
.glance .glance-point.ghost { background: transparent; border: 1.5px dashed #a9c3c8; min-height: 96px; }
.glance .glance-point.ghost + .glance-point.ghost { opacity: 0.55; }
.glance .ghost .glance-n { color: #b6a27c; }
.glance .glance-ghost-lines { display: grid; gap: 8px; padding-top: 6px; }
.glance .glance-ghost-lines span { display: block; height: 9px; border-radius: 5px; background: #cddcdf; }
.glance .glance-ghost-lines span:nth-child(1) { width: 78%; height: 11px; background: #bfd2d6; }
.glance .glance-ghost-lines span:nth-child(2) { width: 94%; }
.glance .glance-ghost-lines span:nth-child(3) { width: 62%; }
.glance .glance-lock { position: absolute; right: 12px; top: 12px; color: #6f8a90; }
.glance .glance-more { margin-top: 14px; background: var(--glance-deep); color: var(--glance-deep-text); border-radius: 10px; padding: 18px 22px 20px; }
.glance .glance-more-title { margin: 0 0 4px; font-size: 1.25rem; line-height: 1.3; font-weight: 600; }
.glance .glance-more-text { margin: 0 0 14px; font: 0.95rem/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; color: #d6e6e8; max-width: 60ch; }
.glance .glance-more .row { display: flex; flex-wrap: wrap; gap: 10px; }
.glance .glance-more .btn { background: #fff; border-color: #fff; color: var(--glance-deep); }
.glance .glance-more .btn.secondary { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.7); }

/* The chapters list's smaller version. */
.glance.compact { margin: 12px 0 8px; }
.glance.compact .glance-head { padding: 14px 18px 16px; border-radius: 12px 12px 0 0; }
.glance.compact .glance-head:last-child { border-radius: 12px; }
.glance.compact .glance-argument { font-size: 1.02rem; line-height: 1.5; }
.glance.compact .glance-body { padding: 12px; border-radius: 0 0 12px 12px; }
.glance.compact .glance-points { grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 10px; }
.glance.compact .glance-point { padding: 11px 13px 12px 46px; font-size: 0.9rem; }
.glance.compact .glance-point strong { font-size: 0.95rem; }
.glance.compact .glance-n { width: 42px; top: 9px; font-size: 1.55rem; }
.glance.compact .glance-point.ghost { min-height: 74px; }
.glance.compact .glance-more { padding: 12px 16px 14px; margin-top: 10px; }
.glance.compact .glance-more-title { font-size: 1.05rem; margin-bottom: 10px; }
.glance .btn { font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
.glance .btn.small { padding: 5px 14px; font-size: 0.875rem; }
@media (max-width: 520px) {
  .glance .glance-head { padding: 16px 18px 18px; }
  .glance .glance-argument { font-size: 1.12rem; }
  .glance .glance-body { padding: 10px; }
}
@media print {
  .glance .glance-head, .glance .glance-more { background: #fff; color: var(--book-ink); border: 1px solid var(--book-rule); }
  .glance .glance-title { color: var(--book-muted); }
}
