/* book.css — Oma und Opa typography, web-only nav + dark mode variant */

:root {
  --book-frame:    #2D2A26;
  --book-paper:    #FDFAF4;
  --book-ink:      #1F1B15;
  --book-ink-soft: #5E5750;
  --book-ink-mute: #7A7165;
  --book-rule:     #C9C2B4;
  --book-rule-em:  #B8AC8E;
  --book-rule-th:  #DDD3BE;
  --book-nav-bg:   #FDFAF4;
  --book-nav-fg:   #5E5750;
  --book-nav-rule: #E5DFD0;
}

[data-theme="dark"] {
  --book-frame:    #0E0C0A;
  --book-paper:    #1F1B15;
  --book-ink:      #E8DFD0;
  --book-ink-soft: #B8AC8E;
  --book-ink-mute: #9A8E78;
  --book-rule:     #3A332A;
  --book-rule-em:  #4A4035;
  --book-rule-th:  #2A2620;
  --book-nav-bg:   #1F1B15;
  --book-nav-fg:   #B8AC8E;
  --book-nav-rule: #2A2620;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --book-frame:    #0E0C0A;
    --book-paper:    #1F1B15;
    --book-ink:      #E8DFD0;
    --book-ink-soft: #B8AC8E;
    --book-ink-mute: #9A8E78;
    --book-rule:     #3A332A;
    --book-rule-em:  #4A4035;
    --book-rule-th:  #2A2620;
    --book-nav-bg:   #1F1B15;
    --book-nav-fg:   #B8AC8E;
    --book-nav-rule: #2A2620;
  }
}

* { box-sizing: border-box; }

html {
  background: var(--book-frame);
  scroll-padding-top: 64px;
}

body {
  background: var(--book-paper);
  color: var(--book-ink);
  font-family: 'Junicode', 'Ezra SIL', Georgia, serif;
  font-size: 18px;
  line-height: 1.55;
  max-width: 36em;
  margin: 0 auto;
  padding: 80px 80px 80px 80px;
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
  transition: background 0.2s ease, color 0.2s ease;
}

/* --- Sticky nav (web only) ------------------------------- */

.book-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 52px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  background: var(--book-nav-bg);
  border-bottom: 1px solid var(--book-nav-rule);
  z-index: 100;
}

.book-nav-title {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 1rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--book-nav-fg);
  text-decoration: none;
  margin: 0 auto;
}

.book-nav-title:hover {
  color: var(--book-ink);
}

.book-nav .toc-toggle {
  position: static;
  width: 40px;
  height: 40px;
  background: transparent;
  border: none;
  border-radius: 4px;
  padding: 11px 9px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: none;
}

.book-nav .toc-toggle:hover {
  background: var(--book-rule);
}

.book-nav .toc-toggle span {
  display: block;
  height: 2px;
  background: var(--book-nav-fg);
  border-radius: 1px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

body.toc-open .toc-toggle span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
body.toc-open .toc-toggle span:nth-child(2) {
  opacity: 0;
}
body.toc-open .toc-toggle span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.book-nav .theme-toggle {
  width: 40px;
  height: 40px;
  background: transparent;
  border: none;
  border-radius: 4px;
  font-size: 1.15rem;
  color: var(--book-nav-fg);
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.book-nav .theme-toggle:hover {
  background: var(--book-rule);
  color: var(--book-ink);
}

/* --- Typography ----------------------------------------- */

h1 {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 1.5em;
  font-weight: 400;
  letter-spacing: 0.2em;
  text-align: center;
  text-transform: uppercase;
  margin: 4em 0 2em 0;
}

h2 {
  font-family: 'EB Garamond', Georgia, serif;
  font-weight: 400;
  font-size: 0.85em;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--book-ink-soft);
  margin: 1.6em 0 0.8em 0;
}

h3 {
  font-family: 'EB Garamond', Georgia, serif;
  font-style: italic;
  font-weight: 400;
  font-size: 1em;
  margin: 1.4em 0 0.6em 0;
}

p {
  margin: 0;
  text-indent: 1.5em;
}
h1 + p,
h2 + p,
h3 + p,
.scenebreak + p,
section > p:first-of-type,
li > p:first-child {
  text-indent: 0;
}

em { font-style: italic; }
strong { font-weight: 600; }

.scenebreak {
  text-align: center;
  margin: 1.4em 0;
  text-indent: 0;
  letter-spacing: 0.6em;
  font-family: 'EB Garamond', Georgia, serif;
  color: var(--book-ink-soft);
}

[lang="he"], [lang="yi"], .he {
  font-family: 'Ezra SIL', serif;
}

blockquote {
  margin: 2em 2.2em;
  font-size: 0.94em;
  line-height: 1.5;
}
blockquote p {
  text-indent: 0;
  margin: 0 0 0.6em 0;
}
blockquote p:last-child {
  margin-bottom: 0;
}
blockquote::before,
blockquote::after {
  content: "";
  display: block;
  width: 3em;
  height: 1px;
  background: var(--book-rule-em);
  margin: 0 auto;
}
blockquote::before { margin-bottom: 1.2em; }
blockquote::after { margin-top: 1.2em; }

blockquote.hebrew {
  direction: rtl;
  text-align: right;
}

table {
  border-collapse: collapse;
  margin: 1.5em 0;
  width: 100%;
  font-size: 0.95em;
}
th, td {
  border-bottom: 1px solid var(--book-rule-th);
  padding: 0.4em 0.6em;
  text-align: left;
  vertical-align: top;
}
th {
  border-bottom: 2px solid var(--book-rule-em);
  font-weight: 600;
  font-style: italic;
  color: var(--book-ink-soft);
}

section { margin-bottom: 4em; }

section.companion::before {
  content: "COMPANION";
  display: block;
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 0.7em;
  letter-spacing: 0.5em;
  color: var(--book-ink-mute);
  text-align: center;
  margin: 4em 0 0 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--book-rule);
}
section.companion h1 {
  margin-top: 1.5em;
  text-transform: none;
  letter-spacing: 0;
}
section.companion h2 {
  text-align: left;
}
section.companion > h1 + p {
  font-style: italic;
  margin: 1.4em 1.5em;
  border-top: 1px solid var(--book-rule);
  border-bottom: 1px solid var(--book-rule);
  padding: 0.9em 0;
  text-indent: 0;
}
section.companion > h1 + p em {
  font-style: normal;
}

