/*
 * A Modern Narrative of Jesus — Modern E-Book Stylesheet
 * Modeled on the Innermost Freethought e-book (if/if-html.css) so the
 * narrative reads with the same warm, paper-on-paper book aesthetic.
 */

/* Design tokens (kept in sync with if/if-html.css) */
:root {
  --bg-page: #f5f0e8;
  --bg-paper: #fffef9;
  --text-primary: #2d2d2d;
  --text-secondary: #555;
  --text-heading: #1a1a1a;
  --link-color: #1a5276;
  --link-visited: #6c3483;
  --link-hover: #2980b9;
  --accent: #c9b99a;
  --border: #e8e0d4;
  --shadow: rgba(0, 0, 0, 0.1);
  --selection-bg: #d4e6f1;
  --selection-fg: #1a1a1a;
  --paper-max-width: 50ch;
  --paper-padding: 3rem 2.5rem;
  --font-body: 'Palatino Linotype', 'Book Antiqua', Palatino, 'Times New Roman', 'Georgia', serif;
  --font-heading: 'Palatino Linotype', 'Book Antiqua', Palatino, 'Times New Roman', 'Georgia', serif;
  --line-height: 1.7;
  --font-size: 17px;
}

html {
  font-size: var(--font-size);
  line-height: var(--line-height);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--text-primary);
  background: var(--bg-page);
  margin: 0;
  padding: 0;
  line-height: var(--line-height);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

/* Outer shell — neutral full-width wrapper */
#shell {
  width: 100%;
  margin: 0 auto;
}

/* Paper column (was #content; styled like if/#paper) */
#content {
  background: var(--bg-paper);
  width: min(var(--paper-max-width), 100vw - 2rem);
  margin: 2rem auto;
  padding: var(--paper-padding);
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.12),
              0 0 0 1px rgba(0, 0, 0, 0.06);
  border-radius: 2px;
  position: relative;
  overflow-wrap: break-word;
  word-break: break-word;
}

/* Wider paper for the comparison-matrix essay */
#content.wide {
  --paper-max-width: 85ch;
}

/* Series header — small centered label above the chapter title */
#series-header {
  text-align: center;
  margin-bottom: 1.75rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

#series-header .series-label {
  display: inline-block;
  font-variant: small-caps;
  letter-spacing: 0.12em;
  font-size: 1em;
  color: var(--text-secondary);
  text-decoration: none;
  border-bottom: 1px dotted var(--border);
  padding-bottom: 2px;
  transition: color 0.2s, border-color 0.2s;
}

#series-header .series-label:hover {
  color: var(--link-color);
  border-bottom-color: var(--link-color);
}

/* Chapter title */
#content h1 {
  font-family: var(--font-heading);
  font-size: 2em;
  font-weight: bold;
  color: var(--text-heading);
  text-align: center;
  margin: 0 0 0.35em 0;
  line-height: 1.25;
  letter-spacing: 0.01em;
}

/* Ornamental divider under the chapter title */
#content h1.title-rule {
  padding-bottom: 1.5rem;
  margin-bottom: 1.5rem;
  position: relative;
}

#content h1.title-rule::after {
  content: "\2766";
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  font-size: 1.1em;
  font-weight: normal;
  color: var(--accent);
}

/* Sub-headings within a chapter */
#content h2 {
  font-family: var(--font-heading);
  font-size: 1.4em;
  font-weight: bold;
  color: var(--text-heading);
  margin: 2.5em 0 0.5em 0;
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--border);
  line-height: 1.3;
}

#content h3 {
  font-family: var(--font-heading);
  font-size: 1.2em;
  font-weight: bold;
  color: var(--text-heading);
  margin: 2em 0 0.5em 0;
  line-height: 1.3;
}

#content h4, #content h5, #content h6 {
  font-weight: bold;
  margin: 1.5em 0 0.5em 0;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--text-heading);
  line-height: 1.3;
}

/* Prose — book-style indentation, no gap between paragraphs */
#content p {
  margin: 0;
  text-indent: 1.5em;
}

/* First paragraph after a heading reads better unindented */
#content h1 + p,
#content h2 + p,
#content h3 + p {
  text-indent: 0;
}

/* Lists */
#content ul,
#content ol {
  padding-left: 1.5em;
  margin: 1em 0;
}

#content li {
  margin: 0.25em 0;
  line-height: 1.5;
}

/* Blockquotes */
blockquote {
  font-style: italic;
  color: var(--text-secondary);
  border-left: 3px solid var(--accent);
  padding: 0.5em 1em;
  margin: 1.5em 0;
}

blockquote p {
  text-indent: 0;
}

/* Inline emphasis */
#content b, #content strong {
  color: var(--text-heading);
}

