/* ============================================================
   ALIGNED — Professional Book Stylesheet
   Typeset for print-ready publication and screen reading
   Typography: EB Garamond (body) + Playfair Display (display)
   ============================================================ */

/* ============================================================
   CSS VARIABLES
   ============================================================ */
:root {
  --font-body:    'EB Garamond', Georgia, 'Times New Roman', serif;
  --font-display: 'Playfair Display', Georgia, serif;
  --color-ink:    #141414;
  --color-mid:    #3d3d3d;
  --color-dim:    #777777;
  --color-rule:   #c4aa84;
  --color-bg:     #f7f4ef;
  --color-paper:  #ffffff;
  --body-size:    13pt;
  --indent:       1.9em;
  --line-height:  1.88;
  --max-width:    720px;
  --gutter:       60px;
}

/* ============================================================
   RESET
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 18px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
ul, ol { list-style: none; }
a { text-decoration: none; color: inherit; }

/* ============================================================
   PAGE SHELL
   ============================================================ */
body {
  font-family: var(--font-body);
  font-size: var(--body-size);
  line-height: var(--line-height);
  color: var(--color-ink);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================================
   HALF-TITLE PAGE
   ============================================================ */
.half-title-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 55vh;
  text-align: center;
  padding: 80px var(--gutter);
  border-bottom: 1px solid var(--color-rule);
  margin-bottom: 0;
}
.half-title-text {
  font-family: var(--font-display);
  font-size: 42pt;
  font-weight: 400;
  letter-spacing: 0.06em;
  color: var(--color-mid);
  font-style: italic;
}

/* ============================================================
   FULL TITLE PAGE
   ============================================================ */
.title-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 80px var(--gutter);
  border-bottom: 1px solid #ddd;
  background: var(--color-paper);
}
.title-page-inner {
  text-align: center;
  max-width: 560px;
  margin: 0 auto;
}
.title-ornament {
  font-size: 16pt;
  color: var(--color-rule);
  letter-spacing: 0.5em;
  margin-bottom: 36px;
  display: block;
}
.book-title {
  font-family: var(--font-display);
  font-size: 78pt;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.0;
  color: var(--color-ink);
  margin-bottom: 30px;
}
.book-subtitle {
  font-family: var(--font-display);
  font-size: 16pt;
  font-weight: 400;
  font-style: italic;
  color: var(--color-mid);
  line-height: 1.5;
  margin-bottom: 60px;
}
.title-rule {
  width: 60px;
  height: 1px;
  background: var(--color-rule);
  margin: 0 auto 56px;
}
.author-name {
  font-family: var(--font-body);
  font-size: 15pt;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--color-mid);
  margin-bottom: 64px;
}
.book-author {
  font-family: var(--font-body);
  font-size: 15pt;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--color-mid);
  margin-top: 40px;
}
.title-publisher {
  margin-top: 40px;
}
.publisher-name {
  font-family: var(--font-body);
  font-size: 12pt;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--color-dim);
}

/* ============================================================
   COPYRIGHT PAGE
   ============================================================ */
.copyright-page {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 80px var(--gutter) 60px;
  border-bottom: 1px solid #e5e0d8;
}
.copyright-text {
  font-family: var(--font-body);
  font-size: 12pt;
  line-height: 1.65;
  color: var(--color-dim);
  margin-bottom: 14px;
  text-indent: 0;
  text-align: left;
}
.copyright-text.isbn { margin-top: 28px; }

/* ============================================================
   EPIGRAPH PAGE
   ============================================================ */
