/* Modern World Library  --  reading HTML (B5)
   Screen: soft dark (easier on eyes than pure white)
   Print/PDF: light paper via @media print
*/

:root {
  /* Soft dark (default on-screen) */
  --ink: #e8e4dc;
  --ink-dim: #b8b2a6;
  --paper: #12151c;
  --paper-elev: #1a1e28;
  --muted: #8b93a7;
  --line: rgba(232, 228, 220, 0.12);
  --accent: #c4a35a;
  --link: #8eb4e0;
  --code-bg: #1e2430;
  --serif: Georgia, "Times New Roman", Times, serif;
  --sans: "Segoe UI", system-ui, sans-serif;
  --mono: Consolas, "Courier New", monospace;
  --measure: 42rem;
}

/* Optional: force soft light if someone prefers it */
body.theme-light {
  --ink: #1e2128;
  --ink-dim: #4a5160;
  --paper: #f3efe6; /* warm paper */
  --paper-elev: #faf7f0;
  --muted: #5c6578;
  --line: rgba(30, 33, 40, 0.12);
  --link: #3d6fa8;
  --code-bg: #e5dfd4;
}

/* Book 11 free reader: open like a short book (warm paper default) */
body.book-11 {
  --ink: #1e2128;
  --ink-dim: #4a5160;
  --paper: #f3efe6;
  --paper-elev: #faf7f0;
  --muted: #5c6578;
  --line: rgba(30, 33, 40, 0.12);
  --link: #3d6fa8;
  --code-bg: #e5dfd4;
}
body.book-11.theme-dark {
  --ink: #e8e4dc;
  --ink-dim: #b8b2a6;
  --paper: #12151c;
  --paper-elev: #1a1e28;
  --muted: #8b93a7;
  --line: rgba(232, 228, 220, 0.12);
  --link: #8eb4e0;
  --code-bg: #1e2430;
}

body.book-11 .page {
  max-width: calc(var(--measure) + 5rem);
  padding: 2rem 1.35rem 4.5rem;
}
body.book-11 .cover-wrap img {
  width: min(300px, 72vw);
  box-shadow:
    0 1px 0 rgba(255,255,255,.35) inset,
    12px 22px 48px rgba(40, 30, 15, 0.22);
}
body.book-11 .meta-block {
  background: var(--paper-elev);
  border-color: rgba(30, 33, 40, 0.1);
  box-shadow: 0 8px 28px rgba(40, 30, 15, 0.06);
}
body.book-11 h2 {
  border-top: 0;
  padding-top: 0.35rem;
  margin-top: 2.75rem;
  font-weight: 600;
  font-size: 1.45rem;
  letter-spacing: -0.01em;
}
body.book-11 h2::before {
  content: "";
  display: block;
  width: 2.5rem;
  height: 2px;
  background: var(--accent);
  margin-bottom: 0.85rem;
  opacity: 0.85;
}
body.book-11 .meta-block + h1,
body.book-11 .cover-wrap + .meta-block + h1 {
  display: none; /* avoid double title after meta block */
}
body.book-11 p {
  font-size: 1.05rem;
  line-height: 1.75;
}
body.book-11 .read-banner {
  font-family: var(--sans);
  font-size: 0.88rem;
  color: var(--muted);
  text-align: center;
  margin: 0 0 1.5rem;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  background: rgba(196, 163, 90, 0.1);
  border: 1px solid rgba(196, 163, 90, 0.25);
}

* { box-sizing: border-box; }
html { font-size: 18px; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: calc(var(--measure) + 4rem);
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

/* Cover */
.cover-wrap {
  text-align: center;
  margin: 0 0 2.75rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--line);
}
.cover-wrap img {
  width: min(280px, 70vw);
  height: auto;
  border-radius: 2px 6px 6px 2px;
  box-shadow: 10px 18px 40px rgba(0, 0, 0, 0.45);
}

/* Title block */
.meta-block {
  margin: 0 0 2.75rem;
  padding: 1.25rem 1.35rem 1.5rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper-elev);
  font-family: var(--sans);
}
.meta-block .series {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.85rem;
}
.meta-block h1 {
  font-family: var(--serif);
  font-size: clamp(1.75rem, 4vw, 2.35rem);
  font-weight: 700;
  line-height: 1.15;
  margin: 0 0 0.55rem;
  color: var(--ink);
  border: 0;
  padding: 0;
}
.meta-block .subtitle {
  font-size: 1.05rem;
  color: var(--muted);
  margin: 0 0 1rem;
  font-weight: 400;
  max-width: 36ch;
}
.meta-block .byline {
  font-size: 0.95rem;
  margin: 0;
  color: var(--ink-dim);
}

/* Body typography  --  chapter openers */
h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 700;
  line-height: 1.25;
  color: var(--ink);
}
/* Book-level / chapter titles (H1) */
h1 {
  font-size: 1.75rem;
  margin: 2.75rem 0 1rem;
  padding-top: 0.75rem;
  letter-spacing: 0.01em;
}
/* Major sections */
h2 {
  font-size: 1.4rem;
  margin: 2.5rem 0 0.9rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}
