/* ==========================================================================
   my-style.css — personal EPUB reading style
   --------------------------------------------------------------------------
   This file is injected LAST into every XHTML page, so its rules override the
   publisher's stylesheets. Edit freely: the script copies whatever is here.

   Notes:
   - !important is used deliberately. Publisher CSS is often very specific
     (e.g. `div.chapter p.first`), and without !important your rules lose.
   - Keep font sizes in em/%, never px, so the reader's font-size control
     still works.
   ========================================================================== */

/* ---- 1. Page margins ---------------------------------------------------- */
@page {
  margin: 5pt;
}

body {
  /* Let the reading app control side margins; kill publisher-imposed ones. */
  margin: 0 !important;
  padding: 0 1em !important;

  /* ---- 2. Body typography ---- */
  font-family: Georgia, "Iowan Old Style", "Palatino Linotype", serif !important;
  font-size: 1em !important;      /* 1em = whatever the reader is set to */
  line-height: 1.5 !important;
  text-align: justify !important;
  -webkit-hyphens: auto;
  -epub-hyphens: auto;
  hyphens: auto;
  widows: 2;
  orphans: 2;

  /* Comment the next two lines out if you prefer the app's own theme. */
  /* color: #1a1a1a !important; */
  /* background-color: #fbf8f1 !important; */
}

/* ---- 3. Paragraphs ------------------------------------------------------ */
p {
  font-family: inherit !important;
  font-size: inherit !important;
  line-height: inherit !important;
  text-align: inherit !important;
  margin: 0 !important;
  text-indent: 1.2em !important;   /* indented paragraphs, no blank line */
}

/* First paragraph of a section / after a heading: no indent (typographic norm) */
p:first-child,
h1 + p, h2 + p, h3 + p, h4 + p, h5 + p, h6 + p,
hr + p,
blockquote + p,
.noindent, .no-indent, .first, .First, .initial {
  text-indent: 0 !important;
}

/* If you prefer block paragraphs (blank line, no indent) instead,
   comment out the two rules above and uncomment this one:

p {
  text-indent: 0 !important;
  margin: 0 0 0.8em 0 !important;
}
*/

/* ---- 4. Headings -------------------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif !important;
  font-weight: 600 !important;
  line-height: 1.25 !important;
  text-align: left !important;
  text-indent: 0 !important;
  -webkit-hyphens: none;
  hyphens: none;
  page-break-after: avoid;
  break-after: avoid;
}

h1 { font-size: 1.6em !important; margin: 1.2em 0 0.8em !important; }
h2 { font-size: 1.35em !important; margin: 1.1em 0 0.6em !important; }
h3 { font-size: 1.15em !important; margin: 1.0em 0 0.5em !important; }
h4, h5, h6 { font-size: 1em !important; margin: 1.0em 0 0.4em !important; }

/* ---- 5. Quotes, lists, code -------------------------------------------- */
blockquote {
  margin: 1em 1.5em !important;
  font-style: italic;
  text-indent: 0 !important;
}

ul, ol {
  margin: 0.8em 0 0.8em 1.5em !important;
  text-align: left !important;
}

li { margin-bottom: 0.3em !important; text-indent: 0 !important; }

pre, code, kbd, samp, tt {
  font-family: "SF Mono", Menlo, Consolas, monospace !important;
  font-size: 0.85em !important;
  text-align: left !important;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* ---- 6. Images ---------------------------------------------------------- */
img, svg, image {
  max-width: 100% !important;
  height: auto !important;
}

figure { margin: 1em 0 !important; text-align: center !important; }
figcaption { font-size: 0.85em !important; text-align: center !important; text-indent: 0 !important; }

/* ---- 7. Links ----------------------------------------------------------- */
a, a:link, a:visited {
  color: inherit !important;
  text-decoration: none !important;
}

/* ---- 8. Tables ---------------------------------------------------------- */
table {
  border-collapse: collapse !important;
  max-width: 100% !important;
  font-size: 0.9em !important;
}
td, th { padding: 0.3em 0.5em !important; text-align: left !important; }

/* ---- 9. Nuisance killers ------------------------------------------------ */
/* Publishers often hard-code fonts/colors on spans. Neutralise the common ones. */
span[style], p[style], div[style] {
  font-family: inherit !important;
}

/* Kill forced page breaks that create half-empty screens (optional). */
/*
div, section, p { page-break-before: auto !important; break-before: auto !important; }
*/