.epigraph-page {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 80px var(--gutter);
  border-bottom: 1px solid #e5e0d8;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
}
.epigraph {
  text-align: center;
  max-width: 380px;
  margin: 0 auto;
}
.epigraph p {
  font-family: var(--font-display);
  font-size: 17pt;
  font-style: italic;
  color: var(--color-mid);
  line-height: 1.55;
  text-align: center;
  text-indent: 0;
  margin-bottom: 24px;
}
.epigraph-text {
  font-family: var(--font-display);
  font-size: 17pt;
  font-style: italic;
  color: var(--color-mid);
  line-height: 1.55;
  text-align: center;
}
.epigraph-source {
  font-family: var(--font-body);
  font-size: 13pt;
  letter-spacing: 0.12em;
  color: var(--color-dim);
  text-align: center;
  margin-top: 18px;
}
.epigraph-attribution {
  font-family: var(--font-body);
  font-size: 12pt;
  letter-spacing: 0.1em;
  color: var(--color-dim);
  display: block;
  text-align: center;
}

/* ============================================================
   TABLE OF CONTENTS
   ============================================================ */
.toc-page {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 80px var(--gutter) 60px;
  border-bottom: 1px solid #e5e0d8;
}
.toc-title {
  font-family: var(--font-display);
  font-size: 32pt;
  font-weight: 400;
  font-style: italic;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--color-ink);
  text-align: center;
  margin-bottom: 48px;
}
.toc-list { margin: 0; }
.toc-item {
  display: flex;
  align-items: baseline;
  padding: 11px 0;
  border-bottom: none;
}
.toc-item a {
  display: flex;
  align-items: baseline;
  width: 100%;
  gap: 10px;
  color: inherit;
}
.toc-item a:hover .toc-chapter-title { color: var(--color-ink); }
.toc-chapter-num {
  font-family: var(--font-body);
  font-size: 11pt;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-dim);
  white-space: nowrap;
  min-width: 130px;
  flex-shrink: 0;
}
.toc-dots {
  flex: 1;
  border-bottom: 1px dotted #c8b89a;
  position: relative;
  top: -4px;
  min-width: 20px;
}
.toc-chapter-title {
  font-family: var(--font-display);
  font-size: 15pt;
  font-weight: 400;
  color: var(--color-mid);
  text-align: right;
  line-height: 1.3;
  transition: color 0.2s;
}
.toc-item.toc-frontmatter {
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid #e5e0d8;
}
.toc-item.toc-frontmatter .toc-chapter-num {
  font-style: italic;
  text-transform: none;
  letter-spacing: 0.04em;
  font-size: 13pt;
  color: var(--color-mid);
}
.toc-item.toc-frontmatter .toc-chapter-title {
  font-style: italic;
}
.toc-missing { opacity: 0.5; }
.toc-placeholder { font-style: italic; }

/* ============================================================
   CHAPTER OPENER
   ============================================================ */
.chapter {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 80px var(--gutter) 60px;
  border-bottom: 1px solid #e5e0d8;
}
.chapter-header {
  text-align: center;
  margin-top: 32px;
  margin-bottom: 72px;
}
.chapter-number {
  font-family: var(--font-body);
  font-size: 12pt;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--color-dim);
  margin-bottom: 22px;
}
.chapter-label {
  font-family: var(--font-body);
  font-size: 13pt;
  font-weight: 500;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--color-mid);
  margin-bottom: 26px;
  display: block;
}
.chapter-title {
  font-family: var(--font-display);
  font-size: 40pt;
  font-weight: 700;
  line-height: 1.12;
  color: var(--color-ink);
  letter-spacing: -0.01em;
  margin-bottom: 36px;
}
.chapter-header::after {
  content: '';
  display: block;
  width: 60px;
  height: 1px;
  background: var(--color-rule);
  margin: 0 auto;
}
/* Author's Note — chapter-like but with italic, softer feel */
.authors-note .chapter-label {
  font-style: italic;
  letter-spacing: 0.08em;
  text-transform: none;
  font-size: 14pt;
  color: var(--color-dim);
}
.authors-note .chapter-title {
  font-size: 34pt;
  font-style: italic;
  font-weight: 400;
}
.chapter-rule {
  width: 36px;
  height: 1px;
  background: var(--color-rule);
  margin: 0 auto;
}
.chapter-body { }

/* ============================================================
   BODY TEXT
   ============================================================ */