#content i, #content em {
  color: var(--text-primary);
}

/* Links */
a {
  color: var(--link-color);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

a:visited {
  color: var(--link-visited);
}

/* Tables (Character of Jesus comparison matrix) */
#content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5em 0;
  font-size: 0.9em;
  line-height: 1.5;
}

#content th,
#content td {
  padding: 0.5em 0.75em;
  border: 1px solid var(--border);
  vertical-align: top;
  text-align: left;
}

#content th {
  background: var(--bg-page);
  font-weight: bold;
  color: var(--text-heading);
}

#content td {
  background: var(--bg-paper);
}

#content td p {
  text-indent: 0;
  margin: 0.25em 0;
}

/* Horizontal rules / chapter breaks */
hr {
  border: none;
  height: 1px;
  background: var(--border);
  margin: 2em 0;
}

.chapter-break {
  border: none;
  height: 0;
  margin: 3em 0;
  text-align: center;
}

.chapter-break::after {
  content: "\2766";
  display: block;
  font-size: 1.2em;
  color: var(--accent);
  letter-spacing: 1em;
}

/* Series table of contents (index page) */
#TOC {
  margin: 1rem 0;
  padding: 1rem 0 1.25rem 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

#TOC h2 {
  font-size: 1.4em;
  font-weight: bold;
  color: var(--text-heading);
  margin: 0 0 1em 0;
  text-align: center;
  font-variant: small-caps;
  letter-spacing: 0.05em;
  border-bottom: none;
  padding-bottom: 0;
}

#TOC ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

#TOC li {
  margin: 0.5em 0;
  line-height: 1.4;
}

#TOC li .episode-num {
  display: inline-block;
  min-width: 2.2em;
  color: var(--accent);
  font-variant: small-caps;
  letter-spacing: 0.05em;
}

#TOC a {
  color: var(--link-color);
  text-decoration: none;
  border-bottom: 1px dotted var(--border);
  transition: border-color 0.2s, color 0.2s;
}

#TOC a:hover {
  border-bottom-color: var(--link-color);
}

/* Footer episode navigation */
#episode-nav {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.95em;
  flex-wrap: wrap;
}

#episode-nav a {
  color: var(--link-color);
  text-decoration: none;
  border-bottom: 1px dotted var(--border);
  transition: border-color 0.2s, color 0.2s;
  max-width: 40%;
}

#episode-nav a:hover {
  color: var(--link-hover);
  border-bottom-color: var(--link-hover);
}

#episode-nav a.nav-index {
  max-width: none;
  font-variant: small-caps;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
}

#episode-nav a.nav-index:hover {
  color: var(--link-color);
}

/* Selection */
::selection {
  background: var(--selection-bg);
  color: var(--selection-fg);
}

::-moz-selection {
  background: var(--selection-bg);
  color: var(--selection-fg);
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-page: #1a1a1a;
    --bg-paper: #2a2a2a;
    --text-primary: #d4d4d4;
    --text-secondary: #999;
    --text-heading: #eee;
    --link-color: #7ab3d4;
    --link-visited: #b388d4;
    --link-hover: #a0d0f0;
    --accent: #8a7a5a;
    --border: #444;
    --shadow: rgba(0, 0, 0, 0.3);
    --selection-bg: #2c3e50;
    --selection-fg: #eee;
  }

  #content {
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.5),
                0 0 0 1px rgba(255, 255, 255, 0.05);
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

/* Print styles */
@media print {
  * {
    background: transparent !important;
    color: black !important;
    filter: none !important;
    -ms-filter: none !important;
  }

  body {
    background: white !important;
    font-size: 12pt;
  }

  #shell {
    width: 100%;
  }

  #content {
    box-shadow: none;
    margin: 0;
    padding: 0;
    max-width: 100%;
    width: 100%;
    border-radius: 0;
  }

  a {
    text-decoration: underline;
  }

  #series-header,
  #episode-nav {
    display: none !important;
  }

  h1, h2, h3 {
    page-break-after: avoid;
  }

  blockquote, table {
    page-break-inside: avoid;
  }
}

/* Mobile responsive */
@media (max-width: 600px) {
  :root {
    --font-size: 16px;
    --paper-padding: 1.5rem 1rem;
  }

  #content {
    margin: 0.5rem auto;
    border-radius: 0;
    box-shadow: none;
  }

  #content h1 {
    font-size: 1.6em;
  }

  #content h2 {
    font-size: 1.25em;
  }

  #episode-nav {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.5rem;
  }

  #episode-nav a {
    max-width: none;
  }

  /* Comparison matrix scrolls horizontally rather than crushing */
  #content table {
    display: block;
    overflow-x: auto;
  }
}