.title-page {
  text-align: center;
  min-height: 85vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  page-break-before: always;
  page-break-after: always;
  padding: 0;
}
.title-page .book-title {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 3em;
  font-weight: 400;
  margin: 0 0 0.3em 0;
  text-align: center;
}
.title-page .book-subtitle {
  font-family: 'EB Garamond', Georgia, serif;
  font-style: italic;
  font-size: 1.3em;
  color: var(--book-ink-soft);
  margin: 0 0 4em 0;
  text-align: center;
}
.title-page .author {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 0.9em;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  text-align: center;
  margin: 0;
}

section.level1.unnumbered > h1.unnumbered {
  display: none;
}

h1.hidden-heading {
  display: none;
}

.copyright-page {
  font-size: 0.9em;
  margin: 6em 0;
}
.copyright-page p { text-indent: 0; margin: 0 0 1em 0; }
.copyright-page ul { list-style: none; padding: 0; }
.copyright-page ul li { margin: 0.4em 0; }

.dedication {
  text-align: center;
  font-style: italic;
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 1.15em;
  min-height: 85vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  page-break-before: always;
  page-break-after: always;
  color: var(--book-ink);
  padding: 0;
}
.dedication p {
  margin: 0;
  text-indent: 0;
  line-height: 2;
}

.colophon {
  font-size: 0.9em;
  min-height: 85vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  color: var(--book-ink);
  padding: 0 1em;
}
.colophon p { text-indent: 0; margin: 0 0 0.8em 0; }
.colophon .claude-credit { margin-top: 5em; font-style: italic; }

nav.toc {
  margin: 4em 0 6em 0;
}
nav.toc h1 {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 1.5em;
  font-weight: 400;
  letter-spacing: 0.2em;
  text-align: center;
  text-transform: uppercase;
  margin: 4em 0 2em 0;
}
nav.toc ul {
  list-style: none;
  padding: 0;
  max-width: 28em;
  margin: 0 auto;
}
nav.toc li {
  margin: 0.4em 0;
  text-indent: 0;
}
nav.toc li a {
  color: inherit;
  text-decoration: none;
  display: block;
}
nav.toc li a:hover {
  text-decoration: underline;
  color: var(--book-ink-soft);
}
nav.toc li.toc-companion {
  margin-left: 2em;
  font-style: italic;
  color: var(--book-ink-soft);
  font-size: 0.95em;
}

.toc-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0);
  pointer-events: none;
  transition: background 0.25s ease;
  z-index: 90;
}
body.toc-open .toc-backdrop {
  background: rgba(0, 0, 0, 0.45);
  pointer-events: auto;
}

.toc-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(360px, 88vw);
  background: var(--book-paper);
  color: var(--book-ink);
  transform: translateX(-100%);
  transition: transform 0.25s ease, background 0.2s ease, color 0.2s ease;
  z-index: 95;
  overflow-y: auto;
  padding: 64px 32px 32px;
  box-shadow: 2px 0 12px rgba(0, 0, 0, 0.25);
  text-align: left;
}
body.toc-open .toc-drawer {
  transform: translateX(0);
}
.toc-drawer nav.toc {
  margin: 0;
}
.toc-drawer nav.toc h1 {
  margin: 0 0 1.5em 0;
  font-size: 1.1em;
}
.toc-drawer nav.toc ul {
  max-width: none;
}

body.toc-open {
  overflow: hidden;
}

@media (max-width: 640px) {
  body {
    font-size: 17px;
    padding: 70px 22px 50px 22px;
    max-width: none;
  }
  h1 {
    margin: 2.5em 0 1.5em 0;
  }
  blockquote {
    margin: 1.6em 0.6em;
  }
  .title-page,
  .dedication,
  .colophon {
    min-height: 75vh;
  }
  section.companion > h1 + p {
    margin: 1.4em 0.4em;
  }
  .book-nav-title {
    font-size: 0.85rem;
    letter-spacing: 0.14em;
  }
}