p {
  font-family: var(--font-body);
  font-size: var(--body-size);
  line-height: var(--line-height);
  color: var(--color-ink);
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
  -moz-hyphens: auto;
}

/* Indent all non-first paragraphs */
p + p { text-indent: var(--indent); }

/* No indent after these */
.section-break + p,
.section-heading + p,
p.first-para         { text-indent: 0 !important; }

/* ============================================================
   DROP CAP — first paragraph of each chapter
   ============================================================ */
p.first-para::first-letter {
  font-family: var(--font-display);
  font-size: 5.0em;
  font-weight: 700;
  float: left;
  line-height: 0.72;
  margin-right: 5px;
  margin-top: 9px;
  color: var(--color-ink);
  padding-right: 1px;
}

/* ============================================================
   SECTION HEADINGS
   ============================================================ */
.section-heading {
  font-family: var(--font-display);
  font-size: 16pt;
  font-weight: 600;
  font-style: italic;
  color: var(--color-ink);
  margin-top: 56px;
  margin-bottom: 22px;
  line-height: 1.3;
}

/* ============================================================
   SECTION BREAK  (replaces * * *)
   ============================================================ */
.section-break {
  text-align: center;
  margin: 40px 0;
  line-height: 1;
  user-select: none;
  clear: both;
}
.section-break::before {
  content: '◆';
  font-size: 7pt;
  letter-spacing: 0.5em;
  color: var(--color-rule);
  display: block;
}

/* ============================================================
   INNER VOICE / THOUGHT ITALICS
   ============================================================ */
em.thought {
  font-style: italic;
}

/* ============================================================
   CHAPTER BRIDGE PARAGRAPH (between-chapter transitions)
   ============================================================ */
p.bridge {
  font-style: italic;
  color: var(--color-mid);
  border-top: 1px solid #e5e0d8;
  margin-top: 36px;
  padding-top: 32px;
  text-indent: 0 !important;
}

/* ============================================================
   BACK MATTER
   ============================================================ */
.backmatter-page {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 80px var(--gutter) 60px;
}
.backmatter-title {
  font-family: var(--font-body);
  font-size: 12pt;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--color-dim);
  text-align: center;
  margin-bottom: 44px;
}

/* ============================================================
   PLACEHOLDER / NOTES TEXT
   ============================================================ */
.placeholder-text {
  font-style: italic;
  color: var(--color-dim);
}
.placeholder-text::first-letter { all: unset; float: none; }

/* ============================================================
   PRINT STYLES — 6 × 9 inch trade paperback
   ============================================================ */
@media print {
  @page {
    size: 6in 9in;
    margin-top: 0.875in;
    margin-bottom: 0.875in;
    margin-inside: 0.875in;
    margin-outside: 0.75in;
  }
  @page :left  { margin-left: 0.875in; margin-right: 0.75in; }
  @page :right { margin-left: 0.75in;  margin-right: 0.875in; }
  @page :first { margin-top: 1in; }

  body { background: white; font-size: 12.5pt; }

  .half-title-page,
  .title-page,
  .copyright-page,
  .epigraph-page,
  .toc-page   { page-break-after: always; min-height: auto; border: none; }

  .chapter    {
    page-break-before: always;
    max-width: 100%;
    padding: 0;
    border: none;
  }
  .title-page { min-height: 100vh; }

  .section-break { page-break-inside: avoid; }
  .section-heading { page-break-after: avoid; }
  p.first-para { page-break-after: avoid; }

  a { color: inherit; text-decoration: none; }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 720px) {
  :root { --gutter: 28px; --body-size: 12.5pt; }
  .book-title  { font-size: 40pt; }
  .chapter-title { font-size: 22pt; }
}
@media (max-width: 480px) {
  :root { --gutter: 18px; --body-size: 12pt; }
  .book-title  { font-size: 30pt; }
  .chapter-title { font-size: 18pt; }
  p.first-para::first-letter { font-size: 3.8em; }
}