/* First heading after meta shouldn't double-rule */
.meta-block + h1,
.cover-wrap + .meta-block + h1 {
  margin-top: 0;
}
h3 {
  font-size: 1.12rem;
  margin: 1.85rem 0 0.55rem;
  color: var(--ink);
}
h4 {
  font-size: 1.02rem;
  margin: 1.4rem 0 0.45rem;
  color: var(--ink-dim);
  font-weight: 600;
}

p {
  margin: 0 0 1.05rem;
  max-width: var(--measure);
  color: var(--ink);
}
li {
  margin: 0.3rem 0;
  max-width: var(--measure);
  color: var(--ink);
}
ul, ol {
  margin: 0 0 1.15rem;
  padding-left: 1.35rem;
}

/* Pull quotes / mottos */
blockquote {
  margin: 1.5rem 0;
  padding: 0.85rem 1rem 0.85rem 1.15rem;
  border-left: 3px solid var(--accent);
  background: var(--paper-elev);
  border-radius: 0 8px 8px 0;
  color: var(--ink);
  font-style: italic;
  max-width: var(--measure);
}
blockquote p { margin: 0 0 0.5rem; }
blockquote p:last-child { margin-bottom: 0; }
blockquote strong { font-style: normal; }

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 2.25rem 0;
}

strong { font-weight: 700; }
em { font-style: italic; }
a {
  color: var(--link);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
a:hover { color: var(--accent); }

code, pre {
  font-family: var(--mono);
  font-size: 0.88em;
}
code {
  background: var(--code-bg);
  padding: 0.12em 0.4em;
  border-radius: 3px;
  color: var(--ink-dim);
}
pre {
  background: var(--code-bg);
  padding: 1rem;
  overflow-x: auto;
  border-radius: 8px;
  max-width: 100%;
  border: 1px solid var(--line);
}

/* Tables  --  claim boards / field cards */
table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin: 1.25rem 0 1.6rem;
  font-family: var(--sans);
  display: block;
  overflow-x: auto;
  background: var(--paper-elev);
  border-radius: 8px;
  border: 1px solid var(--line);
}
thead {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
th, td {
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th { font-weight: 600; color: var(--accent); }
tbody tr:last-child td { border-bottom: 0; }
tr:hover td { background: rgba(196, 163, 90, 0.07); }

img { max-width: 100%; height: auto; }

.footer-export {
  margin-top: 3.25rem;
  padding-top: 1.35rem;
  border-top: 1px solid var(--line);
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.5;
}

/* Accent per book  --  spine spectrum (SHELF-SYSTEM.md) */
body.book-01 { --accent: #c43b3b; --link: #e08a8a; }
body.book-02 { --accent: #e07a3a; --link: #f0a878; }
body.book-03 { --accent: #3d8fd1; --link: #7eb6e8; }
body.book-04 { --accent: #d4a84b; --link: #e0c070; }
body.book-05 { --accent: #c47a9e; --link: #d8a0bc; }
body.book-06 { --accent: #4fae78; --link: #7ec99a; }
body.book-07 { --accent: #8b6bc9; --link: #b8a0e8; }
body.book-08 { --accent: #2f9b88; --link: #5fc4b0; }
body.book-09 { --accent: #b85a42; --link: #d48870; }
body.book-10 { --accent: #5b6f8c; --link: #8fa0b8; }
body.book-11 { --accent: #c4a35a; --link: #8eb4e0; }

/* Theme toggle (screen only) */
.theme-bar {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin: 0 0 1rem;
  font-family: var(--sans);
}
.theme-bar button {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--paper-elev);
  color: var(--muted);
  font: inherit;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  cursor: pointer;
}
.theme-bar button:hover,
.theme-bar button[aria-pressed="true"] {
  color: var(--accent);
  border-color: var(--accent);
}
.theme-toggle-note {
  font-family: var(--sans);
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0 0 1.5rem;
}

/* No first-letter / drop-cap accents.
   Sections start with tables, lists, or bold lead-ins  --  colored
   first letters looked inconsistent (some gold, some not). */

/* Print / PDF: real paper, not dark */
@media print {
  :root {
    --ink: #1a1d24;
    --ink-dim: #3d4450;
    --paper: #fff;
    --paper-elev: #f7f4ef;
    --muted: #5c6578;
    --line: #ddd8ce;
    --link: #1a1d24;
    --code-bg: #f0ebe3;
    --accent: #8a7340;
  }
  html { font-size: 11pt; }
  body {
    background: #fff !important;
    color: #1a1d24 !important;
  }
  .theme-bar { display: none !important; }
  .page { max-width: none; padding: 0; }
  .cover-wrap img { box-shadow: none; }
  .meta-block {
    border: 1px solid #ddd;
    background: #faf8f5;
  }
  a { color: inherit; text-decoration: none; }
  h1 {
    break-before: page;
    border-top: 0;
    padding-top: 0;
  }
  h1:first-of-type,
  .meta-block + h1 {
    break-before: avoid;
  }
  h2 {
    break-after: avoid;
    border-top: 1px solid #ddd;
  }
  table, blockquote { break-inside: avoid; }
  .footer-export { color: #666; }
}
